summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-03-11 15:38:02 +0100
committerTopi Reinio <topi.reinio@qt.io>2020-03-14 23:03:16 +0100
commitbfdbcf2a5800889ae57717899eaeb8e998a68eb2 (patch)
tree6938da051602c3b8a4c5fd26f33dabc890afa029
parentee49537f31aff32fa674292d3d413d8d40f661a7 (diff)
downloadqttools-bfdbcf2a5800889ae57717899eaeb8e998a68eb2.tar.gz
qdoc: Expand \noautolist to cover also C++ module pages
Even though the \noautolist has been documented to work for C++ module pages, using it within \module documentation had no effect. Generate the list of namespaces and classes only if \noautolist does not appear on the module page. Add a test for \noautolist, for both HTML and DocBook generators. Fixes: QTBUG-82822 Change-Id: I27dcdafaa44981f18d08f2f27a148a1febba2d8a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/qdoc/docbookgenerator.cpp29
-rw-r--r--src/qdoc/htmlgenerator.cpp49
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/qdoc-test-qmlmodule.xml12
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/test-componentset-example.xml37
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/testcpp-module.xml15
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/noautolist/qdoc-test-qmlmodule.html16
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/noautolist/test-componentset-example.html51
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/noautolist/testcpp-module.html29
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/configs/noautolist.qdocconf13
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/configs/testcpp.qdocconf1
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/qml/componentset/examples.qdoc2
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/qml/type.cpp2
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/testcpp/testcpp.cpp2
-rw-r--r--tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp12
14 files changed, 233 insertions, 37 deletions
diff --git a/src/qdoc/docbookgenerator.cpp b/src/qdoc/docbookgenerator.cpp
index 063065511..f6476c9ec 100644
--- a/src/qdoc/docbookgenerator.cpp
+++ b/src/qdoc/docbookgenerator.cpp
@@ -4108,21 +4108,22 @@ void DocBookGenerator::generateCollectionNode(CollectionNode *cn)
generateStatus(cn);
generateSince(cn);
- NodeMultiMap nmm;
- cn->getMemberNamespaces(nmm);
- if (!nmm.isEmpty()) {
- startSection(registerRef("namespaces"), "Namespaces");
- generateAnnotatedList(cn, nmm, "namespaces");
- endSection();
- }
- nmm.clear();
- cn->getMemberClasses(nmm);
- if (!nmm.isEmpty()) {
- startSection(registerRef("classes"), "Classes");
- generateAnnotatedList(cn, nmm, "classes");
- endSection();
+ if (!cn->noAutoList()) {
+ NodeMultiMap nmm;
+ cn->getMemberNamespaces(nmm);
+ if (!nmm.isEmpty()) {
+ startSection(registerRef("namespaces"), "Namespaces");
+ generateAnnotatedList(cn, nmm, "namespaces");
+ endSection();
+ }
+ nmm.clear();
+ cn->getMemberClasses(nmm);
+ if (!nmm.isEmpty()) {
+ startSection(registerRef("classes"), "Classes");
+ generateAnnotatedList(cn, nmm, "classes");
+ endSection();
+ }
}
- nmm.clear();
}
Text brief = cn->doc().briefText();
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index c440b31c3..c32e26b4b 100644
--- a/src/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/htmlgenerator.cpp
@@ -1650,23 +1650,24 @@ void HtmlGenerator::generateCollectionNode(CollectionNode *cn, CodeMarker *marke
generateStatus(cn, marker);
generateSince(cn, marker);
- NodeMultiMap nmm;
- cn->getMemberNamespaces(nmm);
- if (!nmm.isEmpty()) {
- ref = registerRef("namespaces");
- out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n';
- out() << "<h2 id=\"" << ref << "\">Namespaces</h2>\n";
- generateAnnotatedList(cn, marker, nmm);
- }
- nmm.clear();
- cn->getMemberClasses(nmm);
- if (!nmm.isEmpty()) {
- ref = registerRef("classes");
- out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n';
- out() << "<h2 id=\"" << ref << "\">Classes</h2>\n";
- generateAnnotatedList(cn, marker, nmm);
+ if (!cn->noAutoList()) {
+ NodeMultiMap nmm;
+ cn->getMemberNamespaces(nmm);
+ if (!nmm.isEmpty()) {
+ ref = registerRef("namespaces");
+ out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n';
+ out() << "<h2 id=\"" << ref << "\">Namespaces</h2>\n";
+ generateAnnotatedList(cn, marker, nmm);
+ }
+ nmm.clear();
+ cn->getMemberClasses(nmm);
+ if (!nmm.isEmpty()) {
+ ref = registerRef("classes");
+ out() << "<a name=\"" << ref << "\"></a>" << divNavTop << '\n';
+ out() << "<h2 id=\"" << ref << "\">Classes</h2>\n";
+ generateAnnotatedList(cn, marker, nmm);
+ }
}
- nmm.clear();
}
Text brief = cn->doc().briefText();
@@ -2281,13 +2282,15 @@ void HtmlGenerator::generateTableOfContents(const Node *node, CodeMarker *marker
out() << "<ul>\n";
if (node->isModule()) {
- if (node->hasNamespaces()) {
- out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
- << registerRef("namespaces") << "\">Namespaces</a></li>\n";
- }
- if (node->hasClasses()) {
- out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
- << registerRef("classes") << "\">Classes</a></li>\n";
+ if (!static_cast<const CollectionNode *>(node)->noAutoList()) {
+ if (node->hasNamespaces()) {
+ out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
+ << registerRef("namespaces") << "\">Namespaces</a></li>\n";
+ }
+ if (node->hasClasses()) {
+ out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
+ << registerRef("classes") << "\">Classes</a></li>\n";
+ }
}
out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" << registerRef("details")
<< "\">Detailed Description</a></li>\n";
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/qdoc-test-qmlmodule.xml b/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/qdoc-test-qmlmodule.xml
new file mode 100644
index 000000000..b99e58480
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/qdoc-test-qmlmodule.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<db:article xmlns:db="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.2" xml:lang="en">
+<db:info>
+<db:title></db:title>
+<db:productname>Test</db:productname>
+<db:titleabbrev>A test project for QDoc build artifacts</db:titleabbrev>
+<db:abstract>
+<db:para>QML Types for the Test module.</db:para>
+</db:abstract>
+</db:info>
+<db:anchor xml:id="details"/>
+</db:article>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/test-componentset-example.xml b/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/test-componentset-example.xml
new file mode 100644
index 000000000..4e1dbf915
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/test-componentset-example.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<db:article xmlns:db="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.2" xml:lang="en">
+<db:info>
+<db:title>QML Documentation Example</db:title>
+<db:productname>Test</db:productname>
+<db:titleabbrev>A test project for QDoc build artifacts</db:titleabbrev>
+<db:abstract>
+<db:para>Example for documenting QML types.</db:para>
+</db:abstract>
+</db:info>
+<db:para>This example demonstrates one of the ways to document QML types.</db:para>
+<db:para>In particular, there are sample types that are documented with QDoc commands comments. There are documentation comments for the QML types and their public interfaces. The types are grouped into a module, the <db:link xlink:href="uicomponents-qmlmodule.xml">UI Components</db:link> module.</db:para>
+<db:para>The uicomponents.qdoc file generates the overview page for the <db:link xlink:href="uicomponents-qmlmodule.xml">UI Components</db:link> module page.</db:para>
+<db:para>The generated documentation is available in the <db:link xlink:href="uicomponents-qmlmodule.xml">UI Components</db:link> module.</db:para>
+<db:section xml:id="qml-class">
+<db:title>QML Class</db:title>
+<db:para>The QML types use the \qmltype to document the type. In addition, they have the \inmodule command in order for QDoc to associate them to the <db:code>UIComponents</db:code> module.</db:para>
+<db:para>QDoc uses the \brief command to place a basic description when listing the types.</db:para>
+</db:section>
+<db:section xml:id="properties-signals-handlers-and-methods">
+<db:title>Properties, Signals, Handlers, and Methods</db:title>
+<db:para>The types have their properties, signals, handlers, and methods defined in their respective QML files. QDoc associates the properties and methods to the types, therefore, you only need to place the documentation above the property, method, or signal.</db:para>
+<db:para>To document the type of a <db:emphasis>property alias</db:emphasis>, you must use the \qmlproperty command to specify the data type.</db:para>
+<db:programlisting language="cpp">\qmlproperty &lt;@type&gt;int&lt;/@type&gt; anAliasedProperty
+An aliased property of type &lt;@type&gt;int&lt;/@type&gt;&lt;@op&gt;.&lt;/@op&gt;
+</db:programlisting>
+<db:section xml:id="internal-documentation">
+<db:title>Internal Documentation</db:title>
+<db:para>You may declare that a documentation is for internal use by placing the \internal command after the beginning QDoc comment <db:code>/*</db:code>. QDoc will prevent the internal documentation from appearing in the public API.</db:para>
+<db:para>If you wish to omit certain parts of the documentation, you may use the \omit and \endomit command.</db:para>
+</db:section>
+</db:section>
+<db:section xml:id="qml-types-with-c-implementation">
+<db:title>QML Types with C++ Implementation</db:title>
+<db:para>This example only demonstrates the documentation for types in QML files, but the regular QML commands may be placed inside C++ classes to define the public API of the QML type.</db:para>
+</db:section>
+</db:article>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/testcpp-module.xml b/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/testcpp-module.xml
new file mode 100644
index 000000000..d2ba83a13
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/noautolist-docbook/testcpp-module.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<db:article xmlns:db="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.2" xml:lang="en">
+<db:info>
+<db:title>QDoc Test C++ Classes</db:title>
+<db:productname>Test</db:productname>
+<db:titleabbrev>A test project for QDoc build artifacts</db:titleabbrev>
+<db:abstract>
+<db:para>A test module page.</db:para>
+</db:abstract>
+</db:info>
+<db:para>A test module page.</db:para>
+<db:section xml:id="details">
+<db:title>Detailed Description</db:title>
+</db:section>
+</db:article>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/noautolist/qdoc-test-qmlmodule.html b/tests/auto/qdoc/generatedoutput/expected_output/noautolist/qdoc-test-qmlmodule.html
new file mode 100644
index 000000000..8efd70c0f
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/noautolist/qdoc-test-qmlmodule.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- type.cpp -->
+ <title>Test</title>
+</head>
+<body>
+<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
+<span class="subtitle"></span>
+<!-- $$$QDoc.Test-description -->
+<div class="descr"> <a name="details"></a>
+</div>
+<!-- @@@QDoc.Test -->
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/noautolist/test-componentset-example.html b/tests/auto/qdoc/generatedoutput/expected_output/noautolist/test-componentset-example.html
new file mode 100644
index 000000000..5331c2b35
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/noautolist/test-componentset-example.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- examples.qdoc -->
+ <title>QML Documentation Example | Test</title>
+</head>
+<body>
+<div class="sidebar">
+<div class="toc">
+<h3><a name="toc">Contents</a></h3>
+<ul>
+<li class="level1"><a href="#qml-class">QML Class</a></li>
+<li class="level1"><a href="#properties-signals-handlers-and-methods">Properties, Signals, Handlers, and Methods</a></li>
+<li class="level2"><a href="#internal-documentation">Internal Documentation</a></li>
+<li class="level1"><a href="#qml-types-with-c-implementation">QML Types with C++ Implementation</a></li>
+</ul>
+</div>
+<div class="sidebar-content" id="sidebar-content"></div></div>
+<h1 class="title">QML Documentation Example</h1>
+<span class="subtitle"></span>
+<!-- $$$componentset-brief -->
+<p>Example for documenting QML types.</p>
+<!-- @@@componentset -->
+<!-- $$$componentset-description -->
+<div class="descr"> <a name="details"></a>
+<p>This example demonstrates one of the ways to document QML types.</p>
+<p>In particular, there are sample types that are documented with QDoc commands comments. There are documentation comments for the QML types and their public interfaces. The types are grouped into a module, the <a href="uicomponents-qmlmodule.html">UI Components</a> module.</p>
+<p>The uicomponents.qdoc file generates the overview page for the <a href="uicomponents-qmlmodule.html">UI Components</a> module page.</p>
+<p>The generated documentation is available in the <a href="uicomponents-qmlmodule.html">UI Components</a> module.</p>
+<a name="qml-class"></a>
+<h4 id="qml-class">QML Class</h4>
+<p>The QML types use the \qmltype to document the type. In addition, they have the \inmodule command in order for QDoc to associate them to the <code>UIComponents</code> module.</p>
+<p>QDoc uses the \brief command to place a basic description when listing the types.</p>
+<a name="properties-signals-handlers-and-methods"></a>
+<h4 id="properties-signals-handlers-and-methods">Properties, Signals, Handlers, and Methods</h4>
+<p>The types have their properties, signals, handlers, and methods defined in their respective QML files. QDoc associates the properties and methods to the types, therefore, you only need to place the documentation above the property, method, or signal.</p>
+<p>To document the type of a <i>property alias</i>, you must use the \qmlproperty command to specify the data type.</p>
+<pre class="cpp">\qmlproperty <span class="type">int</span> anAliasedProperty
+An aliased property of type <span class="type">int</span><span class="operator">.</span></pre>
+<a name="internal-documentation"></a>
+<h5 id="internal-documentation">Internal Documentation</h5>
+<p>You may declare that a documentation is for internal use by placing the \internal command after the beginning QDoc comment <code>/*</code>. QDoc will prevent the internal documentation from appearing in the public API.</p>
+<p>If you wish to omit certain parts of the documentation, you may use the \omit and \endomit command.</p>
+<a name="qml-types-with-c-implementation"></a>
+<h4 id="qml-types-with-c-implementation">QML Types with C++ Implementation</h4>
+<p>This example only demonstrates the documentation for types in QML files, but the regular QML commands may be placed inside C++ classes to define the public API of the QML type.</p>
+</div>
+<!-- @@@componentset -->
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/noautolist/testcpp-module.html b/tests/auto/qdoc/generatedoutput/expected_output/noautolist/testcpp-module.html
new file mode 100644
index 000000000..8108b0979
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/noautolist/testcpp-module.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- testcpp.cpp -->
+ <title>QDoc Test C++ Classes | Test</title>
+</head>
+<body>
+<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">QDoc Test C++ Classes</h1>
+<span class="subtitle"></span>
+<!-- $$$TestCPP-brief -->
+<p>A test module page. <a href="#details">More...</a></p>
+<!-- @@@TestCPP -->
+<!-- $$$TestCPP-description -->
+<a name="details"></a>
+<div class="descr">
+<h2 id="details">Detailed Description</h2>
+</div>
+<!-- @@@TestCPP -->
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/testdata/configs/noautolist.qdocconf b/tests/auto/qdoc/generatedoutput/testdata/configs/noautolist.qdocconf
new file mode 100644
index 000000000..fc720c57e
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/testdata/configs/noautolist.qdocconf
@@ -0,0 +1,13 @@
+include(testqml.qdocconf)
+defines += test_noautolist
+
+outputformats = HTML DocBook
+
+HTML.nosubdirs = true
+DocBook.nosubdirs = true
+HTML.outputsubdir = noautolist
+DocBook.outputsubdir = noautolist-docbook
+
+# TODO: DocBook generator has trouble handling shared comment nodes
+# - allow two warnings related to these
+warninglimit = 2
diff --git a/tests/auto/qdoc/generatedoutput/testdata/configs/testcpp.qdocconf b/tests/auto/qdoc/generatedoutput/testdata/configs/testcpp.qdocconf
index b07aa71c0..7bb7810f1 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/configs/testcpp.qdocconf
+++ b/tests/auto/qdoc/generatedoutput/testdata/configs/testcpp.qdocconf
@@ -6,6 +6,7 @@ sources = ../testcpp/testcpp.cpp
macro.CMDFN = \\\\fn
macro.nothing = \\dontdocument ()
+macro.testnoautolist = \\if defined(test_noautolist)\n\\noautolist\n\\endif
locationinfo = false
# zero warning tolerance
diff --git a/tests/auto/qdoc/generatedoutput/testdata/qml/componentset/examples.qdoc b/tests/auto/qdoc/generatedoutput/testdata/qml/componentset/examples.qdoc
index 0816e624c..bce12a4ae 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/qml/componentset/examples.qdoc
+++ b/tests/auto/qdoc/generatedoutput/testdata/qml/componentset/examples.qdoc
@@ -30,6 +30,8 @@
\title QML Documentation Example
\brief Example for documenting QML types.
+ \testnoautolist
+
\meta tag {test,sample}
\meta installpath tutorials
diff --git a/tests/auto/qdoc/generatedoutput/testdata/qml/type.cpp b/tests/auto/qdoc/generatedoutput/testdata/qml/type.cpp
index bf04bdb43..2e967c4a2 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/qml/type.cpp
+++ b/tests/auto/qdoc/generatedoutput/testdata/qml/type.cpp
@@ -31,6 +31,8 @@
/*!
\qmlmodule QDoc.Test \QDocTestVer
\brief QML Types for the Test module.
+
+ \testnoautolist
*/
/*!
diff --git a/tests/auto/qdoc/generatedoutput/testdata/testcpp/testcpp.cpp b/tests/auto/qdoc/generatedoutput/testdata/testcpp/testcpp.cpp
index b1acdccf0..8422494ac 100644
--- a/tests/auto/qdoc/generatedoutput/testdata/testcpp/testcpp.cpp
+++ b/tests/auto/qdoc/generatedoutput/testdata/testcpp/testcpp.cpp
@@ -34,6 +34,8 @@ namespace TestQDoc {
\qtvariable testcpp
\title QDoc Test C++ Classes
\brief A test module page.
+
+ \testnoautolist
*/
/*!
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
index 5449a50e2..ead94584a 100644
--- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
+++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
@@ -67,6 +67,7 @@ private slots:
void singleExec();
void preparePhase();
void generatePhase();
+ void noAutoList();
private:
QScopedPointer<QTemporaryDir> m_outputDir;
@@ -378,6 +379,17 @@ void tst_generatedOutput::generatePhase()
"-generate");
}
+void tst_generatedOutput::noAutoList()
+{
+ testAndCompare("testdata/configs/noautolist.qdocconf",
+ "noautolist/testcpp-module.html "
+ "noautolist/test-componentset-example.html "
+ "noautolist/qdoc-test-qmlmodule.html "
+ "noautolist-docbook/testcpp-module.xml "
+ "noautolist-docbook/test-componentset-example.xml "
+ "noautolist-docbook/qdoc-test-qmlmodule.xml");
+}
+
QTEST_APPLESS_MAIN(tst_generatedOutput)
#include "tst_generatedoutput.moc"