Mercurial > octave
annotate scripts/help/__makeinfo__.m @ 32632:2e484f9f1f18 stable
maint: update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 Dec 2023 12:08:17 -0500 |
parents | 597f3ee61a48 |
children |
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 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 2009-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27899
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:
20778
diff
changeset
|
27 ## @deftypefn {} {[@var{retval}, @var{status}] =} __makeinfo__ (@var{text}, @var{output_type}) |
25039
40a65b30fadf
maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
28 ## @deftypefnx {} {[@var{retval}, @var{status}] =} __makeinfo__ (@var{text}, @var{output_type}, @var{fsee_also}) |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
29 ## Undocumented internal function. |
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
30 ## @end deftypefn |
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
31 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
32 ## Run @code{makeinfo} on a given text. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
33 ## |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
34 ## The string @var{text} is run through the @code{__makeinfo__} program |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21000
diff
changeset
|
35 ## to generate output in various formats. This string must contain valid |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
36 ## Texinfo formatted text. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
37 ## |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21000
diff
changeset
|
38 ## The @var{output_type} selects the format of the output. This can be either |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21000
diff
changeset
|
39 ## @t{"html"}, @t{"texinfo"}, or @t{"plain text"}. By default this is |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21000
diff
changeset
|
40 ## @t{"plain text"}. If @var{output_type} is @t{"texinfo"}, the @t{@@seealso} |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
41 ## macro is expanded, but otherwise the text is unaltered. |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
42 ## |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
43 ## If the optional argument @var{see_also} is present, it is used to expand the |
25039
40a65b30fadf
maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
44 ## Octave specific @t{@@seealso} macro. This argument must be a function |
40a65b30fadf
maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
45 ## handle, that accepts a cell array of strings as input argument (each |
40a65b30fadf
maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
46 ## elements of the array corresponds to the arguments to the @t{@@seealso} |
40a65b30fadf
maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
47 ## macro), and return the expanded string. If this argument is not given, the |
40a65b30fadf
maint: Match variable names in documentation to those in function prototype.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
48 ## @t{@@seealso} macro will be expanded to the text |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
49 ## |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
50 ## @example |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
51 ## See also: arg1, arg2, ... |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
52 ## @end example |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
53 ## |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
54 ## @noindent |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
55 ## for @t{"plain text"} output, and |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
56 ## |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
57 ## @example |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
58 ## See also: @@ref@{arg1@}, @@ref@{arg2@}, ... |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
59 ## @end example |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
60 ## |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
61 ## @noindent |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
62 ## otherwise. |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
63 ## |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
64 ## The optional output argument @var{status} contains the exit status of the |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
65 ## @code{makeinfo} program as returned by @code{system}. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
66 |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
67 function [retval, status] = __makeinfo__ (text, output_type = "plain text", fsee_also) |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
68 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
69 ## Check input |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
70 if (nargin < 1) |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
71 print_usage (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
72 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
73 |
13122
f80273b38cc4
more fixes to __makeinfo__
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13121
diff
changeset
|
74 if (! ischar (text)) |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
75 error ("__makeinfo__: first input argument must be a string"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
76 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
77 |
13122
f80273b38cc4
more fixes to __makeinfo__
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13121
diff
changeset
|
78 if (! ischar (output_type)) |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
79 error ("__makeinfo__: second input argument must be a string"); |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
80 endif |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
81 |
25836
07cb3e098c0a
Use "Octave Forge" spelling in all files.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
82 ## NOTE: The 3rd argument is used by Octave Forge function |
17425
cc7815488981
__makeinfo__.m: Add documentation note to code about use of 3rd argument.
Rik <rik@octave.org>
parents:
17424
diff
changeset
|
83 ## generate_package_html, not by core Octave. This functionality |
cc7815488981
__makeinfo__.m: Add documentation note to code about use of 3rd argument.
Rik <rik@octave.org>
parents:
17424
diff
changeset
|
84 ## can only be removed when that function has been updated. |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
85 if (nargin < 3) |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
86 if (strcmpi (output_type, "plain text")) |
20778
8513c84a13cb
Use parser string concatenation rather than strcat() for performance in m-files.
Rik <rik@octave.org>
parents:
19928
diff
changeset
|
87 fsee_also = @(T) ["\nSee also:", sprintf(" %s,", T{:})(1:end-1), "\n"]; |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
88 else |
20778
8513c84a13cb
Use parser string concatenation rather than strcat() for performance in m-files.
Rik <rik@octave.org>
parents:
19928
diff
changeset
|
89 fsee_also = @(T) ["\nSee also:", sprintf(" @ref{%s},", T{:})(1:end-1), "\n"]; |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
90 endif |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
91 endif |
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
92 |
25803
23483673ba43
Use is_function_handle instead of isa (x, "function_handle").
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
93 if (! is_function_handle (fsee_also)) |
17424
8c22a8d42833
__makeinfo__.m: Backout changeset 687872d279be which removes 3rd argument to func.
Rik <rik@octave.org>
parents:
17339
diff
changeset
|
94 error ("__makeinfo__: third input argument must be a function handle"); |
13121
390add500107
Add back the third input parameter to __makeinfo__
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13120
diff
changeset
|
95 endif |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13122
diff
changeset
|
96 |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
97 ## Formatting in m-files has an extra space at the beginning of every line. |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
98 ## Remove these unwanted spaces if present. First text char is "\n" delim. |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
99 if (text(2) == " ") |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
100 text = strrep (text, "\n ", "\n"); |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
101 endif |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
102 ## Texinfo crashes if @end tex does not appear first on the line. |
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
103 text = regexprep (text, '^ +@end tex', '@end tex', 'lineanchors'); |
30566
0ef88c485786
doc: Allow links to old-style class files (@class/) in Texinfo @seealso macro.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
104 ## Replace @seealso with Octave specific @xseealso macro, and escape '@' |
31257
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
105 [s, e] = regexp (text, '@seealso{[^}]*}'); |
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
106 cum_rep = 0; |
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
107 for (i_match = 1:numel (s)) |
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
108 esc_text = strrep (text(((s(i_match)+8:e(i_match))+i_match-1)+cum_rep), '@', '@@'); |
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
109 text = [text(1:s(i_match)+i_match+cum_rep-1), 'xseealso', esc_text, ... |
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
110 text(e(i_match)+1+i_match+cum_rep-1:end)]; |
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
111 cum_rep += numel (esc_text) - (e(i_match)-(s(i_match)+8)+1); |
2deb14b9ad27
Replace all occurrences of @seealso in docstring with @xseealso (bug #63141).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30566
diff
changeset
|
112 endfor |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
113 |
27566
b86adf277734
Display documentation cross-references more clearly in plaintext format (bug #56929).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26941
diff
changeset
|
114 ## We don't want *ref macros to clutter plain text output with "Note ..." |
b86adf277734
Display documentation cross-references more clearly in plaintext format (bug #56929).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26941
diff
changeset
|
115 if (strcmp (output_type, "plain text")) |
b86adf277734
Display documentation cross-references more clearly in plaintext format (bug #56929).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26941
diff
changeset
|
116 text = regexprep (text, '@ref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', '$1'); |
b86adf277734
Display documentation cross-references more clearly in plaintext format (bug #56929).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26941
diff
changeset
|
117 text = regexprep (text, '@xref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', 'See $1'); |
b86adf277734
Display documentation cross-references more clearly in plaintext format (bug #56929).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26941
diff
changeset
|
118 text = regexprep (text, '@pxref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', 'see $1'); |
b86adf277734
Display documentation cross-references more clearly in plaintext format (bug #56929).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26941
diff
changeset
|
119 endif |
b86adf277734
Display documentation cross-references more clearly in plaintext format (bug #56929).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
26941
diff
changeset
|
120 |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
121 file = texi_macros_file (); |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
122 fid = fopen (file, "r"); |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
123 if (fid < 0) |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
124 error ("unable to open %s for reading", file); |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
125 else |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
126 macros_text = fread (fid, Inf, "*char")'; |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
15701
diff
changeset
|
127 text = [macros_text text]; |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
128 endif |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14363
diff
changeset
|
129 fclose (fid); |
10803
75780a2b0417
__makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
130 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
131 if (strcmpi (output_type, "texinfo")) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
132 status = 0; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
133 retval = text; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
134 return; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
135 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
136 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
137 ## Create the final TeXinfo input string |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
138 text = sprintf ("\\input texinfo\n\n%s\n\n@bye\n", text); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
139 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
140 unwind_protect |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
141 ## Write Texinfo to tmp file |
9983 | 142 template = "octave-help-XXXXXX"; |
15701
edce7d75597b
Change .m files to use tempdir instead of P_tmpdir (patch #7875)
Corbin Champion <corbinlc@gmail.com>
parents:
14614
diff
changeset
|
143 [fid, name] = mkstemp (fullfile (tempdir, template), true); |
9982
7cef030b8069
let __makeinfo__ create temporary file in P_tmpdir
Jaroslav Hajek <highegg@gmail.com>
parents:
9263
diff
changeset
|
144 if (fid < 0) |
7cef030b8069
let __makeinfo__ create temporary file in P_tmpdir
Jaroslav Hajek <highegg@gmail.com>
parents:
9263
diff
changeset
|
145 error ("__makeinfo__: could not create temporary file"); |
7cef030b8069
let __makeinfo__ create temporary file in P_tmpdir
Jaroslav Hajek <highegg@gmail.com>
parents:
9263
diff
changeset
|
146 endif |
18597
2633b5f3106a
__makeinfo__: Process Texinfo docstrings without type conversion (bug #41965)
Mike Miller <mtmiller@ieee.org>
parents:
18401
diff
changeset
|
147 fprintf (fid, "%s", text); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
148 fclose (fid); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
149 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
150 ## Take action depending on output type |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
151 switch (lower (output_type)) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
152 case "plain text" |
27899
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
153 cmd = sprintf ('%s --no-headers --no-warn --no-validate --plaintext --output=- "%s"', |
13121
390add500107
Add back the third input parameter to __makeinfo__
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13120
diff
changeset
|
154 makeinfo_program (), name); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
155 case "html" |
27899
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
156 cmd = sprintf ('%s --no-headers --html --no-warn --no-validate --output=- "%s"', |
13121
390add500107
Add back the third input parameter to __makeinfo__
Carlo de Falco <kingcrimson@tiscali.it>
parents:
13120
diff
changeset
|
157 makeinfo_program (), name); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
158 otherwise |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
159 error ("__makeinfo__: unsupported output type: '%s'", output_type); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
160 endswitch |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
161 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
162 ## Call makeinfo |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
163 [status, retval] = system (cmd); |
10803
75780a2b0417
__makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
164 |
27899
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
165 ## On error, retry with force to ensure user gets *something* |
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
166 if (status) |
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
167 cmd = regexprep (cmd, '--output=', '--force --output=', 'once'); |
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
168 [status_force, retval] = system (cmd); |
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
169 ## original return value usually more useful |
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
170 if (status_force) |
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
171 status = status_force; |
28947
b73a54c31152
maint: Use Octave-specific end keywords rather than just 'end'.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
172 endif |
b73a54c31152
maint: Use Octave-specific end keywords rather than just 'end'.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
173 endif |
27899
fde18e0a2984
Have TexInfo errors result in warning delivered to user (patch #9464)
Colin Macdonald <cbm@m.fsf.org>
parents:
27566
diff
changeset
|
174 |
19928
e884d5816471
Remove extra newlines at end of help printout (bug #44504).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
175 ## Clean up extra newlines generated by makeinfo |
e884d5816471
Remove extra newlines at end of help printout (bug #44504).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
176 if (strcmpi (output_type, "plain text")) |
e884d5816471
Remove extra newlines at end of help printout (bug #44504).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
177 if (numel (retval) > 2 && retval(end-1:end) == "\n\n") |
e884d5816471
Remove extra newlines at end of help printout (bug #44504).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
178 retval = retval(1:end-2); |
e884d5816471
Remove extra newlines at end of help printout (bug #44504).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
179 endif |
e884d5816471
Remove extra newlines at end of help printout (bug #44504).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
180 endif |
e884d5816471
Remove extra newlines at end of help printout (bug #44504).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
181 |
20944
a7ebc9815d71
doc: Start help text with " -- ", not " -- : ".
Rik <rik@octave.org>
parents:
19928
diff
changeset
|
182 ## Clean up start of @deftypefn expansion which includes extra ':' |
a7ebc9815d71
doc: Start help text with " -- ", not " -- : ".
Rik <rik@octave.org>
parents:
19928
diff
changeset
|
183 retval = regexprep (retval, '^ -- : +', ' -- ', "lineanchors"); |
a7ebc9815d71
doc: Start help text with " -- ", not " -- : ".
Rik <rik@octave.org>
parents:
19928
diff
changeset
|
184 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
185 unwind_protect_cleanup |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
186 if (exist (name, "file")) |
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
187 delete (name); |
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8717
diff
changeset
|
188 endif |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
189 end_unwind_protect |
20944
a7ebc9815d71
doc: Start help text with " -- ", not " -- : ".
Rik <rik@octave.org>
parents:
19928
diff
changeset
|
190 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
191 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
192 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
193 |
13044
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
12606
diff
changeset
|
194 ## No test needed for internal helper function. |
a04e32272ecb
codesprint: Turn off test warning for various internal helper functions
Rik <octave@nomad.inbox5.com>
parents:
12606
diff
changeset
|
195 %!assert (1) |