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

libFAUDES 2.33h --- 2025.06.18 --- c++ api documentaion by doxygen