| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 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 qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | /*
|
|---|
| 43 | doc.h
|
|---|
| 44 | */
|
|---|
| 45 |
|
|---|
| 46 | #ifndef DOC_H
|
|---|
| 47 | #define DOC_H
|
|---|
| 48 |
|
|---|
| 49 | #include <QSet>
|
|---|
| 50 | #include <QString>
|
|---|
| 51 |
|
|---|
| 52 | #include "location.h"
|
|---|
| 53 |
|
|---|
| 54 | QT_BEGIN_NAMESPACE
|
|---|
| 55 |
|
|---|
| 56 | class Atom;
|
|---|
| 57 | class CodeMarker;
|
|---|
| 58 | class Config;
|
|---|
| 59 | class DocPrivate;
|
|---|
| 60 | class Quoter;
|
|---|
| 61 | class Text;
|
|---|
| 62 | class FakeNode;
|
|---|
| 63 |
|
|---|
| 64 | typedef QMap<QString, QStringList> QCommandMap;
|
|---|
| 65 | typedef QMap<QString, QString> QStringMap;
|
|---|
| 66 | typedef QStringMap::const_iterator QStringMapEntry;
|
|---|
| 67 | typedef QMultiMap<QString, QString> QStringMultiMap;
|
|---|
| 68 |
|
|---|
| 69 | class Doc
|
|---|
| 70 | {
|
|---|
| 71 | public:
|
|---|
| 72 | // the order is important
|
|---|
| 73 | enum SectioningUnit {
|
|---|
| 74 | Book = -2,
|
|---|
| 75 | Part,
|
|---|
| 76 | Chapter,
|
|---|
| 77 | Section1,
|
|---|
| 78 | Section2,
|
|---|
| 79 | Section3,
|
|---|
| 80 | Section4
|
|---|
| 81 | };
|
|---|
| 82 |
|
|---|
| 83 | Doc() : priv(0) {}
|
|---|
| 84 | Doc(const Location &start_loc,
|
|---|
| 85 | const Location &end_loc,
|
|---|
| 86 | const QString &source,
|
|---|
| 87 | const QSet<QString> &metaCommandSet);
|
|---|
| 88 | Doc(const Doc &doc);
|
|---|
| 89 | ~Doc();
|
|---|
| 90 |
|
|---|
| 91 | Doc& operator=( const Doc& doc );
|
|---|
| 92 |
|
|---|
| 93 | void renameParameters(const QStringList &oldNames,
|
|---|
| 94 | const QStringList &newNames);
|
|---|
| 95 | void simplifyEnumDoc();
|
|---|
| 96 | void setBody(const Text &body);
|
|---|
| 97 |
|
|---|
| 98 | const Location &location() const;
|
|---|
| 99 | bool isEmpty() const;
|
|---|
| 100 | const QString& source() const;
|
|---|
| 101 | const Text& body() const;
|
|---|
| 102 | Text briefText() const;
|
|---|
| 103 | Text trimmedBriefText(const QString &className) const;
|
|---|
| 104 | Text legaleseText() const;
|
|---|
| 105 | const QString& baseName() const;
|
|---|
| 106 | SectioningUnit granularity() const;
|
|---|
| 107 | const QSet<QString> ¶meterNames() const;
|
|---|
| 108 | const QStringList &enumItemNames() const;
|
|---|
| 109 | const QStringList &omitEnumItemNames() const;
|
|---|
| 110 | const QSet<QString> &metaCommandsUsed() const;
|
|---|
| 111 | QStringList metaCommandArgs( const QString& metaCommand ) const;
|
|---|
| 112 | const QList<Text> &alsoList() const;
|
|---|
| 113 | bool hasTableOfContents() const;
|
|---|
| 114 | bool hasKeywords() const;
|
|---|
| 115 | bool hasTargets() const;
|
|---|
| 116 | const QList<Atom *> &tableOfContents() const;
|
|---|
| 117 | const QList<int> &tableOfContentsLevels() const;
|
|---|
| 118 | const QList<Atom *> &keywords() const;
|
|---|
| 119 | const QList<Atom *> &targets() const;
|
|---|
| 120 | const QStringMap &metaTagMap() const;
|
|---|
| 121 |
|
|---|
| 122 | static void initialize( const Config &config );
|
|---|
| 123 | static void terminate();
|
|---|
| 124 | static QString alias( const QString &english );
|
|---|
| 125 | static void trimCStyleComment( Location& location, QString& str );
|
|---|
| 126 | static CodeMarker *quoteFromFile(const Location &location,
|
|---|
| 127 | Quoter "er,
|
|---|
| 128 | const QString &fileName);
|
|---|
| 129 | static QString canonicalTitle(const QString &title);
|
|---|
| 130 |
|
|---|
| 131 | private:
|
|---|
| 132 | void detach();
|
|---|
| 133 | DocPrivate *priv;
|
|---|
| 134 | };
|
|---|
| 135 |
|
|---|
| 136 | #ifdef QDOC2DOX
|
|---|
| 137 |
|
|---|
| 138 | class DoxWriter
|
|---|
| 139 | {
|
|---|
| 140 | public:
|
|---|
| 141 | DoxWriter(const QString& source, DocPrivate* docPrivate)
|
|---|
| 142 | : commentType(OtherComment),
|
|---|
| 143 | lineLength(0),
|
|---|
| 144 | lineCount(0),
|
|---|
| 145 | priv(docPrivate),
|
|---|
| 146 | oldText(source) {}
|
|---|
| 147 | ~DoxWriter() {}
|
|---|
| 148 |
|
|---|
| 149 | void pass1();
|
|---|
| 150 | void pass2();
|
|---|
| 151 |
|
|---|
| 152 | static void setDoxPass(int pass);
|
|---|
| 153 | static bool isDoxPass(int pass);
|
|---|
| 154 | static bool isDoxPass();
|
|---|
| 155 | static void insertTitle(FakeNode* node, const QString& title);
|
|---|
| 156 | static void writeTitles();
|
|---|
| 157 | static void readTitles();
|
|---|
| 158 | static void writeMembers();
|
|---|
| 159 | static void readMembers();
|
|---|
| 160 | static void writeAnchors();
|
|---|
| 161 | static void readAnchors();
|
|---|
| 162 |
|
|---|
| 163 | private:
|
|---|
| 164 | void indentLine();
|
|---|
| 165 | void newLine();
|
|---|
| 166 | void concatenate(QString text);
|
|---|
| 167 | void wrap(QString text);
|
|---|
| 168 | bool conversionRequired() const;
|
|---|
| 169 | void convertMetaCommands();
|
|---|
| 170 | void convertText();
|
|---|
| 171 | const Atom* link(const Atom* atom);
|
|---|
| 172 | void formattingLeft(const Atom* atom, const Atom* next);
|
|---|
| 173 | void formattingRight(const Atom* atom, const Atom* prev);
|
|---|
| 174 | void tt(const Atom* atom);
|
|---|
| 175 | void formatIf(const Atom* atom);
|
|---|
| 176 | void formatEndif();
|
|---|
| 177 | void formatElse();
|
|---|
| 178 | const Atom* sectionHeading(const Atom* atom);
|
|---|
| 179 | void unhandled(const Atom* atom);
|
|---|
| 180 | void code(const Atom* atom);
|
|---|
| 181 | const Atom* codeQuoteCommand(const Atom* atom);
|
|---|
| 182 | void writeCode(QString text);
|
|---|
| 183 | void writeCommand(QCommandMap::const_iterator cmd);
|
|---|
| 184 |
|
|---|
| 185 | static void insertAnchor(const QString& text);
|
|---|
| 186 | static bool isAnchor(const QString& text);
|
|---|
| 187 |
|
|---|
| 188 | static const QString* getPageFile(const QString& title);
|
|---|
| 189 | static const QString* getFile(const QString& title);
|
|---|
| 190 | static const QString* getExamplePath(const QString& title);
|
|---|
| 191 | static const QString* getHeaderFile(const QString& title);
|
|---|
| 192 | static const QString* getGroup(const QString& title);
|
|---|
| 193 | static const QString* getModule(const QString& title);
|
|---|
| 194 | static const QString* getExternalPage(const QString& title);
|
|---|
| 195 | static const QString* getPageTitle(const QString& text);
|
|---|
| 196 | static const QString* getFileTitle(const QString& text);
|
|---|
| 197 | static const QString* getExampleTitle(const QString& text);
|
|---|
| 198 | static const QString* getHeaderFileTitle(const QString& text);
|
|---|
| 199 | static const QString* getGroupTitle(const QString& text);
|
|---|
| 200 | static const QString* getModuleTitle(const QString& text);
|
|---|
| 201 | static const QString* getExternalPageTitle(const QString& text);
|
|---|
| 202 |
|
|---|
| 203 | static bool isProperty(const QString& title, QStringList& classes);
|
|---|
| 204 | static bool isVariable(const QString& title, QStringList& classes);
|
|---|
| 205 | static bool isEnum(const QString& title, QStringList& classes);
|
|---|
| 206 |
|
|---|
| 207 | private:
|
|---|
| 208 | static void writeMap(const QStringMap& map, const QString& name);
|
|---|
| 209 | static void readMap(QStringMap& map,
|
|---|
| 210 | QStringMap& inverseMap,
|
|---|
| 211 | const QString& name);
|
|---|
| 212 | static void writeMultiMap(const QStringMultiMap& map, const QString& name);
|
|---|
| 213 | static void readMultiMap(QStringMultiMap& map, const QString& name);
|
|---|
| 214 |
|
|---|
| 215 | public: // VS 6, SunCC need this to be public
|
|---|
| 216 | enum StructType { BulletList, NumericList, ValueList, Table };
|
|---|
| 217 | private:
|
|---|
| 218 | struct StructDesc {
|
|---|
| 219 | StructType structType;
|
|---|
| 220 | int count;
|
|---|
| 221 | bool nested;
|
|---|
| 222 | bool inTableHeader;
|
|---|
| 223 | bool inTableRow;
|
|---|
| 224 | bool inTableItem;
|
|---|
| 225 | bool odd;
|
|---|
| 226 |
|
|---|
| 227 | StructDesc()
|
|---|
| 228 | : structType(BulletList),
|
|---|
| 229 | count(0),
|
|---|
| 230 | nested(false),
|
|---|
| 231 | inTableHeader(false),
|
|---|
| 232 | inTableRow(false),
|
|---|
| 233 | inTableItem(false),
|
|---|
| 234 | odd(true) { }
|
|---|
| 235 |
|
|---|
| 236 | StructDesc(StructType t, bool n)
|
|---|
| 237 | : structType(t),
|
|---|
| 238 | count(0),
|
|---|
| 239 | nested(n),
|
|---|
| 240 | inTableHeader(false),
|
|---|
| 241 | inTableRow(false),
|
|---|
| 242 | inTableItem(false),
|
|---|
| 243 | odd(true) { }
|
|---|
| 244 | };
|
|---|
| 245 |
|
|---|
| 246 | typedef QStack<StructDesc> StructStack;
|
|---|
| 247 |
|
|---|
| 248 | enum CommentType {
|
|---|
| 249 | ClassComment,
|
|---|
| 250 | EnumComment,
|
|---|
| 251 | ExampleComment,
|
|---|
| 252 | FnComment,
|
|---|
| 253 | GroupComment,
|
|---|
| 254 | HeaderFileComment,
|
|---|
| 255 | MacroComment,
|
|---|
| 256 | ModuleComment,
|
|---|
| 257 | PageComment,
|
|---|
| 258 | PropertyComment,
|
|---|
| 259 | ServiceComment,
|
|---|
| 260 | TypedefComment,
|
|---|
| 261 | VariableComment,
|
|---|
| 262 | OtherComment
|
|---|
| 263 | };
|
|---|
| 264 |
|
|---|
| 265 | private:
|
|---|
| 266 | CommentType commentType;
|
|---|
| 267 | int lineLength;
|
|---|
| 268 | int lineCount;
|
|---|
| 269 | DocPrivate* priv;
|
|---|
| 270 | QString oldText;
|
|---|
| 271 | QString newText;
|
|---|
| 272 | StructStack structs;
|
|---|
| 273 |
|
|---|
| 274 | QString currentPage;
|
|---|
| 275 | QString currentFn;
|
|---|
| 276 | QString currentTitle;
|
|---|
| 277 | QString currentEnum;
|
|---|
| 278 | QString currentProperty;
|
|---|
| 279 | QString currentVariable;
|
|---|
| 280 | QString currentExample;
|
|---|
| 281 | QString currentGroup;
|
|---|
| 282 | QString currentModule;
|
|---|
| 283 | QString currentMacro;
|
|---|
| 284 | QString currentService;
|
|---|
| 285 | QString currentTypedef;
|
|---|
| 286 | QString currentHeaderFile;
|
|---|
| 287 | static QString currentClass;
|
|---|
| 288 |
|
|---|
| 289 | static int doxPass;
|
|---|
| 290 | static QSet<QString> anchors;
|
|---|
| 291 | static QStringMap exampleTitles;
|
|---|
| 292 | static QStringMap headerFileTitles;
|
|---|
| 293 | static QStringMap fileTitles;
|
|---|
| 294 | static QStringMap groupTitles;
|
|---|
| 295 | static QStringMap moduleTitles;
|
|---|
| 296 | static QStringMap pageTitles;
|
|---|
| 297 | static QStringMap externalPageTitles;
|
|---|
| 298 | static QStringMap exampleTitlesInverse;
|
|---|
| 299 | static QStringMap headerFileTitlesInverse;
|
|---|
| 300 | static QStringMap fileTitlesInverse;
|
|---|
| 301 | static QStringMap groupTitlesInverse;
|
|---|
| 302 | static QStringMap moduleTitlesInverse;
|
|---|
| 303 | static QStringMap pageTitlesInverse;
|
|---|
| 304 | static QStringMap externalPageTitlesInverse;
|
|---|
| 305 |
|
|---|
| 306 | static QStringMultiMap variables;
|
|---|
| 307 | static QStringMultiMap properties;
|
|---|
| 308 | static QStringMultiMap enums;
|
|---|
| 309 | };
|
|---|
| 310 |
|
|---|
| 311 | #endif
|
|---|
| 312 |
|
|---|
| 313 | QT_END_NAMESPACE
|
|---|
| 314 |
|
|---|
| 315 | #endif
|
|---|