Imported Upstream version 1.8.15
[platform/upstream/doxygen.git] / src / htmlgen.h
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
31 class HtmlCodeGenerator : public CodeOutputInterface
32 {
33   public:
34     HtmlCodeGenerator(FTextStream &t,const QCString &relPath);
35     HtmlCodeGenerator();
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);
64     bool m_streamSet;
65     FTextStream m_t;
66     int m_col;
67     QCString m_relPath;
68 };
69
70 /** Generator for HTML output */
71 class HtmlGenerator : public OutputGenerator
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
132     void startIndexSection(IndexSections) {}
133     void endIndexSection(IndexSections) {}
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(const char *classDef);
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 *, int);
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 insertMemberAlignLeft(int,bool);
204     void startMemberDescription(const char *anchor,const char *inheritId, bool typ);
205     void endMemberDescription();
206     void startMemberDeclaration() {}
207     void endMemberDeclaration(const char *anchor,const char *inheritId);
208     void writeInheritedSectionTitle(const char *id,   const char *ref,
209                                     const char *file, const char *anchor,
210                                     const char *title,const char *name);
211
212     void writeRuler()    { t << "<hr/>"; }
213     void writeAnchor(const char *,const char *name) 
214                          { t << "<a name=\"" << name <<"\" id=\"" << name << "\"></a>"; }
215     void startCodeFragment() { t << PREFRAG_START; }
216     void endCodeFragment()   { t << PREFRAG_END; } 
217     void startEmphasis() { t << "<em>";  }
218     void endEmphasis()   { t << "</em>"; }
219     void startBold()     { t << "<b>"; }
220     void endBold()       { t << "</b>"; }
221     void startDescription() { t << endl << "<dl>" << endl; }
222     void endDescription()   { t << endl << "</dl>\n" << endl; }
223     void startDescItem()    { t << "<dt>"; }
224     void endDescItem()      { t << "</dt>"; }
225     void startDescForItem() { t << "<dd>"; }
226     void endDescForItem()   { t << "</dd>\n"; }
227     void lineBreak(const char *style);
228     void writeChar(char c);
229     void startMemberDoc(const char *clName, const char *memName, 
230                         const char *anchor, const char *title, 
231                         int memCount, int memTotal, bool showInline);
232     void endMemberDoc(bool); 
233     void startDoxyAnchor(const char *fName,const char *manName,
234                          const char *anchor,const char *name,
235                          const char *args);
236     void endDoxyAnchor(const char *fName,const char *anchor);
237     void writeLatexSpacing() {}
238     void writeStartAnnoItem(const char *type,const char *file,
239                             const char *path,const char *name);
240     void writeEndAnnoItem(const char *) { t << endl; }
241     void startSubsection()    { t << "<h2>"; }
242     void endSubsection()      { t << "</h2>" << endl; }
243     void startSubsubsection() { t << "<h3>"; }
244     void endSubsubsection()   { t << "</h3>" << endl; }
245     void startCenter()        { t << "<center>" << endl; }
246     void endCenter()          { t << "</center>" << endl; }
247     void startSmall()         { t << "<small>" << endl; }
248     void endSmall()           { t << "</small>" << endl; }
249     void startExamples();
250     void endExamples();
251     void startParamList(ParamListTypes,const char *);
252     void endParamList();
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 *) {}
263     void startQuickIndices() {}
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 startPageDoc(const char *pageTitle);
273     void endPageDoc();
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);
289     void startGroupCollaboration();
290     void endGroupCollaboration(const DotGroupCollaboration &g);
291     void startCallGraph();
292     void endCallGraph(const DotCallGraph &g);
293     void startDirDepGraph();
294     void endDirDepGraph(const DotDirDeps &g);
295     void writeGraphicalHierarchy(const DotGfxHierarchyTable &g);
296
297     void startTextBlock(bool) 
298     { t << "<div class=\"textblock\">"; }
299     void endTextBlock(bool) 
300     { t << "</div>"; }
301     void lastIndexPage() {}
302
303     void startMemberDocPrefixItem();
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
347     HtmlGenerator &operator=(const HtmlGenerator &g);
348     HtmlGenerator(const HtmlGenerator &g);
349
350     int m_sectionCount;
351     bool m_emptySection;
352     HtmlCodeGenerator m_codeGen;
353 };
354
355 #endif