My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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;
67  QCString m_relPath;
68 };
69 
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();
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 *clName, const char *memName,
229  const char *anchor, const char *title,
230  int memCount, int memTotal, bool showInline);
231  void endMemberDoc(bool);
232  void startDoxyAnchor(const char *fName,const char *manName,
233  const char *anchor,const char *name,
234  const char *args);
235  void endDoxyAnchor(const char *fName,const char *anchor);
237  void writeStartAnnoItem(const char *type,const char *file,
238  const char *path,const char *name);
239  void writeEndAnnoItem(const char *) { t << endl; }
240  void startSubsection() { t << "<h2>"; }
241  void endSubsection() { t << "</h2>" << endl; }
242  void startSubsubsection() { t << "<h3>"; }
243  void endSubsubsection() { t << "</h3>" << endl; }
244  void startCenter() { t << "<center>" << endl; }
245  void endCenter() { t << "</center>" << endl; }
246  void startSmall() { t << "<small>" << endl; }
247  void endSmall() { t << "</small>" << endl; }
248  //void startDescList(SectionTypes) { t << "<dl compact><dt><b>" << endl; }
249  //void endDescList() { t << "</dl>"; }
250  void startSimpleSect(SectionTypes,const char *,const char *,const char *);
251  void endSimpleSect();
252  void startParamList(ParamListTypes,const char *);
253  void endParamList();
254  //void writeDescItem() { t << "<dd>" << endl; }
255  void startSection(const char *,const char *,SectionInfo::SectionType);
256  void endSection(const char *,SectionInfo::SectionType);
257  void addIndexItem(const char *,const char *);
258  void startIndent();
259  void endIndent();
260  void writeSynopsis() {}
261  void startClassDiagram();
262  void endClassDiagram(const ClassDiagram &,const char *,const char *);
263  void startPageRef() {}
264  void endPageRef(const char *,const char *) {}
266  void endQuickIndices();
267  void writeSplitBar(const char *name);
268  void writeNavigationPath(const char *s);
269  void writeLogo();
270  void writeQuickLinks(bool compact,HighlightedItem hli,const char *file);
271  void writeSummaryLink(const char *file,const char *anchor,const char *title,bool first);
272  void startContents();
273  void endContents();
274  void writeNonBreakableSpace(int);
275 
276  void startDescTable(const char *title);
277  void endDescTable();
278  void startDescTableRow();
279  void endDescTableRow();
280  void startDescTableTitle();
281  void endDescTableTitle();
282  void startDescTableData();
283  void endDescTableData();
284 
285  void startDotGraph();
286  void endDotGraph(const DotClassGraph &g);
287  void startInclDepGraph();
288  void endInclDepGraph(const DotInclDepGraph &g);
291  void startCallGraph();
292  void endCallGraph(const DotCallGraph &g);
293  void startDirDepGraph();
294  void endDirDepGraph(const DotDirDeps &g);
296 
297  void startTextBlock(bool)
298  { t << "<div class=\"textblock\">"; }
299  void endTextBlock(bool)
300  { t << "</div>"; }
301  void lastIndexPage() {}
302 
304  void endMemberDocPrefixItem();
305  void startMemberDocName(bool);
306  void endMemberDocName();
307  void startParameterType(bool first,const char *key);
308  void endParameterType();
309  void startParameterName(bool);
310  void endParameterName(bool last,bool emptyList,bool closeBracket);
311  void startParameterList(bool);
312  void endParameterList();
313  virtual void exceptionEntry(const char*,bool);
314 
315  void startConstraintList(const char *);
316  void startConstraintParam();
317  void endConstraintParam();
318  void startConstraintType();
319  void endConstraintType();
320  void startConstraintDocs();
321  void endConstraintDocs();
322  void endConstraintList();
323 
324  void startMemberDocSimple(bool);
325  void endMemberDocSimple(bool);
326  void startInlineMemberType();
327  void endInlineMemberType();
328  void startInlineMemberName();
329  void endInlineMemberName();
330  void startInlineMemberDoc();
331  void endInlineMemberDoc();
332 
333  void startLabels();
334  void writeLabel(const char *l,bool isLast);
335  void endLabels();
336 
337 
338  //static void generateSectionImages();
339 
340  private:
341  static void writePageFooter(FTextStream &t,const QCString &,const QCString &,const QCString &);
342  QCString lastTitle;
343  QCString lastFile;
344  QCString relPath;
345  void docify(const char *text,bool inHtmlComment);
346 
348  HtmlGenerator(const HtmlGenerator &g);
349 
353 };
354 
355 #endif