htmlgen.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby
9  * granted. No representations are made about the suitability of this software
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 #ifndef HTMLGEN_H
19 #define HTMLGEN_H
20 
21 #include "outputgen.h"
22 #include "ftextstream.h"
23 
24 //#define PREFRAG_START "<div class=\"fragment\"><pre class=\"fragment\">"
25 //#define PREFRAG_END "</pre></div>"
26 #define PREFRAG_START "<div class=\"fragment\">"
27 #define PREFRAG_END "</div><!-- fragment -->"
28 
29 class QFile;
30 
32 {
33  public:
34  HtmlCodeGenerator(FTextStream &t,const QCString &relPath);
36  void setTextStream(FTextStream &t);
37  void setRelativePath(const QCString &path);
38  void codify(const char *text);
39  void writeCodeLink(const char *ref,const char *file,
40  const char *anchor,const char *name,
41  const char *tooltip);
42  void writeTooltip(const char *id,
43  const DocLinkInfo &docInfo,
44  const char *decl,
45  const char *desc,
46  const SourceLinkInfo &defInfo,
47  const SourceLinkInfo &declInfo
48  );
49  void writeLineNumber(const char *,const char *,const char *,int);
50  void startCodeLine(bool);
51  void endCodeLine();
52  void startFontClass(const char *s);
53  void endFontClass();
54  void writeCodeAnchor(const char *anchor);
55  void setCurrentDoc(Definition *,const char *,bool) {}
56  void addWord(const char *,bool) {}
57 
58  private:
59  void _writeCodeLink(const char *className,
60  const char *ref,const char *file,
61  const char *anchor,const char *name,
62  const char *tooltip);
63  void docify(const char *str);
66  int m_col;
68 };
69 
70 /** Generator for HTML output */
72 {
73  public:
74  HtmlGenerator();
75  virtual ~HtmlGenerator();
76  static void init();
77  static void writeStyleSheetFile(QFile &f);
78  static void writeHeaderFile(QFile &f, const char *cssname);
79  static void writeFooterFile(QFile &f);
80  static void writeTabData();
81  static void writeSearchInfo(FTextStream &t,const QCString &relPath);
82  static void writeSearchData(const char *dir);
83  static void writeSearchPage();
84  static void writeExternalSearchPage();
85  static QCString writeLogoAsString(const char *path);
86  static QCString writeSplitBarAsString(const char *name,const char *relpath);
87 
88  void enable()
89  { if (genStack->top()) active=*genStack->top(); else active=TRUE; }
90  void disable() { active=FALSE; }
91  void enableIf(OutputType o) { if (o==Html) enable(); }
92  void disableIf(OutputType o) { if (o==Html) disable(); }
93  void disableIfNot(OutputType o) { if (o!=Html) disable(); }
94  bool isEnabled(OutputType o) { return (o==Html && active); }
95  OutputGenerator *get(OutputType o) { return (o==Html) ? this : 0; }
96 
97  // ---- CodeOutputInterface
98  void codify(const char *text)
99  { m_codeGen.codify(text); }
100  void writeCodeLink(const char *ref,const char *file,
101  const char *anchor,const char *name,
102  const char *tooltip)
103  { m_codeGen.writeCodeLink(ref,file,anchor,name,tooltip); }
104  void writeLineNumber(const char *ref,const char *file,const char *anchor,int lineNumber)
105  { m_codeGen.writeLineNumber(ref,file,anchor,lineNumber); }
106  void writeTooltip(const char *id, const DocLinkInfo &docInfo, const char *decl,
107  const char *desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo
108  )
109  { m_codeGen.writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); }
110  void startCodeLine(bool hasLineNumbers)
111  { m_codeGen.startCodeLine(hasLineNumbers); }
112  void endCodeLine()
113  { m_codeGen.endCodeLine(); }
114  void startFontClass(const char *s)
115  { m_codeGen.startFontClass(s); }
116  void endFontClass()
117  { m_codeGen.endFontClass(); }
118  void writeCodeAnchor(const char *anchor)
119  { m_codeGen.writeCodeAnchor(anchor); }
120  // ---------------------------
121 
122  void setCurrentDoc(Definition *context,const char *anchor,bool isSourceFile);
123  void addWord(const char *word,bool hiPriority);
124  void writeDoc(DocNode *,Definition *,MemberDef *);
125 
126  void startFile(const char *name,const char *manName,const char *title);
127  void writeFooter(const char *navPath);
128  void endFile();
129  void clearBuffer();
130  void writeSearchInfo();
131 
134  void writePageLink(const char *,bool) {}
135  void startProjectNumber();
136  void endProjectNumber();
137  void writeStyleInfo(int part);
138  void startTitleHead(const char *);
139  void endTitleHead(const char *,const char *);
140  void startTitle() { t << "<div class=\"title\">"; }
141  void endTitle() { t << "</div>"; }
142 
143  void startParagraph();
144  void endParagraph();
145  void writeString(const char *text);
146  void startIndexListItem();
147  void endIndexListItem();
148  void startIndexList();
149  void endIndexList();
150  void startIndexKey();
151  void endIndexKey();
152  void startIndexValue(bool);
153  void endIndexValue(const char *,bool);
154  void startItemList() { t << "<ul>" << endl; }
155  void endItemList() { t << "</ul>" << endl; }
156  void startIndexItem(const char *ref,const char *file);
157  void endIndexItem(const char *ref,const char *file);
158  void docify(const char *text);
159 
160  void writeObjectLink(const char *ref,const char *file,
161  const char *anchor,const char *name);
162 
163  void startTextLink(const char *file,const char *anchor);
164  void endTextLink();
165  void startHtmlLink(const char *url);
166  void endHtmlLink();
167  void startTypewriter() { t << "<code>"; }
168  void endTypewriter() { t << "</code>"; }
169  void startGroupHeader(int);
170  void endGroupHeader(int);
171  void startItemListItem() { t << "<li>"; }
172  void endItemListItem() { t << "</li>\n"; }
173 
174  void startMemberSections();
175  void endMemberSections();
176  void startHeaderSection();
177  void endHeaderSection();
178  void startMemberHeader(const char *);
179  void endMemberHeader();
180  void startMemberSubtitle();
181  void endMemberSubtitle();
182  void startMemberDocList();
183  void endMemberDocList();
184  void startMemberList();
185  void endMemberList();
186  void startInlineHeader();
187  void endInlineHeader();
188  void startAnonTypeScope(int) {}
189  void endAnonTypeScope(int) {}
190  void startMemberItem(const char *anchor,int,const char *inheritId);
191  void endMemberItem();
192  void startMemberTemplateParams();
193  void endMemberTemplateParams(const char *anchor,const char *inheritId);
194 
195  void startMemberGroupHeader(bool);
196  void endMemberGroupHeader();
197  void startMemberGroupDocs();
198  void endMemberGroupDocs();
199  void startMemberGroup();
200  void endMemberGroup(bool);
201 
202  void insertMemberAlign(bool);
203  void startMemberDescription(const char *anchor,const char *inheritId);
204  void endMemberDescription();
206  void endMemberDeclaration(const char *anchor,const char *inheritId);
207  void writeInheritedSectionTitle(const char *id, const char *ref,
208  const char *file, const char *anchor,
209  const char *title,const char *name);
210 
211  void writeRuler() { t << "<hr/>"; }
212  void writeAnchor(const char *,const char *name)
213  { t << "<a name=\"" << name <<"\" id=\"" << name << "\"></a>"; }
215  void endCodeFragment() { t << PREFRAG_END; }
216  void startEmphasis() { t << "<em>"; }
217  void endEmphasis() { t << "</em>"; }
218  void startBold() { t << "<b>"; }
219  void endBold() { t << "</b>"; }
220  void startDescription() { t << endl << "<dl>" << endl; }
221  void endDescription() { t << endl << "</dl>\n" << endl; }
222  void startDescItem() { t << "<dt>"; }
223  void endDescItem() { t << "</dt>"; }
224  void startDescForItem() { t << "<dd>"; }
225  void endDescForItem() { t << "</dd>\n"; }
226  void lineBreak(const char *style);
227  void writeChar(char c);
228  void startMemberDoc(const char *,const char *,const char *,const char *,bool);
229  void endMemberDoc(bool);
230  void startDoxyAnchor(const char *fName,const char *manName,
231  const char *anchor,const char *name,
232  const char *args);
233  void endDoxyAnchor(const char *fName,const char *anchor);
235  void writeStartAnnoItem(const char *type,const char *file,
236  const char *path,const char *name);
237  void writeEndAnnoItem(const char *) { t << endl; }
238  void startSubsection() { t << "<h2>"; }
239  void endSubsection() { t << "</h2>" << endl; }
240  void startSubsubsection() { t << "<h3>"; }
241  void endSubsubsection() { t << "</h3>" << endl; }
242  void startCenter() { t << "<center>" << endl; }
243  void endCenter() { t << "</center>" << endl; }
244  void startSmall() { t << "<small>" << endl; }
245  void endSmall() { t << "</small>" << endl; }
246  //void startDescList(SectionTypes) { t << "<dl compact><dt><b>" << endl; }
247  //void endDescList() { t << "</dl>"; }
248  void startSimpleSect(SectionTypes,const char *,const char *,const char *);
249  void endSimpleSect();
250  void startParamList(ParamListTypes,const char *);
251  void endParamList();
252  //void writeDescItem() { t << "<dd>" << endl; }
253  void startSection(const char *,const char *,SectionInfo::SectionType);
254  void endSection(const char *,SectionInfo::SectionType);
255  void addIndexItem(const char *,const char *);
256  void startIndent();
257  void endIndent();
258  void writeSynopsis() {}
259  void startClassDiagram();
260  void endClassDiagram(const ClassDiagram &,const char *,const char *);
261  void startPageRef() {}
262  void endPageRef(const char *,const char *) {}
264  void endQuickIndices();
265  void writeSplitBar(const char *name);
266  void writeNavigationPath(const char *s);
267  void writeLogo();
268  void writeQuickLinks(bool compact,HighlightedItem hli,const char *file);
269  void writeSummaryLink(const char *file,const char *anchor,const char *title,bool first);
270  void startContents();
271  void endContents();
272  void writeNonBreakableSpace(int);
273 
274  void startDescTable(const char *title)
275  //{ t << "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl; }
276  { t << "<table class=\"fieldtable\">" << endl
277  << "<tr><th colspan=\"2\">" << title << "</th></tr>";
278  }
280  { t << "</table>" << endl; }
282  //{ t << "<tr><td valign=\"top\"><em>"; }
283  { t << "<tr><td class=\"fieldname\">"; }
285  { t << "&#160;</td>"; }
287  //{ t << "<td>" << endl; }
288  { t << "<td class=\"fielddoc\">" << endl; }
290  { t << "</td></tr>" << endl; }
291 
292  void startDotGraph();
293  void endDotGraph(const DotClassGraph &g);
294  void startInclDepGraph();
295  void endInclDepGraph(const DotInclDepGraph &g);
296  void startGroupCollaboration();
297  void endGroupCollaboration(const DotGroupCollaboration &g);
298  void startCallGraph();
299  void endCallGraph(const DotCallGraph &g);
300  void startDirDepGraph();
301  void endDirDepGraph(const DotDirDeps &g);
302  void writeGraphicalHierarchy(const DotGfxHierarchyTable &g);
303 
304  void startTextBlock(bool)
305  { t << "<div class=\"textblock\">"; }
306  void endTextBlock(bool)
307  { t << "</div>"; }
308  void lastIndexPage() {}
309 
310  void startMemberDocPrefixItem();
311  void endMemberDocPrefixItem();
312  void startMemberDocName(bool);
313  void endMemberDocName();
314  void startParameterType(bool first,const char *key);
315  void endParameterType();
316  void startParameterName(bool);
317  void endParameterName(bool last,bool emptyList,bool closeBracket);
318  void startParameterList(bool);
319  void endParameterList();
320  virtual void exceptionEntry(const char*,bool);
321 
322  void startConstraintList(const char *);
323  void startConstraintParam();
324  void endConstraintParam();
325  void startConstraintType();
326  void endConstraintType();
327  void startConstraintDocs();
328  void endConstraintDocs();
329  void endConstraintList();
330 
331  void startMemberDocSimple();
332  void endMemberDocSimple();
333  void startInlineMemberType();
334  void endInlineMemberType();
335  void startInlineMemberName();
336  void endInlineMemberName();
337  void startInlineMemberDoc();
338  void endInlineMemberDoc();
339 
340  void startLabels();
341  void writeLabel(const char *l,bool isLast);
342  void endLabels();
343 
344 
345  //static void generateSectionImages();
346 
347  private:
348  static void writePageFooter(FTextStream &t,const QCString &,const QCString &,const QCString &);
352  void docify(const char *text,bool inHtmlComment);
353 
354  HtmlGenerator &operator=(const HtmlGenerator &g);
355  HtmlGenerator(const HtmlGenerator &g);
356 
360 };
361 
362 #endif
static QCString name
Definition: declinfo.cpp:673
void codify(const char *text)
Definition: htmlgen.cpp:423
void startEmphasis()
Definition: htmlgen.h:216
void startQuickIndices()
Definition: htmlgen.h:263
void endDescForItem()
Definition: htmlgen.h:225
void writeCodeLink(const char *ref, const char *file, const char *anchor, const char *name, const char *tooltip)
Definition: htmlgen.cpp:524
void endFile(OutputList &ol, bool skipNavIndex, bool skipEndContents, const QCString &navPath)
Definition: index.cpp:263
void startFontClass(const char *s)
Definition: htmlgen.h:114
void startDescItem()
Definition: htmlgen.h:222
void writeLineNumber(const char *ref, const char *file, const char *anchor, int lineNumber)
Definition: htmlgen.h:104
void writeEndAnnoItem(const char *)
Definition: htmlgen.h:237
void startDescTable(const char *title)
Definition: htmlgen.h:274
void endItemList()
Definition: htmlgen.h:155
static constexpr double g
Definition: Units.h:144
void startFile(OutputList &ol, const char *name, const char *manName, const char *title, HighlightedItem hli, bool additionalIndices, const char *altSidebarName)
Definition: index.cpp:244
void endEmphasis()
Definition: htmlgen.h:217
void endTextBlock(bool)
Definition: htmlgen.h:306
void endTitle()
Definition: htmlgen.h:141
void startDescTableData()
Definition: htmlgen.h:286
void writeLogo(const char *dir)
void startPageRef()
Definition: htmlgen.h:261
void addWord(const char *, bool)
Definition: htmlgen.h:56
void startCodeLine(bool hasLineNumbers)
Definition: htmlgen.h:110
void endCenter()
Definition: htmlgen.h:243
void endTypewriter()
Definition: htmlgen.h:168
void startTypewriter()
Definition: htmlgen.h:167
IndexSections
Definition: index.h:157
const bool FALSE
Definition: qglobal.h:370
void startMemberDeclaration()
Definition: htmlgen.h:205
void startItemList()
Definition: htmlgen.h:154
void startIndexSection(IndexSections)
Definition: htmlgen.h:132
void writeAnchor(const char *, const char *name)
Definition: htmlgen.h:212
static QCString className
Definition: declinfo.cpp:669
#define PREFRAG_END
Definition: htmlgen.h:27
void writeTooltip(const char *id, const DocLinkInfo &docInfo, const char *decl, const char *desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo)
Definition: htmlgen.h:106
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
string dir
void codify(const char *text)
Definition: htmlgen.h:98
init
Definition: train.py:42
QCString lastTitle
Definition: htmlgen.h:349
void endDescTableTitle()
Definition: htmlgen.h:284
void endCodeLine()
Definition: htmlgen.h:112
void startTitle()
Definition: htmlgen.h:140
void setTextStream(FTextStream &t)
Definition: htmlgen.cpp:412
static QCString args
Definition: declinfo.cpp:674
static QStrList * l
Definition: config.cpp:1044
bool isEnabled(OutputType o)
Definition: htmlgen.h:94
static void writeString(QFile &f, const char *s)
void disableIf(OutputType o)
Definition: htmlgen.h:92
bool m_emptySection
Definition: htmlgen.h:358
void disable()
Definition: htmlgen.h:90
#define PREFRAG_START
Definition: htmlgen.h:26
void docify(const char *str)
Definition: htmlgen.cpp:471
void endSubsubsection()
Definition: htmlgen.h:241
void writeSynopsis()
Definition: htmlgen.h:258
void writeCodeAnchor(const char *anchor)
Definition: htmlgen.cpp:665
void startTextBlock(bool)
Definition: htmlgen.h:304
void startItemListItem()
Definition: htmlgen.h:171
void endSubsection()
Definition: htmlgen.h:239
void endDescTable()
Definition: htmlgen.h:279
void enableIf(OutputType o)
Definition: htmlgen.h:91
void endCodeFragment()
Definition: htmlgen.h:215
def key(type, name=None)
Definition: graph.py:13
void writeLineNumber(const char *, const char *, const char *, int)
Definition: htmlgen.cpp:500
QCString m_relPath
Definition: htmlgen.h:67
void startSmall()
Definition: htmlgen.h:244
void writeCodeLink(const char *ref, const char *file, const char *anchor, const char *name, const char *tooltip)
Definition: htmlgen.h:100
void writePageLink(const char *, bool)
Definition: htmlgen.h:134
void _writeCodeLink(const char *className, const char *ref, const char *file, const char *anchor, const char *name, const char *tooltip)
Definition: htmlgen.cpp:533
void startFontClass(const char *s)
Definition: htmlgen.cpp:655
void startAnonTypeScope(int)
Definition: htmlgen.h:188
void endItemListItem()
Definition: htmlgen.h:172
void endDescItem()
Definition: htmlgen.h:223
void endDescTableData()
Definition: htmlgen.h:289
void lastIndexPage()
Definition: htmlgen.h:308
void endIndexSection(IndexSections)
Definition: htmlgen.h:133
void writeRuler()
Definition: htmlgen.h:211
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
void endFontClass()
Definition: htmlgen.cpp:660
void writeLatexSpacing()
Definition: htmlgen.h:234
void endPageRef(const char *, const char *)
Definition: htmlgen.h:262
void startSubsection()
Definition: htmlgen.h:238
void startDescForItem()
Definition: htmlgen.h:224
void endBold()
Definition: htmlgen.h:219
bool m_streamSet
Definition: htmlgen.h:64
void disableIfNot(OutputType o)
Definition: htmlgen.h:93
void startCodeFragment()
Definition: htmlgen.h:214
void startSubsubsection()
Definition: htmlgen.h:240
void startDescription()
Definition: htmlgen.h:220
void writeCodeAnchor(const char *anchor)
Definition: htmlgen.h:118
int m_sectionCount
Definition: htmlgen.h:357
void setCurrentDoc(Definition *, const char *, bool)
Definition: htmlgen.h:55
void endSmall()
Definition: htmlgen.h:245
QCString lastFile
Definition: htmlgen.h:350
HighlightedItem
Definition: index.h:180
void startDescTableTitle()
Definition: htmlgen.h:281
void setRelativePath(const QCString &path)
Definition: htmlgen.cpp:418
void startBold()
Definition: htmlgen.h:218
void enable()
Definition: htmlgen.h:88
void endAnonTypeScope(int)
Definition: htmlgen.h:189
static QCString * s
Definition: config.cpp:1042
union ptb::content::word::word word
const bool TRUE
Definition: qglobal.h:371
void endCodeLine()
Definition: htmlgen.cpp:650
static QCString str
void writeTooltip(const char *id, const DocLinkInfo &docInfo, const char *decl, const char *desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo)
Definition: htmlgen.cpp:559
void startCenter()
Definition: htmlgen.h:242
FTextStream m_t
Definition: htmlgen.h:65
QTextStream & endl(QTextStream &s)
QCString relPath
Definition: htmlgen.h:351
HtmlCodeGenerator m_codeGen
Definition: htmlgen.h:359
void startCodeLine(bool)
Definition: htmlgen.cpp:641
void endDescription()
Definition: htmlgen.h:221
void endFontClass()
Definition: htmlgen.h:116