qdoc: Don't include inherited members in the class ref
authorMartin Smith <martin.smith@digia.com>
Tue, 4 Dec 2012 13:12:30 +0000 (14:12 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 5 Dec 2012 16:29:46 +0000 (17:29 +0100)
Once upon a time, the inherited functions, signals,
slots, etc were not listed on the class reference
page, but they were counted and a link to the base
class was provided for them, eg:

2 public functions inherited from QAbstractListModel
39 public functions inherited from QAbstractItemModel
31 public functions inherited from QObject

Somehow, this got broken, so that all these inherited
things were listed on the class reference page as if
they were members of the class. But they liunked to
the documentation in the base class.

This now works correctly again. It simnplifies the
class reference pages a lot.

Task-number: QTBUG-27496
Change-Id: If493da8cbf81634f1344b12094d9a06f8528e8e5
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/tools/qdoc/codemarker.cpp
src/tools/qdoc/codemarker.h
src/tools/qdoc/cppcodemarker.cpp
src/tools/qdoc/tree.cpp

index 7cc6b63..9fe91d9 100644 (file)
@@ -396,7 +396,7 @@ void CodeMarker::insert(FastSection &fastSection,
     bool irrelevant = false;
     bool inheritedMember = false;
     if (!node->relates()) {
-        if (node->parent() != (const InnerNode*)fastSection.innerNode && !node->parent()->isAbstract()) {
+        if (node->parent() != fastSection.parent_) { // && !node->parent()->isAbstract()) {
             if (node->type() != Node::QmlProperty) {
                 inheritedMember = true;
             }
@@ -468,7 +468,7 @@ void CodeMarker::insert(FastSection& fastSection,
             (parent->subType() == Node::QmlPropertyGroup)) {
         parent = parent->parent();
     }
-    inheritedMember = (parent != (const InnerNode*)fastSection.innerNode);
+    inheritedMember = (parent != fastSection.parent_);
 
     if (!inheritedMember || style == Subpage) {
         QString key = sortName(node);
@@ -488,24 +488,24 @@ void CodeMarker::insert(FastSection& fastSection,
 }
 
 /*!
-  Returns true if \a node represents a reimplemented member function.
-  If it is, then it is inserted in the reimplemented member map in the
-  section \a fs. And, the test is only performed if \a status is \e OK.
-  Otherwise, false is returned.
+  Returns 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)
-        return false;
-
-    const FunctionNode* fn = static_cast<const FunctionNode*>(node);
-    if ((fn->reimplementedFrom() != 0) && (status == Okay)) {
-        bool inherited = (!fn->relates() && (fn->parent() != (const InnerNode*)fs.innerNode));
-        if (!inherited) {
-            QString key = sortName(fn);
-            if (!fs.reimpMemberMap.contains(key)) {
-                fs.reimpMemberMap.insert(key,node);
-                return true;
+    if ((node->access() != Node::Private) && (node->relates() == 0)) {
+        const FunctionNode* fn = static_cast<const FunctionNode*>(node);
+        if ((fn->reimplementedFrom() != 0) && (status == Okay)) {
+            if (fn->parent() == fs.parent_) {
+                QString key = sortName(fn);
+                if (!fs.reimpMemberMap.contains(key)) {
+                    fs.reimpMemberMap.insert(key,node);
+                    return true;
+                }
             }
         }
     }
index 0e699a6..14d33d3 100644 (file)
@@ -82,7 +82,7 @@ struct Section
 
 struct FastSection
 {
-    const InnerNode *innerNode;
+    const InnerNode *parent_;
     QString name;
     QString divClass;
     QString singularMember;
@@ -91,12 +91,12 @@ struct FastSection
     QMap<QString, Node *> reimpMemberMap;
     QList<QPair<InnerNode *, int> > inherited;
 
-    FastSection(const InnerNode *innerNode0,
+    FastSection(const InnerNode *parent,
                 const QString& name0,
                 const QString& divClass0,
                 const QString& singularMember0,
                 const QString& pluralMember0)
-        : innerNode(innerNode0),
+        : parent_(parent),
           name(name0),
           divClass(divClass0),
           singularMember(singularMember0),
index 3abe4c2..ccff1c1 100644 (file)
@@ -449,74 +449,74 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
     QList<Section> sections;
 
     if (inner->type() == Node::Class) {
-        const ClassNode *classe = static_cast<const ClassNode *>(inner);
+        const ClassNode *classNode = static_cast<const ClassNode *>(inner);
 
         if (style == Summary) {
-            FastSection privateFunctions(classe,
+            FastSection privateFunctions(classNode,
                                          "Private Functions",
                                          QString(),
                                          "private function",
                                          "private functions");
-            FastSection privateSlots(classe, "Private Slots", QString(), "private slot", "private slots");
-            FastSection privateTypes(classe, "Private Types", QString(), "private type", "private types");
-            FastSection protectedFunctions(classe,
+            FastSection privateSlots(classNode, "Private Slots", QString(), "private slot", "private slots");
+            FastSection privateTypes(classNode, "Private Types", QString(), "private type", "private types");
+            FastSection protectedFunctions(classNode,
                                            "Protected Functions",
                                            QString(),
                                            "protected function",
                                            "protected functions");
-            FastSection protectedSlots(classe,
+            FastSection protectedSlots(classNode,
                                        "Protected Slots",
                                        QString(),
                                        "protected slot",
                                        "protected slots");
-            FastSection protectedTypes(classe,
+            FastSection protectedTypes(classNode,
                                        "Protected Types",
                                        QString(),
                                        "protected type",
                                        "protected types");
-            FastSection protectedVariables(classe,
+            FastSection protectedVariables(classNode,
                                            "Protected Variables",
                                            QString(),
                                            "protected type",
                                            "protected variables");
-            FastSection publicFunctions(classe,
+            FastSection publicFunctions(classNode,
                                         "Public Functions",
                                         QString(),
                                         "public function",
                                         "public functions");
-            FastSection publicSignals(classe, "Signals", QString(), "signal", "signal");
-            FastSection publicSlots(classe, "Public Slots", QString(), "public slot", "public slots");
-            FastSection publicTypes(classe, "Public Types", QString(), "public type", "public types");
-            FastSection publicVariables(classe,
+            FastSection publicSignals(classNode, "Signals", QString(), "signal", "signal");
+            FastSection publicSlots(classNode, "Public Slots", QString(), "public slot", "public slots");
+            FastSection publicTypes(classNode, "Public Types", QString(), "public type", "public types");
+            FastSection publicVariables(classNode,
                                         "Public Variables",
                                         QString(),
                                         "public variable",
                                         "public variables");
-            FastSection properties(classe, "Properties", QString(), "property", "properties");
-            FastSection relatedNonMembers(classe,
+            FastSection properties(classNode, "Properties", QString(), "property", "properties");
+            FastSection relatedNonMembers(classNode,
                                           "Related Non-Members",
                                           QString(),
                                           "related non-member",
                                           "related non-members");
-            FastSection staticPrivateMembers(classe,
+            FastSection staticPrivateMembers(classNode,
                                              "Static Private Members",
                                              QString(),
                                              "static private member",
                                              "static private members");
-            FastSection staticProtectedMembers(classe,
+            FastSection staticProtectedMembers(classNode,
                                                "Static Protected Members",
                                                QString(),
                                                "static protected member",
                                                "static protected members");
-            FastSection staticPublicMembers(classe,
+            FastSection staticPublicMembers(classNode,
                                             "Static Public Members",
                                             QString(),
                                             "static public member",
                                             "static public members");
             FastSection macros(inner, "Macros", QString(), "macro", "macros");
 
-            NodeList::ConstIterator r = classe->relatedNodes().constBegin();
-            while (r != classe->relatedNodes().constEnd()) {
+            NodeList::ConstIterator r = classNode->relatedNodes().constBegin();
+            while (r != classNode->relatedNodes().constEnd()) {
                 if ((*r)->type() == Node::Function) {
                     FunctionNode *func = static_cast<FunctionNode *>(*r);
                     if (func->isMacro())
@@ -531,7 +531,7 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
             }
 
             QStack<const ClassNode *> stack;
-            stack.push(classe);
+            stack.push(classNode);
             while (!stack.isEmpty()) {
                 const ClassNode *ancestorClass = stack.pop();
 
@@ -566,8 +566,7 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
                             insert(publicSignals, *c, style, status);
                         }
                         else if (isStatic) {
-                            if ((*c)->type() != Node::Variable
-                                    || !(*c)->doc().isEmpty())
+                            if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty())
                                 insert(staticPublicMembers,*c,style,status);
                         }
                         else if ((*c)->type() == Node::Property) {
@@ -578,8 +577,9 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
                                 insert(publicVariables, *c, style, status);
                         }
                         else if ((*c)->type() == Node::Function) {
-                            if (!insertReimpFunc(publicFunctions,*c,status))
+                            if (!insertReimpFunc(publicFunctions,*c,status)) {
                                 insert(publicFunctions, *c, style, status);
+                            }
                         }
                         else {
                             insert(publicTypes, *c, style, status);
@@ -590,8 +590,7 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
                             insert(protectedSlots, *c, style, status);
                         }
                         else if (isStatic) {
-                            if ((*c)->type() != Node::Variable
-                                    || !(*c)->doc().isEmpty())
+                            if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty())
                                 insert(staticProtectedMembers,*c,style,status);
                         }
                         else if ((*c)->type() == Node::Variable) {
@@ -599,8 +598,9 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
                                 insert(protectedVariables,*c,style,status);
                         }
                         else if ((*c)->type() == Node::Function) {
-                            if (!insertReimpFunc(protectedFunctions,*c,status))
+                            if (!insertReimpFunc(protectedFunctions,*c,status)) {
                                 insert(protectedFunctions, *c, style, status);
+                            }
                         }
                         else {
                             insert(protectedTypes, *c, style, status);
@@ -611,13 +611,13 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
                             insert(privateSlots, *c, style, status);
                         }
                         else if (isStatic) {
-                            if ((*c)->type() != Node::Variable
-                                    || !(*c)->doc().isEmpty())
+                            if ((*c)->type() != Node::Variable || !(*c)->doc().isEmpty())
                                 insert(staticPrivateMembers,*c,style,status);
                         }
                         else if ((*c)->type() == Node::Function) {
-                            if (!insertReimpFunc(privateFunctions,*c,status))
+                            if (!insertReimpFunc(privateFunctions,*c,status)) {
                                 insert(privateFunctions, *c, style, status);
+                            }
                         }
                         else {
                             insert(privateTypes,*c,style,status);
@@ -654,15 +654,15 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
             append(sections, macros);
         }
         else if (style == Detailed) {
-            FastSection memberFunctions(classe,"Member Function Documentation","func","member","members");
-            FastSection memberTypes(classe,"Member Type Documentation","types","member","members");
-            FastSection memberVariables(classe,"Member Variable Documentation","vars","member","members");
-            FastSection properties(classe,"Property Documentation","prop","member","members");
-            FastSection relatedNonMembers(classe,"Related Non-Members","relnonmem","member","members");
-            FastSection macros(classe,"Macro Documentation","macros","member","members");
-
-            NodeList::ConstIterator r = classe->relatedNodes().constBegin();
-            while (r != classe->relatedNodes().constEnd()) {
+            FastSection memberFunctions(classNode,"Member Function Documentation","func","member","members");
+            FastSection memberTypes(classNode,"Member Type Documentation","types","member","members");
+            FastSection memberVariables(classNode,"Member Variable Documentation","vars","member","members");
+            FastSection properties(classNode,"Property Documentation","prop","member","members");
+            FastSection relatedNonMembers(classNode,"Related Non-Members","relnonmem","member","members");
+            FastSection macros(classNode,"Macro Documentation","macros","member","members");
+
+            NodeList::ConstIterator r = classNode->relatedNodes().constBegin();
+            while (r != classNode->relatedNodes().constEnd()) {
                 if ((*r)->type() == Node::Function) {
                     FunctionNode *func = static_cast<FunctionNode *>(*r);
                     if (func->isMacro())
@@ -676,8 +676,8 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
                 ++r;
             }
 
-            NodeList::ConstIterator c = classe->childNodes().constBegin();
-            while (c != classe->childNodes().constEnd()) {
+            NodeList::ConstIterator c = classNode->childNodes().constBegin();
+            while (c != classNode->childNodes().constEnd()) {
                 if ((*c)->type() == Node::Enum ||
                         (*c)->type() == Node::Typedef) {
                     insert(memberTypes, *c, style, status);
@@ -705,10 +705,10 @@ QList<Section> CppCodeMarker::sections(const InnerNode *inner,
             append(sections, macros);
         }
         else {
-            FastSection all(classe,QString(),QString(),"member","members");
+            FastSection all(classNode,QString(),QString(),"member","members");
 
             QStack<const ClassNode *> stack;
-            stack.push(classe);
+            stack.push(classNode);
 
             while (!stack.isEmpty()) {
                 const ClassNode *ancestorClass = stack.pop();
index c622fb9..e7a8f5b 100644 (file)
@@ -398,6 +398,11 @@ void Tree::addPropertyFunction(PropertyNode* property,
 }
 
 /*!
+  This function resolves inheritance and reimplementation settings
+  for each class node found in the namspace beginning ar \a rootNode.
+  If it finds another namespace node in the child list of \a rootNode,
+  it calls itself recursively. For each child of \a rootNode that is a
+  class node, it calls the other resolveInheritance() function.
  */
 void Tree::resolveInheritance(NamespaceNode* rootNode)
 {
@@ -475,11 +480,24 @@ void Tree::resolveProperties()
 }
 
 /*!
+  This function is run twice for each \a classNode in the
+  tree. First it is run with \a pass set to 0 for each
+  \a classNode. Then it is run with \a pass set to 1 for
+  each \a classNode.
+
+  In \a pass 0, all the base classes of \a classNode are
+  found and added to the base class list for \a classNode.
+
+  In \a pass 1, each child of \a classNode that is a function
+  that is reimplemented from one of the base classes is marked
+  as being reimplemented from that class.
+
+  Some property node fixing up is also done in \a pass 1.
  */
-void Tree::resolveInheritance(int pass, ClassNode* classe)
+void Tree::resolveInheritance(int pass, ClassNode* classNode)
 {
     if (pass == 0) {
-        QList<InheritanceBound> bounds = unresolvedInheritanceMap[classe];
+        QList<InheritanceBound> bounds = unresolvedInheritanceMap[classNode];
         QList<InheritanceBound>::ConstIterator b = bounds.constBegin();
         while (b != bounds.constEnd()) {
             Node* n = findClassNode((*b).basePath);
@@ -487,17 +505,17 @@ void Tree::resolveInheritance(int pass, ClassNode* classe)
                 n = findClassNode((*b).basePath, (*b).parent);
             }
             if (n) {
-                classe->addBaseClass((*b).access, static_cast<ClassNode*>(n), (*b).dataTypeWithTemplateArgs);
+                classNode->addBaseClass((*b).access, static_cast<ClassNode*>(n), (*b).dataTypeWithTemplateArgs);
             }
             ++b;
         }
     }
     else {
-        NodeList::ConstIterator c = classe->childNodes().constBegin();
-        while (c != classe->childNodes().constEnd()) {
+        NodeList::ConstIterator c = classNode->childNodes().constBegin();
+        while (c != classNode->childNodes().constEnd()) {
             if ((*c)->type() == Node::Function) {
                 FunctionNode* func = (FunctionNode*)* c;
-                FunctionNode* from = findVirtualFunctionInBaseClasses(classe, func);
+                FunctionNode* from = findVirtualFunctionInBaseClasses(classNode, func);
                 if (from != 0) {
                     if (func->virtualness() == FunctionNode::NonVirtual)
                         func->setVirtualness(FunctionNode::ImpureVirtual);
@@ -505,7 +523,7 @@ void Tree::resolveInheritance(int pass, ClassNode* classe)
                 }
             }
             else if ((*c)->type() == Node::Property) {
-                fixPropertyUsingBaseClasses(classe, static_cast<PropertyNode*>(*c));
+                fixPropertyUsingBaseClasses(classNode, static_cast<PropertyNode*>(*c));
             }
             ++c;
         }
@@ -551,11 +569,11 @@ void Tree::fixInheritance(NamespaceNode* rootNode)
 
 /*!
  */
-FunctionNode* Tree::findVirtualFunctionInBaseClasses(ClassNode* classe,
+FunctionNode* Tree::findVirtualFunctionInBaseClasses(ClassNode* classNode,
                                                      FunctionNode* clone)
 {
-    QList<RelatedClass>::ConstIterator r = classe->baseClasses().constBegin();
-    while (r != classe->baseClasses().constEnd()) {
+    QList<RelatedClass>::ConstIterator r = classNode->baseClasses().constBegin();
+    while (r != classNode->baseClasses().constEnd()) {
         FunctionNode* func;
         if (((func = findVirtualFunctionInBaseClasses((*r).node, clone)) != 0 ||
              (func = (*r).node->findFunctionNode(clone)) != 0)) {
@@ -569,10 +587,10 @@ FunctionNode* Tree::findVirtualFunctionInBaseClasses(ClassNode* classe,
 
 /*!
  */
-void Tree::fixPropertyUsingBaseClasses(ClassNode* classe, PropertyNode* property)
+void Tree::fixPropertyUsingBaseClasses(ClassNode* classNode, PropertyNode* property)
 {
-    QList<RelatedClass>::const_iterator r = classe->baseClasses().constBegin();
-    while (r != classe->baseClasses().constEnd()) {
+    QList<RelatedClass>::const_iterator r = classNode->baseClasses().constBegin();
+    while (r != classNode->baseClasses().constEnd()) {
         Node* n = r->node->findChildNodeByNameAndType(property->name(), Node::Property);
         if (n) {
             PropertyNode* baseProperty = static_cast<PropertyNode*>(n);
@@ -588,10 +606,10 @@ void Tree::fixPropertyUsingBaseClasses(ClassNode* classe, PropertyNode* property
 
 /*!
  */
-NodeList Tree::allBaseClasses(const ClassNode* classe) const
+NodeList Tree::allBaseClasses(const ClassNode* classNode) const
 {
     NodeList result;
-    foreach (const RelatedClass& r, classe->baseClasses()) {
+    foreach (const RelatedClass& r, classNode->baseClasses()) {
         result += r.node;
         result += allBaseClasses(r.node);
     }