Mercurial > hg > octave-lyh
annotate doc/interpreter/munge-texi.cc @ 9912:e9fe12c1b0c0
Set default papersize to the desired imagesize
Set default paperorientation to landscape to stop warning message
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Fri, 04 Dec 2009 09:45:15 -0800 |
parents | 8d20fb66a0dc |
children | 4b270d1540f7 |
rev | line source |
---|---|
3313 | 1 /* |
2 | |
9245 | 3 Copyright (C) 1999, 2000, 2002, 2003, 2005, 2007, 2008, 2009 John W. Eaton |
3313 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3313 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3313 | 20 |
21 */ | |
22 | |
4279 | 23 #if defined (__DECCXX) |
24 #define __USE_STD_IOSTREAM | |
25 #endif | |
26 | |
4177 | 27 #include <cctype> |
3575 | 28 #include <iostream> |
29 #include <fstream> | |
3294 | 30 #include <string> |
4215 | 31 #include <map> |
3294 | 32 |
7048 | 33 #include <cstdlib> |
34 #include <cstring> | |
35 | |
9906 | 36 static std::string top_srcdir; |
37 | |
3294 | 38 static const char doc_delim = ''; |
39 | |
4178 | 40 static std::map<std::string, std::string> help_text; |
4177 | 41 |
3294 | 42 static void |
3575 | 43 fatal (const std::string& msg) |
3294 | 44 { |
3575 | 45 std::cerr << msg << "\n"; |
3294 | 46 exit (1); |
47 } | |
48 | |
49 static void | |
50 usage (void) | |
51 { | |
9906 | 52 std::cerr << "usage: munge-texi TOP-SRCDIR DOCSTRING-FILE < file\n"; |
3294 | 53 exit (1); |
54 } | |
55 | |
3575 | 56 static std::string |
3576 | 57 extract_symbol_name (std::istream& is) |
3294 | 58 { |
3575 | 59 std::string symbol_name; |
3294 | 60 |
61 int c; | |
62 while ((c = is.get ()) != EOF && c != '\n') | |
63 symbol_name += (char) c; | |
64 | |
65 return symbol_name; | |
66 } | |
67 | |
3575 | 68 static std::string |
69 extract_docstring (std::istream& is) | |
3294 | 70 { |
3575 | 71 std::string doc; |
3294 | 72 |
73 int c; | |
74 while ((c = is.get ()) != EOF && c != doc_delim) | |
8287
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
75 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
76 // Expand @seealso commands to Texinfo references. |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
77 if (c == '@') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
78 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
79 char buf[16]; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
80 int i = 0; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
81 buf[i++] = (char) c; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
82 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
83 if (( buf[i++] = (char) is.get ()) == 's' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
84 && (buf[i++] = (char) is.get ()) == 'e' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
85 && (buf[i++] = (char) is.get ()) == 'e' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
86 && (buf[i++] = (char) is.get ()) == 'a' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
87 && (buf[i++] = (char) is.get ()) == 'l' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
88 && (buf[i++] = (char) is.get ()) == 's' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
89 && (buf[i++] = (char) is.get ()) == 'o' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
90 && (buf[i++] = (char) is.get ()) == '{') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
91 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
92 doc += "@seealso{"; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
93 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
94 bool first = true; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
95 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
96 // process @seealso parameters |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
97 while ((c = is.get ()) != EOF |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
98 && c != doc_delim |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
99 && c != '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
100 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
101 // ignore whitespace and delimiters |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
102 while ( c == ' ' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
103 || c == '\t' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
104 || c == '\r' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
105 || c == '\n' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
106 || c == ',') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
107 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
108 c = is.get (); |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
109 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
110 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
111 // test for end of @seealso |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
112 if (c == '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
113 break; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
114 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
115 // get function name |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
116 std::string function_name; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
117 do |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
118 function_name += (char) c; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
119 while ((c = is.get ()) != EOF |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
120 && c != doc_delim |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
121 && c != ' ' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
122 && c != '\t' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
123 && c != '\r' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
124 && c != '\n' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
125 && c != ',' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
126 && c != '}'); |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
127 if (first) |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
128 first = false; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
129 else |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
130 doc += ", "; |
3294 | 131 |
9891
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
132 if (function_name[0] == '@') |
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
133 function_name = "@" + function_name; |
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
134 |
8287
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
135 doc += "@ref{doc-" + function_name + ",," |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
136 + function_name + "}"; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
137 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
138 // test for end of @seealso |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
139 if (c == '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
140 break; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
141 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
142 if (c == '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
143 doc += (char) c; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
144 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
145 else |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
146 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
147 for (int j = 0; j < i; j++) |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
148 doc += buf[j]; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
149 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
150 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
151 else |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
152 doc += (char) c; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
153 } |
3294 | 154 return doc; |
155 } | |
156 | |
157 static void | |
5334 | 158 skip_comments (std::ifstream& is) |
159 { | |
160 int c; | |
161 | |
162 bool in_comment = false; | |
163 | |
164 while ((c = is.get ()) != EOF) | |
165 { | |
166 if (c == '#') | |
167 in_comment = true; | |
168 else if (c == '\n') | |
169 in_comment = false; | |
170 else if (! (in_comment || ::isspace (c))) | |
171 { | |
172 is.putback (c); | |
173 break; | |
174 } | |
175 } | |
176 } | |
177 | |
178 static void | |
3575 | 179 process_doc_file (const std::string& fname) |
3294 | 180 { |
3575 | 181 std::ifstream infile (fname.c_str ()); |
3294 | 182 |
183 if (infile) | |
184 { | |
5334 | 185 skip_comments (infile); |
186 | |
3294 | 187 if (infile.get () != doc_delim) |
188 fatal ("invalid doc file format"); | |
189 | |
3575 | 190 std::string symbol_name; |
3294 | 191 |
192 do | |
193 { | |
194 symbol_name = extract_symbol_name (infile); | |
195 | |
196 if (! symbol_name.empty ()) | |
197 { | |
3575 | 198 std::string doc_string = extract_docstring (infile); |
3294 | 199 |
4177 | 200 if (help_text.find (symbol_name) != help_text.end ()) |
3575 | 201 std::cerr << "ignoring duplicate entry for " |
202 << symbol_name << "\n"; | |
3294 | 203 else |
204 help_text[symbol_name] = doc_string; | |
205 } | |
206 } | |
207 while (! symbol_name.empty ()); | |
208 } | |
209 else | |
210 fatal ("unable to open docfile"); | |
211 } | |
212 | |
9906 | 213 static bool |
214 recover_from_macro (std::ostream& os, char *buf, int i) | |
215 { | |
216 bool bol = false; | |
217 | |
218 buf[i] = '\0'; | |
219 os << buf; | |
220 | |
221 if (buf[i - 1] == '\n') | |
222 bol = true; | |
223 | |
224 return bol; | |
225 } | |
226 | |
227 static void | |
228 process_example_file (const std::string& file_name, std::ostream& os) | |
229 { | |
230 std::ifstream infile (file_name.c_str ()); | |
231 | |
232 if (infile) | |
233 { | |
234 os << "@verbatim\n"; | |
235 | |
236 int c; | |
237 int clast = 0; | |
238 | |
239 while ((c = infile.get ()) != EOF) | |
240 { | |
241 os << (char) c; | |
242 clast = c; | |
243 } | |
244 | |
245 if (clast != '\n') | |
246 os << "\n"; | |
247 | |
248 os << "@end verbatim\n"; | |
249 } | |
250 else | |
251 fatal ("unable to open example file " + file_name); | |
252 } | |
253 | |
3294 | 254 static void |
3575 | 255 process_texi_input_file (std::istream& is, std::ostream& os) |
3294 | 256 { |
3404 | 257 os << "@c DO NOT EDIT! Generated automatically by munge-texi.\n\n"; |
3294 | 258 |
259 bool bol = true; | |
260 | |
261 int c; | |
262 while ((c = is.get ()) != EOF) | |
263 { | |
264 if (bol) | |
265 { | |
266 if (c == '@') | |
267 { | |
268 char buf[16]; | |
269 int i = 0; | |
8287
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
270 buf[i++] = (char) c; |
3294 | 271 |
9906 | 272 buf[i++] = c = (char) is.get (); |
273 | |
274 if (c == 'D') | |
3294 | 275 { |
9906 | 276 std::string symbol_name; |
3294 | 277 |
9906 | 278 if ( (buf[i++] = (char) is.get ()) == 'O' |
279 && (buf[i++] = (char) is.get ()) == 'C' | |
280 && (buf[i++] = (char) is.get ()) == 'S' | |
281 && (buf[i++] = (char) is.get ()) == 'T' | |
282 && (buf[i++] = (char) is.get ()) == 'R' | |
283 && (buf[i++] = (char) is.get ()) == 'I' | |
284 && (buf[i++] = (char) is.get ()) == 'N' | |
285 && (buf[i++] = (char) is.get ()) == 'G' | |
286 && (buf[i++] = (char) is.get ()) == '(') | |
3301 | 287 { |
9906 | 288 while ((c = is.get ()) != EOF && c != ')') |
289 symbol_name += (char) c; | |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
290 |
9906 | 291 if (is.eof ()) |
292 fatal ("end of file while reading @DOCSTRING command"); | |
293 else | |
294 { | |
295 std::string doc_string = help_text[symbol_name]; | |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
296 |
9906 | 297 size_t len = doc_string.length (); |
298 | |
299 int j = 0; | |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
300 |
9906 | 301 // If there is a leading comment with the file |
302 // name, copy it to the output. | |
303 if (len > 1 | |
304 && doc_string[j] == '@' | |
305 && doc_string[j+1] == 'c') | |
306 { | |
307 j = 2; | |
308 while (doc_string[j++] != '\n') | |
309 /* find eol */; | |
3301 | 310 |
9906 | 311 os << doc_string.substr (0, j); |
312 } | |
3301 | 313 |
9906 | 314 while (doc_string[j] == ' ') |
4623 | 315 j++; |
3301 | 316 |
9906 | 317 if (doc_string.substr (j, 15) == "-*- texinfo -*-") |
318 { | |
319 j += 15; | |
320 | |
321 while (isspace (doc_string[j])) | |
322 j++; | |
3401 | 323 |
9906 | 324 // Make `see also' references in functions |
325 // possible using @anchor{TAG} (new with | |
326 // Texinfo 4.0). | |
327 | |
328 if (symbol_name[0] == '@') | |
329 symbol_name = "@" + symbol_name; | |
330 | |
331 os << "@anchor{doc-" << symbol_name << "}\n"; | |
9891
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
332 |
9906 | 333 os << doc_string.substr (j); |
334 } | |
335 else | |
336 os << doc_string; | |
3301 | 337 } |
338 } | |
9906 | 339 else |
340 bol = recover_from_macro (os, buf, i); | |
341 } | |
342 else if (c == 'E') | |
343 { | |
344 std::string file_name; | |
345 | |
346 if ( (buf[i++] = (char) is.get ()) == 'X' | |
347 && (buf[i++] = (char) is.get ()) == 'A' | |
348 && (buf[i++] = (char) is.get ()) == 'M' | |
349 && (buf[i++] = (char) is.get ()) == 'P' | |
350 && (buf[i++] = (char) is.get ()) == 'L' | |
351 && (buf[i++] = (char) is.get ()) == 'E' | |
352 && (buf[i++] = (char) is.get ()) == 'F' | |
353 && (buf[i++] = (char) is.get ()) == 'I' | |
354 && (buf[i++] = (char) is.get ()) == 'L' | |
355 && (buf[i++] = (char) is.get ()) == 'E' | |
356 && (buf[i++] = (char) is.get ()) == '(') | |
357 { | |
358 while ((c = is.get ()) != EOF && c != ')') | |
359 file_name += (char) c; | |
360 | |
361 file_name = top_srcdir + "/examples/" + file_name; | |
362 | |
363 process_example_file (file_name, os); | |
364 } | |
365 else | |
366 bol = recover_from_macro (os, buf, i); | |
3294 | 367 } |
368 else | |
9906 | 369 bol = recover_from_macro (os, buf, i); |
3294 | 370 } |
371 else | |
372 os.put ((char) c); | |
373 } | |
374 else | |
375 { | |
376 if (c == '\n') | |
377 bol = true; | |
378 | |
379 os.put ((char) (c)); | |
380 } | |
381 } | |
382 } | |
383 | |
384 int | |
385 main (int argc, char **argv) | |
386 { | |
9906 | 387 top_srcdir = *++argv; |
388 | |
3294 | 389 while (*++argv) |
9794
0d4613a736e9
convert build system to use automake and libtool
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
390 process_doc_file (*argv); |
3294 | 391 |
3575 | 392 process_texi_input_file (std::cin, std::cout); |
3294 | 393 |
394 return 0; | |
395 } | |
3313 | 396 |
397 /* | |
398 ;;; Local Variables: *** | |
399 ;;; mode: C++ *** | |
400 ;;; End: *** | |
401 */ |