1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*
|
---|
43 | htmlgenerator.h
|
---|
44 | */
|
---|
45 |
|
---|
46 | #ifndef HTMLGENERATOR_H
|
---|
47 | #define HTMLGENERATOR_H
|
---|
48 |
|
---|
49 | #include <qmap.h>
|
---|
50 | #include <qregexp.h>
|
---|
51 | #include <QXmlStreamWriter>
|
---|
52 |
|
---|
53 | #include "codemarker.h"
|
---|
54 | #include "config.h"
|
---|
55 | #include "dcfsection.h"
|
---|
56 | #include "pagegenerator.h"
|
---|
57 |
|
---|
58 | QT_BEGIN_NAMESPACE
|
---|
59 |
|
---|
60 | #if 0
|
---|
61 | struct NavigationBar
|
---|
62 | {
|
---|
63 | SectionIterator prev;
|
---|
64 | SectionIterator current;
|
---|
65 | SectionIterator next;
|
---|
66 | };
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | typedef QMultiMap<QString, Node*> NodeMultiMap;
|
---|
70 | typedef QMap<QString, NodeMultiMap> NewSinceMaps;
|
---|
71 | typedef QMap<Node*, NodeMultiMap> ParentMaps;
|
---|
72 | typedef QMap<QString, const Node*> NodeMap;
|
---|
73 | typedef QMap<QString, NodeMap> NewClassMaps;
|
---|
74 |
|
---|
75 | class HelpProjectWriter;
|
---|
76 |
|
---|
77 | class HtmlGenerator : public PageGenerator
|
---|
78 | {
|
---|
79 | public:
|
---|
80 | enum SinceType {
|
---|
81 | Namespace,
|
---|
82 | Class,
|
---|
83 | MemberFunction,
|
---|
84 | NamespaceFunction,
|
---|
85 | GlobalFunction,
|
---|
86 | Macro,
|
---|
87 | Enum,
|
---|
88 | Typedef,
|
---|
89 | Property,
|
---|
90 | Variable,
|
---|
91 | QmlClass,
|
---|
92 | QmlProperty,
|
---|
93 | QmlSignal,
|
---|
94 | QmlMethod,
|
---|
95 | LastSinceType
|
---|
96 | };
|
---|
97 |
|
---|
98 | enum Application {
|
---|
99 | Online,
|
---|
100 | Creator};
|
---|
101 |
|
---|
102 | public:
|
---|
103 | HtmlGenerator();
|
---|
104 | ~HtmlGenerator();
|
---|
105 |
|
---|
106 | virtual void initializeGenerator(const Config& config);
|
---|
107 | virtual void terminateGenerator();
|
---|
108 | virtual QString format();
|
---|
109 | virtual void generateTree(const Tree *tree, CodeMarker *marker);
|
---|
110 |
|
---|
111 | QString protectEnc(const QString &string);
|
---|
112 | static QString protect(const QString &string, const QString &encoding = "ISO-8859-1");
|
---|
113 | static QString cleanRef(const QString& ref);
|
---|
114 | static QString sinceTitle(int i) { return sinceTitles[i]; }
|
---|
115 |
|
---|
116 | protected:
|
---|
117 | virtual void startText(const Node *relative, CodeMarker *marker);
|
---|
118 | virtual int generateAtom(const Atom *atom,
|
---|
119 | const Node *relative,
|
---|
120 | CodeMarker *marker);
|
---|
121 | virtual void generateClassLikeNode(const InnerNode *inner, CodeMarker *marker);
|
---|
122 | virtual void generateFakeNode(const FakeNode *fake, CodeMarker *marker);
|
---|
123 | virtual QString fileExtension(const Node *node) const;
|
---|
124 | virtual QString refForNode(const Node *node);
|
---|
125 | virtual QString linkForNode(const Node *node, const Node *relative);
|
---|
126 | virtual QString refForAtom(Atom *atom, const Node *node);
|
---|
127 |
|
---|
128 | private:
|
---|
129 | enum SubTitleSize { SmallSubTitle, LargeSubTitle };
|
---|
130 | enum ExtractionMarkType {
|
---|
131 | BriefMark,
|
---|
132 | DetailedDescriptionMark,
|
---|
133 | MemberMark,
|
---|
134 | EndMark
|
---|
135 | };
|
---|
136 |
|
---|
137 | const QPair<QString,QString> anchorForNode(const Node *node);
|
---|
138 | const Node *findNodeForTarget(const QString &target,
|
---|
139 | const Node *relative,
|
---|
140 | CodeMarker *marker,
|
---|
141 | const Atom *atom = 0);
|
---|
142 | void generateBreadCrumbs(const QString& title,
|
---|
143 | const Node *node,
|
---|
144 | CodeMarker *marker);
|
---|
145 | void generateHeader(const QString& title,
|
---|
146 | const Node *node = 0,
|
---|
147 | CodeMarker *marker = 0);
|
---|
148 | void generateTitle(const QString& title,
|
---|
149 | const Text &subTitle,
|
---|
150 | SubTitleSize subTitleSize,
|
---|
151 | const Node *relative,
|
---|
152 | CodeMarker *marker);
|
---|
153 | void generateFooter(const Node *node = 0);
|
---|
154 | void generateBrief(const Node *node,
|
---|
155 | CodeMarker *marker,
|
---|
156 | const Node *relative = 0);
|
---|
157 | void generateIncludes(const InnerNode *inner, CodeMarker *marker);
|
---|
158 | #if 0
|
---|
159 | void generateNavigationBar(const NavigationBar& bar,
|
---|
160 | const Node *node,
|
---|
161 | CodeMarker *marker);
|
---|
162 | #endif
|
---|
163 | void generateTableOfContents(const Node *node,
|
---|
164 | CodeMarker *marker,
|
---|
165 | Doc::SectioningUnit sectioningUnit,
|
---|
166 | int numColumns,
|
---|
167 | const Node *relative = 0);
|
---|
168 | void generateTableOfContents(const Node *node,
|
---|
169 | CodeMarker *marker,
|
---|
170 | QList<Section>* sections = 0);
|
---|
171 | QString generateListOfAllMemberFile(const InnerNode *inner,
|
---|
172 | CodeMarker *marker);
|
---|
173 | QString generateAllQmlMembersFile(const QmlClassNode* qml_cn,
|
---|
174 | CodeMarker* marker);
|
---|
175 | QString generateLowStatusMemberFile(const InnerNode *inner,
|
---|
176 | CodeMarker *marker,
|
---|
177 | CodeMarker::Status status);
|
---|
178 | void generateClassHierarchy(const Node *relative,
|
---|
179 | CodeMarker *marker,
|
---|
180 | const NodeMap &classMap);
|
---|
181 | void generateAnnotatedList(const Node *relative,
|
---|
182 | CodeMarker *marker,
|
---|
183 | const NodeMap &nodeMap);
|
---|
184 | void generateCompactList(const Node *relative,
|
---|
185 | CodeMarker *marker,
|
---|
186 | const NodeMap &classMap,
|
---|
187 | bool includeAlphabet,
|
---|
188 | QString commonPrefix = QString());
|
---|
189 | void generateFunctionIndex(const Node *relative, CodeMarker *marker);
|
---|
190 | void generateLegaleseList(const Node *relative, CodeMarker *marker);
|
---|
191 | void generateOverviewList(const Node *relative, CodeMarker *marker);
|
---|
192 | void generateSectionList(const Section& section,
|
---|
193 | const Node *relative,
|
---|
194 | CodeMarker *marker,
|
---|
195 | CodeMarker::SynopsisStyle style);
|
---|
196 | #ifdef QDOC_QML
|
---|
197 | void generateQmlSummary(const Section& section,
|
---|
198 | const Node *relative,
|
---|
199 | CodeMarker *marker);
|
---|
200 | void generateQmlItem(const Node *node,
|
---|
201 | const Node *relative,
|
---|
202 | CodeMarker *marker,
|
---|
203 | bool summary);
|
---|
204 | void generateDetailedQmlMember(const Node *node,
|
---|
205 | const InnerNode *relative,
|
---|
206 | CodeMarker *marker);
|
---|
207 | void generateQmlInherits(const QmlClassNode* cn, CodeMarker* marker);
|
---|
208 | void generateQmlInheritedBy(const QmlClassNode* cn, CodeMarker* marker);
|
---|
209 | void generateQmlInstantiates(const QmlClassNode* qcn, CodeMarker* marker);
|
---|
210 | void generateInstantiatedBy(const ClassNode* cn, CodeMarker* marker);
|
---|
211 | #endif
|
---|
212 |
|
---|
213 | void generateSection(const NodeList& nl,
|
---|
214 | const Node *relative,
|
---|
215 | CodeMarker *marker,
|
---|
216 | CodeMarker::SynopsisStyle style);
|
---|
217 | void generateSynopsis(const Node *node,
|
---|
218 | const Node *relative,
|
---|
219 | CodeMarker *marker,
|
---|
220 | CodeMarker::SynopsisStyle style,
|
---|
221 | bool alignNames = false);
|
---|
222 | void generateSectionInheritedList(const Section& section,
|
---|
223 | const Node *relative,
|
---|
224 | CodeMarker *marker);
|
---|
225 | QString highlightedCode(const QString& markedCode,
|
---|
226 | CodeMarker* marker,
|
---|
227 | const Node* relative,
|
---|
228 | bool alignNames = false,
|
---|
229 | const Node* self = 0);
|
---|
230 |
|
---|
231 | void generateFullName(const Node *apparentNode,
|
---|
232 | const Node *relative,
|
---|
233 | CodeMarker *marker,
|
---|
234 | const Node *actualNode = 0);
|
---|
235 | void generateDetailedMember(const Node *node,
|
---|
236 | const InnerNode *relative,
|
---|
237 | CodeMarker *marker);
|
---|
238 | void generateLink(const Atom *atom,
|
---|
239 | const Node *relative,
|
---|
240 | CodeMarker *marker);
|
---|
241 | void generateStatus(const Node *node, CodeMarker *marker);
|
---|
242 |
|
---|
243 | QString registerRef(const QString& ref);
|
---|
244 | virtual QString fileBase(const Node *node) const;
|
---|
245 | #if 0
|
---|
246 | QString fileBase(const Node *node, const SectionIterator& section);
|
---|
247 | #endif
|
---|
248 | QString fileName(const Node *node);
|
---|
249 | void findAllClasses(const InnerNode *node);
|
---|
250 | void findAllFunctions(const InnerNode *node);
|
---|
251 | void findAllLegaleseTexts(const InnerNode *node);
|
---|
252 | void findAllNamespaces(const InnerNode *node);
|
---|
253 | void findAllSince(const InnerNode *node);
|
---|
254 | static int hOffset(const Node *node);
|
---|
255 | static bool isThreeColumnEnumValueTable(const Atom *atom);
|
---|
256 | virtual QString getLink(const Atom *atom,
|
---|
257 | const Node *relative,
|
---|
258 | CodeMarker *marker,
|
---|
259 | const Node** node);
|
---|
260 | virtual void generateDcf(const QString &fileBase,
|
---|
261 | const QString &startPage,
|
---|
262 | const QString &title, DcfSection &dcfRoot);
|
---|
263 | virtual void generateIndex(const QString &fileBase,
|
---|
264 | const QString &url,
|
---|
265 | const QString &title);
|
---|
266 | #ifdef GENERATE_MAC_REFS
|
---|
267 | void generateMacRef(const Node *node, CodeMarker *marker);
|
---|
268 | #endif
|
---|
269 | void beginLink(const QString &link,
|
---|
270 | const Node *node,
|
---|
271 | const Node *relative,
|
---|
272 | CodeMarker *marker);
|
---|
273 | void endLink();
|
---|
274 | bool generatePageElement(QXmlStreamWriter& writer,
|
---|
275 | const Node* node,
|
---|
276 | CodeMarker* marker) const;
|
---|
277 | void generatePageElements(QXmlStreamWriter& writer,
|
---|
278 | const Node* node,
|
---|
279 | CodeMarker* marker) const;
|
---|
280 | void generatePageIndex(const QString& fileName,
|
---|
281 | CodeMarker* marker) const;
|
---|
282 | void generateExtractionMark(const Node *node, ExtractionMarkType markType);
|
---|
283 |
|
---|
284 | #if 0
|
---|
285 | NavigationBar currentNavigationBar;
|
---|
286 | #endif
|
---|
287 | QMap<QString, QString> refMap;
|
---|
288 | int codeIndent;
|
---|
289 | DcfSection dcfClassesRoot;
|
---|
290 | DcfSection dcfOverviewsRoot;
|
---|
291 | DcfSection dcfExamplesRoot;
|
---|
292 | DcfSection dcfDesignerRoot;
|
---|
293 | DcfSection dcfLinguistRoot;
|
---|
294 | DcfSection dcfAssistantRoot;
|
---|
295 | DcfSection dcfQmakeRoot;
|
---|
296 | HelpProjectWriter *helpProjectWriter;
|
---|
297 | bool inLink;
|
---|
298 | bool inObsoleteLink;
|
---|
299 | bool inContents;
|
---|
300 | bool inSectionHeading;
|
---|
301 | bool inTableHeader;
|
---|
302 | int numTableRows;
|
---|
303 | bool threeColumnEnumValueTable;
|
---|
304 | Application application;
|
---|
305 | QString link;
|
---|
306 | QStringList sectionNumber;
|
---|
307 | QRegExp funcLeftParen;
|
---|
308 | QString style;
|
---|
309 | QString postHeader;
|
---|
310 | QString postPostHeader;
|
---|
311 | QString creatorPostHeader;
|
---|
312 | QString creatorPostPostHeader;
|
---|
313 | QString footer;
|
---|
314 | QString address;
|
---|
315 | bool pleaseGenerateMacRef;
|
---|
316 | QString project;
|
---|
317 | QString projectDescription;
|
---|
318 | QString projectUrl;
|
---|
319 | QString navigationLinks;
|
---|
320 | QStringList stylesheets;
|
---|
321 | QStringList customHeadElements;
|
---|
322 | const Tree *myTree;
|
---|
323 | bool slow;
|
---|
324 | bool obsoleteLinks;
|
---|
325 | QMap<QString, NodeMap > moduleClassMap;
|
---|
326 | QMap<QString, NodeMap > moduleNamespaceMap;
|
---|
327 | NodeMap nonCompatClasses;
|
---|
328 | NodeMap mainClasses;
|
---|
329 | NodeMap compatClasses;
|
---|
330 | NodeMap obsoleteClasses;
|
---|
331 | NodeMap namespaceIndex;
|
---|
332 | NodeMap serviceClasses;
|
---|
333 | NodeMap qmlClasses;
|
---|
334 | QMap<QString, NodeMap > funcIndex;
|
---|
335 | QMap<Text, const Node *> legaleseTexts;
|
---|
336 | NewSinceMaps newSinceMaps;
|
---|
337 | static QString sinceTitles[];
|
---|
338 | NewClassMaps newClassMaps;
|
---|
339 | NewClassMaps newQmlClassMaps;
|
---|
340 | static int id;
|
---|
341 | public:
|
---|
342 | static bool debugging_on;
|
---|
343 | static QString divNavTop;
|
---|
344 | };
|
---|
345 |
|
---|
346 | #define HTMLGENERATOR_ADDRESS "address"
|
---|
347 | #define HTMLGENERATOR_FOOTER "footer"
|
---|
348 | #define HTMLGENERATOR_GENERATEMACREFS "generatemacrefs" // ### document me
|
---|
349 | #define HTMLGENERATOR_POSTHEADER "postheader"
|
---|
350 | #define HTMLGENERATOR_POSTPOSTHEADER "postpostheader"
|
---|
351 | #define HTMLGENERATOR_CREATORPOSTHEADER "postheader"
|
---|
352 | #define HTMLGENERATOR_CREATORPOSTPOSTHEADER "postpostheader"
|
---|
353 | #define HTMLGENERATOR_STYLE "style"
|
---|
354 | #define HTMLGENERATOR_STYLESHEETS "stylesheets"
|
---|
355 | #define HTMLGENERATOR_CUSTOMHEADELEMENTS "customheadelements"
|
---|
356 |
|
---|
357 | QT_END_NAMESPACE
|
---|
358 |
|
---|
359 | #endif
|
---|
360 |
|
---|