Mercurial > hg > octave-nkf
annotate doc/interpreter/munge-texi.cc @ 9891:1506a17832c9
doc building fixes for class methods
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 30 Nov 2009 14:32:10 -0500 |
parents | 0d4613a736e9 |
children | 8d20fb66a0dc |
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 | |
3294 | 36 static const char doc_delim = ''; |
37 | |
4178 | 38 static std::map<std::string, std::string> help_text; |
4177 | 39 |
3294 | 40 static void |
3575 | 41 fatal (const std::string& msg) |
3294 | 42 { |
3575 | 43 std::cerr << msg << "\n"; |
3294 | 44 exit (1); |
45 } | |
46 | |
47 static void | |
48 usage (void) | |
49 { | |
9794
0d4613a736e9
convert build system to use automake and libtool
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
50 std::cerr << "usage: munge-texi DOCSTRING-FILE file ...\n"; |
3294 | 51 exit (1); |
52 } | |
53 | |
3575 | 54 static std::string |
3576 | 55 extract_symbol_name (std::istream& is) |
3294 | 56 { |
3575 | 57 std::string symbol_name; |
3294 | 58 |
59 int c; | |
60 while ((c = is.get ()) != EOF && c != '\n') | |
61 symbol_name += (char) c; | |
62 | |
63 return symbol_name; | |
64 } | |
65 | |
3575 | 66 static std::string |
67 extract_docstring (std::istream& is) | |
3294 | 68 { |
3575 | 69 std::string doc; |
3294 | 70 |
71 int c; | |
72 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
|
73 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
74 // 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
|
75 if (c == '@') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
76 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
77 char buf[16]; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
78 int i = 0; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
79 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
|
80 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
81 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
|
82 && (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
|
83 && (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
|
84 && (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
|
85 && (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
|
86 && (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
|
87 && (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
|
88 && (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
|
89 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
90 doc += "@seealso{"; |
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 bool first = true; |
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 // process @seealso parameters |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
95 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
|
96 && c != doc_delim |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
97 && c != '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
98 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
99 // 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
|
100 while ( c == ' ' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
101 || c == '\t' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
102 || c == '\r' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
103 || c == '\n' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
104 || c == ',') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
105 { |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
106 c = is.get (); |
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 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
109 // 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
|
110 if (c == '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
111 break; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
112 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
113 // get function name |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
114 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
|
115 do |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
116 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
|
117 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
|
118 && c != doc_delim |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
119 && c != ' ' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
120 && c != '\t' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
121 && c != '\r' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
122 && c != '\n' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
123 && c != ',' |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
124 && c != '}'); |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
125 if (first) |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
126 first = false; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
127 else |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
128 doc += ", "; |
3294 | 129 |
9891
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
130 if (function_name[0] == '@') |
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
131 function_name = "@" + function_name; |
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
132 |
8287
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
133 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
|
134 + function_name + "}"; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
135 |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
136 // 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
|
137 if (c == '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
138 break; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
139 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
140 if (c == '}') |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
141 doc += (char) c; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
142 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
143 else |
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 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
|
146 doc += buf[j]; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
147 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
148 } |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
149 else |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
150 doc += (char) c; |
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
151 } |
3294 | 152 return doc; |
153 } | |
154 | |
155 static void | |
5334 | 156 skip_comments (std::ifstream& is) |
157 { | |
158 int c; | |
159 | |
160 bool in_comment = false; | |
161 | |
162 while ((c = is.get ()) != EOF) | |
163 { | |
164 if (c == '#') | |
165 in_comment = true; | |
166 else if (c == '\n') | |
167 in_comment = false; | |
168 else if (! (in_comment || ::isspace (c))) | |
169 { | |
170 is.putback (c); | |
171 break; | |
172 } | |
173 } | |
174 } | |
175 | |
176 static void | |
3575 | 177 process_doc_file (const std::string& fname) |
3294 | 178 { |
3575 | 179 std::ifstream infile (fname.c_str ()); |
3294 | 180 |
181 if (infile) | |
182 { | |
5334 | 183 skip_comments (infile); |
184 | |
3294 | 185 if (infile.get () != doc_delim) |
186 fatal ("invalid doc file format"); | |
187 | |
3575 | 188 std::string symbol_name; |
3294 | 189 |
190 do | |
191 { | |
192 symbol_name = extract_symbol_name (infile); | |
193 | |
194 if (! symbol_name.empty ()) | |
195 { | |
3575 | 196 std::string doc_string = extract_docstring (infile); |
3294 | 197 |
4177 | 198 if (help_text.find (symbol_name) != help_text.end ()) |
3575 | 199 std::cerr << "ignoring duplicate entry for " |
200 << symbol_name << "\n"; | |
3294 | 201 else |
202 help_text[symbol_name] = doc_string; | |
203 } | |
204 } | |
205 while (! symbol_name.empty ()); | |
206 } | |
207 else | |
208 fatal ("unable to open docfile"); | |
209 } | |
210 | |
211 static void | |
3575 | 212 process_texi_input_file (std::istream& is, std::ostream& os) |
3294 | 213 { |
3404 | 214 os << "@c DO NOT EDIT! Generated automatically by munge-texi.\n\n"; |
3294 | 215 |
216 bool bol = true; | |
217 | |
218 int c; | |
219 while ((c = is.get ()) != EOF) | |
220 { | |
221 if (bol) | |
222 { | |
223 if (c == '@') | |
224 { | |
3575 | 225 std::string symbol_name; |
3294 | 226 |
227 char buf[16]; | |
228 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
|
229 buf[i++] = (char) c; |
3294 | 230 |
8287
f3dbea0e8a1d
Adapted munge-texi to expand @seealso commands to texinfo references
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7048
diff
changeset
|
231 if (( buf[i++] = (char) is.get ()) == 'D' |
3294 | 232 && (buf[i++] = (char) is.get ()) == 'O' |
233 && (buf[i++] = (char) is.get ()) == 'C' | |
234 && (buf[i++] = (char) is.get ()) == 'S' | |
235 && (buf[i++] = (char) is.get ()) == 'T' | |
236 && (buf[i++] = (char) is.get ()) == 'R' | |
237 && (buf[i++] = (char) is.get ()) == 'I' | |
238 && (buf[i++] = (char) is.get ()) == 'N' | |
239 && (buf[i++] = (char) is.get ()) == 'G' | |
240 && (buf[i++] = (char) is.get ()) == '(') | |
241 { | |
242 while ((c = is.get ()) != EOF && c != ')') | |
243 symbol_name += (char) c; | |
244 | |
245 if (is.eof ()) | |
246 fatal ("end of file while reading @DOCSTRING command"); | |
247 else | |
3301 | 248 { |
3575 | 249 std::string doc_string = help_text[symbol_name]; |
3301 | 250 |
9014
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
251 size_t len = doc_string.length (); |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
252 |
4623 | 253 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
|
254 |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
255 // If there is a leading comment with the file |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
256 // name, copy it to the output. |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
257 if (len > 1 |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
258 && doc_string[j] == '@' |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
259 && doc_string[j+1] == 'c') |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
260 { |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
261 j = 2; |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
262 while (doc_string[j++] != '\n') |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
263 /* find eol */; |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
264 |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
265 os << doc_string.substr (0, j); |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
266 } |
71fca0fc2436
save source file names for functions as comments in .texi files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
267 |
4623 | 268 while (doc_string[j] == ' ') |
269 j++; | |
3301 | 270 |
4623 | 271 if (doc_string.substr (j, 15) == "-*- texinfo -*-") |
3301 | 272 { |
4623 | 273 j += 15; |
3301 | 274 |
4623 | 275 while (isspace (doc_string[j])) |
276 j++; | |
3301 | 277 |
3401 | 278 // Make `see also' references in functions |
279 // possible using @anchor{TAG} (new with | |
280 // Texinfo 4.0). | |
281 | |
9891
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
282 if (symbol_name[0] == '@') |
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
283 symbol_name = "@" + symbol_name; |
1506a17832c9
doc building fixes for class methods
John W. Eaton <jwe@octave.org>
parents:
9794
diff
changeset
|
284 |
3401 | 285 os << "@anchor{doc-" << symbol_name << "}\n"; |
286 | |
4623 | 287 os << doc_string.substr (j); |
3301 | 288 } |
289 else | |
290 os << doc_string; | |
291 } | |
3294 | 292 } |
293 else | |
294 { | |
295 buf[i] = '\0'; | |
296 os << buf; | |
297 | |
298 if (buf[i - 1] == '\n') | |
299 bol = true; | |
300 } | |
301 } | |
302 else | |
303 os.put ((char) c); | |
304 } | |
305 else | |
306 { | |
307 if (c == '\n') | |
308 bol = true; | |
309 | |
310 os.put ((char) (c)); | |
311 } | |
312 } | |
313 } | |
314 | |
315 int | |
316 main (int argc, char **argv) | |
317 { | |
318 while (*++argv) | |
9794
0d4613a736e9
convert build system to use automake and libtool
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
319 process_doc_file (*argv); |
3294 | 320 |
3575 | 321 process_texi_input_file (std::cin, std::cout); |
3294 | 322 |
323 return 0; | |
324 } | |
3313 | 325 |
326 /* | |
327 ;;; Local Variables: *** | |
328 ;;; mode: C++ *** | |
329 ;;; End: *** | |
330 */ |