1 /******************************************************************************
3 * $Id: htmlgen.h,v 1.51 2001/03/19 19:27:40 root Exp $
5 * Copyright (C) 1997-2012 by Dimitri van Heesch.
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.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
22 #include "outputgen.h"
23 #include "ftextstream.h"
25 //#define PREFRAG_START "<div class=\"fragment\"><pre class=\"fragment\">"
26 //#define PREFRAG_END "</pre></div>"
27 #define PREFRAG_START "<div class=\"fragment\">"
28 #define PREFRAG_END "</div><!-- fragment -->"
32 class HtmlCodeGenerator : public CodeOutputInterface
35 HtmlCodeGenerator(FTextStream &t,const QCString &relPath);
37 void setTextStream(FTextStream &t);
38 void setRelativePath(const QCString &path);
39 void codify(const char *text);
40 void writeCodeLink(const char *ref,const char *file,
41 const char *anchor,const char *name,
43 void writeLineNumber(const char *,const char *,const char *,int);
44 void startCodeLine(bool);
46 void startCodeAnchor(const char *label);
48 void startFontClass(const char *s);
50 void writeCodeAnchor(const char *anchor);
51 void linkableSymbol(int,const char *,Definition *,Definition *);
54 void docify(const char *str);
61 /** Generator for HTML output */
62 class HtmlGenerator : public OutputGenerator
66 virtual ~HtmlGenerator();
68 static void writeStyleSheetFile(QFile &f);
69 static void writeHeaderFile(QFile &f, const char *cssname);
70 static void writeFooterFile(QFile &f);
71 static void writeTabData();
72 static void writeSearchInfo(FTextStream &t,const QCString &relPath);
73 static void writeSearchData(const char *dir);
74 static void writeSearchPage();
75 static QCString writeLogoAsString(const char *path);
76 static QCString writeSplitBarAsString(const char *name,const char *relpath);
79 { if (genStack->top()) active=*genStack->top(); else active=TRUE; }
80 void disable() { active=FALSE; }
81 void enableIf(OutputType o) { if (o==Html) enable(); }
82 void disableIf(OutputType o) { if (o==Html) disable(); }
83 void disableIfNot(OutputType o) { if (o!=Html) disable(); }
84 bool isEnabled(OutputType o) { return (o==Html && active); }
85 OutputGenerator *get(OutputType o) { return (o==Html) ? this : 0; }
87 // ---- CodeOutputInterface
88 void codify(const char *text)
89 { m_codeGen.codify(text); }
90 void writeCodeLink(const char *ref,const char *file,
91 const char *anchor,const char *name,
93 { m_codeGen.writeCodeLink(ref,file,anchor,name,tooltip); }
94 void writeLineNumber(const char *ref,const char *file,const char *anchor,int lineNumber)
95 { m_codeGen.writeLineNumber(ref,file,anchor,lineNumber); }
96 void startCodeLine(bool hasLineNumbers)
97 { m_codeGen.startCodeLine(hasLineNumbers); }
99 { m_codeGen.endCodeLine(); }
100 void startCodeAnchor(const char *label)
101 { m_codeGen.startCodeAnchor(label); }
103 { m_codeGen.endCodeAnchor(); }
104 void startFontClass(const char *s)
105 { m_codeGen.startFontClass(s); }
107 { m_codeGen.endFontClass(); }
108 void writeCodeAnchor(const char *anchor)
109 { m_codeGen.writeCodeAnchor(anchor); }
110 void linkableSymbol(int line,const char *symName,
111 Definition *symDef,Definition *context)
112 { m_codeGen.linkableSymbol(line,symName,symDef,context); }
113 // ---------------------------
115 void writeDoc(DocNode *,Definition *,MemberDef *);
117 void startFile(const char *name,const char *manName,const char *title);
118 void writeFooter(const char *navPath);
121 void writeSearchInfo();
123 void startIndexSection(IndexSections) {}
124 void endIndexSection(IndexSections) {}
125 void writePageLink(const char *,bool) {}
126 void startProjectNumber();
127 void endProjectNumber();
128 void writeStyleInfo(int part);
129 void startTitleHead(const char *);
130 void endTitleHead(const char *,const char *);
131 void startTitle() { t << "<div class=\"title\">"; }
132 void endTitle() { t << "</div>"; }
134 void startParagraph();
136 void writeString(const char *text);
137 void startIndexListItem();
138 void endIndexListItem();
139 void startIndexList();
141 void startIndexKey();
143 void startIndexValue(bool);
144 void endIndexValue(const char *,bool);
145 void startItemList() { t << "<ul>" << endl; }
146 void endItemList() { t << "</ul>" << endl; }
147 void startIndexItem(const char *ref,const char *file);
148 void endIndexItem(const char *ref,const char *file);
149 void docify(const char *text);
151 void writeObjectLink(const char *ref,const char *file,
152 const char *anchor,const char *name);
154 void startTextLink(const char *file,const char *anchor);
156 void startHtmlLink(const char *url);
158 void startTypewriter() { t << "<code>"; }
159 void endTypewriter() { t << "</code>"; }
160 void startGroupHeader(int);
161 void endGroupHeader(int);
162 void startItemListItem() { t << "<li>"; }
163 void endItemListItem() { t << "</li>\n"; }
165 void startMemberSections();
166 void endMemberSections();
167 void startHeaderSection();
168 void endHeaderSection();
169 void startMemberHeader(const char *);
170 void endMemberHeader();
171 void startMemberSubtitle();
172 void endMemberSubtitle();
173 void startMemberDocList();
174 void endMemberDocList();
175 void startMemberList();
176 void endMemberList();
177 void startInlineHeader();
178 void endInlineHeader();
179 void startAnonTypeScope(int) {}
180 void endAnonTypeScope(int) {}
181 void startMemberItem(const char *anchor,int,const char *inheritId);
182 void endMemberItem();
183 void startMemberTemplateParams();
184 void endMemberTemplateParams(const char *anchor,const char *inheritId);
186 void startMemberGroupHeader(bool);
187 void endMemberGroupHeader();
188 void startMemberGroupDocs();
189 void endMemberGroupDocs();
190 void startMemberGroup();
191 void endMemberGroup(bool);
193 void insertMemberAlign(bool);
194 void startMemberDescription(const char *anchor,const char *inheritId);
195 void endMemberDescription();
196 void startMemberDeclaration() {}
197 void endMemberDeclaration(const char *anchor,const char *inheritId);
198 void writeInheritedSectionTitle(const char *id, const char *ref,
199 const char *file, const char *anchor,
200 const char *title,const char *name);
202 void writeRuler() { t << "<hr/>"; }
203 void writeAnchor(const char *,const char *name)
204 { t << "<a name=\"" << name <<"\" id=\"" << name << "\"></a>"; }
205 void startCodeFragment() { t << PREFRAG_START; }
206 void endCodeFragment() { t << PREFRAG_END; }
207 void startEmphasis() { t << "<em>"; }
208 void endEmphasis() { t << "</em>"; }
209 void startBold() { t << "<b>"; }
210 void endBold() { t << "</b>"; }
211 void startDescription() { t << endl << "<dl>" << endl; }
212 void endDescription() { t << endl << "</dl>\n" << endl; }
213 void startDescItem() { t << "<dt>"; }
214 void endDescItem() { t << "</dt>"; }
215 void startDescForItem() { t << "<dd>"; }
216 void endDescForItem() { t << "</dd>\n"; }
217 void lineBreak(const char *style);
218 void writeChar(char c);
219 void startMemberDoc(const char *,const char *,const char *,const char *,bool);
220 void endMemberDoc(bool);
221 void startDoxyAnchor(const char *fName,const char *manName,
222 const char *anchor,const char *name,
224 void endDoxyAnchor(const char *fName,const char *anchor);
225 void writeLatexSpacing() {}
226 void writeStartAnnoItem(const char *type,const char *file,
227 const char *path,const char *name);
228 void writeEndAnnoItem(const char *) { t << endl; }
229 void startSubsection() { t << "<h2>"; }
230 void endSubsection() { t << "</h2>" << endl; }
231 void startSubsubsection() { t << "<h3>"; }
232 void endSubsubsection() { t << "</h3>" << endl; }
233 void startCenter() { t << "<center>" << endl; }
234 void endCenter() { t << "</center>" << endl; }
235 void startSmall() { t << "<small>" << endl; }
236 void endSmall() { t << "</small>" << endl; }
237 //void startDescList(SectionTypes) { t << "<dl compact><dt><b>" << endl; }
238 //void endDescList() { t << "</dl>"; }
239 void startSimpleSect(SectionTypes,const char *,const char *,const char *);
240 void endSimpleSect();
241 void startParamList(ParamListTypes,const char *);
243 //void writeDescItem() { t << "<dd>" << endl; }
244 void startSection(const char *,const char *,SectionInfo::SectionType);
245 void endSection(const char *,SectionInfo::SectionType);
246 void addIndexItem(const char *,const char *);
249 void writeSynopsis() {}
250 void startClassDiagram();
251 void endClassDiagram(const ClassDiagram &,const char *,const char *);
252 void startPageRef() {}
253 void endPageRef(const char *,const char *) {}
254 void startQuickIndices() {}
255 void endQuickIndices();
256 void writeSplitBar(const char *name);
257 void writeNavigationPath(const char *s);
259 void writeQuickLinks(bool compact,HighlightedItem hli,const char *file);
260 void writeSummaryLink(const char *file,const char *anchor,const char *title,bool first);
261 void startContents();
263 void writeNonBreakableSpace(int);
265 void startDescTable()
266 { t << "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl; }
268 { t << "</table>" << endl; }
269 void startDescTableTitle()
270 { t << "<tr><td valign=\"top\"><em>"; }
271 void endDescTableTitle()
272 { t << "</em> </td>"; }
273 void startDescTableData()
274 { t << "<td>" << endl; }
275 void endDescTableData()
276 { t << "</td></tr>" << endl; }
278 void startDotGraph();
279 void endDotGraph(const DotClassGraph &g);
280 void startInclDepGraph();
281 void endInclDepGraph(const DotInclDepGraph &g);
282 void startGroupCollaboration();
283 void endGroupCollaboration(const DotGroupCollaboration &g);
284 void startCallGraph();
285 void endCallGraph(const DotCallGraph &g);
286 void startDirDepGraph();
287 void endDirDepGraph(const DotDirDeps &g);
288 void writeGraphicalHierarchy(const DotGfxHierarchyTable &g);
290 void startTextBlock(bool)
291 { t << "<div class=\"textblock\">"; }
292 void endTextBlock(bool)
294 void lastIndexPage() {}
296 void startMemberDocPrefixItem();
297 void endMemberDocPrefixItem();
298 void startMemberDocName(bool);
299 void endMemberDocName();
300 void startParameterType(bool first,const char *key);
301 void endParameterType();
302 void startParameterName(bool);
303 void endParameterName(bool last,bool emptyList,bool closeBracket);
304 void startParameterList(bool);
305 void endParameterList();
307 void startConstraintList(const char *);
308 void startConstraintParam();
309 void endConstraintParam();
310 void startConstraintType();
311 void endConstraintType();
312 void startConstraintDocs();
313 void endConstraintDocs();
314 void endConstraintList();
316 void startMemberDocSimple();
317 void endMemberDocSimple();
318 void startInlineMemberType();
319 void endInlineMemberType();
320 void startInlineMemberName();
321 void endInlineMemberName();
322 void startInlineMemberDoc();
323 void endInlineMemberDoc();
326 void writeLabel(const char *l,bool isLast);
330 //static void generateSectionImages();
333 static void writePageFooter(FTextStream &t,const QCString &,const QCString &,const QCString &);
337 void docify(const char *text,bool inHtmlComment);
339 HtmlGenerator &operator=(const HtmlGenerator &g);
340 HtmlGenerator(const HtmlGenerator &g);
344 HtmlCodeGenerator m_codeGen;