Mercurial > octave-antonio
annotate scripts/help/print_usage.m @ 20158:7503499a252b stable
doc: Update docstrings to have one sentence summary as first line.
Update scripts in audio, elfun, general, geometry, and image directories.
* scripts/audio/@audioplayer/__get_properties__.m,
scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m,
scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m,
scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m,
scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m,
scripts/audio/@audiorecorder/audiorecorder.m,
scripts/audio/@audiorecorder/get.m,
scripts/audio/@audiorecorder/getaudiodata.m,
scripts/audio/@audiorecorder/getplayer.m,
scripts/audio/@audiorecorder/isrecording.m,
scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m,
scripts/audio/@audiorecorder/recordblocking.m,
scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m,
scripts/audio/@audiorecorder/subsasgn.m,
scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m,
scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m,
scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m,
scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m,
scripts/general/accumarray.m, scripts/general/accumdim.m,
scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m,
scripts/general/blkdiag.m, scripts/general/cart2pol.m,
scripts/general/cart2sph.m, scripts/general/cell2mat.m,
scripts/general/celldisp.m, scripts/general/chop.m,
scripts/general/circshift.m, scripts/general/common_size.m,
scripts/general/cplxpair.m, scripts/general/cumtrapz.m,
scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m,
scripts/general/display.m, scripts/general/divergence.m,
scripts/general/fieldnames.m, scripts/general/flip.m,
scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m,
scripts/general/gradient.m, scripts/general/interp3.m,
scripts/general/interpft.m, scripts/general/interpn.m,
scripts/general/loadobj.m, scripts/general/logspace.m,
scripts/general/methods.m, scripts/general/nargchk.m,
scripts/general/narginchk.m, scripts/general/nargoutchk.m,
scripts/general/nextpow2.m, scripts/general/nthargout.m,
scripts/general/num2str.m, scripts/general/pol2cart.m,
scripts/general/polyarea.m, scripts/general/postpad.m,
scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m,
scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m,
scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m,
scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m,
scripts/general/shiftdim.m, scripts/general/sortrows.m,
scripts/general/sph2cart.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/trapz.m,
scripts/general/triplequad.m, scripts/geometry/delaunayn.m,
scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m,
scripts/geometry/griddata.m, scripts/geometry/griddata3.m,
scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m,
scripts/geometry/rectint.m, scripts/geometry/tsearchn.m,
scripts/geometry/voronoi.m, scripts/geometry/voronoin.m,
scripts/help/__unimplemented__.m, scripts/help/doc.m,
scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m,
scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m,
scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m,
scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m,
scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m,
scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m,
scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m,
scripts/image/hot.m, scripts/image/hsv.m, scripts/image/image.m,
scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m,
scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m,
scripts/image/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m,
scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m,
scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m,
scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m,
scripts/image/white.m, scripts/image/winter.m:
Update docstrings to have one sentence summary as first line.
Re-structure to have line lengths <= 80 chars.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 03 May 2015 09:36:20 -0700 |
parents | 9fc020886ae9 |
children |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 2009-2015 Søren Hauberg |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
2 ## |
11104 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
8 ## your option) any later version. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
9 ## |
11104 | 10 ## Octave is distributed in the hope that it will be useful, but |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
13 ## General Public License for more details. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
14 ## |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
11104 | 16 ## along with Octave; see the file COPYING. If not, see |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
18 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10131
diff
changeset
|
20 ## @deftypefn {Function File} {} print_usage () |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10131
diff
changeset
|
21 ## @deftypefnx {Function File} {} print_usage (@var{name}) |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
22 ## Print the usage message for the function @var{name}. |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
23 ## |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
24 ## When called with no input arguments the @code{print_usage} function displays |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
25 ## the usage message of the currently executing function. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
26 ## @seealso{help} |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
27 ## @end deftypefn |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
28 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
29 function print_usage (name) |
10131
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
30 x = dbstack (); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
31 ## Handle input |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
32 if (nargin == 0) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
33 ## Determine the name of the calling function |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
34 if (numel (x) > 1) |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
35 name = x(2).name; |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
36 else |
15559
6f3363ff368c
print_usage.m: Adding error identifiers.
Juan Pablo Carbajal (desktop) <ajuanpi+dev@gmail.com>
parents:
15466
diff
changeset
|
37 error ("Octave:invalid-context", "print_usage: invalid function\n"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
38 endif |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
39 fullpath = evalin ("caller", 'mfilename ("fullpath")'); |
9535
936734e15a4d
print_usage: make it work again if an argument is given
John W. Eaton <jwe@octave.org>
parents:
9530
diff
changeset
|
40 if (strcmp (fullpath(end-length(name)+1:end), name)) |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
41 fullname = [fullpath ".m"]; |
9530
f3df413338c5
print_usage: support calling from methods
Jaroslav Hajek <highegg@gmail.com>
parents:
8768
diff
changeset
|
42 endif |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
43 elseif (! ischar (name)) |
15559
6f3363ff368c
print_usage.m: Adding error identifiers.
Juan Pablo Carbajal (desktop) <ajuanpi+dev@gmail.com>
parents:
15466
diff
changeset
|
44 error ("Octave:invalid-input-arg", |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
45 "print_usage: input argument must be a string"); |
9535
936734e15a4d
print_usage: make it work again if an argument is given
John W. Eaton <jwe@octave.org>
parents:
9530
diff
changeset
|
46 else |
936734e15a4d
print_usage: make it work again if an argument is given
John W. Eaton <jwe@octave.org>
parents:
9530
diff
changeset
|
47 fullname = name; |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
48 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
49 |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
50 ## Determine if we were called from top level. |
10131
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
51 at_toplev = length (x) < 2 || (length (x) == 2 && strcmp (x(2).name, name)); |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
52 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
53 ## Do the actual work |
9535
936734e15a4d
print_usage: make it work again if an argument is given
John W. Eaton <jwe@octave.org>
parents:
9530
diff
changeset
|
54 [text, format] = get_help_text (fullname); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
55 max_len = 80; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
56 switch (lower (format)) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
57 case "plain text" |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
58 [usage_string, status] = get_usage_plain_text (text, max_len); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
59 case "texinfo" |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
60 [usage_string, status] = get_usage_texinfo (text, max_len); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
61 case "html" |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
62 [usage_string, status] = get_usage_html (text, max_len); |
8631
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
63 case "not documented" |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
64 error ("print_usage: '%s' is not documented\n", name); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
65 case "not found" |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
66 error ("print_usage: '%s' not found\n", name); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
67 otherwise |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
68 error ("print_usage: internal error: unsupported help text format: '%s'\n", format); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
69 endswitch |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
70 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
71 ## Raise the final error |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
72 if (status != 0) |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
73 warning ("print_usage: Texinfo formatting filter exited abnormally"); |
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
74 warning ("print_usage: raw Texinfo source of help text follows...\n"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
75 endif |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
76 |
10131
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
77 if (at_toplev) |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
78 error ("Octave:invalid-fun-call", |
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
79 "Invalid call to %s. Correct usage is:\n\n%s\n%s", |
10131
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
80 name, usage_string, __additional_help_message__ ()); |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
81 else |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
82 msg = sprintf ("Invalid call to %s. Correct usage is:\n\n%s", |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
83 name, usage_string); |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
84 ## Ensure that the error doesn't end up with a newline, as that disables |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
85 ## backtraces. |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
86 if (msg(end) == "\n") |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
87 msg(end) = " "; |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
88 endif |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
89 |
15559
6f3363ff368c
print_usage.m: Adding error identifiers.
Juan Pablo Carbajal (desktop) <ajuanpi+dev@gmail.com>
parents:
15466
diff
changeset
|
90 error ("Octave:invalid-fun-call", msg); |
10131
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
91 endif |
30817aa3889a
allow print_usage to print backtrace if called from functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9535
diff
changeset
|
92 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
93 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
94 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
95 function [retval, status] = get_usage_plain_text (help_text, max_len) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
96 ## Extract first line by searching for a double line-end. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
97 line_end_idx = strfind (help_text, "\n\n"); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
98 retval = help_text (1:min ([line_end_idx , max_len, length(help_text)])); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
99 status = 0; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
100 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
101 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
102 function [retval, status] = get_usage_texinfo (help_text, max_len) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
103 ## Lines ending with "@\n" are continuation lines, so they should be |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
104 ## concatenated with the following line. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
105 help_text = strrep (help_text, "@\n", " "); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
106 |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
107 ## Find, and keep, lines that start with @def or @end def. This should |
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
108 ## include things such as @deftypefn, @deftypefnx, @defvar, etc. and their |
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
109 ## corresponding @end's. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
110 def_idx = strfind (help_text, "@def"); |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
111 if (! isempty (def_idx)) |
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
112 endf_idx = strfind (help_text, "@end def"); |
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
113 def_idx = sort ([def_idx, endf_idx]); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
114 endl_idx = find (help_text == "\n"); |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
115 buffer = ""; |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
116 for k = 1:length (def_idx) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
117 endl = endl_idx(find (endl_idx > def_idx(k), 1)); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
118 if (isempty (endl)) |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
119 buffer = strcat (buffer, help_text (def_idx(k):end), "\n"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
120 else |
17100
ae7872816611
print_usage.m: Fix handling of functions with multiple @deftypefn/@end deftypefn pairs.
Rik <rik@octave.org>
parents:
15559
diff
changeset
|
121 buffer = strcat (buffer, help_text (def_idx(k):endl)); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
122 endif |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
123 endfor |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
124 else |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
125 [retval, status] = get_usage_plain_text (help_text, max_len); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
126 endif |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
127 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
128 ## Run makeinfo to generate plain text |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
129 [retval, status] = __makeinfo__ (buffer, "plain text"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
130 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
131 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
132 function [retval, status] = get_usage_html (help_text, max_len) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
133 ## Strip tags |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
134 [help_text, status] = strip_html_tags (help_text); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
135 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
136 ## Extract first line with plain text method. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
137 retval = get_usage_plain_text (help_text, max_len); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
138 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
139 |
12830
208f0a181be6
codesprint: Stop reporting print_usage() as missing tests.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
140 |
208f0a181be6
codesprint: Stop reporting print_usage() as missing tests.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
141 ## Stop reporting function as missing tests. No good tests possible. |
208f0a181be6
codesprint: Stop reporting print_usage() as missing tests.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
142 %!assert (1) |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17243
diff
changeset
|
143 |