Mercurial > octave
annotate scripts/help/doc_cache_create.m @ 30893:e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
* accumarray.m, accumdim.m, quadl.m, quadv.m, randi.m, structfun.m,
__is_function__.m, uigetfile.m, uimenu.m, uiputfile.m, doc_cache_create.m,
colorspace_conversion_input_check.m, imageIO.m, argnames.m, vectorize.m,
vectorize.m, normest1.m, inputname.m, nthargout.m, display_info_file.m,
decic.m, ode15i.m, ode15s.m, ode23.m, ode23s.m, ode45.m, odeset.m,
check_default_input.m, integrate_adaptive.m, ode_event_handler.m,
runge_kutta_23.m, runge_kutta_23s.m, runge_kutta_45_dorpri.m,
runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m,
fminsearch.m, fminunc.m, fsolve.m, fzero.m, sqp.m, fplot.m, plotyy.m,
__bar__.m, __ezplot__.m, flat_entry.html, profexport.m, movfun.m, bicg.m,
bicgstab.m, cgs.m, eigs.m, gmres.m, pcg.m, __alltohandles__.m, __sprand__.m,
qmr.m, tfqmr.m, dump_demos.m:
Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 Apr 2022 18:14:56 -0700 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3 ## Copyright (C) 2009-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
7 ## |
11104 | 8 ## This file is part of Octave. |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## 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
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
14 ## |
11104 | 15 ## 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
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
19 ## |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
11104 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
25 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
27 ## @deftypefn {} {} doc_cache_create (@var{out_file}, @var{directory}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
28 ## @deftypefnx {} {} doc_cache_create (@var{out_file}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
29 ## @deftypefnx {} {} doc_cache_create () |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
30 ## Generate documentation cache for all functions in @var{directory}. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
31 ## |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
32 ## A documentation cache is generated for all functions in @var{directory} |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
33 ## which may be a single string or a cell array of strings. The cache is used |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
34 ## to speed up the function @code{lookfor}. |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
35 ## |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
36 ## The cache is saved in the file @var{out_file} which defaults to the value |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
37 ## @file{doc-cache} if not given. |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
38 ## |
18534
f51c1498b9f3
doc: Replace "builtin" with "built-in" for consistency and correctness.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
39 ## If no directory is given (or it is the empty matrix), a cache for built-in |
21529
8d894e463de6
doc_cache_create.m: Tweak docstring, improve performance.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
40 ## functions, operators, and keywords is generated. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
41 ## |
16872
5372068bb148
Rename gen_doc_cache() to doc_cache_create().
Rik <rik@octave.org>
parents:
16724
diff
changeset
|
42 ## @seealso{doc_cache_file, lookfor, path} |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
43 ## @end deftypefn |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
44 |
16872
5372068bb148
Rename gen_doc_cache() to doc_cache_create().
Rik <rik@octave.org>
parents:
16724
diff
changeset
|
45 function doc_cache_create (out_file = "doc-cache", directory = []) |
13067
875577a19d70
codesprint: Add 1 input validation test for gen_doc_cache()
Rik <octave@nomad.inbox5.com>
parents:
11588
diff
changeset
|
46 |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
47 ## Check input |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
48 if (! ischar (out_file)) |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
49 print_usage (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
50 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
52 ## Generate cache |
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
53 if (isempty (directory)) |
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
54 cache = gen_builtin_cache (); |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
55 elseif (iscell (directory)) |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
56 if (all (cellfun ("isclass", directory, "char"))) |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
57 cache = gen_doc_cache_in_dir (directory); |
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
58 else |
16872
5372068bb148
Rename gen_doc_cache() to doc_cache_create().
Rik <rik@octave.org>
parents:
16724
diff
changeset
|
59 error ("doc_cache_create: cell must contain only strings"); |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
60 endif |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
61 elseif (ischar (directory)) |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
62 cache = gen_doc_cache_in_dir (directory); |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
63 else |
16872
5372068bb148
Rename gen_doc_cache() to doc_cache_create().
Rik <rik@octave.org>
parents:
16724
diff
changeset
|
64 error ("doc_cache_create: second input argument must be a string or a cell of strings"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
65 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
66 |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
67 ## Save cache |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
68 if (! isempty (cache)) |
19113
72e32208ff77
Don't save build timestamp in doc-cache header comment (bug #43087)
Mike Miller <mtmiller@ieee.org>
parents:
18534
diff
changeset
|
69 save_header_format_string (["# doc-cache created by Octave " OCTAVE_VERSION], "local"); |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
70 save ("-text", out_file, "cache"); |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
71 endif |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
72 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
73 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
74 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
75 function [text, first_sentence, status] = handle_function (f, text, format) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21529
diff
changeset
|
76 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
77 first_sentence = ""; |
21529
8d894e463de6
doc_cache_create.m: Tweak docstring, improve performance.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
78 ## Skip internal functions starting with "__" |
8d894e463de6
doc_cache_create.m: Tweak docstring, improve performance.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
79 if (strncmp (f, "__", 2)) |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
80 status = 1; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
81 return; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
82 endif |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
83 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
84 ## Take action depending on help text format |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
85 switch (lower (format)) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
86 case "plain text" |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
87 status = 0; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
88 case "texinfo" |
8860
257ed585b471
gen_doc_cache.m: call __makeinfo__, not makeinfo
Jason Riedy <jason@acm.org>
parents:
8729
diff
changeset
|
89 [text, status] = __makeinfo__ (text, "plain text"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
90 case "html" |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
91 [text, status] = strip_html_tags (text); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
92 otherwise |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
93 status = 1; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
94 endswitch |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
95 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
96 ## Did we get the help text? |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
97 if (status != 0 || isempty (text)) |
16872
5372068bb148
Rename gen_doc_cache() to doc_cache_create().
Rik <rik@octave.org>
parents:
16724
diff
changeset
|
98 warning ("doc_cache_create: unusable help text found in file '%s'", f); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
99 return; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
100 endif |
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 ## Get first sentence of help text |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
103 first_sentence = get_first_help_sentence (f); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21529
diff
changeset
|
104 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
105 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
106 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
107 function cache = create_cache (list) |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21529
diff
changeset
|
108 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
109 cache = {}; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
110 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
111 ## For each function: |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
112 for n = 1:length (list) |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
113 f = list{n}; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
114 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
115 ## Get help text |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
116 [text, format] = get_help_text (f); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
117 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
118 [text, first_sentence, status] = handle_function (f, text, format); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
119 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
120 ## Did we get the help text? |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
121 if (status != 0) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
122 continue; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
123 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
124 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
125 ## Store the help text |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
126 cache(1, end+1) = f; |
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
127 cache(2, end) = text; |
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
128 cache(3, end) = first_sentence; |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
129 endfor |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21529
diff
changeset
|
130 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
131 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
132 |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
133 function cache = gen_doc_cache_in_dir (directory) |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
134 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
135 ## If 'directory' is not in the current path, add it so we search it |
16724
b7667fcb9fbc
Substitute ostrsplit() for strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
136 dir_in_path = ismember (directory, ostrsplit (path (), pathsep ())); |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
137 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17243
diff
changeset
|
138 ## dirs not in path |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
139 if (! iscell (directory)) |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
140 directory = {directory}; |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
141 endif |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
142 dirs_notpath = {directory{! dir_in_path}}; |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
143 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17243
diff
changeset
|
144 ## add them |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
145 if (! isempty (dirs_notpath)) |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
146 addpath (dirs_notpath{:}); |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
147 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
148 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17243
diff
changeset
|
149 ## create cache |
30893
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
150 f_lsfcn = @(dir) create_cache (__list_functions__ (dir)); |
e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
151 cache = cellfun (f_lsfcn, directory, "UniformOutput", false); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
152 |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17243
diff
changeset
|
153 ## concatenate results |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
154 cache = [cache{:}]; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
155 |
21529
8d894e463de6
doc_cache_create.m: Tweak docstring, improve performance.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
156 ## remove dirs from path |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
157 if (! isempty (dirs_notpath)) |
17386
6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
158 rmpath (dirs_notpath{:}); |
14552
86854d032a37
maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents:
14486
diff
changeset
|
159 endif |
14486
6bed5141fdad
Let gen_doc_cache_in_dir accept multiple directories as input.
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14138
diff
changeset
|
160 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
161 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
162 |
8729
d65a0a1780b6
Simplify documentation cache generation to only handle one directory per call to 'gen_doc_cache'
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
163 function cache = gen_builtin_cache () |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21529
diff
changeset
|
164 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
165 operators = __operators__ (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
166 keywords = __keywords__ (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
167 builtins = __builtins__ (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
168 list = {operators{:}, keywords{:}, builtins{:}}; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
169 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
170 cache = create_cache (list); |
21758
ffad2baa90f7
maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents:
21529
diff
changeset
|
171 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
172 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
173 |
13067
875577a19d70
codesprint: Add 1 input validation test for gen_doc_cache()
Rik <octave@nomad.inbox5.com>
parents:
11588
diff
changeset
|
174 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
175 ## No true tests desirable for this function. |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
176 ## Test input validation |
16872
5372068bb148
Rename gen_doc_cache() to doc_cache_create().
Rik <rik@octave.org>
parents:
16724
diff
changeset
|
177 %!error doc_cache_create (1) |