Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
[qt-netbsd.git] / tools / qdoc3 / generator.h
blob06f7f885a787f51f80944f18737e19ef2440883d
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the tools applications of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
38 ** $QT_END_LICENSE$
40 ****************************************************************************/
43 generator.h
46 #ifndef GENERATOR_H
47 #define GENERATOR_H
49 #include <qlist.h>
50 #include <qmap.h>
51 #include <qregexp.h>
52 #include <qstring.h>
53 #include <qstringlist.h>
55 #include "node.h"
56 #include "text.h"
58 QT_BEGIN_NAMESPACE
60 class ClassNode;
61 class Config;
62 class CodeMarker;
63 class FakeNode;
64 class FunctionNode;
65 class InnerNode;
66 class Location;
67 class NamespaceNode;
68 class Node;
69 class Tree;
71 class Generator
73 public:
74 Generator();
75 virtual ~Generator();
77 virtual void initializeGenerator(const Config &config);
78 virtual void terminateGenerator();
79 virtual QString format() = 0;
80 virtual bool canHandleFormat(const QString &format) { return format == this->format(); }
81 virtual void generateTree(const Tree *tree, CodeMarker *marker) = 0;
83 static void initialize(const Config& config);
84 static void terminate();
85 static Generator *generatorForFormat(const QString& format);
87 protected:
88 virtual void startText(const Node *relative, CodeMarker *marker);
89 virtual void endText(const Node *relative, CodeMarker *marker);
90 virtual int generateAtom(const Atom *atom,
91 const Node *relative,
92 CodeMarker *marker);
93 virtual void generateClassLikeNode(const InnerNode *inner, CodeMarker *marker);
94 virtual void generateFakeNode(const FakeNode *fake, CodeMarker *marker);
96 virtual bool generateText(const Text& text,
97 const Node *relative,
98 CodeMarker *marker);
99 #ifdef QDOC_QML
100 virtual bool generateQmlText(const Text& text,
101 const Node *relative,
102 CodeMarker *marker,
103 const QString& qmlName);
104 virtual void generateQmlInherits(const QmlClassNode* cn,
105 CodeMarker* marker);
106 #endif
107 virtual void generateBody(const Node *node, CodeMarker *marker);
108 virtual void generateAlsoList(const Node *node, CodeMarker *marker);
109 virtual void generateInherits(const ClassNode *classe,
110 CodeMarker *marker);
111 virtual void generateInheritedBy(const ClassNode *classe,
112 CodeMarker *marker);
114 void generateThreadSafeness(const Node *node, CodeMarker *marker);
115 void generateSince(const Node *node, CodeMarker *marker);
116 void generateStatus(const Node *node, CodeMarker *marker);
117 const Atom *generateAtomList(const Atom *atom,
118 const Node *relative,
119 CodeMarker *marker,
120 bool generate,
121 int& numGeneratedAtoms);
122 void generateFileList(const FakeNode* fake,
123 CodeMarker* marker,
124 Node::SubType subtype,
125 const QString& tag);
126 void generateExampleFiles(const FakeNode *fake, CodeMarker *marker);
127 void generateModuleWarning(const ClassNode *classe, CodeMarker *marker);
129 virtual int skipAtoms(const Atom *atom, Atom::Type type) const;
130 virtual QString fullName(const Node *node,
131 const Node *relative,
132 CodeMarker *marker) const;
134 const QString& outputDir() { return outDir; }
135 QString indent(int level, const QString& markedCode);
136 QString plainCode(const QString& markedCode);
137 virtual QString typeString(const Node *node);
138 virtual QString imageFileName(const Node *relative, const QString& fileBase);
139 void setImageFileExtensions(const QStringList& extensions);
140 void unknownAtom(const Atom *atom);
141 QMap<QString, QString> &formattingLeftMap();
142 QMap<QString, QString> &formattingRightMap();
144 QMap<QString, QStringList> editionModuleMap;
145 QMap<QString, QStringList> editionGroupMap;
147 static QString trimmedTrailing(const QString &string);
148 static bool matchAhead(const Atom *atom, Atom::Type expectedAtomType);
149 static void supplementAlsoList(const Node *node, QList<Text> &alsoList);
151 private:
152 void generateOverload(const Node *node, CodeMarker *marker);
153 void generateReimplementedFrom(const FunctionNode *func,
154 CodeMarker *marker);
155 void appendFullName(Text& text,
156 const Node *apparentNode,
157 const Node *relative,
158 CodeMarker *marker,
159 const Node *actualNode = 0);
160 void appendFullName(Text& text,
161 const Node *apparentNode,
162 const QString& fullName,
163 const Node *actualNode);
164 void appendFullNames(Text& text,
165 const NodeList& nodes,
166 const Node* relative,
167 CodeMarker* marker);
168 void appendSortedNames(Text& text,
169 const ClassNode *classe,
170 const QList<RelatedClass> &classes,
171 CodeMarker *marker);
173 QString amp;
174 QString lt;
175 QString gt;
176 QString quot;
177 QRegExp tag;
179 static QList<Generator *> generators;
180 static QMap<QString, QMap<QString, QString> > fmtLeftMaps;
181 static QMap<QString, QMap<QString, QString> > fmtRightMaps;
182 static QMap<QString, QStringList> imgFileExts;
183 static QSet<QString> outputFormats;
184 static QStringList imageFiles;
185 static QStringList imageDirs;
186 static QStringList exampleDirs;
187 static QStringList exampleImgExts;
188 static QString outDir;
189 static QString project;
192 QT_END_NAMESPACE
194 #endif