annotate scripts/help/__makeinfo__.m @ 11104:2c356a35d7f5

fix copyright notices
author John W. Eaton <jwe@octave.org>
date Sun, 17 Oct 2010 23:43:42 -0400
parents 75780a2b0417
children fd0a3ac60b0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9983
diff changeset
1 ## Copyright (C) 2009 S�ren Hauberg
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
2 ##
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10803
diff changeset
3 ## This file is part of Octave.
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10803
diff changeset
4 ##
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10803
diff changeset
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
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10803
diff changeset
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
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10803
diff changeset
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: 9983
diff changeset
20 ## @deftypefn {Function File} {[@var{retval}, @var{status}] =} __makeinfo__ (@var{text}, @var{output_type})
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9983
diff changeset
21 ## @deftypefnx {Function File} {[@var{retval}, @var{status}] =} __makeinfo__ (@var{text}, @var{output_type}, @var{see_also})
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
22 ## Undocumented internal function.
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
23 ## @end deftypefn
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
24
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
25 ## Run @code{makeinfo} on a given text.
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
26 ##
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
27 ## The string @var{text} is run through the @code{__makeinfo__} program
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
28 ## to generate output in various formats. This string must contain valid
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
29 ## Texinfo formatted text.
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
30 ##
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
31 ## The @var{output_type} selects the format of the output. This can be either
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
32 ## @t{"html"}, @t{"texinfo"}, or @t{"plain text"}. By default this is
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
33 ## @t{"plain text"}. If @var{output_type} is @t{"texinfo"}, the @t{@@seealso}
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
34 ## macro is expanded, but otherwise the text is unaltered.
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
35 ##
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
36 ## If the optional argument @var{see_also} is present, it is used to expand the
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
37 ## Octave specific @t{@@seealso} macro. This argument must be a function handle,
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
38 ## that accepts a cell array of strings as input argument (each elements of the
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
39 ## array corresponds to the arguments to the @t{@@seealso} macro), and return
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
40 ## the expanded string. If this argument is not given, the @t{@@seealso} macro
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
41 ## will be expanded to the text
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
42 ##
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
43 ## @example
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
44 ## See also: arg1, arg2@, ...
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
45 ## @end example
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
46 ##
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
47 ## @noindent
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
48 ## for @t{"plain text"} output, and
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
49 ##
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
50 ## @example
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
51 ## See also: @@ref@{arg1@}, @@ref@{arg2@}, ...
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
52 ## @end example
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
53 ##
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
54 ## @noindent
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
55 ## otherwise.
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
56 ##
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
57 ## 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
58 ## @code{makeinfo} program as returned by @code{system}.
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
59
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
60 function [retval, status] = __makeinfo__ (text, output_type = "plain text", see_also = [])
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
61
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
62 ## Check input
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
63 if (nargin == 0)
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
64 print_usage ();
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
65 endif
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
66
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
67 if (!ischar (text))
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
68 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
69 endif
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
70
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
71 if (!ischar (output_type))
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
72 error ("__makeinfo__: second input argument must be a string");
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
73 endif
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
74
10803
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
75 ## Define the function which expands @seealso macro
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
76 if (isempty (see_also))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
77 if (strcmpi (output_type, "plain text"))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
78 see_also = @simple_see_also;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
79 else
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
80 see_also = @simple_see_also_with_refs;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
81 endif
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 if (!isa (see_also, "function_handle"))
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
85 error ("__makeinfo__: third input argument must be the empty matrix, or a function handle");
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
86 endif
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
87
10803
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
88 ## It seems like makeinfo sometimes gets angry if the first character
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
89 ## on a line is a space, so we remove these.
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
90 text = strrep (text, "\n ", "\n");
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
91
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
92 ## Handle @seealso macro
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
93 SEE_ALSO = "@seealso";
9263
9eb6e8f2b937 scripts/help/__makeinfo__.m: Support several @seealso's in one text.
Soren Hauberg <hauberg@gmail.com>
parents: 8877
diff changeset
94 starts = strfind (text, SEE_ALSO);
10803
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
95 for start = fliplr (starts)
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
96 if (start == 1 || (text (start-1) != "@"))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
97 bracket_start = find (text (start:end) == "{", 1);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
98 stop = find (text (start:end) == "}", 1);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
99 if (!isempty (stop) && !isempty (bracket_start))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
100 stop += start - 1;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
101 bracket_start += start - 1;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
102 else
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
103 bracket_start = start + length (SEE_ALSO);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
104 stop = find (text (start:end) == "\n", 1);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
105 if (isempty (stop))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
106 stop = length (text);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
107 else
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
108 stop += start - 1;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
109 endif
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
110 endif
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
111 see_also_args = text (bracket_start+1:(stop-1));
8877
2c8b2399247b implement strsplit; deprecate split
Jaroslav Hajek <highegg@gmail.com>
parents: 8768
diff changeset
112 see_also_args = strtrim (strsplit (see_also_args, ","));
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
113 expanded = see_also (see_also_args);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
114 text = strcat (text (1:start-1), expanded, text (stop+1:end));
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
115 endif
9263
9eb6e8f2b937 scripts/help/__makeinfo__.m: Support several @seealso's in one text.
Soren Hauberg <hauberg@gmail.com>
parents: 8877
diff changeset
116 endfor
10803
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
117
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
118 ## Handle @nospell macro
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
119 NOSPELL = "@nospell";
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
120 starts = strfind (text, NOSPELL);
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
121 for start = fliplr (starts)
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
122 if (start == 1 || (text (start-1) != "@"))
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
123 bracket_start = find (text (start:end) == "{", 1);
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
124 stop = find (text (start:end) == "}", 1);
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
125 if (!isempty (stop) && !isempty (bracket_start))
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
126 stop += start - 1;
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
127 bracket_start += start - 1;
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
128 else
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
129 bracket_start = start + length (NOSPELL);
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
130 stop = find (text (start:end) == "\n", 1);
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
131 if (isempty (stop))
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
132 stop = length (text);
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
133 else
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
134 stop += start - 1;
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
135 endif
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
136 endif
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
137 text(stop) = [];
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
138 text(start:bracket_start) = [];
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
139 endif
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
140 endfor
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
141
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
142 if (strcmpi (output_type, "texinfo"))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
143 status = 0;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
144 retval = text;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
145 return;
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
146 endif
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
147
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
148 ## Create the final TeXinfo input string
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
149 text = sprintf ("\\input texinfo\n\n%s\n\n@bye\n", text);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
150
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
151 unwind_protect
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
152 ## Write Texinfo to tmp file
9983
2d347a2f4a0a __makeinfo__: style fixes
John W. Eaton <jwe@octave.org>
parents: 9982
diff changeset
153 template = "octave-help-XXXXXX";
2d347a2f4a0a __makeinfo__: style fixes
John W. Eaton <jwe@octave.org>
parents: 9982
diff changeset
154 [fid, name, msg] = mkstemp (fullfile (P_tmpdir, template), true);
9982
7cef030b8069 let __makeinfo__ create temporary file in P_tmpdir
Jaroslav Hajek <highegg@gmail.com>
parents: 9263
diff changeset
155 if (fid < 0)
7cef030b8069 let __makeinfo__ create temporary file in P_tmpdir
Jaroslav Hajek <highegg@gmail.com>
parents: 9263
diff changeset
156 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
157 endif
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
158 fwrite (fid, text);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
159 fclose (fid);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
160
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
161 ## Take action depending on output type
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
162 switch (lower (output_type))
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
163 case "plain text"
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
164 cmd = sprintf ("%s --no-headers --no-warn --force --no-validate %s",
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
165 makeinfo_program (), name);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
166 case "html"
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
167 cmd = sprintf ("%s --no-headers --html --no-warn --no-validate --force %s",
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
168 makeinfo_program (), name);
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
169 otherwise
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
170 error ("__makeinfo__: unsupported output type: '%s'", output_type);
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
171 endswitch
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
172
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
173 ## Call makeinfo
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
174 [status, retval] = system (cmd);
10803
75780a2b0417 __makeinfo__.m: Add support to process @nopsell macro.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
175
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
176 unwind_protect_cleanup
8768
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
177 if (exist (name, "file"))
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
178 delete (name);
e0fbf17a17bb __makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents: 8717
diff changeset
179 endif
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
180 end_unwind_protect
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
181 endfunction
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
182
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
183 function expanded = simple_see_also (args)
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
184 expanded = strcat ("\nSee also:", sprintf (" %s,", args {:}));
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
185 expanded = strcat (expanded (1:end-1), "\n\n");
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
186 endfunction
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
187
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
188 function expanded = simple_see_also_with_refs (args)
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
189 expanded = strcat ("\nSee also:", sprintf (" @ref{%s},", args {:}));
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
190 expanded = strcat (expanded (1:end-1), "\n\n");
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff changeset
191 endfunction