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  // one-arg macros
515  buff=TexMacroSubstitute1(buff,"\\ProInv","Pinv#1");
516  buff=TexMacroSubstitute1(buff,"\\Pro","P#1");
517  buff=TexMacroSubstitute1(buff,"\\Closure","Closure(#1)");
518  buff=TexMacroSubstitute1(buff,"\\Prefix","Prefix(#1)");
519  buff=TexMacroSubstitute1(buff,"\\Shape","Shape(#1)");
520  // tex math spacing and plain text
521  buff=TexMacroSubstitute1(buff,"\\texttt","\\text{<tt>#1</tt>}");
522  buff=TexMacroSubstitute1(buff,"\\mathtt","\\text{<tt>#1</tt>}");
523  buff=TexMacroSubstitute1(buff,"\\textit","\\text{<i>#1</i>}");
524  buff=TexMacroSubstitute1(buff,"\\mathit","\\text{<i>#1</i>}");
525  buff=TexMacroSubstitute1(buff,"\\mathsf","\\text{<sf>#1</sf>}");
526  buff=TexMacroSubstitute1(buff,"\\mathbb","\\text{<it>#1</it>}");
527  buff=TexMacroSubstitute1(buff,"\\textbb","\\text{<it>#1</it>}");
528  buff=TexSpacing(buff);
529  // super- and subscripts
530  buff=TexScripts(buff);
531  // symbols
532  buff=StringSubstitute(buff,"\\{","{");
533  buff=StringSubstitute(buff,"\\}","}");
534  buff=StringSubstitute(buff,"\\[","[");
535  buff=StringSubstitute(buff,"\\]","]");
536  buff=StringSubstitute(buff,"=","&nbsp;=&nbsp;");
537  buff=StringSubstitute(buff,"\\colon","&nbsp:&nbsp;");
538  buff=StringSubstitute(buff,"class&nbsp;=&nbsp;","class="); // fix csss class
539  buff=StringSubstitute(buff,":&nbsp;=&nbsp;","&nbsp;:=&nbsp;"); //fix :=
540  buff=StringSubstitute(buff,"\\neq","&nbsp&ne;&nbsp;");
541  buff=StringSubstitute(buff,"\\lt","&nbsp;&lt;&nbsp;");
542  buff=StringSubstitute(buff,"\\gt","&nbsp;&gt;&nbsp;");
543  buff=StringSubstitute(buff,"\\le","&nbsp;&le;&nbsp;");
544  buff=StringSubstitute(buff,"\\ge","&nbsp;&ge;&nbsp;");
545  buff=StringSubstitute(buff,"\\emptyset","0");
546  buff=StringSubstitute(buff,"\\times","&nbsp;x&nbsp;");
547  buff=StringSubstitute(buff,"\\ldots","...");
548  buff=StringSubstitute(buff,"\\cdots","...");
549  buff=StringSubstitute(buff,"\\cdot",".");
550  buff=StringSubstitute(buff,"\\infty","&infin;");
551  buff=StringSubstitute(buff,"\\nin","&nbsp;&notin;&nbsp;");
552  buff=StringSubstitute(buff,"\\not\\in","&nbsp;&notin;&nbsp;");
553  buff=StringSubstitute(buff,"\\in","&nbsp;&isin;&nbsp;");
554  buff=StringSubstitute(buff,"\\subseteq","&nbsp;&sube;&nbsp;");
555  buff=StringSubstitute(buff,"\\subset","&nbsp;&sub;&nbsp;");
556  buff=StringSubstitute(buff,"\\supseteq","&nbsp;&supe;&nbsp;");
557  buff=StringSubstitute(buff,"\\supset","&nbsp;&sup;&nbsp;");
558  buff=StringSubstitute(buff,"\\cup","&cup;");
559  buff=StringSubstitute(buff,"\\dcup","&cup;"); // should be "&cup;&#775;" for "dot above"
560  buff=StringSubstitute(buff,"\\cap","&cap;");
561  buff=StringSubstitute(buff,"\\sup","sup");
562  buff=StringSubstitute(buff,"\\inf","inf");
563  buff=StringSubstitute(buff,"\\max","max");
564  buff=StringSubstitute(buff,"\\min","min");
565  buff=StringSubstitute(buff,"\\parallel","||");
566  buff=StringSubstitute(buff,"\\forall","&forall;&nbsp;");
567  buff=StringSubstitute(buff,"\\exists","&exist;&nbsp;");
568  buff=StringSubstitute(buff,"\\leftarrow","&larr;");
569  buff=StringSubstitute(buff,"\\rightarrow","&rarr;");
570  buff=StringSubstitute(buff,"\\leftrightarrow","&harr;");
571  buff=StringSubstitute(buff,"\\Leftarrow","&lArr;");
572  buff=StringSubstitute(buff,"\\Rightarrow","&rArr;");
573  buff=StringSubstitute(buff,"\\Leftrightarrow","&hArr;");
574  buff=StringSubstitute(buff,"\\uparrow","&uarr;");
575  buff=StringSubstitute(buff,"\\downarrow","&darr;");
576  buff=StringSubstitute(buff,"\\Uparrow","&#x21e7;");
577  buff=StringSubstitute(buff,"\\Downarrow","&#x21e9;");
578  // ie7 fallback symbols
579  buff=StringSubstitute(buff,"&isin;","<span class=\"faudes_fmath\">&isin;</span>");
580  buff=StringSubstitute(buff,"&notin;","<span class=\"faudes_fmath\">&notin;</span>");
581  buff=StringSubstitute(buff,"&exist;","<span class=\"faudes_fmath\">&exist;</span>");
582  buff=StringSubstitute(buff,"&forall;","<span class=\"faudes_fmath\">&forall;</span>");
583  buff=StringSubstitute(buff,"&cup;","<span class=\"faudes_fmath\">&cup;</span>");
584  buff=StringSubstitute(buff,"&dcup;","<span class=\"faudes_fmath\">&cup;</span>"); // see above
585  buff=StringSubstitute(buff,"&cap;","<span class=\"faudes_fmath\">&cap;</span>");
586  buff=StringSubstitute(buff,"&larr;","<span class=\"faudes_fmath\">&larr;</span>");
587  buff=StringSubstitute(buff,"&rarr;","<span class=\"faudes_fmath\">&rarr;</span>");
588  buff=StringSubstitute(buff,"&harr;","<span class=\"faudes_fmath\">&harr;</span>");
589  buff=StringSubstitute(buff,"&lArr;","<span class=\"faudes_fmath\">&lArr;</span>");
590  buff=StringSubstitute(buff,"&rArr;","<span class=\"faudes_fmath\">&rArr;</span>");
591  buff=StringSubstitute(buff,"&hArr;","<span class=\"faudes_fmath\">&hArr;</span>");
592  buff=StringSubstitute(buff,"&sub;","<span class=\"faudes_fmath\">&sub;</span>");
593  buff=StringSubstitute(buff,"&sube;","<span class=\"faudes_fmath\">&sube;</span>");
594  buff=StringSubstitute(buff,"&sup;","<span class=\"faudes_fmath\">&sup;</span>");
595  buff=StringSubstitute(buff,"&supe;","<span class=\"faudes_fmath\">&supe;</span>");
596  // done
597  *pStream << buff;
598 }
599 
600 
601 // ******************************************************************
602 // record pages
603 // ******************************************************************
604 
605 
606 // section lists (from reading rti/flx)
607 std::set< std::string > mExclLuaSections;
608 std::set< std::string > mInclLuaSections;
609 
610 // page data
611 class PageRecord {
612 public:
613  std::string mTitle;
614  std::string mChapter;
615  std::string mSection;
616  std::string mPage;
617  std::string mLink;
618  std::string mSummary;
619 };
620 
621 
622 // record all pages
623 std::vector<PageRecord> mAllPages;
624 
625 // record all pages within reference section (keys to lower)
626 std::map< std::string , std::map< std::string , PageRecord > > mRefSectPages;
627 
628 // extract page data (works with both, *.flx and *.ftoc)
630  // record my level
631  int clevel = rTr.Level();
632  // std::cerr << "process level " << clevel << "\n";
633  // token loop
634  while(true) {
635  // skip plain text
636  std::string text;
637  rTr.ReadCharacterData(text);
638  if(text.size()>0) continue;
639  // break on no token or end of my level
640  Token token;
641  if(!rTr.Peek(token)) break;
642  if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
643  break;
644  // ignore irrelevant
645  if(!token.IsBegin("ReferencePage")) {
646  rTr.Get(token);
647  continue;
648  }
649  // take my section
650  rTr.ReadBegin("ReferencePage");
651  // extract page data
652  mFrefChapter="";
653  if(token.ExistsAttributeString("chapter"))
654  mFrefChapter=token.AttributeStringValue("chapter");
655  mFrefSection="";
656  if(token.ExistsAttributeString("section"))
657  mFrefSection=token.AttributeStringValue("section");
658  mFrefPage="";
659  if(token.ExistsAttributeString("page"))
660  mFrefPage=token.AttributeStringValue("page");
661  mFrefTitle="";
662  if(token.ExistsAttributeString("title"))
663  mFrefTitle=token.AttributeStringValue("title");
664  mFrefLink=ExtractBasename(rTr.FileName())+".html";;
665  if(token.ExistsAttributeString("link"))
666  mFrefLink=token.AttributeStringValue("link");
667  // find optional findexdoc
668  mFrefSummary="";
669  if(rTr.ExistsBegin("fsummary")) {
670  rTr.ReadBegin("fsummary");
672  rTr.ReadEnd("fsummary");
673  }
674  // autodetect misslabled index pages
675  if(mFrefPage=="") {
676  std::string indexfile=mFrefSection + "_index.fref";
677  std::transform(indexfile.begin(), indexfile.end(), indexfile.begin(), tolower);
678  if(ExtractFilename(rTr.FileName())==indexfile)
679  mFrefPage="0_Index";
680  }
681  // ensure page number for index page
682  if(mFrefPage=="index") mFrefPage="Index";
683  if(mFrefPage=="Index") mFrefPage="0_Index";
684  // autogenerate page name
685  if(mFrefPage=="") {
687  std::string title=mFrefTitle;
688  std::transform(mFrefTitle.begin(), mFrefTitle.end(), title.begin(), tolower);
689  std::string section=mFrefSection;
690  std::transform(mFrefSection.begin(), mFrefSection.end(), section.begin(), tolower);
691  std::size_t spos = title.find(section);
692  if(spos==0 && title.size()>section.size())
693  mFrefPage=mFrefPage.substr(section.size(),mFrefPage.size()-section.size());
694  for(spos=0; spos<mFrefPage.size(); spos++){
695  int c= mFrefPage.at(spos);
696  if(c==' ') continue;
697  if(c=='-') continue;
698  if(c=='_') continue;
699  break;
700  }
701  if(spos<mFrefPage.size())
702  mFrefPage=mFrefPage.substr(spos,mFrefPage.size()-spos);
703  if(mFrefPage=="Index") mFrefPage="";
704  }
705  // read end
706  rTr.ReadEnd("ReferencePage");
707  // report
708  // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
709  // record
710  PageRecord pagerec;
711  pagerec.mChapter = mFrefChapter;
712  pagerec.mSection = mFrefSection;
713  pagerec.mPage = mFrefPage;
714  pagerec.mTitle = mFrefTitle;
715  pagerec.mLink = mFrefLink;
716  pagerec.mSummary=mFrefSummary;
717  // normalize
718  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
719  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
720  std::transform(mFrefPage.begin(), mFrefPage.end(), mFrefPage.begin(), tolower);
721  // insert entry
722  if(mFrefChapter!="")
723  if(mFrefChapter!="none")
724  mAllPages.push_back(pagerec);
725  // insert entry to section pages of reference
726  if(mFrefChapter=="reference")
727  if(mFrefPage!="")
728  if(mFrefPage!="none")
730  }
731 }
732 
733 
734 // dump page records to include file
735 void DumpPages(TokenWriter& rTw) {
736  // loop records
737  std::vector<PageRecord>::iterator pit;
738  for(pit=mAllPages.begin(); pit!=mAllPages.end(); pit++) {
739  Token btag;
740  btag.SetEmpty("ReferencePage");
741  btag.InsAttributeString("title",pit->mTitle);
742  btag.InsAttributeString("chapter",pit->mChapter);
743  btag.InsAttributeString("section",pit->mSection);
744  btag.InsAttributeString("page",pit->mPage);
745  btag.InsAttributeString("link",pit->mLink);
746  // if we have no summary, that's it
747  if(pit->mSummary=="") {
748  rTw << btag;
749  continue;
750  }
751  // summary present
752  btag.ClrEnd();
753  rTw << btag;
754  rTw.WriteBegin("fsummary");
755  rTw.WriteCharacterData(pit->mSummary);
756  rTw.WriteEnd("fsummary");
757  rTw.WriteEnd("ReferencePage");
758  }
759 }
760 
761 
762 // ******************************************************************
763 // search for types
764 // ******************************************************************
765 
766 void ListTypesHtml(std::ostream* pIndexFile, const std::string& key="") {
767 
768  // table output
769  *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
770  // traverse type registry
771  bool found=false;
772  for(TypeRegistry::Iterator tit=TypeRegistry::G()->Begin();
773  tit!=TypeRegistry::G()->End(); tit++) {
774  // test for exact key
775  if(key!="") {
776  std::string section= tit->second->Name();
777  std::transform(section.begin(), section.end(), section.begin(), tolower);
778  if(section!=key) continue;
779  }
780  // test for user doc
781  if(tit->second->TextDoc()=="") continue;
782  // table row
783  *pIndexFile << "<tr><td valign=\"top\">";
784  TypeHtml(pIndexFile,tit->second->Name());
785  *pIndexFile << "</td><td valign=\"top\">";
786  TypeHtml(pIndexFile,tit->second->TextDoc());
787  *pIndexFile << "</td></tr>" << std::endl;
788  // record success
789  found=true;
790  }
791  // no matches
792  if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
793  // table output
794  *pIndexFile << "</table>" << std::endl;
795 }
796 
797 // ******************************************************************
798 // search for functions
799 // ******************************************************************
800 
801 void ListFunctionsHtml(std::ostream* pIndexFile, const std::string& key="") {
802 
803  // table output
804  *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
805  // traverse function registry
806  bool found=false;
808  fit!=FunctionRegistry::G()->End(); fit++) {
809  // test for exact key
810  if(key!="") {
811  std::string section= fit->second->Name();
812  std::transform(section.begin(), section.end(), section.begin(), tolower);
813  if(section!=key) continue;
814  }
815  // test for user doc
816  if(fit->second->TextDoc()=="") continue;
817  // table row
818  *pIndexFile << "<tr><td valign=\"top\">";
819  FunctionHtml(pIndexFile,fit->second->Name());
820  *pIndexFile << "</td><td valign=\"top\">";
821  TypeHtml(pIndexFile,fit->second->TextDoc());
822  *pIndexFile << "</td></tr>" << std::endl;
823  // record success
824  found=true;
825  }
826  // no matches
827  if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
828  // table output
829  *pIndexFile << "</table>" << std::endl;
830 }
831 
832 // ******************************************************************
833 // search for sections
834 // ******************************************************************
835 
836 void ListSectionsHtml(std::ostream* pIndexFile, const std::string& key="") {
837 
838  // here: use special key "luaext" to filter lua-extensions"
839 
840  // traverse pages
841  std::set< std::string > sections;
842  std::map< std::string , std::string > link;
843  std::map< std::string , std::string > summary;
844  std::vector< PageRecord >::iterator pit;
845  for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
846  std::string chap=pit->mChapter;
847  std::transform(chap.begin(), chap.end(), chap.begin(), tolower);
848  std::string sect=pit->mSection;
849  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
850  std::string page=pit->mPage;
851  std::transform(page.begin(), page.end(), page.begin(), tolower);
852  page=PrettyPage(page);
853  // my chapter only
854  if(chap!="reference") continue;
855  if(sect=="none") continue;
856  if(sect=="") continue;
857  if(page!="index") continue;
858  // lua ext only
859  if(key=="luaext") {
860  if(mExclLuaSections.find(sect)!=mExclLuaSections.end()) continue;
861  if(mInclLuaSections.find(sect)==mInclLuaSections.end()) continue;
862  }
863  // get nice name
864  std::string pname = pit->mSection;
865  // use title as fallback summary
866  std::string psumm = pit->mSummary;
867  if(psumm=="") psumm = pit->mTitle;
868  // record
869  sections.insert(pname);
870  link[pname]=pit->mLink;
871  summary[pname]=psumm;
872  }
873 
874  // produce sorted index with corefaudes first
875  std::vector< std::string > sortvec;
876  if(sections.find("CoreFaudes")!=sections.end())
877  sortvec.push_back("CoreFaudes");
878  std::set< std::string >::iterator sit;
879  for(sit=sections.begin(); sit != sections.end(); sit++) {
880  if(*sit=="CoreFaudes") continue;
881  sortvec.push_back(*sit);
882  }
883 
884  // table output
885  *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
886 
887  // populate table
888  std::vector< std::string >::iterator vit;
889  bool found=false;
890  for(vit=sortvec.begin(); vit != sortvec.end(); vit++) {
891  // get nice name
892  std::string sname = *vit;
893  std::string shtml = mReferencePrefix+link[sname];
894  std::string ssumm = summary[sname];
895  // table row
896  *pIndexFile << "<tr>" << std::endl;
897  *pIndexFile << "<td valign=\"top\"><a href=\"" << shtml << "\">" << sname << "</a></td>";
898  *pIndexFile << "<td valign=\"top\">";
899  *pIndexFile << ssumm;
900  *pIndexFile << "</td></tr>"<< std::endl;
901  // record success
902  found=true;
903  }
904  // no matches
905  if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
906 
907  // table output
908  *pIndexFile << "</table>" << std::endl;
909 }
910 
911 
912 
913 
914 
915 // ******************************************************************
916 // Type index by keyword (aka section name)
917 // ******************************************************************
918 
919 void TypeIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
920 
921  // traverse type registry
922  bool head=false;
923  for(TypeRegistry::Iterator tit=TypeRegistry::G()->Begin();
924  tit!=TypeRegistry::G()->End(); tit++)
925  {
926  // test for exact key
927  if(key!="") {
928  std::string section= tit->second->KeywordAt(0);
929  std::transform(section.begin(), section.end(), section.begin(), tolower);
930  if(section!=key) continue;
931  }
932  // get name and reference
933  std::string tyname = tit->second->Name();
934  std::string tyhtml = tit->second->HtmlDoc();
935  // no doc
936  if(tyhtml=="") continue;
937  if(tyhtml=="none") continue;
938  // head line
939  if(!head) {
940  head=true;
941  *pIndexFile << "<li class=\"registry_heading\">Types</li>" << std::endl;
942  }
943  // index entry for this type
944  ListItemHtml(pIndexFile, tyhtml, tyname);
945  }
946  // done
947  if(head) *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
948 }
949 
950 // ******************************************************************
951 // Function index by keyword (aka plugin)
952 // ******************************************************************
953 
954 void FunctionIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
955 
956  // have lower case key
957  std::string lkey=key;
958  std::transform(lkey.begin(), lkey.end(), lkey.begin(), tolower);
959 
960  // traverse function registry
961  bool head=false;
963  fit!=FunctionRegistry::G()->End(); fit++)
964  {
965  // test for key
966  if(lkey!="") {
967  std::string section= fit->second->KeywordAt(0);
968  std::transform(section.begin(), section.end(), section.begin(), tolower);
969  if(section!=lkey) continue;
970  }
971  // test for user doc
972  if(fit->second->TextDoc()=="") continue;
973  // index entry for this function
974  std::string fname = fit->second->Name();
975  std::string fhtml = fit->second->HtmlDoc();
976  if(fhtml=="") continue;
977  // head line
978  if(!head){
979  head=true;
980  *pIndexFile << "<li class=\"registry_heading\">Functions</li>" << std::endl;
981  }
982  // list entry: no doc
983  if(fhtml=="none") {
984  *pIndexFile << "<li class=\"registry_item\"> "<< fname << "</li>" << std::endl;
985  continue;
986  }
987  // list entry: link
988  ListItemHtml(pIndexFile, fhtml, fname);
989  }
990 
991  // done
992  if(head) *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
993 
994 }
995 
996 // ******************************************************************
997 // Reference index by keyword (aka section)
998 // ******************************************************************
999 
1000 void ReferenceIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
1001 
1002  // prepare list of all sections
1003  std::map< std::string , std::string > sectlink;
1004  std::vector< PageRecord >::iterator pit;
1005  for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1006  std::string chap=pit->mChapter;
1007  std::transform(chap.begin(), chap.end(), chap.begin(), tolower);
1008  std::string sect=pit->mSection;
1009  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1010  // my chapter only
1011  if(chap!="reference") continue;
1012  if(sect=="none") continue;
1013  if(sect=="") continue;
1014  // get nice name
1015  std::string pname = pit->mSection;
1016  // have link
1017  std::string phtml = sect+"_index.html";
1018  // record
1019  sectlink[pname]=phtml;
1020  }
1021 
1022  // produce sorted index, have corefaudes first
1023  std::vector< std::string > sections;
1024  if(sectlink["CoreFaudes"]!="") sections.push_back("CoreFaudes");
1025  std::map< std::string , std::string >::iterator sit;
1026  for(sit=sectlink.begin(); sit!=sectlink.end(); sit++) {
1027  std::string psect=sit->first;
1028  if(psect=="CoreFaudes") continue;
1029  sections.push_back(psect);
1030  }
1031 
1032  // sections headline
1033  if(sections.size()!=0)
1034  *pIndexFile << "<li class=\"registry_heading\">Sections</li>" << std::endl;
1035 
1036  // iterate sections
1037  std::size_t vit;
1038  for(vit=0; vit<sections.size(); vit++) {
1039  std::string psect=sections.at(vit);
1040  std::string plink=sectlink[psect];
1041  if(plink=="") continue;
1042  // find all pages within reference that match this section (keys to lower, skip index)
1043  std::string sect=psect;
1044  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1045  std::map< std::string , std::map< std::string , PageRecord > > ::iterator spit = mRefSectPages.find(sect);
1046  int pcnt=0;
1047  if(spit!=mRefSectPages.end()) {
1048  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1049  for(;pit!=spit->second.end();pit++) {
1050  std::string ppage = pit->second.mPage;
1051  std::transform(ppage.begin(), ppage.end(), ppage.begin(), tolower);
1052  if(ppage=="index") continue;
1053  if(ppage=="0_index") continue;
1054  if(ppage=="00_index") continue;
1055  pcnt++;
1056  }
1057  }
1058  // case a) no pages: just a link
1059  if(pcnt==0) {
1060  ListItemHtml(pIndexFile, plink, psect);
1061  continue;
1062  }
1063  // case b) generate link for sub menu for pages (do this my self)
1064  *pIndexFile << "<li class=\"registry_pitem\">" << std::endl
1065  << "<a href=\"" << plink << "\">" << psect << "</a>" << std::endl
1066  << "<a href=\"" << plink << "\" class=\"registry_blinda\">&nbsp;</a>" << std::endl
1067  << "<ul>" << std::endl
1068  << "<li class=\"registry_heading\">" << psect << "</li>" << std::endl;
1069  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1070  for(;pit!=spit->second.end();pit++) {
1071  // swallow page number
1072  std::string ppage = PrettyPage(pit->second.mPage);
1073  // normalize
1074  std::string ipage = ppage;
1075  std::transform(ipage.begin(), ipage.end(), ipage.begin(), tolower);
1076  // rename indes
1077  if(ipage=="index") ppage="Introduction";
1078  // page entry
1079  *pIndexFile << "<li class=\"registry_item\"><a href=\"" << pit->second.mLink << "\">"
1080  << ppage << "</a></li>" << std::endl;
1081  }
1082  // close page list
1083  *pIndexFile << "</ul></li>" << std::endl;
1084  }
1085 
1086  // sections done
1087  if(sections.size()!=0)
1088  *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1089 
1090  // list types
1091  if(key!="") TypeIndexHtml(pIndexFile,key);
1092 
1093  // list functions
1094  if(key!="") FunctionIndexHtml(pIndexFile,key);
1095 }
1096 
1097 
1098 // ******************************************************************
1099 // Section index (aka bottom navigation for key section)
1100 // ******************************************************************
1101 
1102 
1103 void SectionIndexHtml(std::ostream* pIndexFile, const std::string& key) {
1104 
1105  // find all pages within reference that match this section (keys to lower, skip index)
1106  std::string sect=key;
1107  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1108  std::string plink=sect+"_index.html";
1109  std::string psect=key;
1110  std::map< std::string , std::map< std::string , PageRecord > > ::iterator spit = mRefSectPages.find(sect);
1111  int pcnt=0;
1112  if(spit!=mRefSectPages.end()) {
1113  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1114  for(;pit!=spit->second.end();pit++) {
1115  std::string ppage = pit->second.mPage;
1116  psect=pit->second.mSection;
1117  std::transform(ppage.begin(), ppage.end(), ppage.begin(), tolower);
1118  if(ppage=="index") continue;
1119  if(ppage=="0_index") continue;
1120  if(ppage=="00_index") continue;
1121  pcnt++;
1122  }
1123  }
1124 
1125  // bail out if there are no pages
1126  //if(pcnt==0) return;
1127 
1128  // tweak: key="" refers to the reference_index.html
1129  if(key=="") psect="Reference";
1130 
1131  // generate menu for pages
1132  *pIndexFile << "<li class=\"registry_heading\">" << psect << "</li>" << std::endl;
1133  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1134  for(;pit!=spit->second.end();pit++) {
1135  // swallow page number
1136  std::string ppage = PrettyPage(pit->second.mPage);
1137  // normalize
1138  std::string ipage = ppage;
1139  std::transform(ipage.begin(), ipage.end(), ipage.begin(), tolower);
1140  // rename index
1141  if(ipage=="index") ppage="Introduction";
1142  // page entry
1143  *pIndexFile << "<li class=\"registry_item\"><a href=\"" << pit->second.mLink << "\">"
1144  << ppage << "</a></li>" << std::endl;
1145  }
1146 }
1147 
1148 
1149 // ******************************************************************
1150 // signature
1151 // ******************************************************************
1152 
1153 void SignatureHtml(std::ostream* pOutFile, std::string function) {
1154 
1155  // bail out on non existence
1156  if(!FunctionRegistry::G()->Exists(function)) return;
1157 
1158  // function definition
1159  const FunctionDefinition& fdef=FunctionRegistry::G()->Definition(function);
1160 
1161  // bail out if there is no signature
1162  if(fdef.VariantsSize()==0) return;
1163 
1164  // start signature box
1165  *pOutFile << "<div class=\"registry_signature\">" << std::endl;
1166  *pOutFile << "<h5><strong>Signature:</strong></h5>" << std::endl;
1167 
1168  // loop signatures
1169  for(int i=0; i< fdef.VariantsSize(); i++) {
1170  const Signature& sigi=fdef.Variant(i);
1171  *pOutFile << "<p>" << fdef.Name() << "(";
1172  // loop params
1173  for(int j=0; j < sigi.Size(); j++) {
1174  if(j!=0) *pOutFile << ", ";
1175  const Parameter& parj=sigi.At(j);
1176  *pOutFile << "<span>+" << Parameter::AStr(parj.Attribute()) << "+ ";
1177  TypeHtml(pOutFile,parj.Type());
1178  *pOutFile << " <i>" << parj.Name() << "</i></span>";
1179  }
1180  *pOutFile << ")</p>" << std::endl;
1181  }
1182 
1183 
1184  // close signature box
1185  *pOutFile << std::endl << "</div>" << std::endl;
1186 }
1187 
1188 // ******************************************************************
1189 // short doc
1190 // ******************************************************************
1191 
1192 void ShortdocHtml(std::ostream* pOutFile, std::string fname) {
1193 
1194  // its a function
1195  if(FunctionRegistry::G()->Exists(fname)) {
1196 
1197  // function definition
1198  const FunctionDefinition& fdef=FunctionRegistry::G()->Definition(fname);
1199 
1200  // stream doc
1201  //*pOutFile << "<div class=\"registry_signature\">" << std::endl;
1202  *pOutFile << "<p>" << fdef.TextDoc() << "</p>" << std::endl;
1203  //*pOutFile << "</div>" << std::endl;
1204 
1205  // stream signature
1206  SignatureHtml(pOutFile,fname);
1207  }
1208 
1209  // its a type
1210  if(TypeRegistry::G()->Exists(fname)) {
1211 
1212  // type definition
1213  const TypeDefinition& tdef=TypeRegistry::G()->Definition(fname);
1214 
1215  // stream doc
1216  //*pOutFile << "<div class=\"registry_signature\">" << std::endl;
1217  *pOutFile << "<p>" << tdef.TextDoc() << "<p>" << std::endl;
1218  //*pOutFile << "</div>" << std::endl;
1219 
1220  }
1221 
1222 }
1223 
1224 
1225 
1226 
1227 // ******************************************************************
1228 // record literature
1229 // ******************************************************************
1230 
1231 // record
1233 public:
1234  std::string mLabel;
1235  std::string mLink;
1236  std::string mAuthors;
1237  std::string mTitle;
1238  std::string mJournal;
1239  std::string mPublisher;
1240  std::string mYear;
1241 };
1242 
1243 // data
1244 std::map<std::string,LiteratureRecord> mLiterature;
1245 
1246 // extract all from a section
1248  // record my level
1249  int clevel = rTr.Level();
1250  // std::cerr << "process level " << clevel << "\n";
1251  // token loop
1252  while(true) {
1253  // skip plain text
1254  std::string text;
1255  rTr.ReadCharacterData(text);
1256  if(text.size()>0) continue;
1257  // break on no token or end of my level
1258  Token token;
1259  if(!rTr.Peek(token)) break;
1260  if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
1261  break;
1262  // track where we are
1263  if(token.IsBegin("ReferencePage")) {
1264  mFrefChapter="";
1265  if(token.ExistsAttributeString("chapter"))
1266  mFrefChapter=token.AttributeStringValue("chapter");
1267  mFrefSection="";
1268  if(token.ExistsAttributeString("section"))
1269  mFrefSection=token.AttributeStringValue("section");
1270  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1271  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1272  // report
1273  // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
1274  }
1275  // ignore other tokens
1276  if(!token.IsBegin("fliterature")) {
1277  rTr.Get(token);
1278  continue;
1279  }
1280  // do my special tag: fliterature
1281  rTr.ReadBegin("fliterature");
1282  std::string label=token.AttributeStringValue("name");
1283  //std::cerr << "process literature " << label << "\n";
1284  LiteratureRecord litrec;
1285  litrec.mLabel=label;
1286  litrec.mLink = mFrefSection + "_index.html#lit_" + label;
1287  //process entries
1288  while(!rTr.Eos("fliterature")) {
1289  Token token;
1290  rTr.Peek(token);
1291  //std::cerr << "process literature peek " << token.Str() << "\n";
1292  if(token.IsBegin("fauthors")) {
1293  rTr.ReadBegin("fauthors");
1294  rTr.ReadSection(litrec.mAuthors);
1295  rTr.ReadEnd("fauthors");
1296  continue;
1297  }
1298  if(token.IsBegin("ftitle")) {
1299  rTr.ReadBegin("ftitle");
1300  rTr.ReadSection(litrec.mTitle);
1301  rTr.ReadEnd("ftitle");
1302  continue;
1303  }
1304  if(token.IsBegin("fjournal")) {
1305  rTr.ReadBegin("fjournal");
1306  rTr.ReadSection(litrec.mJournal);
1307  rTr.ReadEnd("fjournal");
1308  continue;
1309  }
1310  if(token.IsBegin("fyear")) {
1311  rTr.ReadBegin("fyear");
1312  rTr.ReadSection(litrec.mYear);
1313  rTr.ReadEnd("fyear");
1314  continue;
1315  }
1316  if(token.IsBegin("flink")) {
1317  rTr.ReadBegin("flink");
1318  rTr.ReadSection(litrec.mLink);
1319  rTr.ReadEnd("flink");
1320  continue;
1321  }
1322  if(token.IsBegin()) {
1323  rTr.ReadBegin(token.StringValue());
1324  rTr.ReadEnd(token.StringValue());
1325  continue;
1326  }
1327  rTr.Get(token);
1328  }
1329  // insert entry
1330  if(litrec.mLabel!="")
1331  mLiterature[litrec.mLabel]=litrec;
1332  // done
1333  rTr.ReadEnd("fliterature");
1334  }
1335 }
1336 
1337 
1338 // dump literature records to include file
1340  // loop records
1341  std::map<std::string,LiteratureRecord>::iterator lit;
1342  for(lit=mLiterature.begin(); lit!=mLiterature.end(); lit++) {
1343  Token btag;
1344  btag.SetBegin("fliterature");
1345  btag.InsAttributeString("name",lit->second.mLabel);
1346  rTw << btag;
1347  if(lit->second.mAuthors!="") {
1348  rTw.WriteBegin("fauthors");
1349  rTw.WriteCharacterData(lit->second.mAuthors);
1350  rTw.WriteEnd("fauthors");
1351  }
1352  if(lit->second.mTitle!="") {
1353  rTw.WriteBegin("ftitle");
1354  rTw.WriteCharacterData(lit->second.mTitle);
1355  rTw.WriteEnd("ftitle");
1356  }
1357  if(lit->second.mJournal!="") {
1358  rTw.WriteBegin("fjournal");
1359  rTw.WriteCharacterData(lit->second.mJournal);
1360  rTw.WriteEnd("fjournal");
1361  }
1362  if(lit->second.mPublisher!="") {
1363  rTw.WriteBegin("fpublisher");
1364  rTw.WriteCharacterData(lit->second.mPublisher);
1365  rTw.WriteEnd("fpublisher");
1366  }
1367  if(lit->second.mYear!="") {
1368  rTw.WriteBegin("fyear");
1369  rTw.WriteCharacterData(lit->second.mYear);
1370  rTw.WriteEnd("fyear");
1371  }
1372  if(lit->second.mLink!="") {
1373  rTw.WriteBegin("flink");
1374  rTw.WriteCharacterData(lit->second.mLink);
1375  rTw.WriteEnd("flink");
1376  }
1377  rTw.WriteEnd("fliterature");
1378  rTw.Endl();
1379  }
1380 }
1381 
1382 
1383 // html for (one) literature reference
1384 void LiteratureHtml(std::ostream* pStream, const std::string& rLabel="") {
1385  // loop records
1386  std::map<std::string,LiteratureRecord>::iterator lit;
1387  for(lit=mLiterature.begin(); lit!=mLiterature.end(); lit++) {
1388  // skip for no match
1389  if(rLabel!="")
1390  if(rLabel!=lit->second.mLabel) continue;
1391  // produce html
1392  *pStream << "<p>" << std::endl;
1393  *pStream << "<a id=\"" << "lit_" << lit->second.mLabel << "\">[" << lit->second.mLabel << "]</a>" << std::endl;
1394  *pStream << lit->second.mAuthors << ": ";
1395  *pStream << "<i>" << lit->second.mTitle << "</i>";
1396  if(lit->second.mJournal!="") *pStream << ", " << lit->second.mJournal;
1397  if(lit->second.mPublisher!="") *pStream << ", " << lit->second.mPublisher;
1398  if(lit->second.mYear!="") *pStream << ", " << lit->second.mYear;
1399  *pStream << ".</p>" << std::endl;
1400  }
1401 }
1402 
1403 
1404 // html for literature citation
1405 void CiteHtml(std::ostream* pStream, const std::string& rLabel) {
1406  // prepare
1407  std::string link="reference_literature.html";
1408  // find records
1409  std::map<std::string,LiteratureRecord>::iterator lit;
1410  lit=mLiterature.find(rLabel);
1411  if(lit!=mLiterature.end()) link=lit->second.mLink;
1412  // produce HTML
1413  *pStream << "<a href=\"" << link << "\">[" << rLabel << "]</a>";
1414 }
1415 
1416 
1417 // ******************************************************************
1418 // extract pages
1419 // ******************************************************************
1420 
1421 void XtractPages(TokenReader& src,const std::string& rDstDir) {
1422 
1423  // scan for reference page sections
1424  Token btag;
1425  while(src.Peek(btag)) {
1426  // skip tokens
1427  if(!btag.IsBegin("ReferencePage")) {
1428  src.Get(btag);
1429  continue;
1430  }
1431  // read begin tag
1432  src.ReadBegin("ReferencePage",btag);
1433  // extract title & friends
1434  mFrefTitle="libFAUDES Reference";
1435  if(btag.ExistsAttributeString("title"))
1436  mFrefTitle=btag.AttributeStringValue("title");
1437  mFrefChapter="Reference";
1438  if(btag.ExistsAttributeString("chapter"))
1439  mFrefChapter=btag.AttributeStringValue("chapter");
1440  mFrefSection="";
1441  if(btag.ExistsAttributeString("section"))
1442  mFrefSection=btag.AttributeStringValue("section");
1443  mFrefPage="";
1444  if(btag.ExistsAttributeString("page"))
1445  mFrefPage=btag.AttributeStringValue("page");
1446  // insist in page and section
1447  if(mFrefSection=="" || mFrefPage=="") {
1448  std::cerr << "ref2html: skipping undefined page at " << src.FileLine() << std::endl;
1449  src.ReadEnd("ReferencePage");
1450  continue;
1451  }
1452  // normalize & report
1453  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1454  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1455  std::transform(mFrefPage.begin(), mFrefPage.end(), mFrefPage.begin(), tolower);
1456  // dst file
1457  std::string dstfile=PrependPath(rDstDir,mFrefSection + "_" + mFrefPage +".fref");
1458  std::cerr << "ref2html: extracting page to \"" << dstfile << "\"" << std::endl;
1459  TokenWriter dst(dstfile);
1460  // copy section
1461  dst.Write(btag);
1462  std::string srctext;
1463  src.ReadSection(srctext);
1464  dst.WriteCharacterData(srctext);
1465  dst.WriteEnd("ReferencePage");
1466  // read end tag
1467  src.ReadEnd("ReferencePage");
1468  }
1469 }
1470 
1471 // ******************************************************************
1472 // extract files
1473 // ******************************************************************
1474 
1475 void XtractFiles(TokenReader& src,const std::string& rDstDir) {
1476 
1477  // scan for file sections
1478  Token btag;
1479  while(src.Peek(btag)) {
1480  // skip tokens
1481  if(!btag.IsBegin("ImageFile")) {
1482  src.Get(btag);
1483  continue;
1484  }
1485  // read begin tag
1486  src.ReadBegin("ImageFile",btag);
1487  std::string name=btag.AttributeStringValue("name");
1488  if(name==""){
1489  std::cerr << "ref2html: skipping undefined image file at " << src.FileLine() << std::endl;
1490  src.ReadEnd("ImageFile");
1491  continue;
1492  }
1493  // read data
1494  Token data;
1495  src.Get(data);
1496  if(!data.IsBinary()){
1497  std::cerr << "ref2html: skipping invalid image file at " << src.FileLine() << std::endl;
1498  src.ReadEnd("ImageFile");
1499  continue;
1500  }
1501  // dst file
1502  std::string dstfile;
1503  std::transform(name.begin(), name.end(), name.begin(), tolower);
1504  dstfile=PrependPath(rDstDir,"images");
1505  dstfile=PrependPath(dstfile,name);
1506  std::cerr << "ref2html: extracting image file to \"" << dstfile << "\"" << std::endl;
1507  // setup stream
1508  std::fstream fsout;
1509  fsout.exceptions(std::ios::badbit|std::ios::failbit);
1510  try{
1511  fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
1512  fsout.write(data.StringValue().c_str(),data.StringValue().size());
1513  fsout.close();
1514  }
1515  catch (std::ios::failure&) {
1516  std::cerr << "ref2html: file io error when writing \"" << dstfile << "\"" << std::endl;
1517  }
1518  // read end tag
1519  src.ReadEnd("ImageFile");
1520  }
1521 }
1522 
1523 // ******************************************************************
1524 // luafaudes index
1525 // ******************************************************************
1526 
1527 void LuafaudesIndexHtml(std::ostream* pIndexFile) {
1528 
1529  // prepare list of all sections
1530  std::map< std::string , std::string > pages;
1531  std::vector< PageRecord >::iterator pit;
1532  for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1533  // my chapter only
1534  if(pit->mChapter!="luafaudes") continue;
1535  if(pit->mSection=="none") continue;
1536  if(pit->mSection=="") continue;
1537  if(pit->mPage=="") continue;
1538  // get nice name
1539  std::string pname = pit->mPage;
1540  // have link
1541  std::string phtml = pit->mLink;
1542  // record
1543  pages[pname]=phtml;
1544  }
1545  // produce sorted index
1546  std::map< std::string , std::string >::iterator sit;
1547  for(sit=pages.begin(); sit!=pages.end(); sit++) {
1548  // have entry
1549  ListItemHtml(pIndexFile,sit->second, sit->first);
1550  }
1551  // empty
1552  if(pages.size()==0) {
1553  *pIndexFile << "<li class=\"registry_item\">" << "none" << "</li>" << std::endl;
1554  }
1555 }
1556 
1557 // ******************************************************************
1558 // process current section
1559 // ******************************************************************
1560 
1562 
1563  // record my level/mode
1564  int clevel = rTr.Level();
1565 
1566  // std::cerr << "process level " << clevel << "\n";
1567 
1568  // token copy loop
1569  while(true) {
1570  // see whether we can grab and copy some plain text
1571  std::string text;
1572  rTr.ReadCharacterData(text);
1573  if(text.size()>0) {
1574  //std::cerr << "copy text \"" << text << "\"\n";
1575  rTw.WriteCharacterData(text);
1576  continue;
1577  }
1578  // break on no token or end of my level
1579  Token token;
1580  if(!rTr.Peek(token)) break;
1581  if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
1582  break;
1583  // do my special tags: ftype
1584  if(token.IsBegin("ftype")) {
1585  std::string ftype;
1586  rTr.ReadText("ftype",ftype);
1587  TypeHtml(rTw.Streamp(),ftype);
1588  continue;
1589  }
1590  // do my special tags: ffnct
1591  if(token.IsBegin("ffnct")) {
1592  std::string ffnct;
1593  rTr.ReadText("ffnct",ffnct);
1594  FunctionHtml(rTw.Streamp(),ffnct);
1595  continue;
1596  }
1597  // do my special tags: fimage
1598  if(token.IsBegin("fimage")) {
1599  rTr.ReadBegin("fimage", token);
1600  std::string fsrc=token.AttributeStringValue("fsrc");
1601  fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",""); // be nice
1602  fsrc = ExtractBasename(fsrc); // be even niecer
1603  ImageHtml(rTw.Streamp(),fsrc);
1604  rTr.ReadEnd("fimage");
1605  continue;
1606  }
1607  // do my special tags: dmath
1608  if(token.IsBegin("fdmath")) {
1609  rTr.ReadBegin("fdmath", token);
1610  std::string mtext;
1611  rTr.ReadCharacterData(mtext);
1612  *rTw.Streamp() << "<span class=\"faudes_dmath\">";
1613  MathHtml(rTw.Streamp(),mtext);
1614  *rTw.Streamp()<< "</span>";
1615  rTr.ReadEnd("fdmath");
1616  continue;
1617  }
1618  // do my special tags: dmath
1619  if(token.IsBegin("fimath")) {
1620  rTr.ReadBegin("fimath", token);
1621  std::string mtext;
1622  rTr.ReadCharacterData(mtext);
1623  *rTw.Streamp()<< "<span class=\"faudes_imath\">";
1624  MathHtml(rTw.Streamp(),mtext);
1625  *rTw.Streamp()<< "</span>";
1626  rTr.ReadEnd("fimath");
1627  continue;
1628  }
1629  // do my special tags: ffnct_reference
1630  if(token.IsBegin("ffnct_reference")) {
1631  rTr.ReadBegin("ffnct_reference", token);
1632  std::string ffnct = token.AttributeStringValue("name");
1633  *rTw.Streamp() << "<div class=\"registry_function\"> " << std::endl;
1634  *rTw.Streamp() << "<h2>" << "<a id=\"" << ffnct << "\">" << ffnct << "</a></h2>" << std::endl;
1635  ShortdocHtml(rTw.Streamp(),ffnct);
1636  ProcessSection(rTw,rTr);
1637  *rTw.Streamp() << "</div>" << std::endl;
1638  rTr.ReadEnd("ffnct_reference");
1639  continue;
1640  }
1641  // do my special tags: ftype_reference
1642  if(token.IsBegin("ftype_reference")) {
1643  rTr.ReadBegin("ftype_reference", token);
1644  std::string ftype = token.AttributeStringValue("name");
1645  *rTw.Streamp() << "<div class=\"registry_type\"> " << std::endl;
1646  *rTw.Streamp() << "<h2>" << "<a id=\"" << ftype << "\">" << ftype << "</a></h2>" << std::endl;
1647  ShortdocHtml(rTw.Streamp(),ftype);
1648  ProcessSection(rTw,rTr);
1649  *rTw.Streamp() << "</div>" << std::endl;
1650  rTr.ReadEnd("ftype_reference");
1651  continue;
1652  }
1653  // do my special tags: fdetails
1654  if(token.IsBegin("fdetails")) {
1655  rTr.ReadBegin("fdetails", token);
1656  *rTw.Streamp() << "<h5>Detailed description:</h5>";
1657  rTr.ReadEnd("fdetails");
1658  continue;
1659  }
1660  // do my special tags: fconditions
1661  if(token.IsBegin("fconditions")) {
1662  rTr.ReadBegin("fconditions", token);
1663  *rTw.Streamp() << "<h5>Parameter Conditions:</h5>";
1664  rTr.ReadEnd("fconditions");
1665  continue;
1666  }
1667  // do my special tags: fexample
1668  if(token.IsBegin("fexample")) {
1669  rTr.ReadBegin("fexample", token);
1670  *rTw.Streamp() << "<h5>Example:</h5>";
1671  rTr.ReadEnd("fexample");
1672  continue;
1673  }
1674  // do my special tags: falltypes
1675  if(token.IsBegin("falltypes")) {
1676  rTr.ReadBegin("falltypes", token);
1677  ListTypesHtml(rTw.Streamp());
1678  rTr.ReadEnd("falltypes");
1679  continue;
1680  }
1681  // do my special tags: fallfncts
1682  if(token.IsBegin("fallfncts")) {
1683  rTr.ReadBegin("fallfncts", token);
1684  ListFunctionsHtml(rTw.Streamp());
1685  rTr.ReadEnd("fallfncts");
1686  continue;
1687  }
1688  // do my special tags: fallsects
1689  if(token.IsBegin("fallsects")) {
1690  rTr.ReadBegin("fallsects", token);
1691  ListSectionsHtml(rTw.Streamp());
1692  rTr.ReadEnd("fallsects");
1693  continue;
1694  }
1695  // do my special tags: fluasects
1696  if(token.IsBegin("fluasects")) {
1697  rTr.ReadBegin("fluasects", token);
1698  ListSectionsHtml(rTw.Streamp(),"luaext");
1699  rTr.ReadEnd("fluasects");
1700  continue;
1701  }
1702  // do my special tags: fliteratur (list all)
1703  if(token.IsBegin("falllit")) {
1704  rTr.ReadBegin("falllit");
1705  LiteratureHtml(rTw.Streamp());
1706  rTr.ReadEnd("falllit");
1707  continue;
1708  }
1709  // do my special tags: fliteratur (definition of)
1710  if(token.IsBegin("fliterature")) {
1711  rTr.ReadBegin("fliterature", token);
1712  std::string label=token.AttributeStringValue("name");
1713  LiteratureHtml(rTw.Streamp(),label);
1714  rTr.ReadEnd("fliterature");
1715  continue;
1716  }
1717  // do my special tags: fcontributors
1718  if(token.IsBegin("fcontributors")) {
1719  rTr.ReadBegin("fcontributors");
1720  *rTw.Streamp() << ContributorsString();
1721  rTr.ReadEnd("fcontributors");
1722  continue;
1723  }
1724  // do my special tags: flink
1725  if(token.IsBegin("fcite")) {
1726  rTr.ReadBegin("fcite", token);
1727  std::string label=token.AttributeStringValue("name");
1728  CiteHtml(rTw.Streamp(),label);
1729  rTr.ReadEnd("fcite");
1730  continue;
1731  }
1732  // do my special tags: fix br for HTML
1733  if(token.IsBegin("br")) {
1734  rTr.ReadBegin("br");
1735  Token etag;
1736  rTr.Peek(etag);
1737  if(etag.IsEnd("br")) rTr.ReadEnd("br"); // optionally accept balanced <br>
1738  token.ClrEnd();
1739  token.PreceedingSpace("n");
1740  rTw.Write(token); // intentionall write unbalanced <br> for HTML
1741  continue;
1742  }
1743  // do my special tags: fsummary
1744  if(token.IsBegin("fsummary")) {
1745  rTr.ReadBegin("fsummary");
1746  rTr.ReadEnd("fsummary");
1747  continue;
1748  }
1749  // get token to do my special attributes
1750  rTr.Get(token);
1751  //std::cerr << "copy token (lv " << rTr.Level() << "): " << token.Str() << "\n";
1752  // sense chapter classes
1753  if(token.ExistsAttributeString("ftcclass")) {
1754  mThisChapterClass=token.AttributeStringValue("ftcclass");
1755  token.ClrAttribute("ftcclass");
1756  }
1757  if(token.ExistsAttributeString("focclass")) {
1758  mOtherChapterClass=token.AttributeStringValue("focclass");
1759  token.ClrAttribute("focclass");
1760  }
1761  if(token.ExistsAttributeString("fxcclass")) {
1762  mExitChapterClass=token.AttributeStringValue("fxcclass");
1763  token.ClrAttribute("fxcclass");
1764  }
1765  // chapter attribute
1766  if(token.ExistsAttributeString("fchapter")) {
1767  std::string chapter = token.AttributeStringValue("fchapter");
1768  std::string cclass=mOtherChapterClass;
1769  if(chapter==mFrefChapter) cclass=mThisChapterClass;
1770  if(chapter=="exit") cclass=mExitChapterClass;
1771  token.InsAttributeString("class",cclass);
1772  token.ClrAttribute("fchapter");
1773  }
1774  // fhref attribute: ref only
1775  if(token.ExistsAttributeString("fhref") && mStandaloneReference) {
1776  std::string href = token.AttributeStringValue("fhref");
1777  href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1778  href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1779  href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1780  href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1781  href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourceLink);
1782  href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesLink);
1783  href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1784  href = StringSubstitute(href,"FAUDES_GETLINUX",mDownloadLink+"#Packages");
1785  href = StringSubstitute(href,"FAUDES_GETMSWIN",mDownloadLink+"#Packages");
1786  href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1787  token.InsAttributeString("href",href);
1788  token.ClrAttribute("fhref");
1789  }
1790  // fhref attribute
1791  if(token.ExistsAttributeString("fhref") && !mStandaloneReference) {
1792  std::string href = token.AttributeStringValue("fhref");
1793  href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1794  href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1795  href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1796  href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1797  href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourcePrefix);
1798  href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1799  href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1800  href = StringSubstitute(href,"FAUDES_GETLINUX",mDownloadLink+"#Packages");
1801  href = StringSubstitute(href,"FAUDES_GETMSWIN",mDownloadLink+"#Packages");
1802  href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1803  token.InsAttributeString("href",href);
1804  token.ClrAttribute("fhref");
1805  }
1806  // fsrc attribute
1807  if(token.ExistsAttributeString("fsrc")) {
1808  std::string fsrc = token.AttributeStringValue("fsrc");
1809  fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",mImagePrefix);
1810  fsrc = StringSubstitute(fsrc,"FAUDES_CSOURCE/",mCsourcePrefix);
1811  fsrc = StringSubstitute(fsrc,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1812  token.InsAttributeString("src",fsrc);
1813  token.ClrAttribute("fsrc");
1814  }
1815  token.PreceedingSpace("n");
1816  rTw.Write(token);
1817  }
1818 }
1819 
1820 
1821 // ******************************************************************
1822 // reference page
1823 // ******************************************************************
1824 
1825 void RefpageHtml(std::ostream* pOutFile, std::string inputfile) {
1826 
1827  // setup token io
1828  TokenReader src(inputfile);
1829  TokenWriter dst(*pOutFile);
1830 
1831  // find the reference page section
1832  Token btag;
1833  src.SeekBegin("ReferencePage");
1834  src.ReadBegin("ReferencePage",btag);
1835 
1836  // extract title & friends
1837  mFrefTitle="libFAUDES Reference";
1838  if(btag.ExistsAttributeString("title"))
1839  mFrefTitle=btag.AttributeStringValue("title");
1840  mFrefChapter="";
1841  if(btag.ExistsAttributeString("chapter"))
1842  mFrefChapter=btag.AttributeStringValue("chapter");
1843  mFrefSection="";
1844  if(btag.ExistsAttributeString("section"))
1845  mFrefSection=btag.AttributeStringValue("section");
1846  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1847  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1848 
1849  // report
1850  // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
1851 
1852  // generate generic html header
1853  dst.Flush();
1854  HeaderHtml(pOutFile);
1855 
1856  // begin body
1857  dst.Flush();
1858 
1859  // include chapter level navigation
1860  if(mChapterFile!="") {
1861  //std::cerr << "using " << mChapterFile << std::endl;
1863  ProcessSection(dst,inc);
1864  }
1865 
1866  // include section level navigation, part 1
1867  if(mFrefChapter=="reference") {
1868  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1869  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1870  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1871  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1872  *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
1873  ListItemHtml(pOutFile,"reference_index.html", "Reference");
1874  ListItemHtml(pOutFile,"reference_types.html", "Type Index");
1875  ListItemHtml(pOutFile,"reference_functions.html", "Function Index");
1876  ListItemHtml(pOutFile,"reference_literature.html", "Literature");
1877  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1878  ReferenceIndexHtml(pOutFile, mFrefSection);
1879  *pOutFile << "</ul></td>" << std::endl;
1880  *pOutFile << "<td id=\"registry_content\">" << std::endl;
1881  }
1882 
1883  // include section level navigation, part 1
1884  if(mFrefChapter=="luafaudes") {
1885  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1886  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1887  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1888  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1889  *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
1890  *pOutFile
1891  << "<script language=\"JavaScript\"> var luafaudes=function() { "
1892  << " popupWin = window.open('luafaudes_repl.html','open_window',"
1893  << " 'resizable,dependent, width=720, height=480, left=0, top=0'); } "
1894  << "</script>" << std::endl;
1895  ListItemHtml(pOutFile,"index.html", "Introduction");
1896  ListItemHtml(pOutFile,"javascript:luafaudes();", "Lua-Console");
1897  ListItemHtml(pOutFile,"faudes_luaext.html", "Lua-Extensions");
1898  ListItemHtml(pOutFile,"faudes_luatech.html", "Technical Detail");
1899  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1900  *pOutFile << "<li class=\"registry_heading\">Tutorials</li>" << std::endl;
1901  LuafaudesIndexHtml(pOutFile);
1902  *pOutFile << "</ul></td>" << std::endl;
1903  *pOutFile << "<td id=\"registry_content\">" << std::endl;
1904  }
1905 
1906  // process src
1907  ProcessSection(dst,src);
1908  src.ReadEnd("ReferencePage");
1909  dst.Flush();
1910 
1911  // track bottom line
1912  bool bottom=false;
1913 
1914  // include section level navigation, part 2
1915  if(mFrefChapter=="reference") {
1916  BottomLineHtml(pOutFile);
1917  bottom=true;
1918  *pOutFile << "</td>" << std::endl;
1919  *pOutFile << "</tr>" << std::endl;
1920  *pOutFile << "</table>" << std::endl;
1921  }
1922 
1923  // include section level navigation, part 2
1924  if(mFrefChapter=="luafaudes") {
1925  BottomLineHtml(pOutFile);
1926  bottom=true;
1927  *pOutFile << "</td>" << std::endl;
1928  *pOutFile << "</tr>" << std::endl;
1929  *pOutFile << "</table>" << std::endl;
1930  }
1931 
1932  // include section level navigation, part 3
1933  if(mFrefChapter=="reference") {
1934  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
1935  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
1936  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
1937  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
1938  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1939  SectionIndexHtml(pOutFile,mFrefSection);
1940  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1941  ListItemHtml(pOutFile,"#", "Top of Page");
1942  *pOutFile << "</ul></div>" << std::endl;
1943  }
1944 
1945  // include section level navigation, part 3
1946  if(mFrefChapter=="luafaudes" && mFrefSection=="tutorials") {
1947  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
1948  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
1949  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
1950  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
1951  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1952  *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
1953  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luafaudes.html\">Introduction</a></li>" << std::endl;
1954  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luaext.html\">Lua-Extansions</a></li>" << std::endl;
1955  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luatech.html\">Techn. Details</a></li>" << std::endl;
1956  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1957  *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
1958  *pOutFile << "</ul></div>" << std::endl;
1959  }
1960 
1961  // bottom line
1962  if(!bottom) BottomLineHtml(pOutFile);
1963 
1964  // generic footer
1965  FooterHtml(pOutFile);
1966 
1967 }
1968 
1969 
1970 
1971 // ******************************************************************
1972 // Doxygen header and footer
1973 // ******************************************************************
1974 
1975 void DoxygenHeader(std::ostream* pOutFile) {
1976 
1977  // setup token io
1978  TokenWriter dst(*pOutFile);
1979 
1980  // configure
1981  mFrefTitle="C++ API";
1982  mFrefChapter="cppapi";
1983  mFrefSection="none";
1984 
1985  // generate generic html header
1986  dst.Flush();
1987  HeaderHtml(pOutFile);
1988 
1989  // include chapter level navigation
1990  if(mChapterFile!="") {
1992  ProcessSection(dst,inc);
1993  }
1994 
1995  // include section level navigation, part 1
1996  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1997  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1998  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1999  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2000  *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
2001  ListItemHtml(pOutFile, "index.html", "C++ API");
2002  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2003  *pOutFile << "<li class=\"registry_heading\">Sections</li>" << std::endl;
2004  ListItemHtml(pOutFile, "group__ContainerClasses.html", "Sets");
2005  ListItemHtml(pOutFile, "group__GeneratorClasses.html", "Generators");
2006  ListItemHtml(pOutFile, "group__GeneratorFunctions.html", "Functions");
2007  ListItemHtml(pOutFile, "group__AllPlugins.html", "PlugIns");
2008  ListItemHtml(pOutFile, "group__Tutorials.html", "Tutorials");
2009  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2010  *pOutFile << "<li class=\"registry_heading\">Index</li>" << std::endl;
2011  ListItemHtml(pOutFile, "classes.html", "Classes");
2012  ListItemHtml(pOutFile, "files.html", "Files");
2013  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2014  *pOutFile << "</ul></td>" << std::endl;
2015  *pOutFile << "<td id=\"registry_content\">" << std::endl;
2016 }
2017 
2018 
2019 void DoxygenFooter(std::ostream* pOutFile) {
2020 
2021  // setup token io
2022  TokenWriter dst(*pOutFile);
2023 
2024  // configure
2025  mFrefTitle="C++ API";
2026  mFrefChapter="cppapi";
2027  mFrefSection="none";
2028 
2029  // include section level navigation, part 2
2030  BottomLineHtml(pOutFile);
2031  *pOutFile << "</td>" << std::endl;
2032  *pOutFile << "</tr>" << std::endl;
2033  *pOutFile << "</table>" << std::endl;
2034 
2035  // include section level navigation, part 3
2036  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
2037  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
2038  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
2039  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
2040  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2041  *pOutFile << "<li class=\"registry_heading\">C++ API</li>" << std::endl;
2042  *pOutFile << "<li class=\"registry_item\"><a href=\"index.html\">Introduction</a></li>" << std::endl;
2043  *pOutFile << "<li class=\"registry_item\"><a href=\"group__ContainerClasses.html\">Sets</a></li>" << std::endl;
2044  *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorClasses.html\">Generators</a></li>" << std::endl;
2045  *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorFunctions.html\">Functions</a></li>" << std::endl;
2046  *pOutFile << "<li class=\"registry_item\"><a href=\"group__AllPlugins.html\">PlugIns</a></li>" << std::endl;
2047  *pOutFile << "<li class=\"registry_item\"><a href=\"group__Tutorials.html\">Tutorials</a></li>" << std::endl;
2048  *pOutFile << "<li class=\"registry_item\"><a href=\"classes.html\">Classes</a></li>" << std::endl;
2049  *pOutFile << "<li class=\"registry_item\"><a href=\"files.html\">Files</a></li>" << std::endl;
2050  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2051  *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
2052  *pOutFile << "</ul></div>" << std::endl;
2053 
2054  // end page
2055  dst.Flush();
2056  FooterHtml(pOutFile);
2057 
2058 }
2059 
2060 // ******************************************************************
2061 // command line ui
2062 // ******************************************************************
2063 
2064 
2065 int main(int argc, char *argv[]) {
2066 
2067  // local config
2068  bool dotoc=false;
2069  bool dodhd=false;
2070  bool dodft=false;
2071  bool xpage=false;
2072 
2073  // min args
2074  if(argc < 3) usage_exit();
2075 
2076  // primitive commad line parsing
2077  int i;
2078  for(i=1; i<argc; i++) {
2079  std::string option(argv[i]);
2080  // option: rti file
2081  if(option=="-rti") {
2082  i++; if(i>=argc) usage_exit();
2083  mRtiFile=argv[i];
2084  continue;
2085  }
2086  // option: flx file
2087  if(option=="-flx") {
2088  i++; if(i>=argc) usage_exit();
2089  mFlxFile=argv[i];
2090  continue;
2091  }
2092  // option: css file
2093  if(option=="-css") {
2094  i++; if(i>=argc) usage_exit();
2095  mCssFile=argv[i];
2096  continue;
2097  }
2098  // option: navigation include
2099  if(option=="-cnav") {
2100  i++; if(i>=argc) usage_exit();
2101  mChapterFile=argv[i];
2102  continue;
2103  }
2104  // option: toc include
2105  if(option=="-inc") {
2106  i++; if(i>=argc) usage_exit();
2107  mIncludeFile=argv[i];
2108  continue;
2109  }
2110  // option: target prefix
2111  if(option=="-rel") {
2112  i++; if(i>=argc) usage_exit();
2113  ChaptersPrefix(argv[i]);
2114  continue;
2115  }
2116  // option: overwrite chapter
2117  if(option=="-chapter") {
2118  i++; if(i>=argc) usage_exit();
2119  mFrefChapter=argv[i];
2120  continue;
2121  }
2122  // option: overwrite section
2123  if(option=="-section") {
2124  i++; if(i>=argc) usage_exit();
2125  mFrefSection=argv[i];
2126  continue;
2127  }
2128  // option: extract multiple pages
2129  if(option=="-extract") {
2130  if(i+2!=argc-1) usage_exit();
2131  xpage=true;
2132  break;
2133  }
2134  // option: generate toc (break)
2135  if(option=="-toc") {
2136  i++; if(i+1>=argc) usage_exit();
2137  dotoc=true;
2138  mDstFile = argv[argc-1];
2139  break;
2140  }
2141  // option: generate doxygen header (break)
2142  if(option=="-doxheader") {
2143  i++; if(i>=argc) usage_exit();
2144  dodhd=true;
2145  mDstFile = argv[argc-1];
2146  break;
2147  }
2148  // option: generate doxygen footer (break)
2149  if(option=="-doxfooter") {
2150  i++; if(i>=argc) usage_exit();
2151  dodft=true;
2152  mDstFile = argv[argc-1];
2153  break;
2154  }
2155  // option: generate standalone reference
2156  if(option=="-app") {
2157  mStandaloneReference=true;
2158  continue;
2159  }
2160  // option: help
2161  if((option=="-?") || (option=="--help")) {
2162  usage_exit();
2163  continue;
2164  }
2165  // option: unknown
2166  if(option.size()>1)
2167  if(option.at(0)=='-') {
2168  usage_exit("unknown option " + option);
2169  continue;
2170  }
2171  // non-option: break
2172  break;
2173  }
2174 
2175  // figure source
2176  for(;i<argc-1; i++) {
2177  std::string option(argv[i]);
2178  if(option.size()>1)
2179  if(option.at(0)=='-') {
2180  usage_exit("missplaced/unknown option " + option);
2181  continue;
2182  }
2183  mSrcFiles.insert(option);
2184  }
2185 
2186  // figure destination
2187  for(;i<argc; i++) {
2188  std::string option(argv[i]);
2189  if(option.size()>1)
2190  if(option.at(0)=='-') {
2191  usage_exit("missplaced/unknown option " + option);
2192  continue;
2193  }
2194  mDstFile=option;
2195  }
2196 
2197  // test
2198  if(mDstFile=="") {
2199  usage_exit("no destination file specified");
2200  }
2201  bool dirdst=DirectoryExists(mDstFile);
2202 
2203  // load registry
2204  if(mRtiFile!="") {
2206  }
2207 
2208  // record plug-in and buil-in sections
2209  for(FunctionRegistry::Iterator fit=FunctionRegistry::G()->Begin();
2210  fit!=FunctionRegistry::G()->End(); fit++) {
2211  std::string section=fit->second->KeywordAt(0);
2212  std::transform(section.begin(), section.end(), section.begin(), tolower);
2213  mExclLuaSections.insert(section);
2214  }
2215 
2216  // extend registry
2217  if(mFlxFile!="") {
2219  }
2220 
2221  // record lua sections
2222  for(FunctionRegistry::Iterator fit=FunctionRegistry::G()->Begin();
2223  fit!=FunctionRegistry::G()->End(); fit++) {
2224  std::string section=fit->second->KeywordAt(0);
2225  std::transform(section.begin(), section.end(), section.begin(), tolower);
2226  mInclLuaSections.insert(section);
2227  }
2228 
2229 
2230  // include toc
2231  if(mIncludeFile!="") {
2233  RecordLiterature(tr);
2234  tr.Rewind();
2235  RecordPages(tr);
2236  }
2237 
2238 
2239  // special case: xtract fref
2240  if(xpage) {
2241  if(mSrcFiles.size()!=1) {
2242  usage_exit("extract mode requires one source file");
2243  }
2244  if(!dirdst) {
2245  usage_exit("extract mode requires destination directory");
2246  }
2247  std::cerr << "ref2html: extract pages from " << *mSrcFiles.begin() << std::endl;
2248  TokenReader tr(*mSrcFiles.begin());
2249  XtractPages(tr,mDstFile);
2250  tr.Rewind();
2251  XtractFiles(tr,mDstFile);
2252  exit(0);
2253  }
2254 
2255 
2256  // special case: generate toc
2257  if(dotoc) {
2258  if(dirdst) {
2259  usage_exit("toc mode requires destination file");
2260  }
2261  // output file
2262  std::ostream* hout= &std::cout;
2263  std::ofstream fout;
2264  if(mDstFile != "-") {
2265  fout.open(mDstFile.c_str(), std::ios::out);
2266  hout = &fout;
2267  }
2268  // process all input
2269  std::set< std::string >::iterator sit=mSrcFiles.begin();
2270  for(;sit!=mSrcFiles.end();++sit) {
2271  std::cerr << "ref2html: process toc " << *sit << std::endl;
2272  TokenReader tr(*sit);
2273  RecordLiterature(tr);
2274  tr.Rewind();
2275  RecordPages(tr);
2276  }
2277  // dump
2278  TokenWriter dst(*hout);
2279  DumpPages(dst);
2280  DumpLiterature(dst);
2281  dst.Flush();
2282  exit(0);
2283  }
2284 
2285  // special case: generate dox header/footer
2286  if(dodhd || dodft) {
2287  if(dirdst) {
2288  usage_exit("header-footer mode requires destination file");
2289  }
2290  // output file
2291  std::ostream* hout= &std::cout;
2292  std::ofstream fout;
2293  if(mDstFile != "-") {
2294  fout.open(mDstFile.c_str(), std::ios::out);
2295  hout = &fout;
2296  }
2297  // doit
2298  if(dodhd) DoxygenHeader(hout);
2299  if(dodft) DoxygenFooter(hout);
2300  exit(0);
2301  }
2302 
2303 
2304  // convert all source directories
2305  std::set< std::string > srcfiles;
2306  std::set< std::string >::iterator sit=mSrcFiles.begin();
2307  for(;sit!=mSrcFiles.end();++sit) {
2308  if(!DirectoryExists(*sit)) { srcfiles.insert(*sit); continue;}
2309  std::set< std::string > dirfiles = ReadDirectory(*sit);
2310  std::set< std::string >::iterator dit=dirfiles.begin();
2311  for(;dit!=dirfiles.end();++dit) {
2312  std::string ext = ExtractSuffix(*dit);
2313  std::string base = ExtractBasename(*dit);
2314  std::string src= PrependPath(*sit,base + ".fref");
2315  // skip if not an fref file
2316  if(ext!="fref") continue;
2317  // record
2318  srcfiles.insert(src);
2319  }
2320  }
2321  mSrcFiles=srcfiles;
2322 
2323  // insist in target dir
2324  if(mSrcFiles.size()>1 && ! dirdst) {
2325  usage_exit("multiple source files require destination directory");
2326  }
2327 
2328 
2329  // do loop
2330  /*std::set< std::string >::iterator*/ sit=mSrcFiles.begin();
2331  for(;sit!=mSrcFiles.end();++sit) {
2332  std::string base = ExtractBasename(*sit);
2333  std::string src= *sit;
2334  std::string dst= mDstFile;
2335  if(dirdst) dst=PrependPath(mDstFile,base + ".html");
2336  // process
2337  if(mSrcFiles.size()>1)
2338  std::cout << "ref2html: processing " << src << " to " << dst << std::endl;
2339  std::ofstream fout;
2340  fout.open(dst.c_str(), std::ios::out);
2341  RefpageHtml(&fout,src);
2342  }
2343  exit(0);
2344 }
std::string mJournal
Definition: ref2html.cpp:1238
std::string mTitle
Definition: ref2html.cpp:1237
std::string mYear
Definition: ref2html.cpp:1240
std::string mLabel
Definition: ref2html.cpp:1234
std::string mPublisher
Definition: ref2html.cpp:1239
std::string mAuthors
Definition: ref2html.cpp:1236
std::string mLink
Definition: ref2html.cpp:1235
std::string mSection
Definition: ref2html.cpp:615
std::string mPage
Definition: ref2html.cpp:616
std::string mLink
Definition: ref2html.cpp:617
std::string mSummary
Definition: ref2html.cpp:618
std::string mChapter
Definition: ref2html.cpp:614
std::string mTitle
Definition: ref2html.cpp:613
const std::string & HtmlDoc(void) const
Definition: cfl_types.cpp:401
const std::string & Name(void) const
Definition: cfl_types.cpp:397
const std::string & TextDoc(void) const
Definition: cfl_types.cpp:400
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:505
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:131
std::string PrependPath(const std::string &rLeft, const std::string &rRight)
Definition: cfl_utils.cpp:319
std::string PluginsString()
Definition: cfl_utils.cpp:136
std::string ExtractFilename(const std::string &rFullPath)
Definition: cfl_utils.cpp:281
std::string ContributorsString()
Definition: cfl_utils.cpp:141
std::set< std::string > ReadDirectory(const std::string &rDirectory)
Definition: cfl_utils.cpp:364
std::string StringSubstitute(const std::string &rString, const std::string &rFrom, const std::string &rTo)
Definition: cfl_utils.cpp:111
std::string ExtractBasename(const std::string &rFullPath)
Definition: cfl_utils.cpp:290
bool DirectoryExists(const std::string &rDirectory)
Definition: cfl_utils.cpp:348
std::string ExtractSuffix(const std::string &rFullPath)
Definition: cfl_utils.cpp:304
void SectionIndexHtml(std::ostream *pIndexFile, const std::string &key)
Definition: ref2html.cpp:1103
int main(int argc, char *argv[])
Definition: ref2html.cpp:2065
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:1975
std::set< std::string > mSrcFiles
Definition: ref2html.cpp:105
void RecordPages(TokenReader &rTr)
Definition: ref2html.cpp:629
std::string mChapterFile
Definition: ref2html.cpp:106
void RefpageHtml(std::ostream *pOutFile, std::string inputfile)
Definition: ref2html.cpp:1825
std::map< std::string, std::map< std::string, PageRecord > > mRefSectPages
Definition: ref2html.cpp:626
std::string TimeStamp(void)
Definition: ref2html.cpp:154
void XtractFiles(TokenReader &src, const std::string &rDstDir)
Definition: ref2html.cpp:1475
std::vector< PageRecord > mAllPages
Definition: ref2html.cpp:623
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:1192
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:1339
void BottomLineHtml(std::ostream *pStream)
Definition: ref2html.cpp:196
void ListFunctionsHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:801
void RecordLiterature(TokenReader &rTr)
Definition: ref2html.cpp:1247
std::map< std::string, LiteratureRecord > mLiterature
Definition: ref2html.cpp:1244
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:954
void MathHtml(std::ostream *pStream, const std::string &rMathString)
Definition: ref2html.cpp:501
std::set< std::string > mInclLuaSections
Definition: ref2html.cpp:608
std::string mLuafaudesLink
Definition: ref2html.cpp:128
void LiteratureHtml(std::ostream *pStream, const std::string &rLabel="")
Definition: ref2html.cpp:1384
void TypeIndexHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:919
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:1153
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:735
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:1000
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:1405
void LuafaudesIndexHtml(std::ostream *pIndexFile)
Definition: ref2html.cpp:1527
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:836
void FunctionHtml(std::ostream *pStream, const std::string &rFunctionName)
Definition: ref2html.cpp:306
void XtractPages(TokenReader &src, const std::string &rDstDir)
Definition: ref2html.cpp:1421
void DoxygenFooter(std::ostream *pOutFile)
Definition: ref2html.cpp:2019
void ProcessSection(TokenWriter &rTw, TokenReader &rTr)
Definition: ref2html.cpp:1561
void TypeHtml(std::ostream *pStream, const std::string &rTypeName)
Definition: ref2html.cpp:282
std::set< std::string > mExclLuaSections
Definition: ref2html.cpp:607
void ListTypesHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:766

libFAUDES 2.33c --- 2025.05.15 --- c++ api documentaion by doxygen