diff options
-rw-r--r-- | src/qdoc/codemarker.cpp | 217 | ||||
-rw-r--r-- | src/qdoc/codemarker.h | 133 | ||||
-rw-r--r-- | src/qdoc/cppcodemarker.cpp | 687 | ||||
-rw-r--r-- | src/qdoc/cppcodemarker.h | 22 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 266 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.h | 10 | ||||
-rw-r--r-- | src/qdoc/main.cpp | 1 | ||||
-rw-r--r-- | src/qdoc/node.h | 4 | ||||
-rw-r--r-- | src/qdoc/openedlist.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/openedlist.h | 10 | ||||
-rw-r--r-- | src/qdoc/plaincodemarker.cpp | 114 | ||||
-rw-r--r-- | src/qdoc/plaincodemarker.h | 64 | ||||
-rw-r--r-- | src/qdoc/qdoc.pro | 4 | ||||
-rw-r--r-- | src/qdoc/sections.cpp | 896 | ||||
-rw-r--r-- | src/qdoc/sections.h | 133 |
15 files changed, 1215 insertions, 1348 deletions
diff --git a/src/qdoc/codemarker.cpp b/src/qdoc/codemarker.cpp index 563e2821b..e51cc9426 100644 --- a/src/qdoc/codemarker.cpp +++ b/src/qdoc/codemarker.cpp @@ -340,215 +340,6 @@ QString CodeMarker::linkTag(const Node *node, const QString& body) + QLatin1String("\">") + body + QLatin1String("</@link>"); } -QString CodeMarker::sortName(const Node *node, const QString* name) -{ - QString nodeName; - if (name != 0) - nodeName = *name; - else - nodeName = node->name(); - int numDigits = 0; - for (int i = nodeName.size() - 1; i > 0; --i) { - if (nodeName.at(i).digitValue() == -1) - break; - ++numDigits; - } - - // we want 'qint8' to appear before 'qint16' - if (numDigits > 0) { - for (int i = 0; i < 4 - numDigits; ++i) - nodeName.insert(nodeName.size()-numDigits-1, QLatin1Char('0')); - } - - if (node->type() == Node::Function) { - const FunctionNode *func = static_cast<const FunctionNode *>(node); - QString sortNo; - if (func->isSomeCtor()) { - sortNo = QLatin1String("C"); - } - else if (func->isDtor()) { - sortNo = QLatin1String("D"); - } - else { - if (nodeName.startsWith(QLatin1String("operator")) - && nodeName.length() > 8 - && !nodeName[8].isLetterOrNumber()) - sortNo = QLatin1String("F"); - else - sortNo = QLatin1String("E"); - } - return sortNo + nodeName + QLatin1Char(' ') + QString::number(func->overloadNumber(), 36); - } - - if (node->type() == Node::Class) - return QLatin1Char('A') + nodeName; - - if (node->type() == Node::Property || node->type() == Node::Variable) - return QLatin1Char('E') + nodeName; - - if ((node->type() == Node::QmlMethod) || - (node->type() == Node::QmlSignal) || - (node->type() == Node::QmlSignalHandler)) { - //const FunctionNode* func = static_cast<const FunctionNode *>(node); - //return QLatin1Char('E') + func->name(); - return QLatin1Char('E') + nodeName; - } - - return QLatin1Char('B') + nodeName; -} - -void CodeMarker::insert(FastSection &fastSection, - Node *node, - SynopsisStyle style, - Status status) -{ - bool irrelevant = false; - bool inheritedMember = false; - if (!node->relates()) { - Aggregate* p = node->parent(); - if (p->isQmlPropertyGroup()) - p = p->parent(); - if (!p->isNamespace() && p != fastSection.parent_) { - if ((!p->isQmlType() && !p->isJsType()) || !p->isAbstract()) - inheritedMember = true; - } - } - - if (node->access() == Node::Private) { - irrelevant = true; - } - else if (node->type() == Node::Function) { - FunctionNode *func = (FunctionNode *) node; - irrelevant = (inheritedMember && (func->isSomeCtor() || func->isDtor())); - } - else if (node->isClass() || node->isEnumType() || node->isTypedef()) { - irrelevant = (inheritedMember && style != Subpage); - if (!irrelevant && style == Detailed && node->isTypedef()) { - const TypedefNode* tdn = static_cast<const TypedefNode*>(node); - if (tdn->associatedEnum()) - irrelevant = true; - } - } - - if (!irrelevant) { - if (status == Compat) { - irrelevant = (node->status() != Node::Compat); - } - else if (status == Obsolete) { - irrelevant = (node->status() != Node::Obsolete); - } - else { - irrelevant = (node->status() == Node::Compat || - node->status() == Node::Obsolete); - } - } - - if (!irrelevant) { - if (!inheritedMember || style == Subpage) { - QString key = sortName(node); - fastSection.memberMap.insertMulti(key, node); - } - else { - if (node->parent()->isClass() || node->parent()->isNamespace()) { - if (fastSection.inherited.isEmpty() - || fastSection.inherited.last().first != node->parent()) { - QPair<Aggregate *, int> p(node->parent(), 0); - fastSection.inherited.append(p); - } - fastSection.inherited.last().second++; - } - } - } -} - -/*! - Returns \c true if \a node represents a reimplemented member - function in the class of the FastSection \a fs. If it is - a reimplemented function, then it is inserted into the - reimplemented member map in \a fs. The test is performed - only if \a status is \e OK. True is returned if \a node - is inserted into the map. Otherwise, false is returned. - */ -bool CodeMarker::insertReimpFunc(FastSection& fs, Node* node, Status status) -{ - if ((node->access() != Node::Private) && (node->relates() == 0)) { - const FunctionNode* fn = static_cast<const FunctionNode*>(node); - if (!fn->reimplementedFrom().isEmpty() && (status == Okay)) { - if (fn->parent() == fs.parent_) { - QString key = sortName(fn); - if (!fs.reimpMemberMap.contains(key)) { - fs.reimpMemberMap.insert(key,node); - return true; - } - } - } - } - return false; -} - -/*! - If \a fs is not empty, convert it to a Section and append - the new Section to \a sectionList. - */ -void CodeMarker::append(QList<Section>& sectionList, const FastSection& fs, bool includeKeys) -{ - if (!fs.isEmpty()) { - if (fs.classMapList_.isEmpty()) { - Section section(fs.name,fs.divClass,fs.singularMember,fs.pluralMember); - if (includeKeys) { - section.keys = fs.memberMap.keys(); - } - section.members = fs.memberMap.values(); - section.reimpMembers = fs.reimpMemberMap.values(); - section.inherited = fs.inherited; - sectionList.append(section); - } - else { - Section section(fs.name,fs.divClass,fs.singularMember,fs.pluralMember); - sectionList.append(section); - Section* s = §ionList[sectionList.size()-1]; - for (int i=0; i<fs.classMapList_.size(); i++) { - ClassMap* classMap = fs.classMapList_[i]; - ClassKeysNodes* ckn = new ClassKeysNodes; - ckn->first = classMap->first; - ckn->second.second = classMap->second.values(); - ckn->second.first = classMap->second.keys(); - s->classKeysNodesList_.append(ckn); - } - } - } -} - -/*! - The destructor must delete each member of the - list of QML class lists, if it is not empty; - */ -Section::~Section() -{ - if (!classKeysNodesList_.isEmpty()) { - for (int i=0; i<classKeysNodesList_.size(); i++) { - ClassKeysNodes* classKeysNodes = classKeysNodesList_[i]; - classKeysNodesList_[i] = 0; - delete classKeysNodes; - } - } -} - -/*! - The destructor must delete the QML class maps in the class - map list, if the class map list is not empty. - */ -FastSection::~FastSection() -{ - if (!classMapList_.isEmpty()) { - for (int i=0; i<classMapList_.size(); i++) { - ClassMap* classMap = classMapList_[i]; - classMapList_[i] = 0; - delete classMap; - } - } -} - static QString encode(const QString &string) { return string; @@ -648,12 +439,4 @@ QString CodeMarker::macName(const Node *node, const QString &name) } } -/*! - Returns an empty list of documentation sections. - */ -QList<Section> CodeMarker::qmlSections(Aggregate* , SynopsisStyle , Status ) -{ - return QList<Section>(); -} - QT_END_NAMESPACE diff --git a/src/qdoc/codemarker.h b/src/qdoc/codemarker.h index ff05952a4..15bc34d67 100644 --- a/src/qdoc/codemarker.h +++ b/src/qdoc/codemarker.h @@ -26,124 +26,43 @@ ** ****************************************************************************/ -/* - codemarker.h -*/ - #ifndef CODEMARKER_H #define CODEMARKER_H -#include <qpair.h> - #include "atom.h" -#include "node.h" +#include "sections.h" QT_BEGIN_NAMESPACE class Config; -typedef QMultiMap<QString, Node*> MemberMap; // the string is the member signature -typedef QPair<const QmlTypeNode*, MemberMap> ClassMap; // the node is the QML type -typedef QList<ClassMap*> ClassMapList; - -typedef QPair<QStringList, NodeList> KeysAndNodes; -typedef QPair<const QmlTypeNode*, KeysAndNodes> ClassKeysNodes; -typedef QList<ClassKeysNodes*> ClassKeysNodesList; - -struct Section -{ - QString name; - QString divClass; - QString singularMember; - QString pluralMember; - QStringList keys; - NodeList members; - NodeList reimpMembers; - QList<QPair<Aggregate *, int> > inherited; - ClassKeysNodesList classKeysNodesList_; - - Section() { } - Section(const QString& name0, - const QString& divClass0, - const QString& singularMember0, - const QString& pluralMember0) - : name(name0), - divClass(divClass0), - singularMember(singularMember0), - pluralMember(pluralMember0) { } - ~Section(); - void appendMember(Node* node) { members.append(node); } - void appendReimpMember(Node* node) { reimpMembers.append(node); } -}; - -struct FastSection -{ - const Aggregate *parent_; - QString name; - QString divClass; - QString singularMember; - QString pluralMember; - QMultiMap<QString, Node *> memberMap; - QMultiMap<QString, Node *> reimpMemberMap; - ClassMapList classMapList_; - QList<QPair<Aggregate *, int> > inherited; - - FastSection(const Aggregate *parent, - const QString& name0, - const QString& divClass0, - const QString& singularMember0, - const QString& pluralMember0) - : parent_(parent), - name(name0), - divClass(divClass0), - singularMember(singularMember0), - pluralMember(pluralMember0) { } - ~FastSection(); - bool isEmpty() const { - return (memberMap.isEmpty() && - inherited.isEmpty() && - reimpMemberMap.isEmpty() && - classMapList_.isEmpty()); - } - -}; - class CodeMarker { public: - enum SynopsisStyle { Summary, Detailed, Subpage, Accessors }; - enum Status { Compat, Obsolete, Okay }; - CodeMarker(); virtual ~CodeMarker(); virtual void initializeMarker(const Config& config); virtual void terminateMarker(); - virtual bool recognizeCode(const QString& code) = 0; - virtual bool recognizeExtension(const QString& ext) = 0; - virtual bool recognizeLanguage(const QString& lang) = 0; - virtual Atom::AtomType atomType() const = 0; - virtual QString markedUpCode(const QString& code, - const Node *relative, - const Location &location) = 0; - virtual QString markedUpSynopsis(const Node *node, - const Node *relative, - SynopsisStyle style) = 0; + virtual bool recognizeCode(const QString& /*code*/) { return true; } + virtual bool recognizeExtension(const QString& /*extension*/) { return true; } + virtual bool recognizeLanguage(const QString& /*language*/) { return false; } + virtual Atom::AtomType atomType() const { return Atom::Code; } + virtual QString markedUpCode(const QString &code, + const Node* /*relative*/, + const Location& /*location*/) { return protect(code); } + virtual QString markedUpSynopsis(const Node* /*node*/, + const Node* /*relative*/, + Sections::Style /*style*/) { return QString(); } virtual QString markedUpQmlItem(const Node* , bool) { return QString(); } - virtual QString markedUpName(const Node *node) = 0; - virtual QString markedUpFullName(const Node *node, - const Node *relative = 0) = 0; - virtual QString markedUpEnumValue(const QString &enumValue, - const Node *relative) = 0; - virtual QString markedUpIncludes(const QStringList& includes) = 0; - virtual QString functionBeginRegExp(const QString& funcName) = 0; - virtual QString functionEndRegExp(const QString& funcName) = 0; - virtual QList<Section> sections(const Aggregate *inner, - SynopsisStyle style, - Status status) = 0; - virtual QList<Section> qmlSections(Aggregate* aggregate, - SynopsisStyle style, - Status status = Okay); + virtual QString markedUpName(const Node* /*node*/) { return QString(); } + virtual QString markedUpFullName(const Node* /*node*/, + const Node* /*relative*/) { return QString(); } + virtual QString markedUpEnumValue(const QString& /*enumValue*/, + const Node* /*relative*/) { return QString(); } + virtual QString markedUpIncludes(const QStringList& /*includes*/) { return QString(); } + virtual QString functionBeginRegExp(const QString& /*funcName*/) { return QString(); } + virtual QString functionEndRegExp(const QString& /*funcName*/) { return QString(); } virtual QStringList macRefsForNode(Node* node); static void initialize(const Config& config); @@ -157,18 +76,11 @@ public: QString typified(const QString &string, bool trailingSpace = false); protected: - virtual QString sortName(const Node *node, const QString* name = 0); static QString protect(const QString &string); static void appendProtectedString(QString *output, const QStringRef &str); QString taggedNode(const Node* node); QString taggedQmlNode(const Node* node); QString linkTag(const Node *node, const QString& body); - void insert(FastSection &fastSection, - Node *node, - SynopsisStyle style, - Status status); - bool insertReimpFunc(FastSection& fs, Node* node, Status status); - void append(QList<Section>& sectionList, const FastSection& fastSection, bool includeKeys = false); private: QString macName(const Node *parent, const QString &name = QString()); @@ -177,6 +89,13 @@ private: static QList<CodeMarker *> markers; }; +class PlainCodeMarker : public CodeMarker +{ + public: + PlainCodeMarker() { } + ~PlainCodeMarker() { } +}; + QT_END_NAMESPACE #endif diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp index e1a5040dd..8b334736f 100644 --- a/src/qdoc/cppcodemarker.cpp +++ b/src/qdoc/cppcodemarker.cpp @@ -30,9 +30,7 @@ cppcodemarker.cpp */ -#include "atom.h" #include "cppcodemarker.h" -#include "node.h" #include "text.h" #include "tree.h" #include <qdebug.h> @@ -113,7 +111,7 @@ QString CppCodeMarker::markedUpCode(const QString &code, QString CppCodeMarker::markedUpSynopsis(const Node *node, const Node * /* relative */, - SynopsisStyle style) + Sections::Style style) { const int MaxEnumValues = 6; const FunctionNode *func; @@ -126,11 +124,11 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, QString name; name = taggedNode(node); - if (style != Detailed) + if (style != Sections::Detailed) name = linkTag(node, name); name = "<@name>" + name + "</@name>"; - if ((style == Detailed) && !node->parent()->name().isEmpty() && + if ((style == Sections::Detailed) && !node->parent()->name().isEmpty() && (node->type() != Node::Property) && !node->isQmlNode() && !node->isJsNode()) name.prepend(taggedNode(node->parent()) + "::"); @@ -147,7 +145,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, case Node::QmlMethod: func = (const FunctionNode *) node; - if (style != Subpage && !func->returnType().isEmpty()) + if (style != Sections::Subpage && !func->returnType().isEmpty()) synopsis = typified(func->returnType(), true); synopsis += name; if (!func->isMacroWithoutParams()) { @@ -161,9 +159,9 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, if (hasName) synopsis += typified((*p).dataType(), true); const QString ¶mName = hasName ? (*p).name() : (*p).dataType(); - if (style != Subpage || !hasName) + if (style != Sections::Subpage || !hasName) synopsis += "<@param>" + protect(paramName) + "</@param>"; - if (style != Subpage && !(*p).defaultValue().isEmpty()) + if (style != Sections::Subpage && !(*p).defaultValue().isEmpty()) synopsis += " = " + protect((*p).defaultValue()); ++p; } @@ -173,7 +171,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, if (func->isConst()) synopsis += " const"; - if (style == Summary || style == Accessors) { + if (style == Sections::Summary || style == Sections::Accessors) { if (!func->isNonvirtual()) synopsis.prepend("virtual "); if (func->isFinal()) @@ -191,7 +189,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, else if (func->isRefRef()) synopsis.append(" &&"); } - else if (style == Subpage) { + else if (style == Sections::Subpage) { if (!func->returnType().isEmpty() && func->returnType() != "void") synopsis += " : " + typified(func->returnType()); } @@ -239,7 +237,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, case Node::Enum: enume = static_cast<const EnumNode *>(node); synopsis = "enum " + name; - if (style == Summary) { + if (style == Sections::Summary) { synopsis += " { "; QStringList documentedItems = enume->doc().enumItemNames(); @@ -290,7 +288,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, break; case Node::Variable: variable = static_cast<const VariableNode *>(node); - if (style == Subpage) { + if (style == Sections::Subpage) { synopsis = name + " : " + typified(variable->dataType()); } else { @@ -302,7 +300,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, synopsis = name; } - if (style == Summary) { + if (style == Sections::Summary) { if (node->status() == Node::Preliminary) { extra += "(preliminary) "; } @@ -455,434 +453,6 @@ QString CppCodeMarker::functionEndRegExp(const QString& /* funcName */) return "^\\}$"; } -QList<Section> CppCodeMarker::sections(const Aggregate *aggregate, - SynopsisStyle style, - Status status) -{ - QList<Section> sections; - - bool documentAll = true; - if (aggregate->isClass()) { - if (aggregate->parent() && !aggregate->name().isEmpty() && !aggregate->hasDoc()) - documentAll = false; - if (style == Summary) { - FastSection privateFunctions(aggregate, - "Private Functions", - QString(), - "private function", - "private functions"); - FastSection privateSlots(aggregate, "Private Slots", QString(), "private slot", "private slots"); - FastSection privateTypes(aggregate, "Private Types", QString(), "private type", "private types"); - FastSection protectedFunctions(aggregate, - "Protected Functions", - QString(), - "protected function", - "protected functions"); - FastSection protectedSlots(aggregate, - "Protected Slots", - QString(), - "protected slot", - "protected slots"); - FastSection protectedTypes(aggregate, - "Protected Types", - QString(), - "protected type", - "protected types"); - FastSection protectedVariables(aggregate, - "Protected Variables", - QString(), - "protected type", - "protected variables"); - FastSection publicFunctions(aggregate, - "Public Functions", - QString(), - "public function", - "public functions"); - FastSection publicSignals(aggregate, "Signals", QString(), "signal", "signals"); - FastSection publicSlots(aggregate, "Public Slots", QString(), "public slot", "public slots"); - FastSection publicTypes(aggregate, "Public Types", QString(), "public type", "public types"); - FastSection publicVariables(aggregate, - "Public Variables", - QString(), - "public variable", - "public variables"); - FastSection properties(aggregate, "Properties", QString(), "property", "properties"); - FastSection relatedNonMembers(aggregate, - "Related Non-Members", - QString(), - "related non-member", - "related non-members"); - FastSection staticPrivateMembers(aggregate, - "Static Private Members", - QString(), - "static private member", - "static private members"); - FastSection staticProtectedMembers(aggregate, - "Static Protected Members", - QString(), - "static protected member", - "static protected members"); - FastSection staticPublicMembers(aggregate, - "Static Public Members", - QString(), - "static public member", - "static public members"); - FastSection macros(aggregate, "Macros", QString(), "macro", "macros"); - - NodeList::ConstIterator r = aggregate->relatedNodes().constBegin(); - while (r != aggregate->relatedNodes().constEnd()) { - if ((*r)->isFunction()) { - FunctionNode *func = static_cast<FunctionNode *>(*r); - if (func->isMacro()) - insert(macros, *r, style, status); - else - insert(relatedNonMembers, *r, style, status); - } - else { - insert(relatedNonMembers, *r, style, status); - } - ++r; - } - - QStack<const Aggregate *> stack; - stack.push(aggregate); - while (!stack.isEmpty()) { - const Aggregate* ancestor = stack.pop(); - - NodeList::ConstIterator c = ancestor->childNodes().constBegin(); - while (c != ancestor->childNodes().constEnd()) { - if (!documentAll && !(*c)->hasDoc()) { - ++c; - continue; - } - bool isSlot = false; - bool isSignal = false; - bool isStatic = false; - if ((*c)->isFunction()) { - const FunctionNode *func = (const FunctionNode *) *c; - isSlot = (func->isSlot()); - isSignal = (func->isSignal()); - isStatic = func->isStatic(); - if (func->hasAssociatedProperties() && !func->hasActiveAssociatedProperty()) { - ++c; - continue; - } - else if (func->isIgnored()) { - ++c; - continue; - } - } - else if ((*c)->isVariable()) { - const VariableNode *var = static_cast<const VariableNode *>(*c); - isStatic = var->isStatic(); - } - else if ((*c)->isTypedef()) { - if ((*c)->name() == QLatin1String("QtGadgetHelper")) { - ++c; - continue; - } - } - - switch ((*c)->access()) { - case Node::Public: - if (isSlot) { - insert(publicSlots, *c, style, status); - } - else if (isSignal) { - insert(publicSignals, *c, style, status); - } - else if (isStatic) { - if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty()) - insert(staticPublicMembers,*c,style,status); - } - else if ((*c)->type() == Node::Property) { - insert(properties, *c, style, status); - } - else if ((*c)->type() == Node::Variable) { - if (!(*c)->doc().isEmpty()) - insert(publicVariables, *c, style, status); - } - else if ((*c)->type() == Node::Function) { - if (!insertReimpFunc(publicFunctions,*c,status)) { - insert(publicFunctions, *c, style, status); - } - } - else if ((*c)->type() != Node::SharedComment) { - insert(publicTypes, *c, style, status); - } - break; - case Node::Protected: - if (isSlot) { - insert(protectedSlots, *c, style, status); - } - else if (isStatic) { - if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty()) - insert(staticProtectedMembers,*c,style,status); - } - else if ((*c)->type() == Node::Variable) { - if (!(*c)->doc().isEmpty()) - insert(protectedVariables,*c,style,status); - } - else if ((*c)->type() == Node::Function) { - if (!insertReimpFunc(protectedFunctions,*c,status)) { - insert(protectedFunctions, *c, style, status); - } - } - else { - insert(protectedTypes, *c, style, status); - } - break; - case Node::Private: - if (isSlot) { - insert(privateSlots, *c, style, status); - } - else if (isStatic) { - if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty()) - insert(staticPrivateMembers,*c,style,status); - } - else if ((*c)->type() == Node::Function) { - if (!insertReimpFunc(privateFunctions,*c,status)) { - insert(privateFunctions, *c, style, status); - } - } - else { - insert(privateTypes,*c,style,status); - } - } - ++c; - } - - if (ancestor->isClass()) { - const ClassNode* cn = static_cast<const ClassNode*>(ancestor); - QList<RelatedClass>::ConstIterator r = cn->baseClasses().constBegin(); - while (r != cn->baseClasses().constEnd()) { - if ((*r).node_) - stack.prepend((*r).node_); - ++r; - } - } - } - append(sections, publicTypes); - append(sections, properties); - append(sections, publicFunctions); - append(sections, publicSlots); - append(sections, publicSignals); - append(sections, publicVariables); - append(sections, staticPublicMembers); - append(sections, protectedTypes); - append(sections, protectedFunctions); - append(sections, protectedSlots); - append(sections, protectedVariables); - append(sections, staticProtectedMembers); - append(sections, privateTypes); - append(sections, privateFunctions); - append(sections, privateSlots); - append(sections, staticPrivateMembers); - append(sections, relatedNonMembers); - append(sections, macros); - } - else if (style == Detailed) { - FastSection memberFunctions(aggregate,"Member Function Documentation","func","member","members"); - FastSection memberTypes(aggregate,"Member Type Documentation","types","member","members"); - FastSection memberVariables(aggregate,"Member Variable Documentation","vars","member","members"); - FastSection properties(aggregate,"Property Documentation","prop","member","members"); - FastSection relatedNonMembers(aggregate,"Related Non-Members","relnonmem","member","members"); - FastSection macros(aggregate,"Macro Documentation","macros","member","members"); - - NodeList::ConstIterator r = aggregate->relatedNodes().constBegin(); - while (r != aggregate->relatedNodes().constEnd()) { - if ((*r)->isFunction()) { - FunctionNode *func = static_cast<FunctionNode *>(*r); - if (func->isMacro()) - insert(macros, *r, style, status); - else if (!func->isSharingComment()) - insert(relatedNonMembers, *r, style, status); - } - else { - insert(relatedNonMembers, *r, style, status); - } - ++r; - } - - NodeList::ConstIterator c = aggregate->childNodes().constBegin(); - while (c != aggregate->childNodes().constEnd()) { - if ((*c)->isSharingComment()) { - // do nothing - } else if (!documentAll && !(*c)->hasDoc()) { - ++c; - continue; - } else if ((*c)->isEnumType() || (*c)->isTypedef()) { - if ((*c)->name() == QLatin1String("QtGadgetHelper")) { - ++c; - continue; - } - insert(memberTypes, *c, style, status); - } else if ((*c)->isProperty()) { - insert(properties, *c, style, status); - } else if ((*c)->isVariable()) { - if (!(*c)->doc().isEmpty()) - insert(memberVariables, *c, style, status); - } else if ((*c)->isFunction()) { - FunctionNode *function = static_cast<FunctionNode *>(*c); - if (function->isIgnored()) { - ++c; - continue; - } - if (!function->isSharingComment()) { - if (!function->hasAssociatedProperties() || !function->doc().isEmpty()) - insert(memberFunctions, function, style, status); - } - } else if ((*c)->isSharedCommentNode()) { - SharedCommentNode *scn = static_cast<SharedCommentNode *>(*c); - if (!scn->doc().isEmpty()) - insert(memberFunctions, scn, style, status); - } - ++c; - } - - append(sections, memberTypes); - append(sections, properties); - append(sections, memberFunctions); - append(sections, memberVariables); - append(sections, relatedNonMembers); - append(sections, macros); - } - else { - FastSection all(aggregate,QString(),QString(),"member","members"); - - QStack<const Aggregate*> stack; - stack.push(aggregate); - - while (!stack.isEmpty()) { - const Aggregate* ancestor = stack.pop(); - NodeList::ConstIterator c = ancestor->childNodes().constBegin(); - while (c != ancestor->childNodes().constEnd()) { - if ((*c)->access() != Node::Private && (*c)->type() != Node::Property) - insert(all, *c, style, status); - ++c; - } - - if (ancestor->isClass()) { - const ClassNode* cn = static_cast<const ClassNode*>(ancestor); - QList<RelatedClass>::ConstIterator r = cn->baseClasses().constBegin(); - while (r != cn->baseClasses().constEnd()) { - if ((*r).node_) - stack.prepend((*r).node_); - ++r; - } - } - } - append(sections, all); - } - } else if (style == Summary || style == Detailed) { - FastSection namespaces(aggregate, - "Namespaces", - style == Detailed ? "nmspace" : QString(), - "namespace", - "namespaces"); - FastSection classes(aggregate, - "Classes", - style == Detailed ? "classes" : QString(), - "class", - "classes"); - FastSection types(aggregate, - style == Summary ? "Types" : "Type Documentation", - style == Detailed ? "types" : QString(), - "type", - "types"); - FastSection variables(aggregate, - style == Summary ? "Variables" : "Variable Documentation", - style == Detailed ? "vars" : QString(), - "variable", - "variables"); - FastSection staticVariables(aggregate, - "Static Variables", - QString(), - "static variable", - "static variables"); - FastSection functions(aggregate, - style == Summary ? - "Functions" : "Function Documentation", - style == Detailed ? "func" : QString(), - "function", - "functions"); - FastSection macros(aggregate, - style == Summary ? - "Macros" : "Macro Documentation", - style == Detailed ? "macros" : QString(), - "macro", - "macros"); - - NodeList nodeList = aggregate->childNodes(); - nodeList += aggregate->relatedNodes(); - if (aggregate->isNamespace()) { - const NamespaceNode* ns = static_cast<const NamespaceNode*>(aggregate); - if (!ns->hasDoc()) - documentAll = false; - if (style == Summary) { - if (!ns->orphans().isEmpty()) - nodeList += ns->orphans(); - } - } - NodeList::ConstIterator n = nodeList.constBegin(); - while (n != nodeList.constEnd()) { - if (documentAll || (*n)->hasDoc()) { - switch ((*n)->type()) { - case Node::Namespace: - insert(namespaces, *n, style, status); - break; - case Node::Class: - insert(classes, *n, style, status); - break; - case Node::Enum: - case Node::Typedef: - insert(types, *n, style, status); - break; - case Node::Function: - { - FunctionNode *func = static_cast<FunctionNode *>(*n); - if (func->isMacro()) - insert(macros, *n, style, status); - else - insert(functions, *n, style, status); - } - break; - case Node::Variable: - { - const VariableNode* var = static_cast<const VariableNode*>(*n); - if (!var->doc().isEmpty()) { - if (var->isStatic()) - insert(staticVariables,*n,style,status); - else - insert(variables, *n, style, status); - } - } - break; - case Node::SharedComment: - { - SharedCommentNode *scn = static_cast<SharedCommentNode *>(*n); - if (!scn->doc().isEmpty()) - insert(functions, scn, style, status); - } - break; - default: - break; - } - } - ++n; - } - append(sections, namespaces); - append(sections, classes); - append(sections, types); - append(sections, variables); - append(sections, staticVariables); - append(sections, functions); - append(sections, macros); - } - - return sections; -} - /* @char @class @@ -1148,239 +718,4 @@ QString CppCodeMarker::addMarkUp(const QString &in, return out; } -/*! - This function is for documenting QML properties. It returns - the list of documentation sections for the children of the - \a aggregate. - */ -QList<Section> CppCodeMarker::qmlSections(Aggregate* aggregate, SynopsisStyle style, Status status) -{ - QList<Section> sections; - if (aggregate) { - if (style == Summary) { - FastSection qmlproperties(aggregate, - "Properties", - QString(), - "property", - "properties"); - FastSection qmlattachedproperties(aggregate, - "Attached Properties", - QString(), - "attached property", - "attached properties"); - FastSection qmlsignals(aggregate, - "Signals", - QString(), - "signal", - "signals"); - FastSection qmlsignalhandlers(aggregate, - "Signal Handlers", - QString(), - "signal handler", - "signal handlers"); - FastSection qmlattachedsignals(aggregate, - "Attached Signals", - QString(), - "attached signal", - "attached signals"); - FastSection qmlmethods(aggregate, - "Methods", - QString(), - "method", - "methods"); - FastSection qmlattachedmethods(aggregate, - "Attached Methods", - QString(), - "attached method", - "attached methods"); - - Aggregate* qcn = aggregate; - while (qcn != 0) { - NodeList::ConstIterator c = qcn->childNodes().constBegin(); - while (c != qcn->childNodes().constEnd()) { - if ((*c)->status() == Node::Internal) { - ++c; - continue; - } - if ((*c)->isQmlPropertyGroup() || (*c)->isJsPropertyGroup()) { - insert(qmlproperties, *c, style, status); - } - else if ((*c)->isQmlProperty() || (*c)->isJsProperty()) { - const QmlPropertyNode* pn = static_cast<const QmlPropertyNode*>(*c); - if (pn->isAttached()) - insert(qmlattachedproperties,*c,style, status); - else { - insert(qmlproperties,*c,style, status); - } - } - else if ((*c)->isQmlSignal() || (*c)->isJsSignal()) { - const FunctionNode* sn = static_cast<const FunctionNode*>(*c); - if (sn->isAttached()) - insert(qmlattachedsignals,*c,style, status); - else - insert(qmlsignals,*c,style, status); - } - else if ((*c)->isQmlSignalHandler() || (*c)->isJsSignalHandler()) { - insert(qmlsignalhandlers,*c,style, status); - } - else if ((*c)->isQmlMethod() || (*c)->isJsMethod()) { - const FunctionNode* mn = static_cast<const FunctionNode*>(*c); - if (mn->isAttached()) - insert(qmlattachedmethods,*c,style, status); - else - insert(qmlmethods,*c,style, status); - } - ++c; - } - if (qcn->qmlBaseNode() != 0) { - qcn = static_cast<QmlTypeNode*>(qcn->qmlBaseNode()); - if (!qcn->isAbstract()) - qcn = 0; - } - else - qcn = 0; - } - append(sections,qmlproperties); - append(sections,qmlattachedproperties); - append(sections,qmlsignals); - append(sections,qmlsignalhandlers); - append(sections,qmlattachedsignals); - append(sections,qmlmethods); - append(sections,qmlattachedmethods); - } - else if (style == Detailed) { - FastSection qmlproperties(aggregate, "Property Documentation","qmlprop","member","members"); - FastSection qmlattachedproperties(aggregate,"Attached Property Documentation","qmlattprop", - "member","members"); - FastSection qmlsignals(aggregate,"Signal Documentation","qmlsig","signal","signals"); - FastSection qmlsignalhandlers(aggregate,"Signal Handler Documentation","qmlsighan","signal handler","signal handlers"); - FastSection qmlattachedsignals(aggregate,"Attached Signal Documentation","qmlattsig", - "signal","signals"); - FastSection qmlmethods(aggregate,"Method Documentation","qmlmeth","member","members"); - FastSection qmlattachedmethods(aggregate,"Attached Method Documentation","qmlattmeth", - "member","members"); - Aggregate* qcn = aggregate; - while (qcn != 0) { - NodeList::ConstIterator c = qcn->childNodes().constBegin(); - while (c != qcn->childNodes().constEnd()) { - if ((*c)->status() == Node::Internal) { - ++c; - continue; - } - if ((*c)->isQmlPropertyGroup() || (*c)->isJsPropertyGroup()) { - insert(qmlproperties,*c,style, status); - } - else if ((*c)->isQmlProperty() || (*c)->isJsProperty()) { - const QmlPropertyNode* pn = static_cast<const QmlPropertyNode*>(*c); - if (pn->isAttached()) - insert(qmlattachedproperties,*c,style, status); - else - insert(qmlproperties,*c,style, status); - } - else if ((*c)->isQmlSignal() || (*c)->isJsSignal()) { - const FunctionNode* sn = static_cast<const FunctionNode*>(*c); - if (sn->isAttached()) - insert(qmlattachedsignals,*c,style, status); - else - insert(qmlsignals,*c,style, status); - } - else if ((*c)->isQmlSignalHandler() || (*c)->isJsSignalHandler()) { - insert(qmlsignalhandlers,*c,style, status); - } - else if ((*c)->isQmlMethod() || (*c)->isJsMethod()) { - const FunctionNode* mn = static_cast<const FunctionNode*>(*c); - if (mn->isAttached()) - insert(qmlattachedmethods,*c,style, status); - else - insert(qmlmethods,*c,style, status); - } - ++c; - } - if (qcn->qmlBaseNode() != 0) { - qcn = static_cast<QmlTypeNode*>(qcn->qmlBaseNode()); - if (!qcn->isAbstract()) - qcn = 0; - } - else - qcn = 0; - } - append(sections,qmlproperties); - append(sections,qmlattachedproperties); - append(sections,qmlsignals); - append(sections,qmlsignalhandlers); - append(sections,qmlattachedsignals); - append(sections,qmlmethods); - append(sections,qmlattachedmethods); - } - else { - /* - This is where the list of all members including inherited - members is prepared. - */ - ClassMap* classMap = 0; - FastSection all(aggregate,QString(),QString(),"member","members"); - Aggregate* current = aggregate; - while (current != 0) { - /* - If the QML type is abstract, do not create - a new entry in the list for it. Instead, - add its members to the current entry. - - However, if the first class is abstract, - there is no current entry. In that case, - create a new entry in the list anyway. - I'm not sure that is correct, but it at - least can prevent a crash. - */ - if (!current->isAbstract() || !classMap) { - classMap = new ClassMap; - classMap->first = static_cast<const QmlTypeNode*>(current); - all.classMapList_.append(classMap); - } - NodeList::ConstIterator c = current->childNodes().constBegin(); - while (c != current->childNodes().constEnd()) { - if ((*c)->isQmlPropertyGroup() || (*c)->isJsPropertyGroup()) { - const QmlPropertyGroupNode* qpgn = static_cast<const QmlPropertyGroupNode*>(*c); - NodeList::ConstIterator p = qpgn->childNodes().constBegin(); - while (p != qpgn->childNodes().constEnd()) { - if ((*p)->isQmlProperty() || (*c)->isJsProperty()) { - QString key = (*p)->name(); - key = sortName(*p, &key); - all.memberMap.insert(key,*p); - classMap->second.insert(key,*p); - } - ++p; - } - } - else { - QString key = (*c)->name(); - key = sortName(*c, &key); - all.memberMap.insert(key,*c); - classMap->second.insert(key,*c); - } - ++c; - } - if (current->qmlBaseNode() == current) { - qDebug() << "qdoc internal error: circular type definition." - << "QML type" << current->name() - << "can't be its own base type"; - break; - } - current = current->qmlBaseNode(); - while (current) { - if (current->isAbstract()) - break; - if (current->isInternal()) - current = current->qmlBaseNode(); - else - break; - } - } - append(sections, all, true); - } - } - - return sections; -} - QT_END_NAMESPACE diff --git a/src/qdoc/cppcodemarker.h b/src/qdoc/cppcodemarker.h index 5b9f4970e..4c9102a6c 100644 --- a/src/qdoc/cppcodemarker.h +++ b/src/qdoc/cppcodemarker.h @@ -26,10 +26,6 @@ ** ****************************************************************************/ -/* - cppcodemarker.h -*/ - #ifndef CPPCODEMARKER_H #define CPPCODEMARKER_H @@ -49,12 +45,8 @@ public: bool recognizeExtension(const QString& ext) override; bool recognizeLanguage(const QString& lang) override; Atom::AtomType atomType() const override; - virtual QString markedUpCode(const QString& code, - const Node *relative, - const Location &location) override; - virtual QString markedUpSynopsis(const Node *node, - const Node *relative, - SynopsisStyle style) override; + QString markedUpCode(const QString& code, const Node *relative, const Location &location) override; + QString markedUpSynopsis(const Node *node, const Node *relative, Sections::Style style) override; QString markedUpQmlItem(const Node *node, bool summary) override; QString markedUpName(const Node *node) override; QString markedUpFullName(const Node *node, const Node *relative) override; @@ -62,17 +54,9 @@ public: QString markedUpIncludes(const QStringList& includes) override; QString functionBeginRegExp(const QString& funcName) override; QString functionEndRegExp(const QString& funcName) override; - virtual QList<Section> sections(const Aggregate *innerNode, - SynopsisStyle style, - Status status) override; - virtual QList<Section> qmlSections(Aggregate* aggregate, - SynopsisStyle style, - Status status = Okay) override; private: - QString addMarkUp(const QString& protectedCode, - const Node *relative, - const Location &location); + QString addMarkUp(const QString& protectedCode, const Node *relative, const Location &location); }; QT_END_NAMESPACE diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index dc879b829..e477b5789 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -871,13 +871,13 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << "<ul>\n"; s = sections.constBegin(); while (s != sections.constEnd()) { - if (!(*s).members.isEmpty()) { + if (!s->members_.isEmpty()) { out() << "<li>" << "<a href=\"#" - << Doc::canonicalTitle((*s).name) + << Doc::canonicalTitle(s->name_) << "\">" - << (*s).name + << s->name_ << "</a></li>\n"; } ++s; @@ -887,11 +887,11 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark int idx = 0; s = sections.constBegin(); while (s != sections.constEnd()) { - if (!(*s).members.isEmpty()) { + if (!s->members_.isEmpty()) { out() << "<a name=\"" - << Doc::canonicalTitle((*s).name) + << Doc::canonicalTitle(s->name_) << "\"></a>\n"; - out() << "<h3>" << protectEnc((*s).name) << "</h3>\n"; + out() << "<h3>" << protectEnc(s->name_) << "</h3>\n"; if (idx == Class) generateCompactList(Generic, 0, ncmap, false, QStringLiteral("Q")); else if (idx == QmlClass) @@ -899,8 +899,8 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark else if (idx == MemberFunction) { ParentMaps parentmaps; ParentMaps::iterator pmap; - NodeList::const_iterator i = s->members.constBegin(); - while (i != s->members.constEnd()) { + NodeList::const_iterator i = s->members_.constBegin(); + while (i != s->members_.constEnd()) { Node* p = (*i)->parent(); pmap = parentmaps.find(p); if (pmap == parentmaps.end()) @@ -920,13 +920,13 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << protectEnc(pieces.last()); out() << "</a>" << ":</p>\n"; - generateSection(nlist, 0, marker, CodeMarker::Summary); + generateSection(nlist, 0, marker, Sections::Summary); out() << "<br/>"; ++pmap; } } else - generateSection(s->members, 0, marker, CodeMarker::Summary); + generateSection(s->members_, 0, marker, Sections::Summary); } ++idx; ++s; @@ -1422,7 +1422,7 @@ void HtmlGenerator::generateCppReferencePage(Node* node, CodeMarker* marker) generateHeader(title, aggregate, marker); - sections = marker->sections(aggregate, CodeMarker::Summary, CodeMarker::Okay); + sections = Sections::getStdCppSections(aggregate, Sections::Summary, Sections::Okay); generateTableOfContents(aggregate,marker,§ions); generateKeywordAnchors(aggregate); generateTitle(title, subtitleText, SmallSubTitle, aggregate, marker); @@ -1454,7 +1454,7 @@ void HtmlGenerator::generateCppReferencePage(Node* node, CodeMarker* marker) QString obsoleteLink = generateLowStatusMemberFile(aggregate, marker, - CodeMarker::Obsolete); + Sections::Obsolete); if (!obsoleteLink.isEmpty()) { out() << "<li><a href=\"" << obsoleteLink << "\">" << "Obsolete members</a></li>\n"; @@ -1462,7 +1462,7 @@ void HtmlGenerator::generateCppReferencePage(Node* node, CodeMarker* marker) QString compatLink = generateLowStatusMemberFile(aggregate, marker, - CodeMarker::Compat); + Sections::Compat); if (!compatLink.isEmpty()) out() << "<li><a href=\"" << compatLink << "\">" << "Compatibility members</a></li>\n"; @@ -1477,28 +1477,28 @@ void HtmlGenerator::generateCppReferencePage(Node* node, CodeMarker* marker) */ s = sections.constBegin(); while (s != sections.constEnd()) { - if (s->members.isEmpty() && s->reimpMembers.isEmpty()) { - if (!s->inherited.isEmpty()) + if (s->members_.isEmpty() && s->reimpMembers_.isEmpty()) { + if (!s->inherited_.isEmpty()) needOtherSection = true; } else { - if (!s->members.isEmpty()) { + if (!s->members_.isEmpty()) { // out() << "<hr />\n"; - QString ref = registerRef((*s).name.toLower()); + QString ref = registerRef(s->name_.toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; - out() << "<h2 id=\"" << ref << "\">" << protectEnc((*s).name) << "</h2>\n"; - generateSection(s->members, aggregate, marker, CodeMarker::Summary); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->name_) << "</h2>\n"; + generateSection(s->members_, aggregate, marker, Sections::Summary); } - if (!s->reimpMembers.isEmpty()) { - QString name = QString("Reimplemented ") + (*s).name; + if (!s->reimpMembers_.isEmpty()) { + QString name = QString("Reimplemented ") + s->name_; QString ref = registerRef(name.toLower()); // out() << "<hr />\n"; out() << "<a name=\"" << ref << "\"></a>" << divNavTop << "\n"; out() << "<h2 id=\"" << ref << "\">" << protectEnc(name) << "</h2>\n"; - generateSection(s->reimpMembers, aggregate, marker, CodeMarker::Summary); + generateSection(s->reimpMembers_, aggregate, marker, Sections::Summary); } - if (!s->inherited.isEmpty()) { + if (!s->inherited_.isEmpty()) { out() << "<ul>\n"; generateSectionInheritedList(*s, aggregate); out() << "</ul>\n"; @@ -1513,7 +1513,7 @@ void HtmlGenerator::generateCppReferencePage(Node* node, CodeMarker* marker) s = sections.constBegin(); while (s != sections.constEnd()) { - if (s->members.isEmpty() && !s->inherited.isEmpty()) + if (s->members_.isEmpty() && !s->inherited_.isEmpty()) generateSectionInheritedList(*s, aggregate); ++s; } @@ -1535,16 +1535,16 @@ void HtmlGenerator::generateCppReferencePage(Node* node, CodeMarker* marker) generateExtractionMark(aggregate, EndMark); } - sections = marker->sections(aggregate, CodeMarker::Detailed, CodeMarker::Okay); + sections = Sections::getStdCppSections(aggregate, Sections::Detailed, Sections::Okay); s = sections.constBegin(); while (s != sections.constEnd()) { //out() << "<hr />\n"; - if (!(*s).divClass.isEmpty()) - out() << "<div class=\"" << (*s).divClass << "\">\n"; // QTBUG-9504 - out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; + if (!s->divClass_.isEmpty()) + out() << "<div class=\"" << s->divClass_ << "\">\n"; // QTBUG-9504 + out() << "<h2>" << protectEnc(s->name_) << "</h2>\n"; - NodeList::ConstIterator m = (*s).members.constBegin(); - while (m != (*s).members.constEnd()) { + NodeList::ConstIterator m = s->members_.constBegin(); + while (m != s->members_.constEnd()) { if ((*m)->access() != Node::Private) { // ### check necessary? if ((*m)->type() != Node::Class) generateDetailedMember(*m, aggregate, marker); @@ -1588,7 +1588,7 @@ void HtmlGenerator::generateCppReferencePage(Node* node, CodeMarker* marker) } ++m; } - if (!(*s).divClass.isEmpty()) + if (!s->divClass_.isEmpty()) out() << "</div>\n"; // QTBUG-9504 ++s; } @@ -1611,7 +1611,7 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode* qcn, CodeMarker* marker) htmlTitle += " QML Type"; generateHeader(htmlTitle, qcn, marker); - QList<Section> sections = marker->qmlSections(qcn, CodeMarker::Summary); + QList<Section> sections = Sections::getStdQmlSections(qcn, Sections::Summary); generateTableOfContents(qcn, marker, §ions); marker = CodeMarker::markerForLanguage(QLatin1String("QML")); generateKeywordAnchors(qcn); @@ -1620,7 +1620,7 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode* qcn, CodeMarker* marker) generateQmlRequisites(qcn, marker); QString allQmlMembersLink = generateAllQmlMembersFile(qcn, marker); - QString obsoleteLink = generateQmlMemberFile(qcn, marker, CodeMarker::Obsolete); + QString obsoleteLink = generateQmlMemberFile(qcn, marker, Sections::Obsolete); if (!allQmlMembersLink.isEmpty() || !obsoleteLink.isEmpty()) { out() << "<ul>\n"; if (!allQmlMembersLink.isEmpty()) { @@ -1636,10 +1636,10 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode* qcn, CodeMarker* marker) s = sections.constBegin(); while (s != sections.constEnd()) { - QString ref = registerRef((*s).name.toLower()); + QString ref = registerRef(s->name_.toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc((*s).name) << "</h2>\n"; + out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->name_) << "</h2>\n"; generateQmlSummary(*s, qcn, marker); ++s; } @@ -1656,12 +1656,12 @@ void HtmlGenerator::generateQmlTypePage(QmlTypeNode* qcn, CodeMarker* marker) generateExtractionMark(qcn, EndMark); //out() << "<hr />\n"; - sections = marker->qmlSections(qcn,CodeMarker::Detailed); + sections = Sections::getStdQmlSections(qcn, Sections::Detailed); s = sections.constBegin(); while (s != sections.constEnd()) { - out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; - NodeList::ConstIterator m = (*s).members.constBegin(); - while (m != (*s).members.constEnd()) { + out() << "<h2>" << protectEnc(s->name_) << "</h2>\n"; + NodeList::ConstIterator m = s->members_.constBegin(); + while (m != s->members_.constEnd()) { generateDetailedQmlMember(*m, qcn, marker); out() << "<br/>\n"; ++m; @@ -1689,7 +1689,7 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode* qbtn, CodeMarker* marker = CodeMarker::markerForLanguage(QLatin1String("QML")); generateHeader(htmlTitle, qbtn, marker); - QList<Section> sections = marker->qmlSections(qbtn, CodeMarker::Summary); + QList<Section> sections = Sections::getStdQmlSections(qbtn, Sections::Summary); generateTableOfContents(qbtn,marker,§ions); generateKeywordAnchors(qbtn); generateTitle(htmlTitle, @@ -1700,10 +1700,10 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode* qbtn, CodeMarker* s = sections.constBegin(); while (s != sections.constEnd()) { - QString ref = registerRef((*s).name.toLower()); + QString ref = registerRef(s->name_.toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc((*s).name) << "</h2>\n"; + out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->name_) << "</h2>\n"; generateQmlSummary(*s, qbtn, marker); ++s; } @@ -1716,12 +1716,12 @@ void HtmlGenerator::generateQmlBasicTypePage(QmlBasicTypeNode* qbtn, CodeMarker* generateAlsoList(qbtn, marker); generateExtractionMark(qbtn, EndMark); - sections = marker->qmlSections(qbtn, CodeMarker::Detailed); + sections = Sections::getStdQmlSections(qbtn, Sections::Detailed); s = sections.constBegin(); while (s != sections.constEnd()) { - out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; - NodeList::ConstIterator m = (*s).members.constBegin(); - while (m != (*s).members.constEnd()) { + out() << "<h2>" << protectEnc(s->name_) << "</h2>\n"; + NodeList::ConstIterator m = s->members_.constBegin(); + while (m != s->members_.constEnd()) { generateDetailedQmlMember(*m, qbtn, marker); out() << "<br/>\n"; ++m; @@ -1783,7 +1783,7 @@ void HtmlGenerator::generateDocumentNode(DocumentNode* dn, CodeMarker* marker) QString obsoleteLink = generateLowStatusMemberFile(dn, marker, - CodeMarker::Obsolete); + Sections::Obsolete); if (!obsoleteLink.isEmpty()) { out() << "<li><a href=\"" << obsoleteLink << "\">" << "Obsolete members</a></li>\n"; @@ -1791,7 +1791,7 @@ void HtmlGenerator::generateDocumentNode(DocumentNode* dn, CodeMarker* marker) QString compatLink = generateLowStatusMemberFile(dn, marker, - CodeMarker::Compat); + Sections::Compat); if (!compatLink.isEmpty()) out() << "<li><a href=\"" << compatLink << "\">" << "Compatibility members</a></li>\n"; @@ -1799,13 +1799,13 @@ void HtmlGenerator::generateDocumentNode(DocumentNode* dn, CodeMarker* marker) out() << "</ul>\n"; } - sections = marker->sections(dn, CodeMarker::Summary, CodeMarker::Okay); + sections = Sections::getStdCppSections(dn, Sections::Summary, Sections::Okay); s = sections.constBegin(); while (s != sections.constEnd()) { - QString ref = registerRef((*s).name); + QString ref = registerRef(s->name_); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc((*s).name) << "</h2>\n"; - generateSectionList(*s, dn, marker, CodeMarker::Summary); + out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->name_) << "</h2>\n"; + generateSectionList(*s, dn, marker, Sections::Summary); ++s; } @@ -1817,14 +1817,14 @@ void HtmlGenerator::generateDocumentNode(DocumentNode* dn, CodeMarker* marker) generateAlsoList(dn, marker); generateExtractionMark(dn, EndMark); - sections = marker->sections(dn, CodeMarker::Detailed, CodeMarker::Okay); + sections = Sections::getStdCppSections(dn, Sections::Detailed, Sections::Okay); s = sections.constBegin(); while (s != sections.constEnd()) { //out() << "<hr />\n"; - out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; + out() << "<h2>" << protectEnc(s->name_) << "</h2>\n"; - NodeList::ConstIterator m = (*s).members.constBegin(); - while (m != (*s).members.constEnd()) { + NodeList::ConstIterator m = s->members_.constBegin(); + while (m != s->members_.constEnd()) { generateDetailedMember(*m, dn, marker); ++m; } @@ -2545,21 +2545,21 @@ void HtmlGenerator::generateTableOfContents(const Node *node, node->isJsType())) { QList<Section>::ConstIterator s = sections->constBegin(); while (s != sections->constEnd()) { - if (!s->members.isEmpty()) { + if (!s->members_.isEmpty()) { out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" - << registerRef((*s).pluralMember) - << "\">" << (*s).name + << registerRef(s->plural_) + << "\">" << s->name_ << "</a></li>\n"; } - if (!s->reimpMembers.isEmpty()) { - QString ref = QString("Reimplemented ") + (*s).pluralMember; + if (!s->reimpMembers_.isEmpty()) { + QString ref = QString("Reimplemented ") + s->plural_; out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" << registerRef(ref.toLower()) - << "\">" << QString("Reimplemented ") + (*s).name + << "\">" << QString("Reimplemented ") + s->name_ << "</a></li>\n"; } ++s; @@ -2622,9 +2622,7 @@ QString HtmlGenerator::generateListOfAllMemberFile(const Aggregate *aggregate, QList<Section> sections; QList<Section>::ConstIterator s; - sections = marker->sections(aggregate, - CodeMarker::Subpage, - CodeMarker::Okay); + sections = Sections::getStdCppSections(aggregate, Sections::Subpage, Sections::Okay); if (sections.isEmpty()) return QString(); @@ -2639,7 +2637,7 @@ QString HtmlGenerator::generateListOfAllMemberFile(const Aggregate *aggregate, out() << ", including inherited members.</p>\n"; Section section = sections.first(); - generateSectionList(section, aggregate, marker, CodeMarker::Subpage); + generateSectionList(section, aggregate, marker, Sections::Subpage); generateFooter(); endSubPage(); @@ -2656,7 +2654,7 @@ QString HtmlGenerator::generateAllQmlMembersFile(QmlTypeNode* qml_cn, CodeMarker QList<Section> sections; QList<Section>::ConstIterator s; - sections = marker->qmlSections(qml_cn,CodeMarker::Subpage); + sections = Sections::getStdQmlSections(qml_cn, Sections::Subpage); if (sections.isEmpty()) return QString(); @@ -2699,7 +2697,7 @@ QString HtmlGenerator::generateAllQmlMembersFile(QmlTypeNode* qml_cn, CodeMarker generateQmlItem(nodes[j], qml_cn, marker, true); if (nodes[j]->isAttached()) out() << " [attached]"; - //generateSynopsis(nodes[j], qcn, marker, CodeMarker::Subpage, false, &prefix); + //generateSynopsis(nodes[j], qcn, marker, Sections::Subpage, false, &prefix); out() << "</li>\n"; } out() << "</ul>\n"; @@ -2713,14 +2711,12 @@ QString HtmlGenerator::generateAllQmlMembersFile(QmlTypeNode* qml_cn, CodeMarker QString HtmlGenerator::generateLowStatusMemberFile(Aggregate *aggregate, CodeMarker *marker, - CodeMarker::Status status) + Sections::Status status) { - QList<Section> sections = marker->sections(aggregate, - CodeMarker::Summary, - status); + QList<Section> sections = Sections::getStdCppSections(aggregate, Sections::Summary, status); QMutableListIterator<Section> j(sections); while (j.hasNext()) { - if (j.next().members.size() == 0) + if (j.next().members_.size() == 0) j.remove(); } if (sections.isEmpty()) @@ -2731,7 +2727,7 @@ QString HtmlGenerator::generateLowStatusMemberFile(Aggregate *aggregate, QString title; QString fileName; - if (status == CodeMarker::Compat) { + if (status == Sections::Compat) { title = "Compatibility Members for " + aggregate->name(); fileName = fileBase(aggregate) + "-compat." + fileExtension(); } @@ -2739,7 +2735,7 @@ QString HtmlGenerator::generateLowStatusMemberFile(Aggregate *aggregate, title = "Obsolete Members for " + aggregate->name(); fileName = fileBase(aggregate) + "-obsolete." + fileExtension(); } - if (status == CodeMarker::Obsolete) { + if (status == Sections::Obsolete) { QString link; if (useOutputSubdirs() && !Generator::outputSubdir().isEmpty()) link = QString("../" + Generator::outputSubdir() + QLatin1Char('/')); @@ -2752,7 +2748,7 @@ QString HtmlGenerator::generateLowStatusMemberFile(Aggregate *aggregate, generateSidebar(); generateTitle(title, Text(), SmallSubTitle, aggregate, marker); - if (status == CodeMarker::Compat) { + if (status == Sections::Compat) { out() << "<p><b>The following members of class " << "<a href=\"" << linkForNode(aggregate, 0) << "\">" << protectEnc(aggregate->name()) << "</a>" @@ -2770,17 +2766,17 @@ QString HtmlGenerator::generateLowStatusMemberFile(Aggregate *aggregate, } for (i = 0; i < sections.size(); ++i) { - out() << "<h2>" << protectEnc(sections.at(i).name) << "</h2>\n"; - generateSectionList(sections.at(i), aggregate, marker, CodeMarker::Summary); + out() << "<h2>" << protectEnc(sections.at(i).name_) << "</h2>\n"; + generateSectionList(sections.at(i), aggregate, marker, Sections::Summary); } - sections = marker->sections(aggregate, CodeMarker::Detailed, status); + sections = Sections::getStdCppSections(aggregate, Sections::Detailed, status); for (i = 0; i < sections.size(); ++i) { //out() << "<hr />\n"; - out() << "<h2>" << protectEnc(sections.at(i).name) << "</h2>\n"; + out() << "<h2>" << protectEnc(sections.at(i).name_) << "</h2>\n"; - NodeList::ConstIterator m = sections.at(i).members.constBegin(); - while (m != sections.at(i).members.constEnd()) { + NodeList::ConstIterator m = sections.at(i).members_.constBegin(); + while (m != sections.at(i).members_.constEnd()) { if ((*m)->access() != Node::Private) generateDetailedMember(*m, aggregate, marker); ++m; @@ -2798,16 +2794,16 @@ QString HtmlGenerator::generateLowStatusMemberFile(Aggregate *aggregate, the section lists, which are then traversed and output here. Note that this function currently only handles correctly the - case where \a status is \c {CodeMarker::Obsolete}. + case where \a status is \c {Sections::Obsolete}. */ QString HtmlGenerator::generateQmlMemberFile(QmlTypeNode* qcn, CodeMarker *marker, - CodeMarker::Status status) + Sections::Status status) { - QList<Section> sections = marker->qmlSections(qcn, CodeMarker::Summary, status); + QList<Section> sections = Sections::getStdQmlSections(qcn, Sections::Summary, status); QMutableListIterator<Section> j(sections); while (j.hasNext()) { - if (j.next().members.size() == 0) + if (j.next().members_.size() == 0) j.remove(); } if (sections.isEmpty()) @@ -2816,7 +2812,7 @@ QString HtmlGenerator::generateQmlMemberFile(QmlTypeNode* qcn, QString title = "Obsolete Members for " + qcn->name(); QString fileName = fileBase(qcn) + "-obsolete." + fileExtension(); - if (status == CodeMarker::Obsolete) { + if (status == Sections::Obsolete) { QString link; if (useOutputSubdirs() && !Generator::outputSubdir().isEmpty()) link = QString("../" + Generator::outputSubdir() + QLatin1Char('/')); @@ -2838,18 +2834,18 @@ QString HtmlGenerator::generateQmlMemberFile(QmlTypeNode* qcn, QList<Section>::const_iterator s = sections.constBegin(); while (s != sections.constEnd()) { - QString ref = registerRef((*s).name.toLower()); + QString ref = registerRef(s->name_.toLower()); out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n'; - out() << "<h2 id=\"" << ref << "\">" << protectEnc((*s).name) << "</h2>\n"; + out() << "<h2 id=\"" << ref << "\">" << protectEnc(s->name_) << "</h2>\n"; generateQmlSummary(*s, qcn, marker); ++s; } - sections = marker->qmlSections(qcn, CodeMarker::Detailed, status); + sections = Sections::getStdQmlSections(qcn, Sections::Detailed, status); QMutableListIterator<Section> k(sections); while (k.hasNext()) { - if (k.next().members.size() == 0) + if (k.next().members_.size() == 0) k.remove(); } if (sections.isEmpty()) @@ -2857,9 +2853,9 @@ QString HtmlGenerator::generateQmlMemberFile(QmlTypeNode* qcn, s = sections.constBegin(); while (s != sections.constEnd()) { - out() << "<h2>" << protectEnc((*s).name) << "</h2>\n"; - NodeList::ConstIterator m = (*s).members.constBegin(); - while (m != (*s).members.constEnd()) { + out() << "<h2>" << protectEnc(s->name_) << "</h2>\n"; + NodeList::ConstIterator m = s->members_.constBegin(); + while (m != s->members_.constEnd()) { generateDetailedQmlMember(*m, qcn, marker); out() << "<br/>\n"; ++m; @@ -3315,12 +3311,12 @@ void HtmlGenerator::generateList(const Node* relative, CodeMarker* marker, const void HtmlGenerator::generateSection(const NodeList& nl, const Node *relative, CodeMarker *marker, - CodeMarker::SynopsisStyle style) + Sections::Style style) { bool alignNames = true; if (!nl.isEmpty()) { bool twoColumn = false; - if (style == CodeMarker::Subpage) { + if (style == Sections::Subpage) { alignNames = false; twoColumn = (nl.count() >= 16); } @@ -3376,19 +3372,19 @@ void HtmlGenerator::generateSection(const NodeList& nl, void HtmlGenerator::generateSectionList(const Section& section, const Node *relative, CodeMarker *marker, - CodeMarker::SynopsisStyle style) + Sections::Style style) { bool alignNames = true; - if (!section.members.isEmpty()) { + if (!section.members_.isEmpty()) { bool hasPrivateSignals = false; bool isInvokable = false; bool twoColumn = false; - if (style == CodeMarker::Subpage) { + if (style == Sections::Subpage) { alignNames = false; - twoColumn = (section.members.count() >= 16); + twoColumn = (section.members_.count() >= 16); } - else if (section.members.first()->type() == Node::Property) { - twoColumn = (section.members.count() >= 5); + else if (section.members_.first()->type() == Node::Property) { + twoColumn = (section.members_.count() >= 5); alignNames = false; } if (alignNames) { @@ -3402,8 +3398,8 @@ void HtmlGenerator::generateSectionList(const Section& section, } int i = 0; - NodeList::ConstIterator m = section.members.constBegin(); - while (m != section.members.constEnd()) { + NodeList::ConstIterator m = section.members_.constBegin(); + while (m != section.members_.constEnd()) { if ((*m)->access() == Node::Private) { ++m; continue; @@ -3413,15 +3409,15 @@ void HtmlGenerator::generateSectionList(const Section& section, out() << "<tr><td class=\"memItemLeft topAlign rightAlign\"> "; } else { - if (twoColumn && i == (int) (section.members.count() + 1) / 2) + if (twoColumn && i == (int) (section.members_.count() + 1) / 2) out() << "</ul></td><td class=\"topAlign\"><ul>\n"; out() << "<li class=\"fn\">"; } QString prefix; - if (!section.keys.isEmpty()) { - prefix = section.keys.at(i).mid(1); - prefix = prefix.left(section.keys.at(i).indexOf("::")+1); + if (!section.keys_.isEmpty()) { + prefix = section.keys_.at(i).mid(1); + prefix = prefix.left(section.keys_.at(i).indexOf("::")+1); } generateSynopsis(*m, relative, marker, style, alignNames, &prefix); if ((*m)->isFunction()) { @@ -3459,7 +3455,7 @@ void HtmlGenerator::generateSectionList(const Section& section, } } - if (style == CodeMarker::Summary && !section.inherited.isEmpty()) { + if (style == Sections::Summary && !section.inherited_.isEmpty()) { out() << "<ul>\n"; generateSectionInheritedList(section, relative); out() << "</ul>\n"; @@ -3468,29 +3464,29 @@ void HtmlGenerator::generateSectionList(const Section& section, void HtmlGenerator::generateSectionInheritedList(const Section& section, const Node *relative) { - QList<QPair<Aggregate *, int> >::ConstIterator p = section.inherited.constBegin(); - while (p != section.inherited.constEnd()) { + QList<QPair<Aggregate *, int> >::ConstIterator p = section.inherited_.constBegin(); + while (p != section.inherited_.constEnd()) { out() << "<li class=\"fn\">"; out() << (*p).second << ' '; if ((*p).second == 1) { - out() << section.singularMember; + out() << section.singular_; } else { - out() << section.pluralMember; + out() << section.plural_; } out() << " inherited from <a href=\"" << fileName((*p).first) - << '#' << Generator::cleanRef(section.name.toLower()) << "\">" + << '#' << Generator::cleanRef(section.name_.toLower()) << "\">" << protectEnc((*p).first->plainFullName(relative)) << "</a></li>\n"; ++p; } } -// generateSynopsis(qmn,relative,marker,CodeMarker::Detailed,false); +// generateSynopsis(qmn,relative,marker,Sections::Detailed,false); void HtmlGenerator::generateSynopsis(const Node *node, const Node *relative, CodeMarker *marker, - CodeMarker::SynopsisStyle style, + Sections::Style style, bool alignNames, const QString* prefix) { @@ -3510,12 +3506,12 @@ void HtmlGenerator::generateSynopsis(const Node *node, marked.replace("<@param>", "<i>"); marked.replace("</@param>", "</i>"); - if (style == CodeMarker::Summary) { + if (style == Sections::Summary) { marked.remove("<@name>"); // was "<b>" marked.remove("</@name>"); // was "</b>" } - if (style == CodeMarker::Subpage) { + if (style == Sections::Subpage) { QRegExp extraRegExp("<@extra>.*</@extra>"); extraRegExp.setMinimal(true); marked.remove(extraRegExp); @@ -3524,7 +3520,7 @@ void HtmlGenerator::generateSynopsis(const Node *node, marked.replace("</@extra>", "</code>"); } - if (style != CodeMarker::Detailed) { + if (style != Sections::Detailed) { marked.remove("<@type>"); marked.remove("</@type>"); } @@ -4047,7 +4043,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, nodeRef = refForNode(n); out() << "<h3 class=\"fn fngroupitem\" id=\"" << nodeRef << "\">"; out() << "<a name=\"" + nodeRef + "\"></a>"; - generateSynopsis(n, relative, marker, CodeMarker::Detailed); + generateSynopsis(n, relative, marker, Sections::Detailed); out() << "</h3>"; } } @@ -4063,15 +4059,15 @@ void HtmlGenerator::generateDetailedMember(const Node *node, #endif out() << "<h3 class=\"flags\" id=\"" << nodeRef << "\">"; out() << "<a name=\"" + nodeRef + "\"></a>"; - generateSynopsis(etn, relative, marker, CodeMarker::Detailed); + generateSynopsis(etn, relative, marker, Sections::Detailed); out() << "<br/>"; - generateSynopsis(etn->flagsType(), relative, marker, CodeMarker::Detailed); + generateSynopsis(etn->flagsType(), relative, marker, Sections::Detailed); out() << "</h3>\n"; } else { out() << "<h3 class=\"fn\" id=\"" << nodeRef << "\">"; out() << "<a name=\"" + nodeRef + "\"></a>"; - generateSynopsis(node, relative, marker, CodeMarker::Detailed); + generateSynopsis(node, relative, marker, Sections::Detailed); out() << "</h3>" << divNavTop << '\n'; } } @@ -4086,22 +4082,22 @@ void HtmlGenerator::generateDetailedMember(const Node *node, const PropertyNode *property = static_cast<const PropertyNode *>(node); Section section; - section.members += property->getters(); - section.members += property->setters(); - section.members += property->resetters(); + section.members_ += property->getters(); + section.members_ += property->setters(); + section.members_ += property->resetters(); - if (!section.members.isEmpty()) { + if (!section.members_.isEmpty()) { out() << "<p><b>Access functions:</b></p>\n"; - generateSectionList(section, node, marker, CodeMarker::Accessors); + generateSectionList(section, node, marker, Sections::Accessors); } Section notifiers; - notifiers.members += property->notifiers(); + notifiers.members_ += property->notifiers(); - if (!notifiers.members.isEmpty()) { + if (!notifiers.members_.isEmpty()) { out() << "<p><b>Notifier signal:</b></p>\n"; //out() << "<p>This signal is emitted when the property value is changed.</p>\n"; - generateSectionList(notifiers, node, marker, CodeMarker::Accessors); + generateSectionList(notifiers, node, marker, Sections::Accessors); } } else if (node->isFunction()) { @@ -4257,11 +4253,11 @@ void HtmlGenerator::generateQmlSummary(const Section& section, const Node *relative, CodeMarker *marker) { - if (!section.members.isEmpty()) { + if (!section.members_.isEmpty()) { out() << "<ul>\n"; NodeList::ConstIterator m; - m = section.members.constBegin(); - while (m != section.members.constEnd()) { + m = section.members_.constBegin(); + while (m != section.members_.constEnd()) { out() << "<li class=\"fn\">"; generateQmlItem(*m,relative,marker,true); if ((*m)->type() == Node::QmlPropertyGroup) { @@ -4364,7 +4360,7 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, node->type() == Node::QmlSignalHandler || node->type() == Node::QmlMethod) { out() << qmlItemHeader.arg(nodeRef, "tblQmlFuncNode", refForNode(node)); - generateSynopsis(node, relative, marker, CodeMarker::Detailed, false); + generateSynopsis(node, relative, marker, Sections::Detailed, false); out() << qmlItemFooter; } out() << "<div class=\"qmldoc\">"; diff --git a/src/qdoc/htmlgenerator.h b/src/qdoc/htmlgenerator.h index aa9ef2903..df949261e 100644 --- a/src/qdoc/htmlgenerator.h +++ b/src/qdoc/htmlgenerator.h @@ -154,10 +154,10 @@ private: QString generateAllQmlMembersFile(QmlTypeNode* qml_cn, CodeMarker* marker); QString generateLowStatusMemberFile(Aggregate *inner, CodeMarker *marker, - CodeMarker::Status status); + Sections::Status status); QString generateQmlMemberFile(QmlTypeNode* qcn, CodeMarker *marker, - CodeMarker::Status status); + Sections::Status status); void generateClassHierarchy(const Node *relative, NodeMap &classMap); void generateAnnotatedList(const Node* relative, CodeMarker* marker, const NodeMultiMap& nodeMap); void generateAnnotatedLists(const Node* relative, CodeMarker* marker, const NodeMultiMap& nodeMap); @@ -173,7 +173,7 @@ private: void generateSectionList(const Section& section, const Node *relative, CodeMarker *marker, - CodeMarker::SynopsisStyle style); + Sections::Style style); void generateQmlSummary(const Section& section, const Node *relative, CodeMarker *marker); @@ -191,11 +191,11 @@ private: void generateSection(const NodeList& nl, const Node *relative, CodeMarker *marker, - CodeMarker::SynopsisStyle style); + Sections::Style style); void generateSynopsis(const Node *node, const Node *relative, CodeMarker *marker, - CodeMarker::SynopsisStyle style, + Sections::Style style, bool alignNames = false, const QString* prefix = 0); void generateSectionInheritedList(const Section& section, const Node *relative); diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index 563915d49..f13412333 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -39,7 +39,6 @@ #include "loggingcategory.h" #include "webxmlgenerator.h" #include "location.h" -#include "plaincodemarker.h" #include "puredocparser.h" #include "tokenizer.h" #include "tree.h" diff --git a/src/qdoc/node.h b/src/qdoc/node.h index e6d6d2de8..a5ae1d3a9 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -427,7 +427,7 @@ public: QString outputFileName() const override { return outputFileName_; } QmlPropertyNode* hasQmlProperty(const QString& ) const override; QmlPropertyNode* hasQmlProperty(const QString&, bool attached) const override; - virtual QmlTypeNode* qmlBaseNode() { return 0; } + virtual QmlTypeNode* qmlBaseNode() const { return 0; } void addChild(Node* child, const QString& title); const QStringList& groupNames() const { return groupNames_; } void appendGroupName(const QString& t) override { groupNames_.append(t); } @@ -684,7 +684,7 @@ public: const QString& qmlBaseName() const { return qmlBaseName_; } void setQmlBaseName(const QString& name) { qmlBaseName_ = name; } bool qmlBaseNodeNotSet() const { return (qmlBaseNode_ == 0); } - QmlTypeNode* qmlBaseNode() override { return qmlBaseNode_; } + QmlTypeNode* qmlBaseNode() const override { return qmlBaseNode_; } void setQmlBaseNode(QmlTypeNode* b) { qmlBaseNode_ = b; } void requireCppClass() { cnodeRequired_ = true; } bool cppClassRequired() const { return cnodeRequired_; } diff --git a/src/qdoc/openedlist.cpp b/src/qdoc/openedlist.cpp index 99a8ec827..79a0e8a63 100644 --- a/src/qdoc/openedlist.cpp +++ b/src/qdoc/openedlist.cpp @@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE static const char roman[] = "m\2d\5c\2l\5x\2v\5i"; -OpenedList::OpenedList( Style style ) +OpenedList::OpenedList( ListStyle style ) : sty( style ), ini( 1 ), nex( 0 ) { } diff --git a/src/qdoc/openedlist.h b/src/qdoc/openedlist.h index 8b584658c..77f134a9b 100644 --- a/src/qdoc/openedlist.h +++ b/src/qdoc/openedlist.h @@ -44,18 +44,18 @@ class OpenedList Q_DECLARE_TR_FUNCTIONS(QDoc::OpenedList) public: - enum Style { Bullet, Tag, Value, Numeric, UpperAlpha, LowerAlpha, - UpperRoman, LowerRoman }; + enum ListStyle { Bullet, Tag, Value, Numeric, UpperAlpha, LowerAlpha, + UpperRoman, LowerRoman }; OpenedList() : sty( Bullet ), ini( 1 ), nex( 0 ) { } - OpenedList( Style style ); + OpenedList( ListStyle style ); OpenedList( const Location& location, const QString& hint ); void next() { nex++; } bool isStarted() const { return nex >= ini; } - Style style() const { return sty; } + ListStyle style() const { return sty; } QString styleString() const; int number() const { return nex; } QString numberString() const; @@ -68,7 +68,7 @@ private: static QString toRoman( int n ); static int fromRoman( const QString& str ); - Style sty; + ListStyle sty; int ini; int nex; QString pref; diff --git a/src/qdoc/plaincodemarker.cpp b/src/qdoc/plaincodemarker.cpp deleted file mode 100644 index b2aa9d5f4..000000000 --- a/src/qdoc/plaincodemarker.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "plaincodemarker.h" - -QT_BEGIN_NAMESPACE - -PlainCodeMarker::PlainCodeMarker() -{ -} - -PlainCodeMarker::~PlainCodeMarker() -{ -} - -bool PlainCodeMarker::recognizeCode( const QString& /* code */ ) -{ - return true; -} - -bool PlainCodeMarker::recognizeExtension( const QString& /* ext */ ) -{ - return true; -} - -bool PlainCodeMarker::recognizeLanguage( const QString& /* lang */ ) -{ - return false; -} - -Atom::AtomType PlainCodeMarker::atomType() const -{ - return Atom::Code; -} - -QString PlainCodeMarker::markedUpCode( const QString& code, - const Node * /* relative */, - const Location & /* location */ ) -{ - return protect( code ); -} - -QString PlainCodeMarker::markedUpSynopsis( const Node * /* node */, - const Node * /* relative */, - SynopsisStyle /* style */ ) -{ - return "foo"; -} - -QString PlainCodeMarker::markedUpName( const Node * /* node */ ) -{ - return QString(); -} - -QString PlainCodeMarker::markedUpFullName( const Node * /* node */, - const Node * /* relative */ ) -{ - return QString(); -} - -QString PlainCodeMarker::markedUpEnumValue(const QString & /* enumValue */, - const Node * /* relative */) -{ - return QString(); -} - -QString PlainCodeMarker::markedUpIncludes( const QStringList& /* includes */ ) -{ - return QString(); -} - -QString PlainCodeMarker::functionBeginRegExp( const QString& /* funcName */ ) -{ - return QString(); -} - -QString PlainCodeMarker::functionEndRegExp( const QString& /* funcName */ ) -{ - return QString(); -} - -QList<Section> PlainCodeMarker::sections(const Aggregate * /* innerNode */, - SynopsisStyle /* style */, - Status /* status */) -{ - return QList<Section>(); -} - -QT_END_NAMESPACE diff --git a/src/qdoc/plaincodemarker.h b/src/qdoc/plaincodemarker.h deleted file mode 100644 index cb831b315..000000000 --- a/src/qdoc/plaincodemarker.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - plaincodemarker.h -*/ - -#ifndef PLAINCODEMARKER_H -#define PLAINCODEMARKER_H - -#include "codemarker.h" - -QT_BEGIN_NAMESPACE - -class PlainCodeMarker : public CodeMarker -{ -public: - PlainCodeMarker(); - ~PlainCodeMarker(); - - bool recognizeCode( const QString& code ) override; - bool recognizeExtension( const QString& ext ) override; - bool recognizeLanguage( const QString& lang ) override; - Atom::AtomType atomType() const override; - QString markedUpCode( const QString& code, const Node *relative, const Location &location ) override; - QString markedUpSynopsis( const Node *node, const Node *relative, - SynopsisStyle style ) override; - QString markedUpName( const Node *node ) override; - QString markedUpFullName( const Node *node, const Node *relative ) override; - QString markedUpEnumValue(const QString &enumValue, const Node *relative) override; - QString markedUpIncludes( const QStringList& includes ) override; - QString functionBeginRegExp( const QString& funcName ) override; - QString functionEndRegExp( const QString& funcName ) override; - QList<Section> sections(const Aggregate *innerNode, SynopsisStyle style, Status status) override; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/qdoc/qdoc.pro b/src/qdoc/qdoc.pro index 229c2c676..c88074a66 100644 --- a/src/qdoc/qdoc.pro +++ b/src/qdoc/qdoc.pro @@ -56,12 +56,12 @@ HEADERS += atom.h \ loggingcategory.h \ node.h \ openedlist.h \ - plaincodemarker.h \ puredocparser.h \ qdocdatabase.h \ qdoctagfiles.h \ qdocindexfiles.h \ quoter.h \ + sections.h \ separator.h \ text.h \ tokenizer.h \ @@ -85,12 +85,12 @@ SOURCES += atom.cpp \ main.cpp \ node.cpp \ openedlist.cpp \ - plaincodemarker.cpp \ puredocparser.cpp \ qdocdatabase.cpp \ qdoctagfiles.cpp \ qdocindexfiles.cpp \ quoter.cpp \ + sections.cpp \ separator.cpp \ text.cpp \ tokenizer.cpp \ diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp new file mode 100644 index 000000000..c91ae72ef --- /dev/null +++ b/src/qdoc/sections.cpp @@ -0,0 +1,896 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qobjectdefs.h> +#include "sections.h" +#include "config.h" +#include <qdebug.h> +#include <stdio.h> + +QT_BEGIN_NAMESPACE + +const Aggregate *Sections::aggregate_ = 0; + +static FastSection privateFuncs("Private Functions", "private function", "private functions"); +static FastSection privateSlots("Private Slots", "private slot", "private slots"); +static FastSection privateTypes("Private Types", "private type", "private types"); +static FastSection protectedFuncs("Protected Functions", "protected function", "protected functions"); +static FastSection protectedSlots("Protected Slots", "protected slot", "protected slots"); +static FastSection protectedTypes("Protected Types", "protected type", "protected types"); +static FastSection protectedVars("Protected Variables", "protected type", "protected variables"); +static FastSection publicFuncs("Public Functions", "public function", "public functions"); +static FastSection publicSignals("Signals", "signal", "signals"); +static FastSection publicSlots("Public Slots", "public slot", "public slots"); +static FastSection publicTypes("Public Types", "public type", "public types"); +static FastSection publicVars("Public Variables", "public variable", "public variables"); +static FastSection properties("Properties", "property", "properties"); +static FastSection relatedNonMembs("Related Non-Members", "related non-member", "related non-members"); +static FastSection staticPrivMembs("Static Private Members", "static private member", "static private members"); +static FastSection staticProtMembs("Static Protected Members", "static protected member", "static protected members"); +static FastSection staticPubMembs("Static Public Members", "static public member", "static public members"); +static FastSection macros("Macros", "macro", "macros"); + +static FastSection detMemberFuncs("Member Function Documentation", "func", "member", "members"); +static FastSection detMemberTypes("Member Type Documentation", "types", "member", "members"); +static FastSection detMemberVars("Member Variable Documentation", "vars", "member", "members"); +static FastSection detProperties("Property Documentation", "prop", "member", "members"); +static FastSection detRelatedNonMembs("Related Non-Members", "relnonmem", "member", "members"); +static FastSection detMacros("Macro Documentation", "macros", "member", "members"); + +/*! + The destructor must delete each member of the + list of QML class lists, if it is not empty; + */ +Section::~Section() +{ + if (!classKeysNodesList_.isEmpty()) { + for (int i=0; i<classKeysNodesList_.size(); i++) { + ClassKeysNodes* classKeysNodes = classKeysNodesList_[i]; + classKeysNodesList_[i] = 0; + delete classKeysNodes; + } + } +} + +/*! + The destructor must delete the QML class maps in the class + map list, if the class map list is not empty. + */ +FastSection::~FastSection() +{ + clear(); +} + +/*! + The FastSection variables are now static variables so we + don't have to repeatedly construct and destroy them. But + we do need to clear them for each call to sections() or + qmlSections(). + */ +void FastSection::clear() +{ + memberMap_.clear(); + reimpMemberMap_.clear(); + if (!classMapList_.isEmpty()) { + for (int i=0; i<classMapList_.size(); i++) { + ClassMap* classMap = classMapList_[i]; + classMapList_[i] = 0; + delete classMap; + } + } + inherited_.clear(); +} + +/*! + \class Sections + \brief A class for creating a list of collections for documentation + + Each element in the list is a Section struct, which contains all the + elements that will be documented in a section of a reference page. + */ + +/*! + Construct a name for the \a node that can be used for sorting + a set of nodes into equivalence classes. If \a name is provided, + start with that name. Itherwise start with the name in \a node. + */ +QString Sections::sortName(const Node *node, const QString* name) +{ + QString nodeName; + if (name != 0) + nodeName = *name; + else + nodeName = node->name(); + int numDigits = 0; + for (int i = nodeName.size() - 1; i > 0; --i) { + if (nodeName.at(i).digitValue() == -1) + break; + ++numDigits; + } + + // we want 'qint8' to appear before 'qint16' + if (numDigits > 0) { + for (int i = 0; i < 4 - numDigits; ++i) + nodeName.insert(nodeName.size()-numDigits-1, QLatin1Char('0')); + } + + if (node->isFunction()) { + const FunctionNode *func = static_cast<const FunctionNode *>(node); + QString sortNo; + if (func->isSomeCtor()) + sortNo = QLatin1String("C"); + else if (func->isDtor()) + sortNo = QLatin1String("D"); + else if (nodeName.startsWith(QLatin1String("operator")) + && nodeName.length() > 8 + && !nodeName[8].isLetterOrNumber()) + sortNo = QLatin1String("F"); + else + sortNo = QLatin1String("E"); + return sortNo + nodeName + QLatin1Char(' ') + QString::number(func->overloadNumber(), 36); + } + + if (node->isClass()) + return QLatin1Char('A') + nodeName; + + if (node->isProperty() || node->isVariable()) + return QLatin1Char('E') + nodeName; + + if (node->isQmlMethod() || node->isQmlSignal() || node->isQmlSignalHandler()) + return QLatin1Char('E') + nodeName; + + return QLatin1Char('B') + nodeName; +} + +/*! + Insert the \a node into the temporary section \a fs. Whether + the \a node is actually inserted can depend on the \a style + and the \a status. + */ +void Sections::insert(FastSection &fs, Node *node, Style style, Status status) +{ + bool irrelevant = false; + bool inheritedMember = false; + if (!node->relates()) { + Aggregate* p = node->parent(); + if (p->isQmlPropertyGroup()) + p = p->parent(); + if (!p->isNamespace() && p != aggregate_) { + if ((!p->isQmlType() && !p->isJsType()) || !p->isAbstract()) + inheritedMember = true; + } + } + + if (node->isPrivate()) { + irrelevant = true; + } + else if (node->isFunction()) { + FunctionNode *func = (FunctionNode *) node; + irrelevant = (inheritedMember && (func->isSomeCtor() || func->isDtor())); + } + else if (node->isClass() || node->isEnumType() || node->isTypedef()) { + irrelevant = (inheritedMember && style != Subpage); + if (!irrelevant && style == Detailed && node->isTypedef()) { + const TypedefNode* tdn = static_cast<const TypedefNode*>(node); + if (tdn->associatedEnum()) + irrelevant = true; + } + } + + if (!irrelevant) { + if (status == Compat) { + irrelevant = (node->status() != Node::Compat); + } + else if (status == Obsolete) { + irrelevant = (node->status() != Node::Obsolete); + } + else { + irrelevant = (node->status() == Node::Compat || + node->status() == Node::Obsolete); + } + } + + if (!irrelevant) { + if (!inheritedMember || style == Subpage) { + QString key = sortName(node); + fs.memberMap_.insertMulti(key, node); + } + else { + if (node->parent()->isClass() || node->parent()->isNamespace()) { + if (fs.inherited_.isEmpty() || fs.inherited_.last().first != node->parent()) { + QPair<Aggregate *, int> p(node->parent(), 0); + fs.inherited_.append(p); + } + fs.inherited_.last().second++; + } + } + } +} + +/*! + Returns \c true if \a node represents a reimplemented member + function in the class of the FastSection \a fs. If it is + a reimplemented function, then it is inserted into the + reimplemented member map in \a fs. The test is performed + only if \a status is \e OK. True is returned if \a node + is inserted into the map. Otherwise, false is returned. + */ +bool Sections::insertReimpFunc(FastSection& fs, Node* node, Status status) +{ + if (!node->isPrivate() && (node->relates() == 0)) { + const FunctionNode* fn = static_cast<const FunctionNode*>(node); + if (!fn->reimplementedFrom().isEmpty() && (status == Okay)) { + if (fn->parent() == aggregate_) { + QString key = sortName(fn); + if (!fs.reimpMemberMap_.contains(key)) { + fs.reimpMemberMap_.insert(key,node); + return true; + } + } + } + } + return false; +} + +/*! + If \a fs is not empty, convert it to a Section and append + the new Section to \a sectionList. + */ +void Sections::append(QList<Section>& sectionList, const FastSection& fs, bool includeKeys) +{ + if (!fs.isEmpty()) { + Section section(fs.name_, fs.divClass_, fs.singular_, fs.plural_); + sectionList.append(section); + Section* s = §ionList[sectionList.size()-1]; + if (fs.classMapList_.isEmpty()) { + Section section(fs.name_, fs.divClass_, fs.singular_, fs.plural_); + if (includeKeys) + s->keys_ = fs.memberMap_.keys(); + s->members_ = fs.memberMap_.values(); + s->reimpMembers_ = fs.reimpMemberMap_.values(); + s->inherited_ = fs.inherited_; + } + else { + for (int i=0; i<fs.classMapList_.size(); i++) { + ClassMap* classMap = fs.classMapList_[i]; + ClassKeysNodes* ckn = new ClassKeysNodes; + ckn->first = classMap->first; + ckn->second.second = classMap->second.values(); + ckn->second.first = classMap->second.keys(); + s->classKeysNodesList_.append(ckn); + } + } + } +} + +static void clearClassSummaryVars() +{ + privateFuncs.clear(); + privateSlots.clear(); + privateTypes.clear(); + protectedFuncs.clear(); + protectedSlots.clear(); + protectedTypes.clear(); + protectedVars.clear(); + publicFuncs.clear(); + publicSignals.clear(); + publicSlots.clear(); + publicTypes.clear(); + publicVars.clear(); + properties.clear(); + relatedNonMembs.clear(); + staticPrivMembs.clear(); + staticProtMembs.clear(); + staticPubMembs.clear(); + macros.clear(); +} + +static void clearClassDetailedVars() +{ + detMemberFuncs.clear(); + detMemberTypes.clear(); + detMemberVars.clear(); + detProperties.clear(); + detRelatedNonMembs.clear(); + detMacros.clear(); +} + +QList<Section> Sections::getStdCppSections(const Aggregate *aggregate, Style style, Status status) +{ + QList<Section> sections; + setCurrentNode(aggregate); + if (aggregate->isClass()) { + if (style == Summary) + getCppClassStdSummarySections(sections, style, status); + else if (style == Detailed) + getCppClassStdDetailedSections(sections, style, status); + else + getAllCppClassMembers(sections, style, status); + } else if (style == Summary || style == Detailed) { + getAllStdCppSections(sections, style, status); + } + + return sections; +} + +void Sections::getAllStdCppSections(QList<Section> §ions, Style style, Status status) +{ + FastSection namespaces("Namespaces", + style == Detailed ? "nmspace" : QString(), + "namespace", + "namespaces"); + FastSection classes("Classes", + style == Detailed ? "classes" : QString(), + "class", + "classes"); + FastSection types(style == Summary ? "Types" : "Type Documentation", + style == Detailed ? "types" : QString(), + "type", + "types"); + FastSection variables(style == Summary ? "Variables" : "Variable Documentation", + style == Detailed ? "vars" : QString(), + "variable", + "variables"); + FastSection staticVars("Static Variables", + QString(), + "static variable", + "static variables"); + FastSection functions(style == Summary ? "Functions" : "Function Documentation", + style == Detailed ? "func" : QString(), + "function", + "functions"); + FastSection macros(style == Summary ? "Macros" : "Macro Documentation", + style == Detailed ? "macros" : QString(), + "macro", + "macros"); + + bool documentAll = true; + NodeList nodeList = aggregate_->childNodes(); + nodeList += aggregate_->relatedNodes(); + if (aggregate_->isNamespace()) { + const NamespaceNode* ns = static_cast<const NamespaceNode*>(aggregate_); + if (!ns->hasDoc()) + documentAll = false; + if (style == Summary) { + if (!ns->orphans().isEmpty()) + nodeList += ns->orphans(); + } + } + NodeList::ConstIterator c = nodeList.constBegin(); + while (c != nodeList.constEnd()) { + Node *n = *c; + if (documentAll || n->hasDoc()) { + switch (n->type()) { + case Node::Namespace: + insert(namespaces, n, style, status); + break; + case Node::Class: + insert(classes, n, style, status); + break; + case Node::Enum: + case Node::Typedef: + insert(types, n, style, status); + break; + case Node::Function: + { + FunctionNode *func = static_cast<FunctionNode *>(n); + if (func->isMacro()) + insert(macros, n, style, status); + else + insert(functions, n, style, status); + } + break; + case Node::Variable: + { + const VariableNode* var = static_cast<const VariableNode*>(n); + if (!var->doc().isEmpty()) { + if (var->isStatic()) + insert(staticVars, n, style, status); + else + insert(variables, n, style, status); + } + } + break; + case Node::SharedComment: + { + SharedCommentNode *scn = static_cast<SharedCommentNode *>(n); + if (!scn->doc().isEmpty()) + insert(functions, scn, style, status); + } + break; + default: + break; + } + } + ++c; + } + append(sections, namespaces); + append(sections, classes); + append(sections, types); + append(sections, variables); + append(sections, staticVars); + append(sections, functions); + append(sections, macros); +} + +void Sections::getCppClassStdSummarySections(QList<Section> §ions, Style style, Status status) +{ + clearClassSummaryVars(); + NodeList::ConstIterator r = aggregate_->relatedNodes().constBegin(); + while (r != aggregate_->relatedNodes().constEnd()) { + if ((*r)->isFunction()) { + FunctionNode *func = static_cast<FunctionNode *>(*r); + if (func->isMacro()) + insert(macros, *r, style, status); + else + insert(relatedNonMembs, *r, style, status); + } else { + insert(relatedNonMembs, *r, style, status); + } + ++r; + } + + bool documentAll = true; + if (aggregate_->parent() && !aggregate_->name().isEmpty() && !aggregate_->hasDoc()) + documentAll = false; + QStack<const Aggregate *> stack; + stack.push(aggregate_); + while (!stack.isEmpty()) { + const Aggregate* ancestor = stack.pop(); + NodeList::ConstIterator c = ancestor->childNodes().constBegin(); + while (c != ancestor->childNodes().constEnd()) { + Node* n = *c; + if (!documentAll && !n->hasDoc()) { + ++c; + continue; + } + bool isSlot = false; + bool isSignal = false; + bool isStatic = false; + if (n->isFunction()) { + const FunctionNode *func = (const FunctionNode *) n; + isSlot = (func->isSlot()); + isSignal = (func->isSignal()); + isStatic = func->isStatic(); + if (func->hasAssociatedProperties() && !func->hasActiveAssociatedProperty()) { + ++c; + continue; + } else if (func->isIgnored()) { + ++c; + continue; + } + } + else if (n->isVariable()) { + const VariableNode *var = static_cast<const VariableNode *>(n); + isStatic = var->isStatic(); + } else if (n->isTypedef()) { + if (n->name() == QLatin1String("QtGadgetHelper")) { + ++c; + continue; + } + } + + switch (n->access()) { + case Node::Public: + if (isSlot) { + insert(publicSlots, n, style, status); + } + else if (isSignal) { + insert(publicSignals, n, style, status); + } else if (isStatic) { + if (!n->isVariable() || !n->doc().isEmpty()) + insert(staticPubMembs, n, style, status); + } else if (n->isProperty()) { + insert(properties, n, style, status); + } else if (n->isVariable()) { + if (!n->doc().isEmpty()) + insert(publicVars, n, style, status); + } else if (n->isFunction()) { + if (!insertReimpFunc(publicFuncs,n,status)) + insert(publicFuncs, n, style, status); + } else if (!n->isSharedCommentNode()) { + insert(publicTypes, n, style, status); + } + break; + case Node::Protected: + if (isSlot) { + insert(protectedSlots, n, style, status); + } else if (isStatic) { + if (!n->isVariable() || !n->doc().isEmpty()) + insert(staticProtMembs, n, style, status); + } else if (n->isVariable()) { + if (!n->doc().isEmpty()) + insert(protectedVars, n, style, status); + } else if (n->isFunction()) { + if (!insertReimpFunc(protectedFuncs, n, status)) + insert(protectedFuncs, n, style, status); + } else { + insert(protectedTypes, n, style, status); + } + break; + case Node::Private: + if (isSlot) { + insert(privateSlots, n, style, status); + } else if (isStatic) { + if (!n->isVariable() || !n->doc().isEmpty()) + insert(staticPrivMembs, n, style, status); + } else if (n->isFunction()) { + if (!insertReimpFunc(privateFuncs, n, status)) + insert(privateFuncs, n, style, status); + } else { + insert(privateTypes, n, style, status); + } + } + ++c; + } + + if (ancestor->isClass()) { + const ClassNode* cn = static_cast<const ClassNode*>(ancestor); + QList<RelatedClass>::ConstIterator r = cn->baseClasses().constBegin(); + while (r != cn->baseClasses().constEnd()) { + if (r->node_) + stack.prepend(r->node_); + ++r; + } + } + } + append(sections, publicTypes); + append(sections, properties); + append(sections, publicFuncs); + append(sections, publicSlots); + append(sections, publicSignals); + append(sections, publicVars); + append(sections, staticPubMembs); + append(sections, protectedTypes); + append(sections, protectedFuncs); + append(sections, protectedSlots); + append(sections, protectedVars); + append(sections, staticProtMembs); + append(sections, privateTypes); + append(sections, privateFuncs); + append(sections, privateSlots); + append(sections, staticPrivMembs); + append(sections, relatedNonMembs); + append(sections, macros); +} + +void Sections::getCppClassStdDetailedSections(QList<Section> §ions, Style style, Status status) +{ + clearClassDetailedVars(); + NodeList::ConstIterator r = aggregate_->relatedNodes().constBegin(); + while (r != aggregate_->relatedNodes().constEnd()) { + Node* n = *r; + if (n->isFunction()) { + FunctionNode *func = static_cast<FunctionNode *>(n); + if (func->isMacro()) + insert(detMacros, n, style, status); + else if (!func->isSharingComment()) + insert(detRelatedNonMembs, n, style, status); + } else { + insert(detRelatedNonMembs, n, style, status); + } + ++r; + } + + bool documentAll = true; + if (aggregate_->parent() && !aggregate_->name().isEmpty() && !aggregate_->hasDoc()) + documentAll = false; + NodeList::ConstIterator c = aggregate_->childNodes().constBegin(); + while (c != aggregate_->childNodes().constEnd()) { + Node* n = *c; + if (n->isSharingComment()) { + // do nothing + } else if (!documentAll && !n->hasDoc()) { + ++c; + continue; + } else if (n->isEnumType() || n->isTypedef()) { + if (n->name() == QLatin1String("QtGadgetHelper")) { + ++c; + continue; + } + insert(detMemberTypes, *c, style, status); + } else if (n->isProperty()) { + insert(detProperties, *c, style, status); + } else if (n->isVariable()) { + if (!n->doc().isEmpty()) + insert(detMemberVars, *c, style, status); + } else if (n->isFunction()) { + FunctionNode *function = static_cast<FunctionNode *>(n); + if (function->isIgnored()) { + ++c; + continue; + } + if (!function->isSharingComment()) { + if (!function->hasAssociatedProperties() || !function->doc().isEmpty()) + insert(detMemberFuncs, function, style, status); + } + } else if (n->isSharedCommentNode()) { + SharedCommentNode *scn = static_cast<SharedCommentNode *>(n); + if (!scn->doc().isEmpty()) + insert(detMemberFuncs, scn, style, status); + } + ++c; + } + + append(sections, detMemberTypes); + append(sections, detProperties); + append(sections, detMemberFuncs); + append(sections, detMemberVars); + append(sections, detRelatedNonMembs); + append(sections, detMacros); +} + +/*! + Build the "all members" list for a C++ class. + */ +void Sections::getAllCppClassMembers(QList<Section> §ions, Style style, Status status) +{ + FastSection all(QString(), QString(), "member", "members"); + QStack<const Aggregate*> stack; + stack.push(aggregate_); + while (!stack.isEmpty()) { + const Aggregate* ancestor = stack.pop(); + NodeList::ConstIterator c = ancestor->childNodes().constBegin(); + while (c != ancestor->childNodes().constEnd()) { + Node *n = *c; + if (!n->isPrivate() && !n->isProperty()) + insert(all, n, style, status); + ++c; + } + if (ancestor->isClass()) { + const ClassNode* cn = static_cast<const ClassNode*>(ancestor); + QList<RelatedClass>::ConstIterator r = cn->baseClasses().constBegin(); + while (r != cn->baseClasses().constEnd()) { + if (r->node_) + stack.prepend(r->node_); + ++r; + } + } + } + append(sections, all); +} + +/*! + This function is for documenting QML properties. It returns + the list of documentation sections for the children of the + \a aggregate. + */ +QList<Section> Sections::getStdQmlSections(Aggregate* aggregate, Style style, Status status) +{ + QList<Section> sections; + setCurrentNode(aggregate); + if (aggregate) { + if (style == Summary) + getQmlTypeStdSummarySections(sections, style, status); + else if (style == Detailed) + getQmlTypeStdDetailedSections(sections, style, status); + else + getAllQmlTypeMembers(sections); + } + return sections; +} + +void Sections::getQmlTypeStdSummarySections(QList<Section> §ions, Style style, Status status) +{ + FastSection qmlproperties("Properties", QString(), "property", "properties"); + FastSection qmlattachedproperties("Attached Properties", QString(), "attached property", "attached properties"); + FastSection qmlsignals("Signals", QString(), "signal", "signals"); + FastSection qmlsignalhandlers("Signal Handlers", QString(), "signal handler", "signal handlers"); + FastSection qmlattachedsignals("Attached Signals", QString(), "attached signal", "attached signals"); + FastSection qmlmethods("Methods", QString(), "method", "methods"); + FastSection qmlattachedmethods("Attached Methods", QString(), "attached method", "attached methods"); + const Aggregate* qcn = aggregate_; + while (qcn != 0) { + NodeList::ConstIterator c = qcn->childNodes().constBegin(); + while (c != qcn->childNodes().constEnd()) { + if ((*c)->status() == Node::Internal) { + ++c; + continue; + } + if ((*c)->isQmlPropertyGroup() || (*c)->isJsPropertyGroup()) { + insert(qmlproperties, *c, style, status); + } + else if ((*c)->isQmlProperty() || (*c)->isJsProperty()) { + const QmlPropertyNode* pn = static_cast<const QmlPropertyNode*>(*c); + if (pn->isAttached()) + insert(qmlattachedproperties,*c,style, status); + else { + insert(qmlproperties,*c,style, status); + } + } + else if ((*c)->isQmlSignal() || (*c)->isJsSignal()) { + const FunctionNode* sn = static_cast<const FunctionNode*>(*c); + if (sn->isAttached()) + insert(qmlattachedsignals,*c,style, status); + else + insert(qmlsignals,*c,style, status); + } + else if ((*c)->isQmlSignalHandler() || (*c)->isJsSignalHandler()) { + insert(qmlsignalhandlers,*c,style, status); + } + else if ((*c)->isQmlMethod() || (*c)->isJsMethod()) { + const FunctionNode* mn = static_cast<const FunctionNode*>(*c); + if (mn->isAttached()) + insert(qmlattachedmethods,*c,style, status); + else + insert(qmlmethods,*c,style, status); + } + ++c; + } + if (qcn->qmlBaseNode() != 0) { + qcn = static_cast<QmlTypeNode*>(qcn->qmlBaseNode()); + if (!qcn->isAbstract()) + qcn = 0; + } + else + qcn = 0; + } + append(sections,qmlproperties); + append(sections,qmlattachedproperties); + append(sections,qmlsignals); + append(sections,qmlsignalhandlers); + append(sections,qmlattachedsignals); + append(sections,qmlmethods); + append(sections,qmlattachedmethods); +} + +void Sections::getQmlTypeStdDetailedSections(QList<Section> §ions, Style style, Status status) +{ + FastSection qmlproperties( "Property Documentation","qmlprop","member","members"); + FastSection qmlattachedproperties("Attached Property Documentation","qmlattprop", + "member","members"); + FastSection qmlsignals("Signal Documentation","qmlsig","signal","signals"); + FastSection qmlsignalhandlers("Signal Handler Documentation","qmlsighan","signal handler","signal handlers"); + FastSection qmlattachedsignals("Attached Signal Documentation","qmlattsig", + "signal","signals"); + FastSection qmlmethods("Method Documentation","qmlmeth","member","members"); + FastSection qmlattachedmethods("Attached Method Documentation","qmlattmeth", + "member","members"); + const Aggregate* qcn = aggregate_; + while (qcn != 0) { + NodeList::ConstIterator c = qcn->childNodes().constBegin(); + while (c != qcn->childNodes().constEnd()) { + if ((*c)->status() == Node::Internal) { + ++c; + continue; + } + if ((*c)->isQmlPropertyGroup() || (*c)->isJsPropertyGroup()) { + insert(qmlproperties,*c,style, status); + } + else if ((*c)->isQmlProperty() || (*c)->isJsProperty()) { + const QmlPropertyNode* pn = static_cast<const QmlPropertyNode*>(*c); + if (pn->isAttached()) + insert(qmlattachedproperties,*c,style, status); + else + insert(qmlproperties,*c,style, status); + } + else if ((*c)->isQmlSignal() || (*c)->isJsSignal()) { + const FunctionNode* sn = static_cast<const FunctionNode*>(*c); + if (sn->isAttached()) + insert(qmlattachedsignals,*c,style, status); + else + insert(qmlsignals,*c,style, status); + } + else if ((*c)->isQmlSignalHandler() || (*c)->isJsSignalHandler()) { + insert(qmlsignalhandlers,*c,style, status); + } + else if ((*c)->isQmlMethod() || (*c)->isJsMethod()) { + const FunctionNode* mn = static_cast<const FunctionNode*>(*c); + if (mn->isAttached()) + insert(qmlattachedmethods,*c,style, status); + else + insert(qmlmethods,*c,style, status); + } + ++c; + } + if (qcn->qmlBaseNode() != 0) { + qcn = static_cast<QmlTypeNode*>(qcn->qmlBaseNode()); + if (!qcn->isAbstract()) + qcn = 0; + } + else + qcn = 0; + } + append(sections,qmlproperties); + append(sections,qmlattachedproperties); + append(sections,qmlsignals); + append(sections,qmlsignalhandlers); + append(sections,qmlattachedsignals); + append(sections,qmlmethods); + append(sections,qmlattachedmethods); +} + +/*! + This is where the list of all members including inherited + members is prepared. +*/ +void Sections::getAllQmlTypeMembers(QList<Section> §ions) +{ + ClassMap* classMap = 0; + FastSection all(QString(), QString(), "member", "members"); + const Aggregate* current = aggregate_; + while (current != 0) { + /* + If the QML type is abstract, do not create + a new entry in the list for it. Instead, + add its members to the current entry. + + However, if the first class is abstract, + there is no current entry. In that case, + create a new entry in the list anyway. + I'm not sure that is correct, but it at + least can prevent a crash. + */ + if (!current->isAbstract() || !classMap) { + classMap = new ClassMap; + classMap->first = static_cast<const QmlTypeNode*>(current); + all.classMapList_.append(classMap); + } + NodeList::ConstIterator c = current->childNodes().constBegin(); + while (c != current->childNodes().constEnd()) { + if ((*c)->isQmlPropertyGroup() || (*c)->isJsPropertyGroup()) { + const QmlPropertyGroupNode* qpgn = static_cast<const QmlPropertyGroupNode*>(*c); + NodeList::ConstIterator p = qpgn->childNodes().constBegin(); + while (p != qpgn->childNodes().constEnd()) { + if ((*p)->isQmlProperty() || (*c)->isJsProperty()) { + QString key = (*p)->name(); + key = sortName(*p, &key); + all.memberMap_.insert(key,*p); + classMap->second.insert(key,*p); + } + ++p; + } + } + else { + QString key = (*c)->name(); + key = sortName(*c, &key); + all.memberMap_.insert(key,*c); + classMap->second.insert(key,*c); + } + ++c; + } + if (current->qmlBaseNode() == current) { + qDebug() << "qdoc internal error: circular type definition." + << "QML type" << current->name() + << "can't be its own base type"; + break; + } + current = current->qmlBaseNode(); + while (current) { + if (current->isAbstract()) + break; + if (current->isInternal()) + current = current->qmlBaseNode(); + else + break; + } + } + append(sections, all, true); +} + +QT_END_NAMESPACE diff --git a/src/qdoc/sections.h b/src/qdoc/sections.h new file mode 100644 index 000000000..fbb573173 --- /dev/null +++ b/src/qdoc/sections.h @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SECTIONS_H +#define SECTIONS_H + +#include <qpair.h> +#include "node.h" + +QT_BEGIN_NAMESPACE + +typedef QMultiMap<QString, Node*> MemberMap; // the string is the member signature +typedef QPair<const QmlTypeNode*, MemberMap> ClassMap; // the node is the QML type +typedef QList<ClassMap*> ClassMapList; + +typedef QPair<QStringList, NodeList> KeysAndNodes; +typedef QPair<const QmlTypeNode*, KeysAndNodes> ClassKeysNodes; +typedef QList<ClassKeysNodes*> ClassKeysNodesList; + +struct Section +{ + QString name_; + QString divClass_; + QString singular_; + QString plural_; + QStringList keys_; + NodeList members_; + NodeList reimpMembers_; + QList<QPair<Aggregate *, int> > inherited_; + ClassKeysNodesList classKeysNodesList_; + + Section() { } + Section(const QString& name, + const QString& divClass, + const QString& singular, + const QString& plural) + : name_(name), divClass_(divClass), singular_(singular), plural_(plural) { } + ~Section(); + + void appendMember(Node* node) { members_.append(node); } + void appendReimpMember(Node* node) { reimpMembers_.append(node); } +}; + +struct FastSection +{ + QString name_; + QString divClass_; + QString singular_; + QString plural_; + QMultiMap<QString, Node *> memberMap_; + QMultiMap<QString, Node *> reimpMemberMap_; + ClassMapList classMapList_; + QList<QPair<Aggregate *, int> > inherited_; + + FastSection(const QString& name, const QString& singular, const QString& plural) + : name_(name), singular_(singular), plural_(plural) { } + + FastSection(const QString& name, + const QString& divClass, + const QString& singular, + const QString& plural) + : name_(name), divClass_(divClass), singular_(singular), plural_(plural) { } + + ~FastSection(); + + void clear(); + bool isEmpty() const { + return (memberMap_.isEmpty() && + inherited_.isEmpty() && + reimpMemberMap_.isEmpty() && + classMapList_.isEmpty()); + } + +}; + +class Sections +{ + public: + enum Style { Summary, Detailed, Subpage, Accessors }; + enum Status { Compat, Obsolete, Okay }; + + Sections() { } + ~Sections() { } + + static QList<Section> getStdCppSections(const Aggregate *aggregate, Style style, Status status); + static QList<Section> getStdQmlSections(Aggregate* aggregate, Style style, Status status = Okay); + static QString sortName(const Node *node, const QString* name = 0); + static void insert(FastSection &fs, Node *node, Style style, Status status); + static bool insertReimpFunc(FastSection& fs, Node* node, Status status); + static void append(QList<Section>& sections, const FastSection& fs, bool includeKeys = false); + static void setCurrentNode(const Aggregate *t) { aggregate_ = t; } + + private: + static void getAllCppClassMembers(QList<Section> §ions, Style style, Status status); + static void getCppClassStdSummarySections(QList<Section> §ions, Style style, Status status); + static void getCppClassStdDetailedSections(QList<Section> §ions, Style style, Status status); + static void getAllStdCppSections(QList<Section> §ions, Style style, Status status); + static void getAllQmlTypeMembers(QList<Section> §ions); + static void getQmlTypeStdSummarySections(QList<Section> §ions, Style style, Status status); + static void getQmlTypeStdDetailedSections(QList<Section> §ions, Style style, Status status); + + private: + static const Aggregate *aggregate_; +}; + +QT_END_NAMESPACE + +#endif |