1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the tools applications of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department 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 |
|
---|
52 | #include "codemarker.h"
|
---|
53 | #include "config.h"
|
---|
54 | #include "dcfsection.h"
|
---|
55 | #include "pagegenerator.h"
|
---|
56 |
|
---|
57 | QT_BEGIN_NAMESPACE
|
---|
58 |
|
---|
59 | #if 0
|
---|
60 | struct NavigationBar
|
---|
61 | {
|
---|
62 | SectionIterator prev;
|
---|
63 | SectionIterator current;
|
---|
64 | SectionIterator next;
|
---|
65 | };
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | class HelpProjectWriter;
|
---|
69 |
|
---|
70 | class HtmlGenerator : public PageGenerator
|
---|
71 | {
|
---|
72 | public:
|
---|
73 | HtmlGenerator();
|
---|
74 | ~HtmlGenerator();
|
---|
75 |
|
---|
76 | virtual void initializeGenerator(const Config& config);
|
---|
77 | virtual void terminateGenerator();
|
---|
78 | virtual QString format();
|
---|
79 | virtual void generateTree(const Tree *tree, CodeMarker *marker);
|
---|
80 |
|
---|
81 | static QString protect(const QString& string);
|
---|
82 | static QString cleanRef(const QString& ref);
|
---|
83 |
|
---|
84 | protected:
|
---|
85 | virtual void startText(const Node *relative, CodeMarker *marker);
|
---|
86 | virtual int generateAtom(const Atom *atom,
|
---|
87 | const Node *relative,
|
---|
88 | CodeMarker *marker);
|
---|
89 | virtual void generateClassLikeNode(const InnerNode *inner, CodeMarker *marker);
|
---|
90 | virtual void generateFakeNode(const FakeNode *fake, CodeMarker *marker);
|
---|
91 | virtual QString fileExtension(const Node *node);
|
---|
92 | virtual QString refForNode(const Node *node);
|
---|
93 | virtual QString linkForNode(const Node *node, const Node *relative);
|
---|
94 | virtual QString refForAtom(Atom *atom, const Node *node);
|
---|
95 |
|
---|
96 | private:
|
---|
97 | enum SubTitleSize { SmallSubTitle, LargeSubTitle };
|
---|
98 |
|
---|
99 | const QPair<QString,QString> anchorForNode(const Node *node);
|
---|
100 | const Node *findNodeForTarget(const QString &target,
|
---|
101 | const Node *relative,
|
---|
102 | CodeMarker *marker,
|
---|
103 | const Atom *atom = 0);
|
---|
104 | void generateHeader(const QString& title, const Node *node = 0,
|
---|
105 | CodeMarker *marker = 0, bool mainPage = true);
|
---|
106 | void generateTitle(const QString& title,
|
---|
107 | const Text &subTitle,
|
---|
108 | SubTitleSize subTitleSize,
|
---|
109 | const Node *relative,
|
---|
110 | CodeMarker *marker);
|
---|
111 | void generateFooter(const Node *node = 0);
|
---|
112 | void generateBrief(const Node *node,
|
---|
113 | CodeMarker *marker,
|
---|
114 | const Node *relative = 0);
|
---|
115 | void generateIncludes(const InnerNode *inner, CodeMarker *marker);
|
---|
116 | #if 0
|
---|
117 | void generateNavigationBar(const NavigationBar& bar,
|
---|
118 | const Node *node,
|
---|
119 | CodeMarker *marker);
|
---|
120 | #endif
|
---|
121 | void generateTableOfContents(const Node *node,
|
---|
122 | CodeMarker *marker,
|
---|
123 | Doc::SectioningUnit sectioningUnit,
|
---|
124 | int numColumns,
|
---|
125 | const Node *relative = 0);
|
---|
126 | QString generateListOfAllMemberFile(const InnerNode *inner, CodeMarker *marker);
|
---|
127 | QString generateLowStatusMemberFile(const InnerNode *inner,
|
---|
128 | CodeMarker *marker,
|
---|
129 | CodeMarker::Status status);
|
---|
130 | void generateClassHierarchy(const Node *relative,
|
---|
131 | CodeMarker *marker,
|
---|
132 | const QMap<QString,const Node *> &classMap);
|
---|
133 | void generateAnnotatedList(const Node *relative,
|
---|
134 | CodeMarker *marker,
|
---|
135 | const QMap<QString, const Node *> &nodeMap);
|
---|
136 | void generateCompactList(const Node *relative,
|
---|
137 | CodeMarker *marker,
|
---|
138 | const QMap<QString, const Node *> &classMap);
|
---|
139 | void generateFunctionIndex(const Node *relative, CodeMarker *marker);
|
---|
140 | void generateLegaleseList(const Node *relative, CodeMarker *marker);
|
---|
141 | void generateOverviewList(const Node *relative, CodeMarker *marker);
|
---|
142 | void generateSynopsis(const Node *node,
|
---|
143 | const Node *relative,
|
---|
144 | CodeMarker *marker,
|
---|
145 | CodeMarker::SynopsisStyle style);
|
---|
146 | void generateSectionList(const Section& section,
|
---|
147 | const Node *relative,
|
---|
148 | CodeMarker *marker,
|
---|
149 | CodeMarker::SynopsisStyle style);
|
---|
150 | void generateSectionInheritedList(const Section& section,
|
---|
151 | const Node *relative,
|
---|
152 | CodeMarker *marker);
|
---|
153 | void generateFullName(const Node *apparentNode,
|
---|
154 | const Node *relative,
|
---|
155 | CodeMarker *marker,
|
---|
156 | const Node *actualNode = 0);
|
---|
157 | void generateDetailedMember(const Node *node, const InnerNode *relative, CodeMarker *marker);
|
---|
158 | void generateLink(const Atom *atom, const Node *relative, CodeMarker *marker);
|
---|
159 | void generateStatus(const Node *node, CodeMarker *marker);
|
---|
160 |
|
---|
161 | QString registerRef(const QString& ref);
|
---|
162 | QString highlightedCode(const QString& markedCode, CodeMarker *marker, const Node *relative);
|
---|
163 | QString fileBase(const Node *node);
|
---|
164 | #if 0
|
---|
165 | QString fileBase(const Node *node, const SectionIterator& section);
|
---|
166 | #endif
|
---|
167 | QString fileName(const Node *node);
|
---|
168 | void findAllClasses(const InnerNode *node);
|
---|
169 | void findAllFunctions(const InnerNode *node);
|
---|
170 | void findAllLegaleseTexts(const InnerNode *node);
|
---|
171 | void findAllNamespaces(const InnerNode *node);
|
---|
172 | #ifdef ZZZ_QDOC_QML
|
---|
173 | void findAllQmlClasses(const InnerNode *node);
|
---|
174 | #endif
|
---|
175 | static int hOffset(const Node *node);
|
---|
176 | static bool isThreeColumnEnumValueTable(const Atom *atom);
|
---|
177 | virtual QString getLink(const Atom *atom,
|
---|
178 | const Node *relative,
|
---|
179 | CodeMarker *marker,
|
---|
180 | const Node *node = 0);
|
---|
181 | virtual void generateDcf(const QString &fileBase,
|
---|
182 | const QString &startPage,
|
---|
183 | const QString &title, DcfSection &dcfRoot);
|
---|
184 | virtual void generateIndex(const QString &fileBase,
|
---|
185 | const QString &url,
|
---|
186 | const QString &title);
|
---|
187 | void generateMacRef(const Node *node, CodeMarker *marker);
|
---|
188 | void beginLink(const QString &link,
|
---|
189 | const Node *node,
|
---|
190 | const Node *relative,
|
---|
191 | CodeMarker *marker);
|
---|
192 | void endLink();
|
---|
193 |
|
---|
194 | #if 0
|
---|
195 | NavigationBar currentNavigationBar;
|
---|
196 | #endif
|
---|
197 | QMap<QString, QString> refMap;
|
---|
198 | int codeIndent;
|
---|
199 | DcfSection dcfClassesRoot;
|
---|
200 | DcfSection dcfOverviewsRoot;
|
---|
201 | DcfSection dcfExamplesRoot;
|
---|
202 | DcfSection dcfDesignerRoot;
|
---|
203 | DcfSection dcfLinguistRoot;
|
---|
204 | DcfSection dcfAssistantRoot;
|
---|
205 | DcfSection dcfQmakeRoot;
|
---|
206 | HelpProjectWriter *helpProjectWriter;
|
---|
207 | bool inLink;
|
---|
208 | bool inContents;
|
---|
209 | bool inSectionHeading;
|
---|
210 | bool inTableHeader;
|
---|
211 | int numTableRows;
|
---|
212 | bool threeColumnEnumValueTable;
|
---|
213 | QString link;
|
---|
214 | QStringList sectionNumber;
|
---|
215 | QRegExp funcLeftParen;
|
---|
216 | QString style;
|
---|
217 | QString postHeader;
|
---|
218 | QString footer;
|
---|
219 | QString address;
|
---|
220 | bool pleaseGenerateMacRef;
|
---|
221 | QString project;
|
---|
222 | QString projectDescription;
|
---|
223 | QString projectUrl;
|
---|
224 | QString navigationLinks;
|
---|
225 | QStringList stylesheets;
|
---|
226 | QStringList customHeadElements;
|
---|
227 | const Tree *tre;
|
---|
228 | bool slow;
|
---|
229 | QMap<QString, QMap<QString, const Node *> > moduleClassMap;
|
---|
230 | QMap<QString, QMap<QString, const Node *> > moduleNamespaceMap;
|
---|
231 | QMap<QString, const Node *> nonCompatClasses;
|
---|
232 | QMap<QString, const Node *> mainClasses;
|
---|
233 | QMap<QString, const Node *> compatClasses;
|
---|
234 | QMap<QString, const Node *> namespaceIndex;
|
---|
235 | QMap<QString, const Node *> serviceClasses;
|
---|
236 | #ifdef QDOC_QML
|
---|
237 | QMap<QString, const Node *> qmlClasses;
|
---|
238 | #endif
|
---|
239 | QMap<QString, QMap<QString, const Node *> > funcIndex;
|
---|
240 | QMap<Text, const Node *> legaleseTexts;
|
---|
241 | };
|
---|
242 |
|
---|
243 | #define HTMLGENERATOR_ADDRESS "address"
|
---|
244 | #define HTMLGENERATOR_FOOTER "footer"
|
---|
245 | #define HTMLGENERATOR_GENERATEMACREFS "generatemacrefs" // ### document me
|
---|
246 | #define HTMLGENERATOR_POSTHEADER "postheader"
|
---|
247 | #define HTMLGENERATOR_STYLE "style"
|
---|
248 | #define HTMLGENERATOR_STYLESHEETS "stylesheets"
|
---|
249 | #define HTMLGENERATOR_CUSTOMHEADELEMENTS "customheadelements"
|
---|
250 |
|
---|
251 | QT_END_NAMESPACE
|
---|
252 |
|
---|
253 | #endif
|
---|