htmlgen.h 10.1 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2
/******************************************************************************
 *
3
 * 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4
 *
5
 * Copyright (C) 1997-2011 by Dimitri van Heesch.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
6 7 8 9 10 11 12
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
13 14
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
15 16 17 18 19 20
 *
 */

#ifndef HTMLGEN_H
#define HTMLGEN_H

21
#include "qtbc.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
22 23
#include "outputgen.h"

24 25 26
#define PREFRAG_START "<div class=\"fragment\"><pre class=\"fragment\">"
#define PREFRAG_END   "</pre></div>"

Dimitri van Heesch's avatar
Dimitri van Heesch committed
27
class QFile;
28
class FTextStream;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
29 30 31 32 33

class HtmlGenerator : public OutputGenerator
{
  public:
    HtmlGenerator();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
34
    virtual ~HtmlGenerator();
35 36
    static void init();
    static void writeStyleSheetFile(QFile &f);
37
    static void writeHeaderFile(QFile &f, const char *cssname);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
38
    static void writeFooterFile(QFile &f);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
39
    static void writeTabData();
40 41 42 43 44
    static void writeSearchFooter(FTextStream &t,const QCString &relPath);
    static void writeSearchData(const char *dir);
    static void writeSearchPage();
    static QCString writeLogoAsString(const char *path);
    static QCString writeSplitBarAsString(const char *name,const char *relpath);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
45
   
46 47
    void enable() 
    { if (genStack->top()) active=*genStack->top(); else active=TRUE; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
48 49 50 51 52 53
    void disable() { active=FALSE; }
    void enableIf(OutputType o)  { if (o==Html) active=TRUE;  }
    void disableIf(OutputType o) { if (o==Html) active=FALSE; }
    void disableIfNot(OutputType o) { if (o!=Html) active=FALSE; }
    bool isEnabled(OutputType o) { return (o==Html && active); } 
    OutputGenerator *get(OutputType o) { return (o==Html) ? this : 0; }
54

55
    void printDoc(DocNode *,const char *);
56

57 58
    void startFile(const char *name,const char *manName,const char *title);
    void writeFooter();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
59 60 61 62 63
    void endFile();
    void clearBuffer();

    void startIndexSection(IndexSections) {}
    void endIndexSection(IndexSections) {}
64
    void writePageLink(const char *,bool) {}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
65 66 67
    void startProjectNumber();
    void endProjectNumber();
    void writeStyleInfo(int part);
68 69
    void startTitleHead(const char *);
    void endTitleHead(const char *,const char *);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
70 71 72
    void startTitle() { t << "<h1>"; }
    void endTitle() { t << "</h1>"; }
    
73 74
    void startParagraph();
    void endParagraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
75
    void writeString(const char *text);
76 77
    void startIndexListItem();
    void endIndexListItem();
78 79
    void startIndexList();
    void endIndexList();
80 81
    void startIndexKey();
    void endIndexKey();
82 83
    void startIndexValue(bool);
    void endIndexValue(const char *,bool);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
84 85
    void startItemList()  { t << "<ul>"  << endl; }
    void endItemList()    { t << "</ul>" << endl; }
86 87
    void startIndexItem(const char *ref,const char *file);
    void endIndexItem(const char *ref,const char *file);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
88 89 90 91
    void docify(const char *text);
    void codify(const char *text);
    void writeObjectLink(const char *ref,const char *file,
                         const char *anchor,const char *name);
92
    void writeCodeLink(const char *ref,const char *file,
93 94
                       const char *anchor,const char *name,
                       const char *tooltip);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
95 96
    void startTextLink(const char *file,const char *anchor);
    void endTextLink();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
97 98
    void startHtmlLink(const char *url);
    void endHtmlLink();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
99 100 101 102
    void startTypewriter() { t << "<code>"; }
    void endTypewriter()   { t << "</code>"; }
    void startGroupHeader();
    void endGroupHeader();
103 104
    void startItemListItem() { t << "<li>"; }
    void endItemListItem() { t << "</li>\n"; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
105

106 107
    void startMemberSections();
    void endMemberSections();
108 109 110
    void startHeaderSection();
    void endHeaderSection();
    void startMemberHeader(const char *);
111
    void endMemberHeader();
112 113
    void startMemberSubtitle();
    void endMemberSubtitle();
114 115
    void startMemberDocList();
    void endMemberDocList();
116 117
    void startMemberList();
    void endMemberList();
118 119
    void startAnonTypeScope(int) {}
    void endAnonTypeScope(int) {}
120
    void startMemberItem(int);
121
    void endMemberItem();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
122 123
    void startMemberTemplateParams();
    void endMemberTemplateParams();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
124

Dimitri van Heesch's avatar
Dimitri van Heesch committed
125
    void startMemberGroupHeader(bool);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
126 127 128 129 130 131
    void endMemberGroupHeader();
    void startMemberGroupDocs();
    void endMemberGroupDocs();
    void startMemberGroup();
    void endMemberGroup(bool);

Dimitri van Heesch's avatar
Dimitri van Heesch committed
132
    void insertMemberAlign(bool);
133 134
    void startMemberDescription();
    void endMemberDescription();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
135

136
    void writeRuler()    { t << "<hr/>"; }
137
    void writeAnchor(const char *,const char *name) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
138
                         { t << "<a name=\"" << name <<"\"></a>"; }
139 140
    void startCodeFragment() { t << PREFRAG_START; }
    void endCodeFragment()   { t << PREFRAG_END; } 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
141
    void writeLineNumber(const char *,const char *,const char *,int);
142 143
    void startCodeLine() { col=0; }
    void endCodeLine()   { codify("\n"); }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
144 145 146 147
    void startEmphasis() { t << "<em>";  }
    void endEmphasis()   { t << "</em>"; }
    void startBold()     { t << "<b>"; }
    void endBold()       { t << "</b>"; }
148 149
    void startDescription() { t << endl << "<dl>" << endl; }
    void endDescription()   { t << endl << "</dl>\n" << endl; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
150
    void startDescItem()    { t << "<dt>"; }
151 152 153
    void endDescItem()      { t << "</dt>"; }
    void startDescForItem() { t << "<dd>"; }
    void endDescForItem()   { t << "</dd>\n"; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
154
    void lineBreak(const char *style);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
155
    void writeChar(char c);
156
    void startMemberDoc(const char *,const char *,const char *,const char *);
157
    void endMemberDoc(bool); 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
158
    void startDoxyAnchor(const char *fName,const char *manName,
159 160
                         const char *anchor,const char *name,
                         const char *args);
161
    void endDoxyAnchor(const char *fName,const char *anchor);
162 163
    void startCodeAnchor(const char *label) { t << "<a name=\"" << label << "\"></a>"; }
    void endCodeAnchor() { }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
164 165 166 167 168 169 170 171 172 173 174 175
    void writeLatexSpacing() {}
    void writeStartAnnoItem(const char *type,const char *file,
                            const char *path,const char *name);
    void writeEndAnnoItem(const char *) { t << endl; }
    void startSubsection()    { t << "<h2>"; }
    void endSubsection()      { t << "</h2>" << endl; }
    void startSubsubsection() { t << "<h3>"; }
    void endSubsubsection()   { t << "</h3>" << endl; }
    void startCenter()        { t << "<center>" << endl; }
    void endCenter()          { t << "</center>" << endl; }
    void startSmall()         { t << "<small>" << endl; }
    void endSmall()           { t << "</small>" << endl; }
176 177
    //void startDescList(SectionTypes)      { t << "<dl compact><dt><b>" << endl; }
    //void endDescList()        { t << "</dl>"; }
178 179 180 181
    void startSimpleSect(SectionTypes,const char *,const char *,const char *);
    void endSimpleSect();
    void startParamList(ParamListTypes,const char *);
    void endParamList();
182
    //void writeDescItem()      { t << "<dd>" << endl; }
183 184
    void startSection(const char *,const char *,SectionInfo::SectionType);
    void endSection(const char *,SectionInfo::SectionType);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
185
    void addIndexItem(const char *,const char *);
186 187
    void startIndent();
    void endIndent();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
188 189
    void writeSynopsis() {}
    void startClassDiagram();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
190
    void endClassDiagram(const ClassDiagram &,const char *,const char *);
191 192
    void startPageRef() {}
    void endPageRef(const char *,const char *) {}
193 194
    void startQuickIndices();
    void endQuickIndices();
195 196
    void writeSplitBar(const char *name);
    void writeLogo();
197
    void writeQuickLinks(bool compact,HighlightedItem hli);
198 199
    void startContents();
    void endContents();
200
    void writeNonBreakableSpace(int);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
201
    
202
    void startDescTable()
203
    { t << "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl; }
204 205 206
    void endDescTable()
    { t << "</table>" << endl; }
    void startDescTableTitle()
207
    { t << "<tr><td valign=\"top\"><em>"; }
208
    void endDescTableTitle()
209
    { t << "</em>&nbsp;</td>"; }
210 211 212 213
    void startDescTableData()
    { t << "<td>" << endl; }
    void endDescTableData()
    { t << "</td></tr>" << endl; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
214
    
Dimitri van Heesch's avatar
Dimitri van Heesch committed
215
    void startDotGraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
216
    void endDotGraph(const DotClassGraph &g);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
217
    void startInclDepGraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
218
    void endInclDepGraph(const DotInclDepGraph &g);
219
    void startGroupCollaboration();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
220
    void endGroupCollaboration(const DotGroupCollaboration &g);
221
    void startCallGraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
222
    void endCallGraph(const DotCallGraph &g);
223
    void startDirDepGraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
224 225
    void endDirDepGraph(const DotDirDeps &g);
    void writeGraphicalHierarchy(const DotGfxHierarchyTable &g);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
226

Dimitri van Heesch's avatar
Dimitri van Heesch committed
227 228 229 230
    void startTextBlock(bool) 
    { t << "<div class=\"textblock\">"; }
    void endTextBlock(bool) 
    { t << "</div>"; }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
231 232
    void lastIndexPage() {}

233 234
    void startMemberDocPrefixItem();
    void endMemberDocPrefixItem();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
235
    void startMemberDocName(bool);
236
    void endMemberDocName();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
237
    void startParameterType(bool first,const char *key);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
238
    void endParameterType();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
239
    void startParameterName(bool);
240
    void endParameterName(bool last,bool emptyList,bool closeBracket);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
241
    void startParameterList(bool);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
242
    void endParameterList();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
243

244 245 246 247 248 249 250 251 252
    void startConstraintList(const char *);
    void startConstraintParam();
    void endConstraintParam();
    void startConstraintType();
    void endConstraintType();
    void startConstraintDocs();
    void endConstraintDocs();
    void endConstraintList();

253 254
    void startFontClass(const char *s) { t << "<span class=\"" << s << "\">"; }
    void endFontClass() { t << "</span>"; }
255

256

257 258
    void writeCodeAnchor(const char *anchor) 
    { t << "<a name=\"" << anchor << "\"></a>"; }
259 260
    void linkableSymbol(int,const char *,Definition *,Definition *) {}

261
    //static void generateSectionImages();
262

Dimitri van Heesch's avatar
Dimitri van Heesch committed
263
  private:
264
    static void writePageFooter(FTextStream &t,const QCString &,const QCString &);
265
    QCString lastTitle;
266
    QCString lastFile;
267
    QCString relPath;
268
    void docify(const char *text,bool inHtmlComment);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
269 270 271

    HtmlGenerator &operator=(const HtmlGenerator &g);
    HtmlGenerator(const HtmlGenerator &g);
272

273
    int col;
274
    int m_sectionCount;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
275 276 277
};

#endif