tools/qdoc3/generator.h
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 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.
       
    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 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 /*
       
    43   generator.h
       
    44 */
       
    45 
       
    46 #ifndef GENERATOR_H
       
    47 #define GENERATOR_H
       
    48 
       
    49 #include <qlist.h>
       
    50 #include <qmap.h>
       
    51 #include <qregexp.h>
       
    52 #include <qstring.h>
       
    53 #include <qstringlist.h>
       
    54 
       
    55 #include "node.h"
       
    56 #include "text.h"
       
    57 
       
    58 QT_BEGIN_NAMESPACE
       
    59 
       
    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;
       
    70 
       
    71 class Generator
       
    72 {
       
    73  public:
       
    74     Generator();
       
    75     virtual ~Generator();
       
    76 
       
    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;
       
    82 
       
    83     static void initialize(const Config& config);
       
    84     static void terminate();
       
    85     static Generator *generatorForFormat(const QString& format);
       
    86 
       
    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);
       
    95 
       
    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);
       
   113 
       
   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 generateExampleFiles(const FakeNode *fake, CodeMarker *marker);
       
   123     void generateModuleWarning(const ClassNode *classe, CodeMarker *marker);
       
   124 
       
   125     virtual int skipAtoms(const Atom *atom, Atom::Type type) const;
       
   126     virtual QString fullName(const Node *node, 
       
   127                              const Node *relative,
       
   128                              CodeMarker *marker) const;
       
   129 
       
   130     const QString& outputDir() { return outDir; }
       
   131     QString indent(int level, const QString& markedCode);
       
   132     QString plainCode(const QString& markedCode);
       
   133     virtual QString typeString(const Node *node);
       
   134     virtual QString imageFileName(const Node *relative, const QString& fileBase);
       
   135     void setImageFileExtensions(const QStringList& extensions);
       
   136     void unknownAtom(const Atom *atom);
       
   137     QMap<QString, QString> &formattingLeftMap();
       
   138     QMap<QString, QString> &formattingRightMap();
       
   139 
       
   140     QMap<QString, QStringList> editionModuleMap;
       
   141     QMap<QString, QStringList> editionGroupMap;
       
   142 
       
   143     static QString trimmedTrailing(const QString &string);
       
   144     static bool matchAhead(const Atom *atom, Atom::Type expectedAtomType);
       
   145     static void supplementAlsoList(const Node *node, QList<Text> &alsoList);
       
   146 
       
   147  private:
       
   148     void generateOverload(const Node *node, CodeMarker *marker);
       
   149     void generateReimplementedFrom(const FunctionNode *func,
       
   150                                    CodeMarker *marker);
       
   151     void appendFullName(Text& text, 
       
   152                         const Node *apparentNode,
       
   153                         const Node *relative, 
       
   154                         CodeMarker *marker,
       
   155                         const Node *actualNode = 0);
       
   156     void appendFullName(Text& text,
       
   157                         const Node *apparentNode,
       
   158                         const QString& fullName,
       
   159                         const Node *actualNode);
       
   160     void appendFullNames(Text& text,
       
   161                          const NodeList& nodes,
       
   162                          const Node* relative,
       
   163                          CodeMarker* marker);
       
   164     void appendSortedNames(Text& text, 
       
   165                            const ClassNode *classe,
       
   166                            const QList<RelatedClass> &classes,
       
   167                            CodeMarker *marker);
       
   168 
       
   169     QString amp;
       
   170     QString lt;
       
   171     QString gt;
       
   172     QString quot;
       
   173     QRegExp tag;
       
   174 
       
   175     static QList<Generator *> generators;
       
   176     static QMap<QString, QMap<QString, QString> > fmtLeftMaps;
       
   177     static QMap<QString, QMap<QString, QString> > fmtRightMaps;
       
   178     static QMap<QString, QStringList> imgFileExts;
       
   179     static QSet<QString> outputFormats;
       
   180     static QStringList imageFiles;
       
   181     static QStringList imageDirs;
       
   182     static QString outDir;
       
   183     static QString project;
       
   184 };
       
   185 
       
   186 QT_END_NAMESPACE
       
   187 
       
   188 #endif