summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-01-23 23:42:18 +0100
committerTopi Reinio <topi.reinio@qt.io>2020-01-24 12:18:36 +0100
commit11e62fb056a715075b034a63e248d980bc88b29d (patch)
treee04385e278b93b8a44e6d3bb8a7a43dc7f87d91a
parentc0431f14b665a2d56ed7a064ba15e39f29905d77 (diff)
qdoc: Ensure that \dontdocument works as expected
Class nodes marked with \dontdocument are not supposed to be seen in the generated documentation. They already did not generate an output page, but they still appeared as base classes in 'Inherits' information as well as class listings, resulting in broken links. Remove these nodes from all relevant lists. Handle Node::DontDocument status in the .index files, and add a test to cover \dontdocument usage. Fixes: QTBUG-81468 Change-Id: I933817ff0ebf372cfa493a5ea824b682e0b1b160 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/qdoc/node.cpp6
-rw-r--r--src/qdoc/qdocdatabase.cpp4
-rw-r--r--src/qdoc/qdocindexfiles.cpp4
-rw-r--r--tests/auto/qdoc/generatedoutput/dontdocument/TestCPP2
-rw-r--r--tests/auto/qdoc/generatedoutput/dontdocument/dont.cpp47
-rw-r--r--tests/auto/qdoc/generatedoutput/dontdocument/dont.h41
-rw-r--r--tests/auto/qdoc/generatedoutput/dontdocument/dontdocument.qdocconf7
-rw-r--r--tests/auto/qdoc/generatedoutput/dontdocument/test.qdoc36
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/dontdocument/classes.html22
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/dontdocument/seenclass.html33
-rw-r--r--tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp8
11 files changed, 205 insertions, 5 deletions
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index d3118a166..38c567feb 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -2702,7 +2702,7 @@ void Aggregate::findAllObsoleteThings()
void Aggregate::findAllClasses()
{
for (auto *node : qAsConst(children_)) {
- if (!node->isPrivate() && !node->isInternal()
+ if (!node->isPrivate() && !node->isInternal() && !node->isDontDocument()
&& node->tree()->camelCaseModuleName() != QString("QDoc")) {
if (node->isClassNode()) {
QDocDatabase::cppClasses().insert(node->qualifyCppName().toLower(), node);
@@ -2947,7 +2947,7 @@ void ClassNode::removePrivateAndInternalBases()
ClassNode *bc = bases_.at(i).node_;
if (bc == nullptr)
bc = QDocDatabase::qdocDB()->findClassNode(bases_.at(i).path_);
- if (bc != nullptr && (bc->isPrivate() || bc->isInternal() || found.contains(bc))) {
+ if (bc != nullptr && (bc->isPrivate() || bc->isInternal() || bc->isDontDocument() || found.contains(bc))) {
RelatedClass rc = bases_.at(i);
bases_.removeAt(i);
ignoredBases_.append(rc);
@@ -2961,7 +2961,7 @@ void ClassNode::removePrivateAndInternalBases()
i = 0;
while (i < derived_.size()) {
ClassNode *dc = derived_.at(i).node_;
- if (dc != nullptr && (dc->isPrivate() || dc->isInternal())) {
+ if (dc != nullptr && (dc->isPrivate() || dc->isInternal() || dc->isDontDocument())) {
derived_.removeAt(i);
const QVector<RelatedClass> &dd = dc->derivedClasses();
for (int j = dd.size() - 1; j >= 0; --j)
diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp
index ed305b20e..7f585cc51 100644
--- a/src/qdoc/qdocdatabase.cpp
+++ b/src/qdoc/qdocdatabase.cpp
@@ -1103,12 +1103,13 @@ const NodeMap &QDocDatabase::getSinceMap(const QString &key)
void QDocDatabase::resolveStuff()
{
if (Generator::dualExec() || Generator::preparing()) {
+ // order matters
primaryTree()->resolveBaseClasses(primaryTreeRoot());
primaryTree()->resolvePropertyOverriddenFromPtrs(primaryTreeRoot());
primaryTreeRoot()->normalizeOverloads();
+ primaryTree()->markDontDocumentNodes();
primaryTree()->removePrivateAndInternalBases(primaryTreeRoot());
primaryTree()->resolveProperties();
- primaryTree()->markDontDocumentNodes();
primaryTreeRoot()->markUndocumentedChildrenInternal();
primaryTreeRoot()->resolveQmlInheritance();
primaryTree()->resolveTargets(primaryTreeRoot());
@@ -1119,7 +1120,6 @@ void QDocDatabase::resolveStuff()
primaryTree()->resolveBaseClasses(primaryTreeRoot());
primaryTree()->resolvePropertyOverriddenFromPtrs(primaryTreeRoot());
primaryTreeRoot()->resolveQmlInheritance();
- // primaryTree()->resolveTargets(primaryTreeRoot());
primaryTree()->resolveCppToQmlLinks();
primaryTree()->resolveUsingClauses();
}
diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp
index c68d675ea..6a09571dd 100644
--- a/src/qdoc/qdocindexfiles.cpp
+++ b/src/qdoc/qdocindexfiles.cpp
@@ -587,6 +587,8 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader &reader, Node *current,
node->setStatus(Node::Active);
else if (status == QLatin1String("internal"))
node->setStatus(Node::Internal);
+ else if (status == QLatin1String("ignored"))
+ node->setStatus(Node::DontDocument);
else
node->setStatus(Node::Active);
@@ -737,6 +739,8 @@ static const QString getStatusString(Node::Status t)
return QLatin1String("active");
case Node::Internal:
return QLatin1String("internal");
+ case Node::DontDocument:
+ return QLatin1String("ignored");
default:
break;
}
diff --git a/tests/auto/qdoc/generatedoutput/dontdocument/TestCPP b/tests/auto/qdoc/generatedoutput/dontdocument/TestCPP
new file mode 100644
index 000000000..7291e6d8f
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/dontdocument/TestCPP
@@ -0,0 +1,2 @@
+#include "../TestCPP"
+#include "dont.h"
diff --git a/tests/auto/qdoc/generatedoutput/dontdocument/dont.cpp b/tests/auto/qdoc/generatedoutput/dontdocument/dont.cpp
new file mode 100644
index 000000000..33e208459
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/dontdocument/dont.cpp
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "dont.h"
+
+/*!
+ \class UnseenClass
+ \inmodule TestCPP
+ \brief A public but undocumented class.
+*/
+UnseenClass::UnseenClass()
+{
+}
+
+/*!
+ \class SeenClass
+ \inmodule TestCPP
+ \brief A public but undocumented class.
+*/
+SeenClass::SeenClass()
+{
+}
diff --git a/tests/auto/qdoc/generatedoutput/dontdocument/dont.h b/tests/auto/qdoc/generatedoutput/dontdocument/dont.h
new file mode 100644
index 000000000..5ef436b5c
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/dontdocument/dont.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#pragma once
+
+class UnseenClass
+{
+public:
+ UnseenClass();
+};
+
+class SeenClass : public UnseenClass
+{
+public:
+ SeenClass();
+};
diff --git a/tests/auto/qdoc/generatedoutput/dontdocument/dontdocument.qdocconf b/tests/auto/qdoc/generatedoutput/dontdocument/dontdocument.qdocconf
new file mode 100644
index 000000000..1c141784b
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/dontdocument/dontdocument.qdocconf
@@ -0,0 +1,7 @@
+include(../testcpp.qdocconf)
+
+headers += dont.h
+sources += dont.cpp test.qdoc
+
+HTML.nosubdirs = true
+HTML.outputsubdir = dontdocument
diff --git a/tests/auto/qdoc/generatedoutput/dontdocument/test.qdoc b/tests/auto/qdoc/generatedoutput/dontdocument/test.qdoc
new file mode 100644
index 000000000..3f6e0be30
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/dontdocument/test.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \dontdocument (UnseenClass)
+*/
+
+/*! \page classes.html
+ \title Classes
+ \generatelist annotatedclasses
+*/
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/dontdocument/classes.html b/tests/auto/qdoc/generatedoutput/expected_output/dontdocument/classes.html
new file mode 100644
index 000000000..f5bae610a
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/dontdocument/classes.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- test.qdoc -->
+ <title>Classes | TestCPP</title>
+</head>
+<body>
+<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
+<h1 class="title">Classes</h1>
+<span class="subtitle"></span>
+<!-- $$$classes.html-description -->
+<div class="descr"> <a name="details"></a>
+<div class="table"><table class="annotated">
+<tr class="odd topAlign"><td class="tblName"><p><a href="seenclass.html">SeenClass</a></p></td><td class="tblDescr"><p>A public but undocumented class</p></td></tr>
+<tr class="even topAlign"><td class="tblName"><p><a href="testqdoc-test.html">TestQDoc::Test</a></p></td><td class="tblDescr"><p>A class in a namespace</p></td></tr>
+<tr class="odd topAlign"><td class="tblName"><p><a href="testqdoc-testderived.html">TestQDoc::TestDerived</a></p></td><td class="tblDescr"><p>A derived class in a namespace</p></td></tr>
+</table></div>
+</div>
+<!-- @@@classes.html -->
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/dontdocument/seenclass.html b/tests/auto/qdoc/generatedoutput/expected_output/dontdocument/seenclass.html
new file mode 100644
index 000000000..119841e44
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/dontdocument/seenclass.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- dont.cpp -->
+ <title>SeenClass Class | TestCPP</title>
+</head>
+<body>
+<li>SeenClass</li>
+<div class="sidebar">
+<div class="toc">
+<h3><a name="toc">Contents</a></h3>
+<ul>
+<li class="level1"><a href="#details">Detailed Description</a></li>
+</ul>
+</div>
+<div class="sidebar-content" id="sidebar-content"></div></div>
+<h1 class="title">SeenClass Class</h1>
+<!-- $$$SeenClass-brief -->
+<p>A public but undocumented class. <a href="#details">More...</a></p>
+<!-- @@@SeenClass -->
+<div class="table"><table class="alignedsummary">
+<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &lt;SeenClass&gt;</span>
+</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += testcpp</td></tr></table></div><ul>
+</ul>
+<a name="details"></a>
+<!-- $$$SeenClass-description -->
+<div class="descr">
+<h2 id="details">Detailed Description</h2>
+</div>
+<!-- @@@SeenClass -->
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
index 932441b4e..7d87470f6 100644
--- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
+++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
@@ -59,6 +59,7 @@ private slots:
void ignoresinceVariable();
void templateParameters();
void scopedEnum();
+ void dontDocument();
private:
QScopedPointer<QTemporaryDir> m_outputDir;
@@ -290,6 +291,13 @@ void tst_generatedOutput::scopedEnum()
testAndCompare("scopedenum.qdocconf", "scopedenum/testqdoc-test.html");
}
+void tst_generatedOutput::dontDocument()
+{
+ testAndCompare("dontdocument/dontdocument.qdocconf", "dontdocument/classes.html "
+ "dontdocument/seenclass.html");
+}
+
+
QTEST_APPLESS_MAIN(tst_generatedOutput)
#include "tst_generatedoutput.moc"