1 /******************************************************************************
5 * Copyright (C) 1997-2015 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.
21 #include "outputgen.h"
22 #include "ftextstream.h"
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 -->"
31 class HtmlCodeGenerator : public CodeOutputInterface
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,
42 void writeTooltip(const char *id,
43 const DocLinkInfo &docInfo,
46 const SourceLinkInfo &defInfo,
47 const SourceLinkInfo &declInfo
49 void writeLineNumber(const char *,const char *,const char *,int);
50 void startCodeLine(bool);
52 void startFontClass(const char *s);
54 void writeCodeAnchor(const char *anchor);
55 void setCurrentDoc(Definition *,const char *,bool) {}
56 void addWord(const char *,bool) {}
59 void _writeCodeLink(const char *className,
60 const char *ref,const char *file,
61 const char *anchor,const char *name,
63 void docify(const char *str);
70 /** Generator for HTML output */
71 class HtmlGenerator : public OutputGenerator
75 virtual ~HtmlGenerator();
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);
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; }
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,
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
109 { m_codeGen.writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); }
110 void startCodeLine(bool hasLineNumbers)
111 { m_codeGen.startCodeLine(hasLineNumbers); }
113 { m_codeGen.endCodeLine(); }
114 void startFontClass(const char *s)
115 { m_codeGen.startFontClass(s); }
117 { m_codeGen.endFontClass(); }
118 void writeCodeAnchor(const char *anchor)
119 { m_codeGen.writeCodeAnchor(anchor); }
120 // ---------------------------
122 void setCurrentDoc(Definition *context,const char *anchor,bool isSourceFile);
123 void addWord(const char *word,bool hiPriority);
124 void writeDoc(DocNode *,Definition *,MemberDef *);
126 void startFile(const char *name,const char *manName,const char *title);
127 void writeFooter(const char *navPath);
130 void writeSearchInfo();
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>"; }
143 void startParagraph(const char *classDef);
145 void writeString(const char *text);
146 void startIndexListItem();
147 void endIndexListItem();
148 void startIndexList();
150 void startIndexKey();
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);
160 void writeObjectLink(const char *ref,const char *file,
161 const char *anchor,const char *name);
163 void startTextLink(const char *file,const char *anchor);
165 void startHtmlLink(const char *url);
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"; }
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);
195 void startMemberGroupHeader(bool);
196 void endMemberGroupHeader();
197 void startMemberGroupDocs();
198 void endMemberGroupDocs();
199 void startMemberGroup();
200 void endMemberGroup(bool);
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);
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,
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();
251 void startParamList(ParamListTypes,const char *);
253 void startSection(const char *,const char *,SectionInfo::SectionType);
254 void endSection(const char *,SectionInfo::SectionType);
255 void addIndexItem(const char *,const char *);
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);
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();
272 void startPageDoc(const char *pageTitle);
274 void writeNonBreakableSpace(int);
276 void startDescTable(const char *title);
278 void startDescTableRow();
279 void endDescTableRow();
280 void startDescTableTitle();
281 void endDescTableTitle();
282 void startDescTableData();
283 void endDescTableData();
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);
297 void startTextBlock(bool)
298 { t << "<div class=\"textblock\">"; }
299 void endTextBlock(bool)
301 void lastIndexPage() {}
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);
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();
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();
334 void writeLabel(const char *l,bool isLast);
338 //static void generateSectionImages();
341 static void writePageFooter(FTextStream &t,const QCString &,const QCString &,const QCString &);
345 void docify(const char *text,bool inHtmlComment);
347 HtmlGenerator &operator=(const HtmlGenerator &g);
348 HtmlGenerator(const HtmlGenerator &g);
352 HtmlCodeGenerator m_codeGen;