summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-01-22 11:05:50 +0100
committerTopi Reinio <topi.reinio@qt.io>2020-01-24 11:33:01 +0100
commitb693122a4e08e5745d1b288ef7e1525b085c1ebd (patch)
tree88fc2238fa472809a91988d72480150ef654a066
parent447f33743c3e07d645831f07b821ad76a203fd6f (diff)
qdoc: Fix regression in QML types inheriting property groups
Property groups from base types were not listed on 'All Members' pages of a QML type. This was because we skipped all shared comment nodes for base types; property group is a special type of SCN. Remove duplication in the code that distributes the nodes; this ensures that there is no difference in output between members of a type and members inherited from its base types. Use logging category to display debug warnings instead of qDebug(). Add a test to cover this. Fixes: QTBUG-81262 Change-Id: I46c3e6afa87c510a7929088acbd1fb354f6733af Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/qdoc/sections.cpp40
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/qmlpropertygroups/qml-qdoc-test-anotherchild-members.html25
-rw-r--r--tests/auto/qdoc/generatedoutput/qmlpropertygroups/parent.qdoc52
-rw-r--r--tests/auto/qdoc/generatedoutput/qmlpropertygroups/qmlpropertygroups.qdocconf7
-rw-r--r--tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp7
5 files changed, 100 insertions, 31 deletions
diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp
index edfa212ce..64bef16b4 100644
--- a/src/qdoc/sections.cpp
+++ b/src/qdoc/sections.cpp
@@ -30,6 +30,7 @@
#include "config.h"
#include "generator.h"
+#include "loggingcategory.h"
#include <QtCore/qdebug.h>
#include <QtCore/qobjectdefs.h>
@@ -979,7 +980,6 @@ void Sections::buildStdCppClassRefPageSections()
allMembers.insert(n);
if (!documentAll && !n->hasDoc())
continue;
- // distributeNodeInSummaryVector(sv, n); Why was this here? mws 03/07/2019
}
pushBaseClasses(stack, cn);
}
@@ -1000,51 +1000,29 @@ void Sections::buildStdQmlTypeRefPageSections()
Section &allMembers = allMembersSection();
const Aggregate *qtn = aggregate_;
- while (true) {
+ while (qtn) {
if (!qtn->isAbstract() || !classMap)
classMap = allMembers.newClassMap(qtn);
- for (auto it = qtn->constBegin(); it != qtn->constEnd(); ++it) {
- Node *n = *it;
+ for (const auto n : qtn->childNodes()) {
if (n->isInternal())
continue;
if (!n->isSharedCommentNode() || n->isPropertyGroup())
allMembers.add(classMap, n);
- distributeQmlNodeInSummaryVector(summarySections, n);
- distributeQmlNodeInDetailsVector(detailsSections, n);
+ if (qtn == aggregate_ || qtn->isAbstract()) {
+ distributeQmlNodeInSummaryVector(summarySections, n);
+ distributeQmlNodeInDetailsVector(detailsSections, n);
+ }
}
if (qtn->qmlBaseNode() == qtn) {
- qDebug() << "qdoc internal error: circular type definition."
- << "QML type" << qtn->name() << "can't be its own base type";
- qtn = nullptr;
+ qCDebug(lcQdoc, "error: circular type definition: '%s' inherits itself",
+ qPrintable(qtn->name()));
break;
}
qtn = static_cast<QmlTypeNode *>(qtn->qmlBaseNode());
- if (qtn == nullptr)
- break;
- if (!qtn->isAbstract())
- break;
}
- while (qtn != nullptr) {
- if (!qtn->isAbstract() || !classMap)
- classMap = allMembers.newClassMap(qtn);
- for (auto it = qtn->constBegin(); it != qtn->constEnd(); ++it) {
- Node *n = *it;
- if (n->isInternal() || n->isSharedCommentNode())
- continue;
-
- allMembers.add(classMap, n);
- }
- if (qtn->qmlBaseNode() == qtn) {
- qDebug() << "qdoc internal error: circular type definition."
- << "QML type" << qtn->name() << "can't be its own base type";
- qtn = nullptr;
- break;
- }
- qtn = static_cast<QmlTypeNode *>(qtn->qmlBaseNode());
- }
reduce(summarySections);
reduce(detailsSections);
allMembers.reduce();
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/qmlpropertygroups/qml-qdoc-test-anotherchild-members.html b/tests/auto/qdoc/generatedoutput/expected_output/qmlpropertygroups/qml-qdoc-test-anotherchild-members.html
new file mode 100644
index 000000000..557061cc0
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/qmlpropertygroups/qml-qdoc-test-anotherchild-members.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- parent.qdoc -->
+ <title>List of All Members for AnotherChild | Test</title>
+</head>
+<body>
+<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
+<h1 class="title">List of All Members for AnotherChild</h1>
+<p>This is the complete list of members for <a href="qml-qdoc-test-anotherchild.html">AnotherChild</a>, including inherited members.</p>
+<ul>
+<li class="fn"><b><b><a href="qml-qdoc-test-anotherchild.html#name-prop">name</a></b></b> : string</li>
+</ul>
+<p>The following members are inherited from <a href="qml-qdoc-test-parent.html">Parent</a>.</p>
+<ul>
+<li class="fn"><b><b><a href="qml-qdoc-test-parent.html#group-prop">group</a></b></b><ul>
+<li class="fn"><b><b><a href="qml-qdoc-test-parent.html#group.c-prop">group.c</a></b></b> : int</li>
+<li class="fn"><b><b><a href="qml-qdoc-test-parent.html#group.a-prop">group.a</a></b></b> : int</li>
+<li class="fn"><b><b><a href="qml-qdoc-test-parent.html#group.b-prop">group.b</a></b></b> : int</li>
+</ul>
+</li>
+</ul>
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/qmlpropertygroups/parent.qdoc b/tests/auto/qdoc/generatedoutput/qmlpropertygroups/parent.qdoc
new file mode 100644
index 000000000..c7002e96b
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/qmlpropertygroups/parent.qdoc
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 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$
+**
+****************************************************************************/
+
+/*!
+ \qmltype Parent
+ \inqmlmodule QDoc.Test
+ \brief Base QML type.
+*/
+
+/*!
+ \qmlproperty int Parent::group.c
+ \qmlproperty int Parent::group.a
+ \qmlproperty int Parent::group.b
+ \brief Property group.
+*/
+
+/*!
+ \qmltype AnotherChild
+ \inqmlmodule QDoc.Test
+ \inherits Parent
+ \brief Just another child inheriting a parent.
+*/
+
+/*!
+ \qmlproperty string AnotherChild::name
+ \brief Name of this child.
+*/
diff --git a/tests/auto/qdoc/generatedoutput/qmlpropertygroups/qmlpropertygroups.qdocconf b/tests/auto/qdoc/generatedoutput/qmlpropertygroups/qmlpropertygroups.qdocconf
new file mode 100644
index 000000000..6ed830c82
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/qmlpropertygroups/qmlpropertygroups.qdocconf
@@ -0,0 +1,7 @@
+include(../testqml.qdocconf)
+
+includepaths += ..
+sourcedirs += .
+
+HTML.nosubdirs = true
+HTML.outputsubdir = qmlpropertygroups
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
index a56e0fd7d..ce4aefa99 100644
--- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
+++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
@@ -48,6 +48,7 @@ private slots:
void webXmlFromCppBug80259();
void examplesManifestXml();
+ void inheritedQmlPropertyGroups();
private:
QScopedPointer<QTemporaryDir> m_outputDir;
@@ -244,6 +245,12 @@ void tst_generatedOutput::examplesManifestXml()
"examples-manifest.xml");
}
+void tst_generatedOutput::inheritedQmlPropertyGroups()
+{
+ testAndCompare("qmlpropertygroups/qmlpropertygroups.qdocconf",
+ "qmlpropertygroups/qml-qdoc-test-anotherchild-members.html");
+}
+
QTEST_APPLESS_MAIN(tst_generatedOutput)
#include "tst_generatedoutput.moc"