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