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 | codemarker.h
|
---|
44 | */
|
---|
45 |
|
---|
46 | #ifndef CODEMARKER_H
|
---|
47 | #define CODEMARKER_H
|
---|
48 |
|
---|
49 | #include <qpair.h>
|
---|
50 |
|
---|
51 | #include "node.h"
|
---|
52 |
|
---|
53 | QT_BEGIN_NAMESPACE
|
---|
54 |
|
---|
55 | class Config;
|
---|
56 | class Tree;
|
---|
57 |
|
---|
58 | struct Section
|
---|
59 | {
|
---|
60 | QString name;
|
---|
61 | QString divClass;
|
---|
62 | QString singularMember;
|
---|
63 | QString pluralMember;
|
---|
64 | NodeList members;
|
---|
65 | NodeList reimpMembers;
|
---|
66 | QList<QPair<ClassNode *, int> > inherited;
|
---|
67 |
|
---|
68 | Section() { }
|
---|
69 | Section(const QString& name0,
|
---|
70 | const QString& divClass0,
|
---|
71 | const QString& singularMember0,
|
---|
72 | const QString& pluralMember0)
|
---|
73 | : name(name0),
|
---|
74 | divClass(divClass0),
|
---|
75 | singularMember(singularMember0),
|
---|
76 | pluralMember(pluralMember0) { }
|
---|
77 | void appendMember(Node* node) { members.append(node); }
|
---|
78 | void appendReimpMember(Node* node) { reimpMembers.append(node); }
|
---|
79 | };
|
---|
80 |
|
---|
81 | struct FastSection
|
---|
82 | {
|
---|
83 | const InnerNode *innerNode;
|
---|
84 | QString name;
|
---|
85 | QString divClass;
|
---|
86 | QString singularMember;
|
---|
87 | QString pluralMember;
|
---|
88 | QMap<QString, Node *> memberMap;
|
---|
89 | QMap<QString, Node *> reimpMemberMap;
|
---|
90 | QList<QPair<ClassNode *, int> > inherited;
|
---|
91 |
|
---|
92 | FastSection(const InnerNode *innerNode0,
|
---|
93 | const QString& name0,
|
---|
94 | const QString& divClass0,
|
---|
95 | const QString& singularMember0,
|
---|
96 | const QString& pluralMember0)
|
---|
97 | : innerNode(innerNode0),
|
---|
98 | name(name0),
|
---|
99 | divClass(divClass0),
|
---|
100 | singularMember(singularMember0),
|
---|
101 | pluralMember(pluralMember0) { }
|
---|
102 | bool isEmpty() const {
|
---|
103 | return (memberMap.isEmpty() &&
|
---|
104 | inherited.isEmpty() &&
|
---|
105 | reimpMemberMap.isEmpty());
|
---|
106 | }
|
---|
107 |
|
---|
108 | };
|
---|
109 |
|
---|
110 | #if 0
|
---|
111 | const QString& name0 = "",
|
---|
112 | const QString& divClass0 = "",
|
---|
113 | const QString& singularMember0 = "member",
|
---|
114 | const QString& pluralMember0 = "members")
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | class CodeMarker
|
---|
118 | {
|
---|
119 | public:
|
---|
120 | enum SynopsisStyle { Summary, Detailed, SeparateList, Accessors };
|
---|
121 | enum Status { Compat, Obsolete, Okay };
|
---|
122 |
|
---|
123 | CodeMarker();
|
---|
124 | virtual ~CodeMarker();
|
---|
125 |
|
---|
126 | virtual void initializeMarker(const Config& config);
|
---|
127 | virtual void terminateMarker();
|
---|
128 | virtual bool recognizeCode(const QString& code) = 0;
|
---|
129 | virtual bool recognizeExtension(const QString& ext) = 0;
|
---|
130 | virtual bool recognizeLanguage(const QString& lang) = 0;
|
---|
131 | virtual QString plainName(const Node *node) = 0;
|
---|
132 | virtual QString plainFullName(const Node *node,
|
---|
133 | const Node *relative = 0) = 0;
|
---|
134 | virtual QString markedUpCode(const QString& code,
|
---|
135 | const Node *relative,
|
---|
136 | const QString& dirPath) = 0;
|
---|
137 | virtual QString markedUpSynopsis(const Node *node,
|
---|
138 | const Node *relative,
|
---|
139 | SynopsisStyle style) = 0;
|
---|
140 | #ifdef QDOC_QML
|
---|
141 | virtual QString markedUpQmlItem(const Node* , bool) { return QString(); }
|
---|
142 | #endif
|
---|
143 | virtual QString markedUpName(const Node *node) = 0;
|
---|
144 | virtual QString markedUpFullName(const Node *node,
|
---|
145 | const Node *relative = 0) = 0;
|
---|
146 | virtual QString markedUpEnumValue(const QString &enumValue,
|
---|
147 | const Node *relative) = 0;
|
---|
148 | virtual QString markedUpIncludes(const QStringList& includes) = 0;
|
---|
149 | virtual QString functionBeginRegExp(const QString& funcName) = 0;
|
---|
150 | virtual QString functionEndRegExp(const QString& funcName) = 0;
|
---|
151 | virtual QList<Section> sections(const InnerNode *inner,
|
---|
152 | SynopsisStyle style,
|
---|
153 | Status status) = 0;
|
---|
154 | #ifdef QDOC_QML
|
---|
155 | virtual QList<Section> qmlSections(const QmlClassNode* qmlClassNode,
|
---|
156 | SynopsisStyle style,
|
---|
157 | const Tree* tree);
|
---|
158 | #endif
|
---|
159 | virtual const Node* resolveTarget(const QString& target,
|
---|
160 | const Tree* tree,
|
---|
161 | const Node* relative,
|
---|
162 | const Node* self = 0);
|
---|
163 | virtual QStringList macRefsForNode(const Node* node);
|
---|
164 |
|
---|
165 | static void initialize(const Config& config);
|
---|
166 | static void terminate();
|
---|
167 | static CodeMarker *markerForCode(const QString& code);
|
---|
168 | static CodeMarker *markerForFileName(const QString& fileName);
|
---|
169 | static CodeMarker *markerForLanguage(const QString& lang);
|
---|
170 | static const Node *nodeForString(const QString& string);
|
---|
171 | static QString stringForNode(const Node *node);
|
---|
172 |
|
---|
173 | protected:
|
---|
174 | bool hurryUp() const { return !slow; }
|
---|
175 |
|
---|
176 | virtual QString sortName(const Node *node);
|
---|
177 | QString protect(const QString &string);
|
---|
178 | QString typified(const QString &string);
|
---|
179 | QString taggedNode(const Node* node);
|
---|
180 | #ifdef QDOC_QML
|
---|
181 | QString taggedQmlNode(const Node* node);
|
---|
182 | #endif
|
---|
183 | QString linkTag(const Node *node, const QString& body);
|
---|
184 | void insert(FastSection &fastSection,
|
---|
185 | Node *node,
|
---|
186 | SynopsisStyle style,
|
---|
187 | Status status);
|
---|
188 | bool insertReimpFunc(FastSection& fs, Node* node, Status status);
|
---|
189 | void append(QList<Section>& sectionList, const FastSection& fastSection);
|
---|
190 |
|
---|
191 | private:
|
---|
192 | QString macName(const Node *parent, const QString &name = QString());
|
---|
193 |
|
---|
194 | bool slow;
|
---|
195 |
|
---|
196 | static QString defaultLang;
|
---|
197 | static QList<CodeMarker *> markers;
|
---|
198 | };
|
---|
199 |
|
---|
200 | QT_END_NAMESPACE
|
---|
201 |
|
---|
202 | #endif
|
---|