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,
|
---|
|
---|