ref2html.cpp
Go to the documentation of this file.
1/** ref2html.cpp Utility to generate a html documents from fref files */
2
3/* FAU Discrete Event Systems Library (libfaudes)
4
5Copyright (C) 2011 Thomas Moor
6
7This library is free software; you can redistribute it and/or
8modify it under the terms of the GNU Lesser General Public
9License as published by the Free Software Foundation; either
10version 2.1 of the License, or (at your option) any later version.
11
12This library is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public
18License along with this library; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
20
21
22/*
23
24Note: in its current state, this utility is badly organized.
25
26Issues include
27- preformance (linear searchs)
28- normalised section labels etc
29- global configuration data
30- embedded HTML fragments
31... however, it does its job
32
33*/
34
35
36
37#include <string>
38#include <cctype>
39#include <ctime>
40#include <iostream>
41#include <fstream>
42#include "corefaudes.h"
43
44
45using namespace faudes;
46
47// ******************************************************************
48// error exit
49// ******************************************************************
50
51void usage_exit(const std::string& rMessage="") {
52 // ui hints
53 if(rMessage!="") {
54 std::cerr << rMessage << std::endl;
55 std::cout << "" << std::endl;
56 }
57 std::cerr << "ref2html: " << VersionString() << std::endl;
58 std::cout << "" << std::endl;
59 std::cerr << "utility to generate HTML from libFAUDES reference pages (*.fref)" << std::endl;
60 std::cerr << std::endl << "usage: " << std::endl;
61 std::cerr << " ref2html [options...] <fref-file> <html-file>" << std::endl;
62 std::cerr << " ref2html [options...] <fref-file 1> [...] <fref-file n> <html-dir>" << std::endl;
63 std::cerr << " ref2html [options...] <fref-dir> <html-dir>" << std::endl;
64 std::cerr << "with options as follows:" << std::endl;
65 std::cerr << " -rti <rti-file> use specified run-time-interface definition" << std::endl;
66 std::cerr << " -flx <flx-file> use specified lua-extension file" << std::endl;
67 std::cerr << " -css <css-file> use specified style sheet" << std::endl;
68 std::cerr << " -cnav <fref-file> use specified chapter navigation file" << std::endl;
69 std::cerr << " -chapter <label> overwrite chapter label" << std::endl;
70 std::cerr << " -section <label> overwrite section label" << std::endl;
71 std::cerr << " -rel <prefix> prefix to chapter documentation base" << std::endl;
72 std::cerr << " -inc <fref-file> include table of contents" << std::endl;
73 std::cerr << std::endl << std::endl;
74 std::cerr << " ref2html -toc <fref-files> <output-file>" << std::endl;
75 std::cerr << "to generate table of contents file" << std::endl;
76 std::cerr << std::endl << std::endl;
77 std::cerr << " ref2html -doxheader <output-file>" << std::endl;
78 std::cerr << " ref2html -doxfooter <output-file>" << std::endl;
79 std::cerr << "to generate header/footer for c++ api documentation" << std::endl;
80 std::cerr << std::endl << std::endl;
81 std::cerr << " ref2html -extract <input-file> <output-directory>" << std::endl;
82 std::cerr << "to extract multiple reference pages from one file" << std::endl;
83 std::cerr << std::endl;
84 std::cerr << std::endl << "note: use \"-\" as output file for console output" << std::endl;
85 exit(1);
86}
87
88
89// ******************************************************************
90// configuration
91// ******************************************************************
92
94
95std::string mFrefTitle="";
96std::string mFrefChapter="";
97std::string mFrefSection="";
98std::string mFrefPage="";
99std::string mFrefLink="";
100std::string mFrefSummary="";
101
102std::string mRtiFile="";
103std::string mFlxFile="";
104std::string mDstFile="";
105std::set< std::string > mSrcFiles;
106std::string mChapterFile="";
107std::string mIncludeFile="";
108
109std::string mBooksPrefix="../";
110std::string mChaptersPrefix="./";
111std::string mImagePrefix="./images/";
112std::string mReferencePrefix="./reference/";
113std::string mCsourcePrefix="./csource/";
114std::string mLuafaudesPrefix="./luafaudes/";
115std::string mPythonmodPrefix="./pythonmod/";
116
117std::string mDownloadLink="http://fgdes.tf.fau.de/download.html";
118std::string mFaudesLink="http://fgdes.tf.fau.de/faudes";
119std::string mDestoolLink="http://fgdes.tf.fau.de/destool";
120std::string mLuafaudesLink="http://fgdes.tf.fau.de/faudes/luafaudes/";
121std::string mPythonmodLink="http://fgdes.tf.fau.de/faudes/pythonmod/";
122std::string mCsourceLink="http://fgdes.tf.fau.de/faudes/csource/";
123std::string mCssFile="faudes.css";
124
125std::string mThisChapterClass="chapter_this";
126std::string mOtherChapterClass="chapter_other";
127std::string mExitChapterClass="chapter_exit";
128
129// ******************************************************************
130// configure: set my chapter prefix
131// ******************************************************************
132
133void ChaptersPrefix(const std::string& prefix) {
134 mChaptersPrefix=prefix;
135 mBooksPrefix=prefix+"../";
136 mImagePrefix=prefix+"images/";
137 mReferencePrefix=prefix+"reference/";
138 mCsourcePrefix=prefix+"csource/";
139 mLuafaudesPrefix=prefix+"luafaudes/";
140 mPythonmodPrefix=prefix+"pythonmod/";
141 mCssFile=prefix+mCssFile;
142}
143
144// ******************************************************************
145// helper: time stamp
146// ******************************************************************
147
148std::string TimeStamp(void) {
149 time_t now;
150 struct tm * local;
151 char buffer[80];
152 time(&now );
153 local=localtime(&now);
154 strftime(buffer,80,"%Y.%m.%d",local);
155 return std::string(buffer);
156}
157
158
159// ******************************************************************
160// helper: convert page to printable
161// ******************************************************************
162
163std::string PrettyPage(const std::string page){
164 // swallow page number
165 std::string ppage = page;
166 std::size_t upos = ppage.find_first_of("_");
167 std::size_t spos = ppage.find_first_of(" ");
168 std::size_t dpos = 0;
169 for(; dpos < ppage.size();dpos++)
170 if(!isdigit(ppage.at(dpos))) break;
171 if(upos!=std::string::npos)
172 if(upos==dpos)
173 if(upos+1<ppage.size())
174 ppage=ppage.substr(upos+1,ppage.size()-upos-1);
175 if(spos!=std::string::npos)
176 if(spos==dpos)
177 if(spos+1<ppage.size())
178 ppage=ppage.substr(spos+1,ppage.size()-spos-1);
179 // turn underscore to space
180 ppage=StringSubstitute(ppage,"_"," ");
181 // done
182 return ppage;
183}
184
185
186// ******************************************************************
187// helper: bottom line
188// ******************************************************************
189
190void BottomLineHtml(std::ostream* pStream) {
191 *pStream << "<p class=\"bottom_line\"> " << std::endl;
192 *pStream << "<a href=\"" << mFaudesLink << "\" target=\"_top\">" << VersionString() << "</a> " << std::endl;
193 *pStream << "--- " << TimeStamp() << " " << std::endl;
194 if(PluginsString()!="" && mFrefChapter!="cppapi")
195 *pStream << "--- with &quot;" << PluginsString() << "&quot; " << std::endl;
196 if(mFrefChapter=="cppapi")
197 *pStream << "--- c++ api documentaion by <a href=\"http://www.doxygen.org\" target=\"_top\">doxygen</a>" << std::endl;
198 *pStream << "</p>" << std::endl;
199 if(mFrefChapter=="reference") {
200 *pStream << "<!--[if IE]>" << std::endl;
201 *pStream << "<p class=\"bottom_line_warning\">" << std::endl;
202 *pStream << "If MS Internet Explorer fails to display certain mathematical symbols," << std::endl;
203 *pStream << "your system misses the corresponding unicode fonts." << std::endl;
204 *pStream << "<br>" << std::endl;
205 *pStream << "You may either install &quot;Arial Unicode MS&quot; from a recent MS Office package" << std::endl;
206 *pStream << "or the freely available" << std::endl;
207 *pStream << "&quot;<a href=\"http://greekfonts.teilar.gr/\">Symbola</a>&quot;" << std::endl;
208 *pStream << "<br>" << std::endl;
209 *pStream << "See also <a href=\"http://www.alanwood.net/\">Allan Woods</a> unicode page." << std::endl;
210 *pStream << "B.t.w.: <a href=\"http://www.mozilla.com\">Firefox</a> will display" << std::endl;
211 *pStream << "all relevant symbols out-of-the-box and nicely render SVG diagrams." << std::endl;
212 *pStream << "<br>" << std::endl;
213 *pStream << "<br>" << std::endl;
214 *pStream << "</p>" << std::endl;
215 *pStream << "<![endif]-->" << std::endl;
216 }
217}
218
219
220// ******************************************************************
221// helper: html header
222// ******************************************************************
223
224void HeaderHtml(std::ostream* pStream) {
225 *pStream << "<!doctype html>" << std::endl;
226 *pStream << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
227 *pStream << "<head>" << std::endl;
228 *pStream << "<title>" << mFrefTitle << "</title>" << std::endl;
229 *pStream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" << std::endl;
230 *pStream << "<meta name=\"contents\" content=\"discrete event systems, libFAUDES, supervisory control, controller synthesis, automata, software library, regular languages, open source, GPL.\"/>" << std::endl;
231 *pStream << "<link href=\"" << mCssFile << "\" rel=\"stylesheet\" type=\"text/css\" />" << std::endl;
232 *pStream << "<link rel=\"shortcut icon\" href=\""<< mImagePrefix << "des.ico\">" << std::endl;
233 *pStream << "</head>" << std::endl;
234 *pStream << "<body>" << std::endl;
235 *pStream << "<div id=\"cwrapper1000\">" << std::endl;
236 *pStream << "<div id=\"dwrapper1000\">" << std::endl;
237}
238
239// ******************************************************************
240// helper: html footer
241// ******************************************************************
242
243void FooterHtml(std::ostream* pStream) {
244 *pStream << "</div>" << std::endl;
245 *pStream << "</div>" << std::endl;
246 *pStream << "</body>" << std::endl;
247 *pStream << "</html>" << std::endl;
248}
249
250// ******************************************************************
251// helper: html for image
252// ******************************************************************
253
254void ImageHtml(std::ostream* pStream, const std::string& rFileName) {
255 *pStream << "<a class=\"faudes_image\" href=\"" << mImagePrefix << rFileName << ".html\">";
256 *pStream << "<img src=\"" << mImagePrefix << rFileName << ".png\"/>";
257 *pStream << "</a>";
258}
259
260// ******************************************************************
261// helper: fancy reference for resgistry list
262// ******************************************************************
263
264
265void ListItemHtml(std::ostream* pStream, const std::string& rLink, const std::string& rText) {
266 *pStream << "<li class=\"registry_item\">" << std::endl
267 << "<a href=\"" << rLink << "\">" << rText << "</a>" << std::endl
268 << "<a href=\"" << rLink << "\" class=\"registry_blinda\">&nbsp;</a>" << std::endl
269 << "</li>" << std::endl;
270 }
271
272// ******************************************************************
273// helper: html for linked type name
274// ******************************************************************
275
276void TypeHtml(std::ostream* pStream, const std::string& rTypeName) {
277
278 // just text if unknown
279 if(!TypeRegistry::G()->Exists(rTypeName)) {
280 *pStream << rTypeName;
281 return;
282 }
283
284 // retrieve definition
285 const TypeDefinition& tdef=TypeRegistry::G()->Definition(rTypeName);
286 std::string tyname = tdef.Name();
287 std::string tyhtml = tdef.HtmlDoc();
288 if(tyhtml=="" || tyhtml=="none") {
289 *pStream << tyname;
290 } else {
291 *pStream << "<a href=\"" << mReferencePrefix << tyhtml << "\">" << tyname << "</a>";
292 }
293}
294
295
296// ******************************************************************
297// helper: html for linked function name
298// ******************************************************************
299
300void FunctionHtml(std::ostream* pStream, const std::string& rFunctionName) {
301
302 // just text if unknown
303 if(!FunctionRegistry::G()->Exists(rFunctionName)) {
304 *pStream << rFunctionName;
305 return;
306 }
307
308 // retrieve definition
309 const FunctionDefinition& fdef=FunctionRegistry::G()->Definition(rFunctionName);
310 std::string fname = fdef.Name();
311 std::string fhtml = fdef.HtmlDoc();
312 if(fhtml=="" || fhtml=="none") {
313 *pStream << fname;
314 } else {
315 *pStream << "<a href=\"" << mReferencePrefix << fhtml << "\">" << fname << "</a>";
316 }
317}
318
319// ******************************************************************
320// helper: html for ascii text
321// ******************************************************************
322
323void TextHtml(std::ostream* pStream, const std::string& rText) {
324 std::string buff;
325 buff=StringSubstitute(buff,"<","&lt;");
326 buff=StringSubstitute(buff,">","&gt;");
327 buff=StringSubstitute(buff,"&","&amp;");
328 *pStream << buff;
329}
330
331// ******************************************************************
332// helper: html for math
333// (we really need at least regex here!)
334// ******************************************************************
335
336// resolve simple one-arg macros
337std::string TexMacroSubstitute1(const std::string& rTexString, const std::string& rMacro, const std::string& rSubst) {
338 // prep result
339 std::string res;
340 std::size_t pos=0;
341 // loop over occurences of "macro"
342 while(pos<rTexString.length()) {
343 std::size_t next=rTexString.find(rMacro,pos);
344 if(next==std::string::npos) break;
345 res.append(rTexString.substr(pos,next-pos));
346 std::string arg;
347 pos=next+rMacro.length();
348 if(!(pos+1<rTexString.length())) continue;
349 if(rTexString.at(pos)!='{') continue;
350 std::size_t aend=rTexString.find('}',pos);
351 if(aend==std::string::npos) break;
352 arg=rTexString.substr(pos+1,aend-pos-1);
353 arg=StringSubstitute(rSubst,"#1",arg);
354 res.append(arg);
355 pos=aend+1;
356 }
357 // get end
358 if(pos<rTexString.length())
359 res.append(rTexString.substr(pos));
360 // done
361 return res;
362}
363
364
365// mimique tex spacing
366std::string TexSpacing(const std::string& rTexString) {
367 // prep result
368 std::string res;
369 std::size_t pos=0;
370 bool math=true;
371 // traverse string
372 while(pos<rTexString.length()) {
373 // explict: "\ "
374 if(pos+1 < rTexString.length())
375 if(rTexString.substr(pos,2)=="\\ ")
376 {pos+=2; res.append("&nbsp;"); continue;}
377 // explicit: "\,"
378 if(pos+1 < rTexString.length())
379 if(rTexString.substr(pos,2)=="\\,")
380 {pos+=2; res.append("&ensp;"); continue;}
381 // explicit: "\;"
382 if(pos+1 < rTexString.length())
383 if(rTexString.substr(pos,2)=="\\;")
384 {pos+=2; res.append("&ensp;"); continue;}
385 // explict: "\quad"
386 if(pos+4 < rTexString.length())
387 if(rTexString.substr(pos,5)=="\\quad")
388 {pos+=5; res.append("&nbsp;&nbsp;&nbsp;&nbsp;"); continue;}
389 // math swallow space
390 if(math)
391 if(isspace(rTexString.at(pos)))
392 { pos+=1; continue;}
393 // sense end of math mode
394 if(math)
395 if(pos+5 < rTexString.length())
396 if(rTexString.substr(pos,6)=="\\text{")
397 {pos+=6; math=false; continue;};
398 // sense end of text mode
399 if(!math)
400 if(rTexString.at(pos)=='}')
401 { pos+=1; math=true; continue;}
402 // default: copy
403 res.append(1,rTexString.at(pos));
404 pos+=1;
405 }
406 return res;
407}
408
409// mimique tex scripts
410std::string TexScripts(const std::string& rTexString) {
411 // prep result
412 std::string res;
413 std::size_t pos=0;
414 int c0=-1;
415 int cm1=-1;
416 int cm2=-1;
417 // traverse string
418 while(pos<rTexString.length()) {
419 // fill buffer
420 cm2=cm1; cm1=c0; c0=rTexString.at(pos);
421 // full script
422 if(cm1=='^' || cm1=='_')
423 if(c0=='{') {
424 std::size_t aend=rTexString.find('}',pos);
425 if(aend==std::string::npos) break;
426 std::string script=rTexString.substr(pos+1,aend-pos-1);
427 res.append(1,cm1);
428 res.append(script);
429 cm1=-1; cm2=-1; pos=aend+1;
430 continue;
431 }
432 // superscript uparrow
433 if(cm1=='^')
434 if(c0=='\\') {
435 size_t mpos=rTexString.find("\\uparrow",pos);
436 if(mpos==pos) {
437 res.append("<span class=\"faudes_sup\">&uarr;</span>");
438 cm1=-1; cm2=-1; pos+=8;
439 continue;
440 }
441 }
442 // superscript uparrow
443 if(cm1=='^')
444 if(c0=='\\') {
445 size_t mpos=rTexString.find("\\Uparrow",pos);
446 if(mpos==pos) {
447 res.append("<span class=\"faudes_sup\">&#x21e7;</span>");
448 cm1=-1; cm2=-1; pos+=8;
449 continue;
450 }
451 }
452 // digit subscript
453 if(cm1=='_')
454 if(isalpha(cm2))
455 if(isdigit(c0)) {
456 res.append(1,c0);
457 cm1=-1; cm2=-1; pos+=1;
458 continue;
459 }
460 // lower subscript
461 if(cm1=='_')
462 if(islower(c0))
463 if(isupper(cm2)) {
464 res.append(1,c0);
465 cm1=-1; cm2=-1; pos+=1;
466 continue;
467 }
468 // super star
469 if(cm1=='^')
470 if(c0=='*' || c0=='+') {
471 res.append(1,c0);
472 cm1=-1; cm2=-1; pos+=1;
473 continue;
474 }
475 // other script
476 if(cm1=='^' || cm1=='_') {
477 res.append(1,cm1);
478 res.append(1,c0);
479 cm1=-1; cm2=-1; pos+=1;
480 continue;
481 }
482 // plain copy default
483 if(c0!='_')
484 if(c0!='^') {
485 res.append(1,c0);
486 }
487 // continue
488 pos+=1;
489 }
490 return res;
491}
492
493
494// over all tex processing
495void MathHtml(std::ostream* pStream, const std::string& rMathString) {
496 std::string buff=rMathString;
497 // xml quote
498 buff=StringSubstitute(buff,"&","&amp;");
499 // tex quote
500 buff=StringSubstitute(buff,"#","&hash;");
501 // greek letters
502 buff=StringSubstitute(buff,"\\Sigma","Sigma");
503 buff=StringSubstitute(buff,"\\sigma","o");
504 buff=StringSubstitute(buff,"\\delta","delta");
505 buff=StringSubstitute(buff,"\\epsilon","epsilon");
506 buff=StringSubstitute(buff,"\\omega","w");
507 buff=StringSubstitute(buff,"\\Upsilon","Upsilon");
508 buff=StringSubstitute(buff,"\\pi","pi");
509 // one-arg macros
510 buff=TexMacroSubstitute1(buff,"\\ProInv","Pinv#1");
511 buff=TexMacroSubstitute1(buff,"\\Pro","P#1");
512 buff=TexMacroSubstitute1(buff,"\\Closure","Closure(#1)");
513 buff=TexMacroSubstitute1(buff,"\\Prefix","Prefix(#1)");
514 buff=TexMacroSubstitute1(buff,"\\CtrlPfx","CtrlPfx(#1)");
515 buff=TexMacroSubstitute1(buff,"\\Shape","Shape(#1)");
516 // tex math spacing and plain text
517 buff=TexMacroSubstitute1(buff,"\\texttt","\\text{<tt>#1</tt>}");
518 buff=TexMacroSubstitute1(buff,"\\mathtt","\\text{<tt>#1</tt>}");
519 buff=TexMacroSubstitute1(buff,"\\textit","\\text{<i>#1</i>}");
520 buff=TexMacroSubstitute1(buff,"\\mathit","\\text{<i>#1</i>}");
521 buff=TexMacroSubstitute1(buff,"\\mathsf","\\text{<sf>#1</sf>}");
522 buff=TexMacroSubstitute1(buff,"\\mathbb","\\text{<it>#1</it>}");
523 buff=TexMacroSubstitute1(buff,"\\textbb","\\text{<it>#1</it>}");
524 buff=TexSpacing(buff);
525 // super- and subscripts
526 buff=TexScripts(buff);
527 // symbols
528 buff=StringSubstitute(buff,"\\{","{");
529 buff=StringSubstitute(buff,"\\}","}");
530 buff=StringSubstitute(buff,"\\[","[");
531 buff=StringSubstitute(buff,"\\]","]");
532 buff=StringSubstitute(buff,"=","&nbsp;=&nbsp;");
533 buff=StringSubstitute(buff,"\\colon","&nbsp:&nbsp;");
534 buff=StringSubstitute(buff,"class&nbsp;=&nbsp;","class="); // fix csss class
535 buff=StringSubstitute(buff,":&nbsp;=&nbsp;","&nbsp;:=&nbsp;"); //fix :=
536 buff=StringSubstitute(buff,"\\neq","&nbsp&ne;&nbsp;");
537 buff=StringSubstitute(buff,"\\lt","&nbsp;&lt;&nbsp;");
538 buff=StringSubstitute(buff,"\\gt","&nbsp;&gt;&nbsp;");
539 buff=StringSubstitute(buff,"\\le","&nbsp;&le;&nbsp;");
540 buff=StringSubstitute(buff,"\\ge","&nbsp;&ge;&nbsp;");
541 buff=StringSubstitute(buff,"\\emptyset","0");
542 buff=StringSubstitute(buff,"\\times","&nbsp;x&nbsp;");
543 buff=StringSubstitute(buff,"\\ldots","...");
544 buff=StringSubstitute(buff,"\\cdots","...");
545 buff=StringSubstitute(buff,"\\cdot",".");
546 buff=StringSubstitute(buff,"\\infty","&infin;");
547 buff=StringSubstitute(buff,"\\inf","inf");
548 buff=StringSubstitute(buff,"\\in","&nbsp;&isin;&nbsp;");
549 buff=StringSubstitute(buff,"\\nin","&nbsp;&notin;&nbsp;");
550 buff=StringSubstitute(buff,"\\not\\in","&nbsp;&notin;&nbsp;");
551 buff=StringSubstitute(buff,"\\subseteq","&nbsp;&sube;&nbsp;");
552 buff=StringSubstitute(buff,"\\subset","&nbsp;&sub;&nbsp;");
553 buff=StringSubstitute(buff,"\\supseteq","&nbsp;&supe;&nbsp;");
554 buff=StringSubstitute(buff,"\\supset","&nbsp;&sup;&nbsp;");
555 buff=StringSubstitute(buff,"\\cup","&cup;");
556 buff=StringSubstitute(buff,"\\dcup","&cup;"); // should be "&cup;&#775;" for "dot above"
557 buff=StringSubstitute(buff,"\\cap","&cap;");
558 buff=StringSubstitute(buff,"\\sup","sup");
559 buff=StringSubstitute(buff,"\\max","max");
560 buff=StringSubstitute(buff,"\\min","min");
561 buff=StringSubstitute(buff,"\\parallel","||");
562 buff=StringSubstitute(buff,"\\forall","&forall;&nbsp;");
563 buff=StringSubstitute(buff,"\\exists","&exist;&nbsp;");
564 buff=StringSubstitute(buff,"\\leftarrow","&larr;");
565 buff=StringSubstitute(buff,"\\rightarrow","&rarr;");
566 buff=StringSubstitute(buff,"\\leftrightarrow","&harr;");
567 buff=StringSubstitute(buff,"\\Leftarrow","&lArr;");
568 buff=StringSubstitute(buff,"\\Rightarrow","&rArr;");
569 buff=StringSubstitute(buff,"\\Leftrightarrow","&hArr;");
570 buff=StringSubstitute(buff,"\\uparrow","&uarr;");
571 buff=StringSubstitute(buff,"\\downarrow","&darr;");
572 buff=StringSubstitute(buff,"\\Uparrow","&#x21e7;");
573 buff=StringSubstitute(buff,"\\Downarrow","&#x21e9;");
574 // ie7 fallback symbols
575 /*
576 buff=StringSubstitute(buff,"&isin;","<span class=\"faudes_fmath\">&isin;</span>");
577 buff=StringSubstitute(buff,"&notin;","<span class=\"faudes_fmath\">&notin;</span>");
578 buff=StringSubstitute(buff,"&exist;","<span class=\"faudes_fmath\">&exist;</span>");
579 buff=StringSubstitute(buff,"&forall;","<span class=\"faudes_fmath\">&forall;</span>");
580 buff=StringSubstitute(buff,"&cup;","<span class=\"faudes_fmath\">&cup;</span>");
581 buff=StringSubstitute(buff,"&dcup;","<span class=\"faudes_fmath\">&cup;</span>"); // see above
582 buff=StringSubstitute(buff,"&cap;","<span class=\"faudes_fmath\">&cap;</span>");
583 buff=StringSubstitute(buff,"&larr;","<span class=\"faudes_fmath\">&larr;</span>");
584 buff=StringSubstitute(buff,"&rarr;","<span class=\"faudes_fmath\">&rarr;</span>");
585 buff=StringSubstitute(buff,"&harr;","<span class=\"faudes_fmath\">&harr;</span>");
586 buff=StringSubstitute(buff,"&lArr;","<span class=\"faudes_fmath\">&lArr;</span>");
587 buff=StringSubstitute(buff,"&rArr;","<span class=\"faudes_fmath\">&rArr;</span>");
588 buff=StringSubstitute(buff,"&hArr;","<span class=\"faudes_fmath\">&hArr;</span>");
589 buff=StringSubstitute(buff,"&sub;","<span class=\"faudes_fmath\">&sub;</span>");
590 buff=StringSubstitute(buff,"&sube;","<span class=\"faudes_fmath\">&sube;</span>");
591 buff=StringSubstitute(buff,"&sup;","<span class=\"faudes_fmath\">&sup;</span>");
592 buff=StringSubstitute(buff,"&supe;","<span class=\"faudes_fmath\">&supe;</span>");
593 */
594 // done
595 *pStream << buff;
596}
597
598
599// ******************************************************************
600// record pages
601// ******************************************************************
602
603
604// section lists (from reading rti/flx)
605std::set< std::string > mExclLuaSections;
606std::set< std::string > mInclLuaSections;
607
608// page data
610public:
611 std::string mTitle;
612 std::string mChapter;
613 std::string mSection;
614 std::string mPage;
615 std::string mLink;
616 std::string mSummary;
617};
618
619
620// record all pages
621std::vector<PageRecord> mAllPages;
622
623// record all pages within reference section (keys to lower)
624std::map< std::string , std::map< std::string , PageRecord > > mRefSectPages;
625
626// extract page data (works with both, *.flx and *.ftoc)
628 // record my level
629 int clevel = rTr.Level();
630 // std::cerr << "process level " << clevel << "\n";
631 // token loop
632 while(true) {
633 // skip plain text
634 std::string text;
635 rTr.ReadCharacterData(text);
636 if(text.size()>0) continue;
637 // break on no token or end of my level
638 Token token;
639 if(!rTr.Peek(token)) break;
640 if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
641 break;
642 // ignore irrelevant
643 if(!token.IsBegin("ReferencePage")) {
644 rTr.Get(token);
645 continue;
646 }
647 // take my section
648 rTr.ReadBegin("ReferencePage");
649 // extract page data
650 mFrefChapter="";
651 if(token.ExistsAttributeString("chapter"))
652 mFrefChapter=token.AttributeStringValue("chapter");
653 mFrefSection="";
654 if(token.ExistsAttributeString("section"))
655 mFrefSection=token.AttributeStringValue("section");
656 mFrefPage="";
657 if(token.ExistsAttributeString("page"))
658 mFrefPage=token.AttributeStringValue("page");
659 mFrefTitle="";
660 if(token.ExistsAttributeString("title"))
661 mFrefTitle=token.AttributeStringValue("title");
662 mFrefLink=ExtractBasename(rTr.FileName())+".html";;
663 if(token.ExistsAttributeString("link"))
664 mFrefLink=token.AttributeStringValue("link");
665 // find optional findexdoc
666 mFrefSummary="";
667 if(rTr.ExistsBegin("fsummary")) {
668 rTr.ReadBegin("fsummary");
670 rTr.ReadEnd("fsummary");
671 }
672 // autodetect misslabled index pages
673 if(mFrefPage=="") {
674 std::string indexfile=mFrefSection + "_index.fref";
675 std::transform(indexfile.begin(), indexfile.end(), indexfile.begin(), tolower);
676 if(ExtractFilename(rTr.FileName())==indexfile)
677 mFrefPage="0_Index";
678 }
679 // ensure page number for index page
680 if(mFrefPage=="index") mFrefPage="Index";
681 if(mFrefPage=="Index") mFrefPage="0_Index";
682 // autogenerate page name
683 if(mFrefPage=="") {
685 std::string title=mFrefTitle;
686 std::transform(mFrefTitle.begin(), mFrefTitle.end(), title.begin(), tolower);
687 std::string section=mFrefSection;
688 std::transform(mFrefSection.begin(), mFrefSection.end(), section.begin(), tolower);
689 std::size_t spos = title.find(section);
690 if(spos==0 && title.size()>section.size())
691 mFrefPage=mFrefPage.substr(section.size(),mFrefPage.size()-section.size());
692 for(spos=0; spos<mFrefPage.size(); spos++){
693 int c= mFrefPage.at(spos);
694 if(c==' ') continue;
695 if(c=='-') continue;
696 if(c=='_') continue;
697 break;
698 }
699 if(spos<mFrefPage.size())
700 mFrefPage=mFrefPage.substr(spos,mFrefPage.size()-spos);
701 if(mFrefPage=="Index") mFrefPage="";
702 }
703 // read end
704 rTr.ReadEnd("ReferencePage");
705 // report
706 //std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
707 // record
708 PageRecord pagerec;
709 pagerec.mChapter = mFrefChapter;
710 pagerec.mSection = mFrefSection;
711 pagerec.mPage = mFrefPage;
712 pagerec.mTitle = mFrefTitle;
713 pagerec.mLink = mFrefLink;
714 pagerec.mSummary=mFrefSummary;
715 // normalize
716 std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
717 std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
718 std::transform(mFrefPage.begin(), mFrefPage.end(), mFrefPage.begin(), tolower);
719 // insert entry
720 if(mFrefChapter!="")
721 if(mFrefChapter!="none")
722 mAllPages.push_back(pagerec);
723 // insert entry to section pages of reference
724 if(mFrefChapter=="reference")
725 if(mFrefPage!="")
726 if(mFrefPage!="none")
728 }
729}
730
731
732// dump page records to include file
734 // loop records
735 std::vector<PageRecord>::iterator pit;
736 for(pit=mAllPages.begin(); pit!=mAllPages.end(); pit++) {
737 Token btag;
738 btag.SetEmpty("ReferencePage");
739 btag.InsAttributeString("title",pit->mTitle);
740 btag.InsAttributeString("chapter",pit->mChapter);
741 btag.InsAttributeString("section",pit->mSection);
742 btag.InsAttributeString("page",pit->mPage);
743 btag.InsAttributeString("link",pit->mLink);
744 // if we have no summary, that's it
745 if(pit->mSummary=="") {
746 rTw << btag;
747 continue;
748 }
749 // summary present
750 btag.ClrEnd();
751 rTw << btag;
752 rTw.WriteBegin("fsummary");
753 rTw.WriteCharacterData(pit->mSummary);
754 rTw.WriteEnd("fsummary");
755 rTw.WriteEnd("ReferencePage");
756 }
757}
758
759
760// ******************************************************************
761// search for types
762// ******************************************************************
763
764void ListTypesHtml(std::ostream* pIndexFile, const std::string& key="") {
765
766 // table output
767 *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
768 // traverse type registry
769 bool found=false;
770 for(TypeRegistry::Iterator tit=TypeRegistry::G()->Begin();
771 tit!=TypeRegistry::G()->End(); tit++) {
772 // test for exact key
773 if(key!="") {
774 std::string section= tit->second->Name();
775 std::transform(section.begin(), section.end(), section.begin(), tolower);
776 if(section!=key) continue;
777 }
778 // test for user doc
779 if(tit->second->TextDoc()=="") continue;
780 // table row
781 *pIndexFile << "<tr><td valign=\"top\">";
782 TypeHtml(pIndexFile,tit->second->Name());
783 *pIndexFile << "</td><td valign=\"top\">";
784 TypeHtml(pIndexFile,tit->second->TextDoc());
785 *pIndexFile << "</td></tr>" << std::endl;
786 // record success
787 found=true;
788 }
789 // no matches
790 if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
791 // table output
792 *pIndexFile << "</table>" << std::endl;
793}
794
795// ******************************************************************
796// search for functions
797// ******************************************************************
798
799void ListFunctionsHtml(std::ostream* pIndexFile, const std::string& key="") {
800
801 // table output
802 *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
803 // traverse function registry
804 bool found=false;
806 fit!=FunctionRegistry::G()->End(); fit++) {
807 // test for exact key
808 if(key!="") {
809 std::string section= fit->second->Name();
810 std::transform(section.begin(), section.end(), section.begin(), tolower);
811 if(section!=key) continue;
812 }
813 // test for user doc
814 if(fit->second->TextDoc()=="") continue;
815 // table row
816 *pIndexFile << "<tr><td valign=\"top\">";
817 FunctionHtml(pIndexFile,fit->second->Name());
818 *pIndexFile << "</td><td valign=\"top\">";
819 TypeHtml(pIndexFile,fit->second->TextDoc());
820 *pIndexFile << "</td></tr>" << std::endl;
821 // record success
822 found=true;
823 }
824 // no matches
825 if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
826 // table output
827 *pIndexFile << "</table>" << std::endl;
828}
829
830// ******************************************************************
831// search for sections
832// ******************************************************************
833
834void ListSectionsHtml(std::ostream* pIndexFile, const std::string& key="") {
835
836 // here: use special key "luaext" to filter lua-extensions"
837
838 // traverse pages
839 std::set< std::string > sections;
840 std::map< std::string , std::string > link;
841 std::map< std::string , std::string > summary;
842 std::vector< PageRecord >::iterator pit;
843 for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
844 std::string chap=pit->mChapter;
845 std::transform(chap.begin(), chap.end(), chap.begin(), tolower);
846 std::string sect=pit->mSection;
847 std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
848 std::string page=pit->mPage;
849 std::transform(page.begin(), page.end(), page.begin(), tolower);
850 page=PrettyPage(page);
851 // my chapter only
852 if(chap!="reference") continue;
853 if(sect=="none") continue;
854 if(sect=="") continue;
855 if(page!="index") continue;
856 // lua ext only
857 if(key=="luaext") {
858 if(mExclLuaSections.find(sect)!=mExclLuaSections.end()) continue;
859 if(mInclLuaSections.find(sect)==mInclLuaSections.end()) continue;
860 }
861 // get nice name
862 std::string pname = pit->mSection;
863 // use title as fallback summary
864 std::string psumm = pit->mSummary;
865 if(psumm=="") psumm = pit->mTitle;
866 // record
867 sections.insert(pname);
868 link[pname]=pit->mLink;
869 summary[pname]=psumm;
870 }
871
872 // produce sorted index with corefaudes first
873 std::vector< std::string > sortvec;
874 if(sections.find("CoreFaudes")!=sections.end())
875 sortvec.push_back("CoreFaudes");
876 std::set< std::string >::iterator sit;
877 for(sit=sections.begin(); sit != sections.end(); sit++) {
878 if(*sit=="CoreFaudes") continue;
879 sortvec.push_back(*sit);
880 }
881
882 // table output
883 *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
884
885 // populate table
886 std::vector< std::string >::iterator vit;
887 bool found=false;
888 for(vit=sortvec.begin(); vit != sortvec.end(); vit++) {
889 // get nice name
890 std::string sname = *vit;
891 std::string shtml = mReferencePrefix+link[sname];
892 std::string ssumm = summary[sname];
893 // table row
894 *pIndexFile << "<tr>" << std::endl;
895 *pIndexFile << "<td valign=\"top\"><a href=\"" << shtml << "\">" << sname << "</a></td>";
896 *pIndexFile << "<td valign=\"top\">";
897 *pIndexFile << ssumm;
898 *pIndexFile << "</td></tr>"<< std::endl;
899 // record success
900 found=true;
901 }
902 // no matches
903 if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
904
905 // table output
906 *pIndexFile << "</table>" << std::endl;
907}
908
909
910
911
912
913// ******************************************************************
914// Type index by keyword (aka section name)
915// ******************************************************************
916
917void TypeIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
918
919 // traverse type registry
920 bool head=false;
921 for(TypeRegistry::Iterator tit=TypeRegistry::G()->Begin();
922 tit!=TypeRegistry::G()->End(); tit++)
923 {
924 // test for exact key
925 if(key!="") {
926 std::string section= tit->second->KeywordAt(0);
927 std::transform(section.begin(), section.end(), section.begin(), tolower);
928 if(section!=key) continue;
929 }
930 // get name and reference
931 std::string tyname = tit->second->Name();
932 std::string tyhtml = tit->second->HtmlDoc();
933 // no doc
934 if(tyhtml=="") continue;
935 if(tyhtml=="none") continue;
936 // head line
937 if(!head) {
938 head=true;
939 *pIndexFile << "<li class=\"registry_heading\">Types</li>" << std::endl;
940 }
941 // index entry for this type
942 ListItemHtml(pIndexFile, tyhtml, tyname);
943 }
944 // done
945 if(head) *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
946}
947
948// ******************************************************************
949// Function index by keyword (aka plugin)
950// ******************************************************************
951
952void FunctionIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
953
954 // have lower case key
955 std::string lkey=key;
956 std::transform(lkey.begin(), lkey.end(), lkey.begin(), tolower);
957
958 // traverse function registry
959 bool head=false;
961 fit!=FunctionRegistry::G()->End(); fit++)
962 {
963 // test for key
964 if(lkey!="") {
965 std::string section= fit->second->KeywordAt(0);
966 std::transform(section.begin(), section.end(), section.begin(), tolower);
967 if(section!=lkey) continue;
968 }
969 // test for user doc
970 if(fit->second->TextDoc()=="") continue;
971 // index entry for this function
972 std::string fname = fit->second->Name();
973 std::string fhtml = fit->second->HtmlDoc();
974 if(fhtml=="") continue;
975 // head line
976 if(!head){
977 head=true;
978 *pIndexFile << "<li class=\"registry_heading\">Functions</li>" << std::endl;
979 }
980 // list entry: no doc
981 if(fhtml=="none") {
982 *pIndexFile << "<li class=\"registry_item\"> "<< fname << "</li>" << std::endl;
983 continue;
984 }
985 // list entry: link
986 ListItemHtml(pIndexFile, fhtml, fname);
987 }
988
989 // done
990 if(head) *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
991
992}
993
994// ******************************************************************
995// Reference index by keyword (aka section)
996// ******************************************************************
997
998void ReferenceIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
999
1000 // prepare list of all sections
1001 std::map< std::string , std::string > sectlink;
1002 std::vector< PageRecord >::iterator pit;
1003 for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1004 std::string chap=pit->mChapter;
1005 std::transform(chap.begin(), chap.end(), chap.begin(), tolower);
1006 std::string sect=pit->mSection;
1007 std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1008 // my chapter only
1009 if(chap!="reference") continue;
1010 if(sect=="none") continue;
1011 if(sect=="") continue;
1012 // get nice name
1013 std::string pname = pit->mSection;
1014 // have link
1015 std::string phtml = sect+"_index.html";
1016 // record
1017 sectlink[pname]=phtml;
1018 }
1019
1020 // produce sorted index, have corefaudes first
1021 std::vector< std::string > sections;
1022 if(sectlink["CoreFaudes"]!="") sections.push_back("CoreFaudes");
1023 std::map< std::string , std::string >::iterator sit;
1024 for(sit=sectlink.begin(); sit!=sectlink.end(); sit++) {
1025 std::string psect=sit->first;
1026 if(psect=="CoreFaudes") continue;
1027 sections.push_back(psect);
1028 }
1029
1030 // sections headline
1031 if(sections.size()!=0)
1032 *pIndexFile << "<li class=\"registry_heading\">Sections</li>" << std::endl;
1033
1034 // iterate sections
1035 std::size_t vit;
1036 for(vit=0; vit<sections.size(); vit++) {
1037 std::string psect=sections.at(vit);
1038 std::string plink=sectlink[psect];
1039 if(plink=="") continue;
1040 // find all pages within reference that match this section (keys to lower, skip index)
1041 std::string sect=psect;
1042 std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1043 std::map< std::string , std::map< std::string , PageRecord > > ::iterator spit = mRefSectPages.find(sect);
1044 int pcnt=0;
1045 if(spit!=mRefSectPages.end()) {
1046 std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1047 for(;pit!=spit->second.end();pit++) {
1048 std::string ppage = pit->second.mPage;
1049 std::transform(ppage.begin(), ppage.end(), ppage.begin(), tolower);
1050 if(ppage=="index") continue;
1051 if(ppage=="0_index") continue;
1052 if(ppage=="00_index") continue;
1053 pcnt++;
1054 }
1055 }
1056 // case a) no pages: just a link
1057 if(pcnt==0) {
1058 ListItemHtml(pIndexFile, plink, psect);
1059 continue;
1060 }
1061 // case b) generate link for sub menu for pages (do this my self)
1062 *pIndexFile << "<li class=\"registry_pitem\">" << std::endl
1063 << "<a href=\"" << plink << "\">" << psect << "</a>" << std::endl
1064 << "<a href=\"" << plink << "\" class=\"registry_blinda\">&nbsp;</a>" << std::endl
1065 << "<ul>" << std::endl
1066 << "<li class=\"registry_heading\">" << psect << "</li>" << std::endl;
1067 std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1068 for(;pit!=spit->second.end();pit++) {
1069 // swallow page number
1070 std::string ppage = PrettyPage(pit->second.mPage);
1071 // normalize
1072 std::string ipage = ppage;
1073 std::transform(ipage.begin(), ipage.end(), ipage.begin(), tolower);
1074 // rename indes
1075 if(ipage=="index") ppage="Introduction";
1076 // page entry
1077 *pIndexFile << "<li class=\"registry_item\"><a href=\"" << pit->second.mLink << "\">"
1078 << ppage << "</a></li>" << std::endl;
1079 }
1080 // close page list
1081 *pIndexFile << "</ul></li>" << std::endl;
1082 }
1083
1084 // sections done
1085 if(sections.size()!=0)
1086 *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1087
1088 // list types
1089 if(key!="") TypeIndexHtml(pIndexFile,key);
1090
1091 // list functions
1092 if(key!="") FunctionIndexHtml(pIndexFile,key);
1093}
1094
1095
1096// ******************************************************************
1097// Section index (aka bottom navigation for key section)
1098// ******************************************************************
1099
1100
1101void SectionIndexHtml(std::ostream* pIndexFile, const std::string& key) {
1102
1103 // find all pages within reference that match this section (keys to lower, skip index)
1104 std::string sect=key;
1105 std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1106 std::string plink=sect+"_index.html";
1107 std::string psect=key;
1108 std::map< std::string , std::map< std::string , PageRecord > > ::iterator spit = mRefSectPages.find(sect);
1109 int pcnt=0;
1110 if(spit!=mRefSectPages.end()) {
1111 std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1112 for(;pit!=spit->second.end();pit++) {
1113 std::string ppage = pit->second.mPage;
1114 psect=pit->second.mSection;
1115 std::transform(ppage.begin(), ppage.end(), ppage.begin(), tolower);
1116 if(ppage=="index") continue;
1117 if(ppage=="0_index") continue;
1118 if(ppage=="00_index") continue;
1119 pcnt++;
1120 }
1121 }
1122
1123 // bail out if there are no pages
1124 //if(pcnt==0) return;
1125
1126 // tweak: key="" refers to the reference_index.html
1127 if(key=="") psect="Reference";
1128
1129 // generate menu for pages
1130 *pIndexFile << "<li class=\"registry_heading\">" << psect << "</li>" << std::endl;
1131 std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1132 for(;pit!=spit->second.end();pit++) {
1133 // swallow page number
1134 std::string ppage = PrettyPage(pit->second.mPage);
1135 // normalize
1136 std::string ipage = ppage;
1137 std::transform(ipage.begin(), ipage.end(), ipage.begin(), tolower);
1138 // rename index
1139 if(ipage=="index") ppage="Introduction";
1140 // page entry
1141 *pIndexFile << "<li class=\"registry_item\"><a href=\"" << pit->second.mLink << "\">"
1142 << ppage << "</a></li>" << std::endl;
1143 }
1144}
1145
1146
1147// ******************************************************************
1148// signature
1149// ******************************************************************
1150
1151void SignatureHtml(std::ostream* pOutFile, std::string function) {
1152
1153 // bail out on non existence
1154 if(!FunctionRegistry::G()->Exists(function)) return;
1155
1156 // function definition
1157 const FunctionDefinition& fdef=FunctionRegistry::G()->Definition(function);
1158
1159 // bail out if there is no signature
1160 if(fdef.VariantsSize()==0) return;
1161
1162 // start signature box
1163 *pOutFile << "<div class=\"registry_signature\">" << std::endl;
1164 *pOutFile << "<h5><strong>Signature:</strong></h5>" << std::endl;
1165
1166 // loop signatures
1167 for(int i=0; i< fdef.VariantsSize(); i++) {
1168 const Signature& sigi=fdef.Variant(i);
1169 *pOutFile << "<p>" << fdef.Name() << "(";
1170 // loop params
1171 for(int j=0; j < sigi.Size(); j++) {
1172 if(j!=0) *pOutFile << ", ";
1173 const Parameter& parj=sigi.At(j);
1174 *pOutFile << "<span>+" << Parameter::AStr(parj.Attribute()) << "+ ";
1175 TypeHtml(pOutFile,parj.Type());
1176 *pOutFile << " <i>" << parj.Name() << "</i></span>";
1177 }
1178 *pOutFile << ")</p>" << std::endl;
1179 }
1180
1181
1182 // close signature box
1183 *pOutFile << std::endl << "</div>" << std::endl;
1184}
1185
1186// ******************************************************************
1187// short doc
1188// ******************************************************************
1189
1190void ShortdocHtml(std::ostream* pOutFile, std::string fname) {
1191
1192 // its a function
1193 if(FunctionRegistry::G()->Exists(fname)) {
1194
1195 // function definition
1197
1198 // stream doc
1199 //*pOutFile << "<div class=\"registry_signature\">" << std::endl;
1200 *pOutFile << "<p>" << fdef.TextDoc() << "</p>" << std::endl;
1201 //*pOutFile << "</div>" << std::endl;
1202
1203 // stream signature
1204 SignatureHtml(pOutFile,fname);
1205 }
1206
1207 // its a type
1208 if(TypeRegistry::G()->Exists(fname)) {
1209
1210 // type definition
1211 const TypeDefinition& tdef=TypeRegistry::G()->Definition(fname);
1212
1213 // stream doc
1214 //*pOutFile << "<div class=\"registry_signature\">" << std::endl;
1215 *pOutFile << "<p>" << tdef.TextDoc() << "<p>" << std::endl;
1216 //*pOutFile << "</div>" << std::endl;
1217
1218 }
1219
1220}
1221
1222
1223
1224
1225// ******************************************************************
1226// record literature
1227// ******************************************************************
1228
1229// record
1231public:
1232 std::string mLabel;
1233 std::string mLink;
1234 std::string mAuthors;
1235 std::string mTitle;
1236 std::string mJournal;
1237 std::string mPublisher;
1238 std::string mYear;
1239};
1240
1241// data
1242std::map<std::string,LiteratureRecord> mLiterature;
1243
1244// extract all from a section
1246 // record my level
1247 int clevel = rTr.Level();
1248 // std::cerr << "process level " << clevel << "\n";
1249 // token loop
1250 while(true) {
1251 // skip plain text
1252 std::string text;
1253 rTr.ReadCharacterData(text);
1254 if(text.size()>0) continue;
1255 // break on no token or end of my level
1256 Token token;
1257 if(!rTr.Peek(token)) break;
1258 if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
1259 break;
1260 // track where we are
1261 if(token.IsBegin("ReferencePage")) {
1262 mFrefChapter="";
1263 if(token.ExistsAttributeString("chapter"))
1264 mFrefChapter=token.AttributeStringValue("chapter");
1265 mFrefSection="";
1266 if(token.ExistsAttributeString("section"))
1267 mFrefSection=token.AttributeStringValue("section");
1268 std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1269 std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1270 // report
1271 // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
1272 }
1273 // ignore other tokens
1274 if(!token.IsBegin("fliterature")) {
1275 rTr.Get(token);
1276 continue;
1277 }
1278 // do my special tag: fliterature
1279 rTr.ReadBegin("fliterature");
1280 std::string label=token.AttributeStringValue("name");
1281 //std::cerr << "process literature " << label << "\n";
1282 LiteratureRecord litrec;
1283 litrec.mLabel=label;
1284 litrec.mLink = mFrefSection + "_index.html#lit_" + label;
1285 //process entries
1286 while(!rTr.Eos("fliterature")) {
1287 Token token;
1288 rTr.Peek(token);
1289 //std::cerr << "process literature peek " << token.Str() << "\n";
1290 if(token.IsBegin("fauthors")) {
1291 rTr.ReadBegin("fauthors");
1292 rTr.ReadSection(litrec.mAuthors);
1293 rTr.ReadEnd("fauthors");
1294 continue;
1295 }
1296 if(token.IsBegin("ftitle")) {
1297 rTr.ReadBegin("ftitle");
1298 rTr.ReadSection(litrec.mTitle);
1299 rTr.ReadEnd("ftitle");
1300 continue;
1301 }
1302 if(token.IsBegin("fjournal")) {
1303 rTr.ReadBegin("fjournal");
1304 rTr.ReadSection(litrec.mJournal);
1305 rTr.ReadEnd("fjournal");
1306 continue;
1307 }
1308 if(token.IsBegin("fyear")) {
1309 rTr.ReadBegin("fyear");
1310 rTr.ReadSection(litrec.mYear);
1311 rTr.ReadEnd("fyear");
1312 continue;
1313 }
1314 if(token.IsBegin("flink")) {
1315 rTr.ReadBegin("flink");
1316 rTr.ReadSection(litrec.mLink);
1317 rTr.ReadEnd("flink");
1318 continue;
1319 }
1320 if(token.IsBegin()) {
1321 rTr.ReadBegin(token.StringValue());
1322 rTr.ReadEnd(token.StringValue());
1323 continue;
1324 }
1325 rTr.Get(token);
1326 }
1327 // insert entry
1328 if(litrec.mLabel!="")
1329 mLiterature[litrec.mLabel]=litrec;
1330 // done
1331 rTr.ReadEnd("fliterature");
1332 }
1333}
1334
1335
1336// dump literature records to include file
1338 // loop records
1339 std::map<std::string,LiteratureRecord>::iterator lit;
1340 for(lit=mLiterature.begin(); lit!=mLiterature.end(); lit++) {
1341 Token btag;
1342 btag.SetBegin("fliterature");
1343 btag.InsAttributeString("name",lit->second.mLabel);
1344 rTw << btag;
1345 if(lit->second.mAuthors!="") {
1346 rTw.WriteBegin("fauthors");
1347 rTw.WriteCharacterData(lit->second.mAuthors);
1348 rTw.WriteEnd("fauthors");
1349 }
1350 if(lit->second.mTitle!="") {
1351 rTw.WriteBegin("ftitle");
1352 rTw.WriteCharacterData(lit->second.mTitle);
1353 rTw.WriteEnd("ftitle");
1354 }
1355 if(lit->second.mJournal!="") {
1356 rTw.WriteBegin("fjournal");
1357 rTw.WriteCharacterData(lit->second.mJournal);
1358 rTw.WriteEnd("fjournal");
1359 }
1360 if(lit->second.mPublisher!="") {
1361 rTw.WriteBegin("fpublisher");
1362 rTw.WriteCharacterData(lit->second.mPublisher);
1363 rTw.WriteEnd("fpublisher");
1364 }
1365 if(lit->second.mYear!="") {
1366 rTw.WriteBegin("fyear");
1367 rTw.WriteCharacterData(lit->second.mYear);
1368 rTw.WriteEnd("fyear");
1369 }
1370 if(lit->second.mLink!="") {
1371 rTw.WriteBegin("flink");
1372 rTw.WriteCharacterData(lit->second.mLink);
1373 rTw.WriteEnd("flink");
1374 }
1375 rTw.WriteEnd("fliterature");
1376 rTw.Endl();
1377 }
1378}
1379
1380
1381// html for (one) literature reference
1382void LiteratureHtml(std::ostream* pStream, const std::string& rLabel="") {
1383 // loop records
1384 std::map<std::string,LiteratureRecord>::iterator lit;
1385 for(lit=mLiterature.begin(); lit!=mLiterature.end(); lit++) {
1386 // skip for no match
1387 if(rLabel!="")
1388 if(rLabel!=lit->second.mLabel) continue;
1389 // produce html
1390 *pStream << "<p>" << std::endl;
1391 *pStream << "<a id=\"" << "lit_" << lit->second.mLabel << "\">[" << lit->second.mLabel << "]</a>" << std::endl;
1392 *pStream << lit->second.mAuthors << ": ";
1393 *pStream << "<i>" << lit->second.mTitle << "</i>";
1394 if(lit->second.mJournal!="") *pStream << ", " << lit->second.mJournal;
1395 if(lit->second.mPublisher!="") *pStream << ", " << lit->second.mPublisher;
1396 if(lit->second.mYear!="") *pStream << ", " << lit->second.mYear;
1397 *pStream << ".</p>" << std::endl;
1398 }
1399}
1400
1401
1402// html for literature citation
1403void CiteHtml(std::ostream* pStream, const std::string& rLabel) {
1404 // prepare
1405 std::string link="reference_literature.html";
1406 // find records
1407 std::map<std::string,LiteratureRecord>::iterator lit;
1408 lit=mLiterature.find(rLabel);
1409 if(lit!=mLiterature.end()) link=lit->second.mLink;
1410 // produce HTML
1411 *pStream << "<a href=\"" << link << "\">[" << rLabel << "]</a>";
1412}
1413
1414
1415// ******************************************************************
1416// extract pages
1417// ******************************************************************
1418
1419void XtractPages(TokenReader& src,const std::string& rDstDir) {
1420
1421 // scan for reference page sections
1422 Token btag;
1423 while(src.Peek(btag)) {
1424 // skip tokens
1425 if(!btag.IsBegin("ReferencePage")) {
1426 src.Get(btag);
1427 continue;
1428 }
1429 // read begin tag
1430 src.ReadBegin("ReferencePage",btag);
1431 // extract title & friends
1432 mFrefTitle="libFAUDES Reference";
1433 if(btag.ExistsAttributeString("title"))
1434 mFrefTitle=btag.AttributeStringValue("title");
1435 mFrefChapter="Reference";
1436 if(btag.ExistsAttributeString("chapter"))
1437 mFrefChapter=btag.AttributeStringValue("chapter");
1438 mFrefSection="";
1439 if(btag.ExistsAttributeString("section"))
1440 mFrefSection=btag.AttributeStringValue("section");
1441 mFrefPage="";
1442 if(btag.ExistsAttributeString("page"))
1443 mFrefPage=btag.AttributeStringValue("page");
1444 // insist in page and section
1445 if(mFrefSection=="" || mFrefPage=="") {
1446 std::cerr << "ref2html: skipping undefined page at " << src.FileLine() << std::endl;
1447 src.ReadEnd("ReferencePage");
1448 continue;
1449 }
1450 // normalize & report
1451 std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1452 std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1453 std::transform(mFrefPage.begin(), mFrefPage.end(), mFrefPage.begin(), tolower);
1454 // dst file
1455 std::string dstfile=PrependPath(rDstDir,mFrefSection + "_" + mFrefPage +".fref");
1456 std::cerr << "ref2html: extracting page to \"" << dstfile << "\"" << std::endl;
1457 TokenWriter dst(dstfile);
1458 // copy section
1459 dst.Write(btag);
1460 std::string srctext;
1461 src.ReadSection(srctext);
1462 dst.WriteCharacterData(srctext);
1463 dst.WriteEnd("ReferencePage");
1464 // read end tag
1465 src.ReadEnd("ReferencePage");
1466 }
1467}
1468
1469// ******************************************************************
1470// extract files
1471// ******************************************************************
1472
1473void XtractFiles(TokenReader& src,const std::string& rDstDir) {
1474
1475 // scan for file sections
1476 Token btag;
1477 while(src.Peek(btag)) {
1478 // skip tokens
1479 if(!btag.IsBegin("ImageFile")) {
1480 src.Get(btag);
1481 continue;
1482 }
1483 // read begin tag
1484 src.ReadBegin("ImageFile",btag);
1485 std::string name=btag.AttributeStringValue("name");
1486 if(name==""){
1487 std::cerr << "ref2html: skipping undefined image file at " << src.FileLine() << std::endl;
1488 src.ReadEnd("ImageFile");
1489 continue;
1490 }
1491 // read data
1492 Token data;
1493 src.Get(data);
1494 if(!data.IsBinary()){
1495 std::cerr << "ref2html: skipping invalid image file at " << src.FileLine() << std::endl;
1496 src.ReadEnd("ImageFile");
1497 continue;
1498 }
1499 // dst file
1500 std::string dstfile;
1501 std::transform(name.begin(), name.end(), name.begin(), tolower);
1502 dstfile=PrependPath(rDstDir,"images");
1503 dstfile=PrependPath(dstfile,name);
1504 std::cerr << "ref2html: extracting image file to \"" << dstfile << "\"" << std::endl;
1505 // setup stream
1506 std::fstream fsout;
1507 fsout.exceptions(std::ios::badbit|std::ios::failbit);
1508 try{
1509 fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
1510 fsout.write(data.StringValue().c_str(),data.StringValue().size());
1511 fsout.close();
1512 }
1513 catch (std::ios::failure&) {
1514 std::cerr << "ref2html: file io error when writing \"" << dstfile << "\"" << std::endl;
1515 }
1516 // read end tag
1517 src.ReadEnd("ImageFile");
1518 }
1519}
1520
1521// ******************************************************************
1522// luafaudes index
1523// ******************************************************************
1524
1525void LuafaudesIndexHtml(std::ostream* pIndexFile) {
1526
1527 // prepare list of all sections
1528 std::map< std::string , std::string > pages;
1529 std::vector< PageRecord >::iterator pit;
1530 for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1531 // my chapter only
1532 if(pit->mChapter!="luafaudes") continue;
1533 if(pit->mSection=="none") continue;
1534 if(pit->mSection=="") continue;
1535 if(pit->mPage=="") continue;
1536 // get nice name
1537 std::string pname = pit->mPage;
1538 // have link
1539 std::string phtml = pit->mLink;
1540 // record
1541 pages[pname]=phtml;
1542 }
1543 // produce sorted index
1544 std::map< std::string , std::string >::iterator sit;
1545 for(sit=pages.begin(); sit!=pages.end(); sit++) {
1546 // have entry
1547 ListItemHtml(pIndexFile,sit->second, sit->first);
1548 }
1549 // empty
1550 if(pages.size()==0) {
1551 *pIndexFile << "<li class=\"registry_item\">" << "none" << "</li>" << std::endl;
1552 }
1553}
1554
1555// ******************************************************************
1556// pythonmod index
1557// ******************************************************************
1558
1559void PythonmodIndexHtml(std::ostream* pIndexFile) {
1560
1561 // prepare list of all sections
1562 std::map< std::string , std::string > pages;
1563 std::vector< PageRecord >::iterator pit;
1564 for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1565 // my chapter only
1566 if(pit->mChapter!="pythonmod") continue;
1567 if(pit->mSection=="none") continue;
1568 if(pit->mSection=="") continue;
1569 if(pit->mPage=="") continue;
1570 // get nice name
1571 std::string pname = pit->mPage;
1572 // have link
1573 std::string phtml = pit->mLink;
1574 // record
1575 pages[pname]=phtml;
1576 }
1577 // produce sorted index
1578 std::map< std::string , std::string >::iterator sit;
1579 for(sit=pages.begin(); sit!=pages.end(); sit++) {
1580 // have entry
1581 ListItemHtml(pIndexFile,sit->second, sit->first);
1582 }
1583 // empty
1584 if(pages.size()==0) {
1585 *pIndexFile << "<li class=\"registry_item\">" << "none" << "</li>" << std::endl;
1586 }
1587}
1588
1589
1590// ******************************************************************
1591// process current section
1592// ******************************************************************
1593
1595
1596 // record my level/mode
1597 int clevel = rTr.Level();
1598
1599 // std::cerr << "process level " << clevel << "\n";
1600
1601 // token copy loop
1602 while(true) {
1603 // see whether we can grab and copy some plain text
1604 std::string text;
1605 rTr.ReadCharacterData(text);
1606 if(text.size()>0) {
1607 //std::cerr << "copy text \"" << text << "\"\n";
1608 rTw.WriteCharacterData(text);
1609 continue;
1610 }
1611 // break on no token or end of my level
1612 Token token;
1613 if(!rTr.Peek(token)) break;
1614 if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
1615 break;
1616 // do my special tags: ftype
1617 if(token.IsBegin("ftype")) {
1618 std::string ftype;
1619 rTr.ReadText("ftype",ftype);
1620 TypeHtml(rTw.Streamp(),ftype);
1621 continue;
1622 }
1623 // do my special tags: ffnct
1624 if(token.IsBegin("ffnct")) {
1625 std::string ffnct;
1626 rTr.ReadText("ffnct",ffnct);
1627 FunctionHtml(rTw.Streamp(),ffnct);
1628 continue;
1629 }
1630 // do my special tags: fimage
1631 if(token.IsBegin("fimage")) {
1632 rTr.ReadBegin("fimage", token);
1633 std::string fsrc=token.AttributeStringValue("fsrc");
1634 fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",""); // be nice
1635 fsrc = ExtractBasename(fsrc); // be even niecer
1636 ImageHtml(rTw.Streamp(),fsrc);
1637 rTr.ReadEnd("fimage");
1638 continue;
1639 }
1640 // do my special tags: dmath
1641 if(token.IsBegin("fdmath")) {
1642 rTr.ReadBegin("fdmath", token);
1643 std::string mtext;
1644 rTr.ReadCharacterData(mtext);
1645 *rTw.Streamp() << "<span class=\"faudes_dmath\">";
1646 MathHtml(rTw.Streamp(),mtext);
1647 *rTw.Streamp()<< "</span>";
1648 rTr.ReadEnd("fdmath");
1649 continue;
1650 }
1651 // do my special tags: imath
1652 if(token.IsBegin("fimath")) {
1653 rTr.ReadBegin("fimath", token);
1654 std::string mtext;
1655 rTr.ReadCharacterData(mtext);
1656 *rTw.Streamp()<< "<span class=\"faudes_imath\">";
1657 MathHtml(rTw.Streamp(),mtext);
1658 *rTw.Streamp()<< "</span>";
1659 rTr.ReadEnd("fimath");
1660 continue;
1661 }
1662 // do my special tags: ffnct_reference
1663 if(token.IsBegin("ffnct_reference")) {
1664 rTr.ReadBegin("ffnct_reference", token);
1665 std::string ffnct = token.AttributeStringValue("name");
1666 *rTw.Streamp() << "<div class=\"registry_function\"> " << std::endl;
1667 *rTw.Streamp() << "<h2>" << "<a id=\"" << ffnct << "\">" << ffnct << "</a></h2>" << std::endl;
1668 ShortdocHtml(rTw.Streamp(),ffnct);
1669 ProcessSection(rTw,rTr);
1670 *rTw.Streamp() << "</div>" << std::endl;
1671 rTr.ReadEnd("ffnct_reference");
1672 continue;
1673 }
1674 // do my special tags: ftype_reference
1675 if(token.IsBegin("ftype_reference")) {
1676 rTr.ReadBegin("ftype_reference", token);
1677 std::string ftype = token.AttributeStringValue("name");
1678 *rTw.Streamp() << "<div class=\"registry_type\"> " << std::endl;
1679 *rTw.Streamp() << "<h2>" << "<a id=\"" << ftype << "\">" << ftype << "</a></h2>" << std::endl;
1680 ShortdocHtml(rTw.Streamp(),ftype);
1681 ProcessSection(rTw,rTr);
1682 *rTw.Streamp() << "</div>" << std::endl;
1683 rTr.ReadEnd("ftype_reference");
1684 continue;
1685 }
1686 // do my special tags: fdetails
1687 if(token.IsBegin("fdetails")) {
1688 rTr.ReadBegin("fdetails", token);
1689 *rTw.Streamp() << "<h5>Detailed description:</h5>";
1690 rTr.ReadEnd("fdetails");
1691 continue;
1692 }
1693 // do my special tags: fconditions
1694 if(token.IsBegin("fconditions")) {
1695 rTr.ReadBegin("fconditions", token);
1696 *rTw.Streamp() << "<h5>Parameter Conditions:</h5>";
1697 rTr.ReadEnd("fconditions");
1698 continue;
1699 }
1700 // do my special tags: fexample
1701 if(token.IsBegin("fexample")) {
1702 rTr.ReadBegin("fexample", token);
1703 *rTw.Streamp() << "<h5>Example:</h5>";
1704 rTr.ReadEnd("fexample");
1705 continue;
1706 }
1707 // do my special tags: falltypes
1708 if(token.IsBegin("falltypes")) {
1709 rTr.ReadBegin("falltypes", token);
1710 ListTypesHtml(rTw.Streamp());
1711 rTr.ReadEnd("falltypes");
1712 continue;
1713 }
1714 // do my special tags: fallfncts
1715 if(token.IsBegin("fallfncts")) {
1716 rTr.ReadBegin("fallfncts", token);
1718 rTr.ReadEnd("fallfncts");
1719 continue;
1720 }
1721 // do my special tags: fallsects
1722 if(token.IsBegin("fallsects")) {
1723 rTr.ReadBegin("fallsects", token);
1725 rTr.ReadEnd("fallsects");
1726 continue;
1727 }
1728 // do my special tags: fluasects
1729 if(token.IsBegin("fluasects")) {
1730 rTr.ReadBegin("fluasects", token);
1731 ListSectionsHtml(rTw.Streamp(),"luaext");
1732 rTr.ReadEnd("fluasects");
1733 continue;
1734 }
1735 // do my special tags: fliteratur (list all)
1736 if(token.IsBegin("falllit")) {
1737 rTr.ReadBegin("falllit");
1738 LiteratureHtml(rTw.Streamp());
1739 rTr.ReadEnd("falllit");
1740 continue;
1741 }
1742 // do my special tags: fliterature (definition of)
1743 if(token.IsBegin("fliterature")) {
1744 rTr.ReadBegin("fliterature", token);
1745 std::string label=token.AttributeStringValue("name");
1746 LiteratureHtml(rTw.Streamp(),label);
1747 rTr.ReadEnd("fliterature");
1748 continue;
1749 }
1750 // do my special tags: fcontributors
1751 if(token.IsBegin("fcontributors")) {
1752 rTr.ReadBegin("fcontributors");
1753 *rTw.Streamp() << ContributorsString();
1754 rTr.ReadEnd("fcontributors");
1755 continue;
1756 }
1757 // do my special tags: fcite
1758 if(token.IsBegin("fcite")) {
1759 rTr.ReadBegin("fcite", token);
1760 std::string label=token.AttributeStringValue("name");
1761 CiteHtml(rTw.Streamp(),label);
1762 rTr.ReadEnd("fcite");
1763 continue;
1764 }
1765 // do my special tags: fix br for HTML
1766 if(token.IsBegin("br")) {
1767 rTr.ReadBegin("br");
1768 Token etag;
1769 rTr.Peek(etag);
1770 if(etag.IsEnd("br")) rTr.ReadEnd("br"); // optionally accept balanced <br>
1771 token.ClrEnd();
1772 token.PreceedingSpace("n");
1773 rTw.Write(token); // intentionall write unbalanced <br> for HTML
1774 continue;
1775 }
1776 // do my special tags: fsummary
1777 if(token.IsBegin("fsummary")) {
1778 rTr.ReadBegin("fsummary");
1779 rTr.ReadEnd("fsummary");
1780 continue;
1781 }
1782 // get token to do my special attributes
1783 rTr.Get(token);
1784 //std::cerr << "copy token (lv " << rTr.Level() << "): " << token.Str() << "\n";
1785 // sense chapter classes
1786 if(token.ExistsAttributeString("ftcclass")) {
1787 mThisChapterClass=token.AttributeStringValue("ftcclass");
1788 token.ClrAttribute("ftcclass");
1789 }
1790 if(token.ExistsAttributeString("focclass")) {
1791 mOtherChapterClass=token.AttributeStringValue("focclass");
1792 token.ClrAttribute("focclass");
1793 }
1794 if(token.ExistsAttributeString("fxcclass")) {
1795 mExitChapterClass=token.AttributeStringValue("fxcclass");
1796 token.ClrAttribute("fxcclass");
1797 }
1798 // chapter attribute
1799 if(token.ExistsAttributeString("fchapter")) {
1800 std::string chapter = token.AttributeStringValue("fchapter");
1801 std::string cclass=mOtherChapterClass;
1802 if(chapter==mFrefChapter) cclass=mThisChapterClass;
1803 if(chapter=="exit") cclass=mExitChapterClass;
1804 token.InsAttributeString("class",cclass);
1805 token.ClrAttribute("fchapter");
1806 }
1807 // fhref attribute: ref only
1808 if(token.ExistsAttributeString("fhref") && mStandaloneReference) {
1809 std::string href = token.AttributeStringValue("fhref");
1810 href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1811 href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1812 href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1813 href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1814 href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourceLink);
1815 href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesLink);
1816 href = StringSubstitute(href,"FAUDES_PYTHONMOD/",mPythonmodLink);
1817 href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1818 href = StringSubstitute(href,"FAUDES_DOWNLOAD",mDownloadLink);
1819 href = StringSubstitute(href,"FAUDES_GETLX",mDownloadLink+"#Packages");
1820 href = StringSubstitute(href,"FAUDES_GETOSX",mDownloadLink+"#Packages");
1821 href = StringSubstitute(href,"FAUDES_GETWIN",mDownloadLink+"#Packages");
1822 href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1823 token.InsAttributeString("href",href);
1824 token.ClrAttribute("fhref");
1825 }
1826 // fhref attribute
1827 if(token.ExistsAttributeString("fhref") && !mStandaloneReference) {
1828 std::string href = token.AttributeStringValue("fhref");
1829 href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1830 href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1831 href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1832 href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1833 href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourcePrefix);
1834 href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1835 href = StringSubstitute(href,"FAUDES_PYTHONMOD/",mPythonmodPrefix);
1836 href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1837 href = StringSubstitute(href,"FAUDES_DOWNLOAD",mDownloadLink);
1838 href = StringSubstitute(href,"FAUDES_GETLX",mDownloadLink+"#Packages");
1839 href = StringSubstitute(href,"FAUDES_GETOSX",mDownloadLink+"#Packages");
1840 href = StringSubstitute(href,"FAUDES_GETWIN",mDownloadLink+"#Packages");
1841 href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1842 token.InsAttributeString("href",href);
1843 token.ClrAttribute("fhref");
1844 }
1845 // fsrc attribute
1846 if(token.ExistsAttributeString("fsrc")) {
1847 std::string fsrc = token.AttributeStringValue("fsrc");
1848 fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",mImagePrefix);
1849 fsrc = StringSubstitute(fsrc,"FAUDES_CSOURCE/",mCsourcePrefix);
1850 fsrc = StringSubstitute(fsrc,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1851 fsrc = StringSubstitute(fsrc,"FAUDES_PYTHONMOD/",mPythonmodPrefix);
1852 token.InsAttributeString("src",fsrc);
1853 token.ClrAttribute("fsrc");
1854 }
1855 token.PreceedingSpace("n");
1856 rTw.Write(token);
1857 }
1858}
1859
1860
1861// ******************************************************************
1862// reference page
1863// ******************************************************************
1864
1865void RefpageHtml(std::ostream* pOutFile, std::string inputfile) {
1866
1867 // setup token io
1868 TokenReader src(inputfile);
1869 TokenWriter dst(*pOutFile);
1870
1871 // find the reference page section
1872 Token btag;
1873 src.SeekBegin("ReferencePage");
1874 src.ReadBegin("ReferencePage",btag);
1875
1876 // extract title & friends
1877 mFrefTitle="libFAUDES Reference";
1878 if(btag.ExistsAttributeString("title"))
1879 mFrefTitle=btag.AttributeStringValue("title");
1880 mFrefChapter="";
1881 if(btag.ExistsAttributeString("chapter"))
1882 mFrefChapter=btag.AttributeStringValue("chapter");
1883 mFrefSection="";
1884 if(btag.ExistsAttributeString("section"))
1885 mFrefSection=btag.AttributeStringValue("section");
1886 std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1887 std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1888
1889 // report
1890 // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
1891
1892 // generate generic html header
1893 dst.Flush();
1894 HeaderHtml(pOutFile);
1895
1896 // begin body
1897 dst.Flush();
1898
1899 // include chapter level navigation
1900 if(mChapterFile!="") {
1901 //std::cerr << "using " << mChapterFile << std::endl;
1903 ProcessSection(dst,inc);
1904 }
1905
1906 // include section level navigation, part 1
1907 if(mFrefChapter=="reference") {
1908 *pOutFile << "<table id=\"registry_page\">" << std::endl;
1909 *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1910 *pOutFile << "<td id=\"registry_index\">" << std::endl;
1911 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1912 *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
1913 ListItemHtml(pOutFile,"reference_index.html", "Reference");
1914 ListItemHtml(pOutFile,"reference_types.html", "Type Index");
1915 ListItemHtml(pOutFile,"reference_functions.html", "Function Index");
1916 ListItemHtml(pOutFile,"reference_literature.html", "Literature");
1917 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1919 *pOutFile << "</ul></td>" << std::endl;
1920 *pOutFile << "<td id=\"registry_content\">" << std::endl;
1921 }
1922
1923 // include section level navigation, part 1
1924 if(mFrefChapter=="luafaudes") {
1925 *pOutFile << "<table id=\"registry_page\">" << std::endl;
1926 *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1927 *pOutFile << "<td id=\"registry_index\">" << std::endl;
1928 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1929 *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
1930 *pOutFile
1931 << "<script language=\"JavaScript\"> var luafaudes=function() { "
1932 << " popupWin = window.open('luafaudes_repl.html','open_window',"
1933 << " 'resizable,dependent, width=720, height=480, left=0, top=0'); } "
1934 << "</script>" << std::endl;
1935 ListItemHtml(pOutFile,"index.html", "Introduction");
1936 ListItemHtml(pOutFile,"javascript:luafaudes();", "Lua-Console");
1937 ListItemHtml(pOutFile,"faudes_luaext.html", "Lua-Extensions");
1938 ListItemHtml(pOutFile,"faudes_luatech.html", "Technical Detail");
1939 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1940 *pOutFile << "<li class=\"registry_heading\">Tutorials</li>" << std::endl;
1941 LuafaudesIndexHtml(pOutFile);
1942 *pOutFile << "</ul></td>" << std::endl;
1943 *pOutFile << "<td id=\"registry_content\">" << std::endl;
1944 }
1945
1946 // include section level navigation, part 1
1947 if(mFrefChapter=="pythonmod") {
1948 *pOutFile << "<table id=\"registry_page\">" << std::endl;
1949 *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1950 *pOutFile << "<td id=\"registry_index\">" << std::endl;
1951 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1952 *pOutFile << "<li class=\"registry_heading\">Python Module</li>" << std::endl;
1953 ListItemHtml(pOutFile,"index.html", "Introduction");
1954 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1955 *pOutFile << "<li class=\"registry_heading\">Tutorials</li>" << std::endl;
1956 PythonmodIndexHtml(pOutFile);
1957 *pOutFile << "</ul></td>" << std::endl;
1958 *pOutFile << "<td id=\"registry_content\">" << std::endl;
1959 }
1960
1961 // process src
1962 ProcessSection(dst,src);
1963 src.ReadEnd("ReferencePage");
1964 dst.Flush();
1965
1966 // track bottom line
1967 bool bottom=false;
1968
1969 // include section level navigation, part 2
1970 if(mFrefChapter=="reference") {
1971 BottomLineHtml(pOutFile);
1972 bottom=true;
1973 *pOutFile << "</td>" << std::endl;
1974 *pOutFile << "</tr>" << std::endl;
1975 *pOutFile << "</table>" << std::endl;
1976 }
1977
1978 // include section level navigation, part 2
1979 if(mFrefChapter=="luafaudes") {
1980 BottomLineHtml(pOutFile);
1981 bottom=true;
1982 *pOutFile << "</td>" << std::endl;
1983 *pOutFile << "</tr>" << std::endl;
1984 *pOutFile << "</table>" << std::endl;
1985 }
1986
1987 // include section level navigation, part 2
1988 if(mFrefChapter=="pythonmod") {
1989 BottomLineHtml(pOutFile);
1990 bottom=true;
1991 *pOutFile << "</td>" << std::endl;
1992 *pOutFile << "</tr>" << std::endl;
1993 *pOutFile << "</table>" << std::endl;
1994 }
1995
1996 // include section level navigation, part 3
1997 if(mFrefChapter=="reference") {
1998 *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
1999 *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
2000 *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
2001 *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
2002 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2004 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2005 ListItemHtml(pOutFile,"#", "Top of Page");
2006 *pOutFile << "</ul></div>" << std::endl;
2007 }
2008
2009 // include section level navigation, part 3
2010 if(mFrefChapter=="luafaudes" && mFrefSection=="tutorials") {
2011 *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
2012 *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
2013 *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
2014 *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
2015 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2016 *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
2017 *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luafaudes.html\">Introduction</a></li>" << std::endl;
2018 *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luaext.html\">Lua-Extansions</a></li>" << std::endl;
2019 *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luatech.html\">Techn. Details</a></li>" << std::endl;
2020 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2021 *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
2022 *pOutFile << "</ul></div>" << std::endl;
2023 }
2024
2025 // include section level navigation, part 3
2026 if(mFrefChapter=="pythonmod" && mFrefSection=="tutorials") {
2027 *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
2028 *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
2029 *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
2030 *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
2031 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2032 *pOutFile << "<li class=\"registry_heading\">Python Module</li>" << std::endl;
2033 *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_pythonmod.html\">Introduction</a></li>" << std::endl;
2034 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2035 *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
2036 *pOutFile << "</ul></div>" << std::endl;
2037 }
2038
2039 // bottom line
2040 if(!bottom) BottomLineHtml(pOutFile);
2041
2042 // generic footer
2043 FooterHtml(pOutFile);
2044
2045}
2046
2047
2048
2049// ******************************************************************
2050// Doxygen header and footer
2051// ******************************************************************
2052
2053void DoxygenHeader(std::ostream* pOutFile) {
2054
2055 // setup token io
2056 TokenWriter dst(*pOutFile);
2057
2058 // configure
2059 mFrefTitle="C++ API";
2060 mFrefChapter="cppapi";
2061 mFrefSection="none";
2062
2063 // generate generic html header
2064 dst.Flush();
2065 HeaderHtml(pOutFile);
2066
2067 // include chapter level navigation
2068 if(mChapterFile!="") {
2070 ProcessSection(dst,inc);
2071 }
2072
2073 // include section level navigation, part 1
2074 *pOutFile << "<table id=\"registry_page\">" << std::endl;
2075 *pOutFile << "<tr id=\"registry_row\">" << std::endl;
2076 *pOutFile << "<td id=\"registry_index\">" << std::endl;
2077 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2078 *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
2079 ListItemHtml(pOutFile, "index.html", "C++ API");
2080 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2081 *pOutFile << "<li class=\"registry_heading\">Sections</li>" << std::endl;
2082 ListItemHtml(pOutFile, "group__ContainerClasses.html", "Sets");
2083 ListItemHtml(pOutFile, "group__GeneratorClasses.html", "Generators");
2084 ListItemHtml(pOutFile, "group__GeneratorFunctions.html", "Functions");
2085 ListItemHtml(pOutFile, "group__AllPlugins.html", "PlugIns");
2086 ListItemHtml(pOutFile, "group__Tutorials.html", "Tutorials");
2087 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2088 *pOutFile << "<li class=\"registry_heading\">Index</li>" << std::endl;
2089 ListItemHtml(pOutFile, "classes.html", "Classes");
2090 ListItemHtml(pOutFile, "files.html", "Files");
2091 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2092 *pOutFile << "</ul></td>" << std::endl;
2093 *pOutFile << "<td id=\"registry_content\">" << std::endl;
2094}
2095
2096
2097void DoxygenFooter(std::ostream* pOutFile) {
2098
2099 // setup token io
2100 TokenWriter dst(*pOutFile);
2101
2102 // configure
2103 mFrefTitle="C++ API";
2104 mFrefChapter="cppapi";
2105 mFrefSection="none";
2106
2107 // include section level navigation, part 2
2108 BottomLineHtml(pOutFile);
2109 *pOutFile << "</td>" << std::endl;
2110 *pOutFile << "</tr>" << std::endl;
2111 *pOutFile << "</table>" << std::endl;
2112
2113 // include section level navigation, part 3
2114 *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
2115 *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
2116 *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
2117 *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
2118 *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2119 *pOutFile << "<li class=\"registry_heading\">C++ API</li>" << std::endl;
2120 *pOutFile << "<li class=\"registry_item\"><a href=\"index.html\">Introduction</a></li>" << std::endl;
2121 *pOutFile << "<li class=\"registry_item\"><a href=\"group__ContainerClasses.html\">Sets</a></li>" << std::endl;
2122 *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorClasses.html\">Generators</a></li>" << std::endl;
2123 *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorFunctions.html\">Functions</a></li>" << std::endl;
2124 *pOutFile << "<li class=\"registry_item\"><a href=\"group__AllPlugins.html\">PlugIns</a></li>" << std::endl;
2125 *pOutFile << "<li class=\"registry_item\"><a href=\"group__Tutorials.html\">Tutorials</a></li>" << std::endl;
2126 *pOutFile << "<li class=\"registry_item\"><a href=\"classes.html\">Classes</a></li>" << std::endl;
2127 *pOutFile << "<li class=\"registry_item\"><a href=\"files.html\">Files</a></li>" << std::endl;
2128 *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2129 *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
2130 *pOutFile << "</ul></div>" << std::endl;
2131
2132 // end page
2133 dst.Flush();
2134 FooterHtml(pOutFile);
2135
2136}
2137
2138// ******************************************************************
2139// command line ui
2140// ******************************************************************
2141
2142
2143int main(int argc, char *argv[]) {
2144
2145 // local config
2146 bool dotoc=false;
2147 bool dodhd=false;
2148 bool dodft=false;
2149 bool xpage=false;
2150
2151 // min args
2152 if(argc < 3) usage_exit();
2153
2154 // primitive commad line parsing
2155 int i;
2156 for(i=1; i<argc; i++) {
2157 std::string option(argv[i]);
2158 // option: rti file
2159 if(option=="-rti") {
2160 i++; if(i>=argc) usage_exit();
2161 mRtiFile=argv[i];
2162 continue;
2163 }
2164 // option: flx file
2165 if(option=="-flx") {
2166 i++; if(i>=argc) usage_exit();
2167 mFlxFile=argv[i];
2168 continue;
2169 }
2170 // option: css file
2171 if(option=="-css") {
2172 i++; if(i>=argc) usage_exit();
2173 mCssFile=argv[i];
2174 continue;
2175 }
2176 // option: navigation include
2177 if(option=="-cnav") {
2178 i++; if(i>=argc) usage_exit();
2179 mChapterFile=argv[i];
2180 continue;
2181 }
2182 // option: toc include
2183 if(option=="-inc") {
2184 i++; if(i>=argc) usage_exit();
2185 mIncludeFile=argv[i];
2186 continue;
2187 }
2188 // option: target prefix
2189 if(option=="-rel") {
2190 i++; if(i>=argc) usage_exit();
2191 ChaptersPrefix(argv[i]);
2192 continue;
2193 }
2194 // option: overwrite chapter
2195 if(option=="-chapter") {
2196 i++; if(i>=argc) usage_exit();
2197 mFrefChapter=argv[i];
2198 continue;
2199 }
2200 // option: overwrite section
2201 if(option=="-section") {
2202 i++; if(i>=argc) usage_exit();
2203 mFrefSection=argv[i];
2204 continue;
2205 }
2206 // option: extract multiple pages
2207 if(option=="-extract") {
2208 if(i+2!=argc-1) usage_exit();
2209 xpage=true;
2210 break;
2211 }
2212 // option: generate toc (break)
2213 if(option=="-toc") {
2214 i++; if(i+1>=argc) usage_exit();
2215 dotoc=true;
2216 mDstFile = argv[argc-1];
2217 break;
2218 }
2219 // option: generate doxygen header (break)
2220 if(option=="-doxheader") {
2221 i++; if(i>=argc) usage_exit();
2222 dodhd=true;
2223 mDstFile = argv[argc-1];
2224 break;
2225 }
2226 // option: generate doxygen footer (break)
2227 if(option=="-doxfooter") {
2228 i++; if(i>=argc) usage_exit();
2229 dodft=true;
2230 mDstFile = argv[argc-1];
2231 break;
2232 }
2233 // option: generate standalone reference
2234 if(option=="-app") {
2236 continue;
2237 }
2238 // option: help
2239 if((option=="-?") || (option=="--help")) {
2240 usage_exit();
2241 continue;
2242 }
2243 // option: unknown
2244 if(option.size()>1)
2245 if(option.at(0)=='-') {
2246 usage_exit("unknown option " + option);
2247 continue;
2248 }
2249 // non-option: break
2250 break;
2251 }
2252
2253 // figure source
2254 for(;i<argc-1; i++) {
2255 std::string option(argv[i]);
2256 if(option.size()>1)
2257 if(option.at(0)=='-') {
2258 usage_exit("missplaced/unknown option " + option);
2259 continue;
2260 }
2261 mSrcFiles.insert(option);
2262 }
2263
2264 // figure destination
2265 for(;i<argc; i++) {
2266 std::string option(argv[i]);
2267 if(option.size()>1)
2268 if(option.at(0)=='-') {
2269 usage_exit("missplaced/unknown option " + option);
2270 continue;
2271 }
2272 mDstFile=option;
2273 }
2274
2275 // test
2276 if(mDstFile=="") {
2277 usage_exit("no destination file specified");
2278 }
2279 bool dirdst=DirectoryExists(mDstFile);
2280
2281 // load registry
2282 if(mRtiFile!="") {
2284 }
2285
2286 // record plug-in and buil-in sections
2288 fit!=FunctionRegistry::G()->End(); fit++) {
2289 std::string section=fit->second->KeywordAt(0);
2290 std::transform(section.begin(), section.end(), section.begin(), tolower);
2291 mExclLuaSections.insert(section);
2292 }
2293
2294 // extend registry
2295 if(mFlxFile!="") {
2297 }
2298
2299 // record lua sections
2301 fit!=FunctionRegistry::G()->End(); fit++) {
2302 std::string section=fit->second->KeywordAt(0);
2303 std::transform(section.begin(), section.end(), section.begin(), tolower);
2304 mInclLuaSections.insert(section);
2305 }
2306
2307
2308 // include toc
2309 if(mIncludeFile!="") {
2311 RecordLiterature(tr);
2312 tr.Rewind();
2313 RecordPages(tr);
2314 }
2315
2316
2317 // special case: xtract fref
2318 if(xpage) {
2319 if(mSrcFiles.size()!=1) {
2320 usage_exit("extract mode requires one source file");
2321 }
2322 if(!dirdst) {
2323 usage_exit("extract mode requires destination directory");
2324 }
2325 std::cerr << "ref2html: extract pages from " << *mSrcFiles.begin() << std::endl;
2326 TokenReader tr(*mSrcFiles.begin());
2328 tr.Rewind();
2330 exit(0);
2331 }
2332
2333
2334 // special case: generate toc
2335 if(dotoc) {
2336 if(dirdst) {
2337 usage_exit("toc mode requires destination file");
2338 }
2339 // output file
2340 std::ostream* hout= &std::cout;
2341 std::ofstream fout;
2342 if(mDstFile != "-") {
2343 fout.open(mDstFile.c_str(), std::ios::out);
2344 hout = &fout;
2345 }
2346 // process all input
2347 std::set< std::string >::iterator sit=mSrcFiles.begin();
2348 for(;sit!=mSrcFiles.end();++sit) {
2349 std::cerr << "ref2html: process toc " << *sit << std::endl;
2350 TokenReader tr(*sit);
2351 RecordLiterature(tr);
2352 tr.Rewind();
2353 RecordPages(tr);
2354 }
2355 // dump
2356 TokenWriter dst(*hout);
2357 DumpPages(dst);
2358 DumpLiterature(dst);
2359 dst.Flush();
2360 exit(0);
2361 }
2362
2363 // special case: generate dox header/footer
2364 if(dodhd || dodft) {
2365 if(dirdst) {
2366 usage_exit("header-footer mode requires destination file");
2367 }
2368 // output file
2369 std::ostream* hout= &std::cout;
2370 std::ofstream fout;
2371 if(mDstFile != "-") {
2372 fout.open(mDstFile.c_str(), std::ios::out);
2373 hout = &fout;
2374 }
2375 // doit
2376 if(dodhd) DoxygenHeader(hout);
2377 if(dodft) DoxygenFooter(hout);
2378 exit(0);
2379 }
2380
2381
2382 // convert all source directories
2383 std::set< std::string > srcfiles;
2384 std::set< std::string >::iterator sit=mSrcFiles.begin();
2385 for(;sit!=mSrcFiles.end();++sit) {
2386 if(!DirectoryExists(*sit)) { srcfiles.insert(*sit); continue;}
2387 std::set< std::string > dirfiles = ReadDirectory(*sit);
2388 std::set< std::string >::iterator dit=dirfiles.begin();
2389 for(;dit!=dirfiles.end();++dit) {
2390 std::string ext = ExtractSuffix(*dit);
2391 std::string base = ExtractBasename(*dit);
2392 std::string src= PrependPath(*sit,base + ".fref");
2393 // skip if not an fref file
2394 if(ext!="fref") continue;
2395 // record
2396 srcfiles.insert(src);
2397 }
2398 }
2399 mSrcFiles=srcfiles;
2400
2401 // insist in target dir
2402 if(mSrcFiles.size()>1 && ! dirdst) {
2403 usage_exit("multiple source files require destination directory");
2404 }
2405
2406
2407 // do loop
2408 /*std::set< std::string >::iterator*/ sit=mSrcFiles.begin();
2409 for(;sit!=mSrcFiles.end();++sit) {
2410 std::string base = ExtractBasename(*sit);
2411 std::string src= *sit;
2412 std::string dst= mDstFile;
2413 if(dirdst) dst=PrependPath(mDstFile,base + ".html");
2414 // process
2415 if(mSrcFiles.size()>1)
2416 std::cout << "ref2html: processing " << src << " to " << dst << std::endl;
2417 std::ofstream fout;
2418 fout.open(dst.c_str(), std::ios::out);
2419 RefpageHtml(&fout,src);
2420 }
2421 exit(0);
2422}
int main()
std::string mJournal
std::string mTitle
std::string mYear
std::string mLabel
std::string mPublisher
std::string mAuthors
std::string mLink
std::string mSection
Definition ref2html.cpp:613
std::string mPage
Definition ref2html.cpp:614
std::string mLink
Definition ref2html.cpp:615
std::string mSummary
Definition ref2html.cpp:616
std::string mChapter
Definition ref2html.cpp:612
std::string mTitle
Definition ref2html.cpp:611
const std::string & HtmlDoc(void) const
const std::string & Name(void) const
const std::string & TextDoc(void) const
const Signature & Variant(const std::string &rName) const
Iterator End(void) const
static FunctionRegistry * G()
std::map< std::string, FunctionDefinition * >::const_iterator Iterator
const FunctionDefinition & Definition(const std::string &rFunctionName) const
void MergeDocumentation(TokenReader &rTr)
const std::string & Type(void) const
const ParamAttr & Attribute(void) const
static std::string AStr(Parameter::ParamAttr attr)
const std::string & Name(void) const
int Size(void) const
const Parameter & At(int n) const
std::string FileLine(void) const
void ReadCharacterData(std::string &rData)
void ReadText(const std::string &rLabel, std::string &rText)
bool Eos(const std::string &rLabel)
void SeekBegin(const std::string &rLabel)
int Level(void) const
void ReadEnd(const std::string &rLabel)
void ReadSection(std::string &rSectionString)
void ReadBegin(const std::string &rLabel)
bool Get(Token &token)
bool Peek(Token &token)
bool ExistsBegin(const std::string &rLabel)
std::string FileName(void) const
void WriteCharacterData(const std::string &rCharData)
void Write(Token &rToken)
std::ostream * Streamp(void)
void WriteEnd(const std::string &rLabel)
void WriteBegin(const std::string &rLabel)
bool IsBinary(void) const
const std::string & PreceedingSpace(void) const
const std::string & StringValue(void) const
void ClrEnd(void)
bool ExistsAttributeString(const std::string &name)
bool IsBegin(void) const
void SetEmpty(const std::string &rName)
void ClrAttribute(const std::string &name)
void SetBegin(const std::string &rName)
Definition cfl_token.cpp:92
void InsAttributeString(const std::string &name, const std::string &value)
bool IsEnd(void) const
const std::string & AttributeStringValue(const std::string &name)
const TypeDefinition & Definition(const std::string &rTypeName) const
static TypeRegistry * G()
std::map< std::string, TypeDefinition * >::const_iterator Iterator
Iterator End(void) const
void LoadRegistry(const std::string &rPath)
std::string VersionString()
std::string PrependPath(const std::string &rLeft, const std::string &rRight)
std::string PluginsString()
std::string ExtractFilename(const std::string &rFullPath)
std::string ContributorsString()
std::set< std::string > ReadDirectory(const std::string &rDirectory)
std::string StringSubstitute(const std::string &rString, const std::string &rFrom, const std::string &rTo)
std::string ExtractBasename(const std::string &rFullPath)
bool DirectoryExists(const std::string &rDirectory)
std::string ExtractSuffix(const std::string &rFullPath)
void SectionIndexHtml(std::ostream *pIndexFile, const std::string &key)
std::string mExitChapterClass
Definition ref2html.cpp:127
std::string mFrefLink
Definition ref2html.cpp:99
void ChaptersPrefix(const std::string &prefix)
Definition ref2html.cpp:133
void DoxygenHeader(std::ostream *pOutFile)
std::set< std::string > mSrcFiles
Definition ref2html.cpp:105
void RecordPages(TokenReader &rTr)
Definition ref2html.cpp:627
std::string mChapterFile
Definition ref2html.cpp:106
void RefpageHtml(std::ostream *pOutFile, std::string inputfile)
std::map< std::string, std::map< std::string, PageRecord > > mRefSectPages
Definition ref2html.cpp:624
std::string TimeStamp(void)
Definition ref2html.cpp:148
void XtractFiles(TokenReader &src, const std::string &rDstDir)
std::vector< PageRecord > mAllPages
Definition ref2html.cpp:621
std::string mFlxFile
Definition ref2html.cpp:103
std::string mReferencePrefix
Definition ref2html.cpp:112
std::string mDstFile
Definition ref2html.cpp:104
std::string mFaudesLink
Definition ref2html.cpp:118
void ShortdocHtml(std::ostream *pOutFile, std::string fname)
std::string mThisChapterClass
Definition ref2html.cpp:125
std::string mPythonmodPrefix
Definition ref2html.cpp:115
std::string mLuafaudesPrefix
Definition ref2html.cpp:114
void FooterHtml(std::ostream *pStream)
Definition ref2html.cpp:243
std::string mFrefSection
Definition ref2html.cpp:97
std::string TexScripts(const std::string &rTexString)
Definition ref2html.cpp:410
std::string mChaptersPrefix
Definition ref2html.cpp:110
std::string mIncludeFile
Definition ref2html.cpp:107
void ListItemHtml(std::ostream *pStream, const std::string &rLink, const std::string &rText)
Definition ref2html.cpp:265
void DumpLiterature(TokenWriter &rTw)
void BottomLineHtml(std::ostream *pStream)
Definition ref2html.cpp:190
void ListFunctionsHtml(std::ostream *pIndexFile, const std::string &key="")
Definition ref2html.cpp:799
void RecordLiterature(TokenReader &rTr)
std::map< std::string, LiteratureRecord > mLiterature
std::string mBooksPrefix
Definition ref2html.cpp:109
std::string mImagePrefix
Definition ref2html.cpp:111
std::string mFrefSummary
Definition ref2html.cpp:100
std::string mOtherChapterClass
Definition ref2html.cpp:126
void FunctionIndexHtml(std::ostream *pIndexFile, const std::string &key="")
Definition ref2html.cpp:952
void MathHtml(std::ostream *pStream, const std::string &rMathString)
Definition ref2html.cpp:495
std::set< std::string > mInclLuaSections
Definition ref2html.cpp:606
std::string mPythonmodLink
Definition ref2html.cpp:121
std::string mLuafaudesLink
Definition ref2html.cpp:120
void LiteratureHtml(std::ostream *pStream, const std::string &rLabel="")
void TypeIndexHtml(std::ostream *pIndexFile, const std::string &key="")
Definition ref2html.cpp:917
std::string mFrefPage
Definition ref2html.cpp:98
std::string TexSpacing(const std::string &rTexString)
Definition ref2html.cpp:366
void SignatureHtml(std::ostream *pOutFile, std::string function)
std::string mFrefTitle
Definition ref2html.cpp:95
std::string mDownloadLink
Definition ref2html.cpp:117
std::string mCsourceLink
Definition ref2html.cpp:122
std::string mFrefChapter
Definition ref2html.cpp:96
void DumpPages(TokenWriter &rTw)
Definition ref2html.cpp:733
std::string PrettyPage(const std::string page)
Definition ref2html.cpp:163
void TextHtml(std::ostream *pStream, const std::string &rText)
Definition ref2html.cpp:323
std::string mCsourcePrefix
Definition ref2html.cpp:113
void ImageHtml(std::ostream *pStream, const std::string &rFileName)
Definition ref2html.cpp:254
void ReferenceIndexHtml(std::ostream *pIndexFile, const std::string &key="")
Definition ref2html.cpp:998
std::string mCssFile
Definition ref2html.cpp:123
std::string mRtiFile
Definition ref2html.cpp:102
void usage_exit(const std::string &rMessage="")
Definition ref2html.cpp:51
void HeaderHtml(std::ostream *pStream)
Definition ref2html.cpp:224
void CiteHtml(std::ostream *pStream, const std::string &rLabel)
void LuafaudesIndexHtml(std::ostream *pIndexFile)
std::string mDestoolLink
Definition ref2html.cpp:119
std::string TexMacroSubstitute1(const std::string &rTexString, const std::string &rMacro, const std::string &rSubst)
Definition ref2html.cpp:337
void PythonmodIndexHtml(std::ostream *pIndexFile)
bool mStandaloneReference
Definition ref2html.cpp:93
void ListSectionsHtml(std::ostream *pIndexFile, const std::string &key="")
Definition ref2html.cpp:834
void FunctionHtml(std::ostream *pStream, const std::string &rFunctionName)
Definition ref2html.cpp:300
void XtractPages(TokenReader &src, const std::string &rDstDir)
void DoxygenFooter(std::ostream *pOutFile)
void ProcessSection(TokenWriter &rTw, TokenReader &rTr)
void TypeHtml(std::ostream *pStream, const std::string &rTypeName)
Definition ref2html.cpp:276
std::set< std::string > mExclLuaSections
Definition ref2html.cpp:605
void ListTypesHtml(std::ostream *pIndexFile, const std::string &key="")
Definition ref2html.cpp:764

libFAUDES 2.34e --- 2026.03.16 --- c++ api documentaion by doxygen