summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-05-12 22:33:25 +0200
committerTopi Reinio <topi.reinio@qt.io>2020-05-19 11:13:07 +0200
commit12801a531be233eafbf81ebd579bd03b1363e30a (patch)
tree59c271e30cf197e37c2965667d6e4548b4bf6f49
parentbed49e664c0ae6719e712c4750feb2b704484977 (diff)
qdoc: Fix regression in HeaderNode name handling
Node::plainFullName() constructs a fully qualified name for a node, traversing the chain of parents until it comes across the root namespace or a HeaderNode - but if the start node was already a header, it incorrectly returned an empty string as the node name. Fix the issue and add a test for output generated by \headerfile command. Fixes: QTBUG-84070 Change-Id: Ib214c53be8ed0eea98708219a00ba43970cd4177 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit a4d4aad793561ee3e397595f8a1db71651bc1b1b) Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/node.cpp2
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/headers.xml19
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml22
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/headerfile/headers.html20
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/headerfile/testheader.html72
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/configs/headerfile.qdocconf17
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.cpp61
-rw-r--r--tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.h33
-rw-r--r--tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp11
9 files changed, 256 insertions, 1 deletions
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index cf8fa00f5..bf2fcd4f7 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -608,6 +608,8 @@ QString Node::plainFullName(const Node *relative) const
{
if (name_.isEmpty())
return QLatin1String("global");
+ if (isHeader())
+ return plainName();
QStringList parts;
const Node *node = this;
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/headers.xml b/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/headers.xml
new file mode 100644
index 000000000..052108b2a
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/headers.xml
@@ -0,0 +1,19 @@
+<?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>Headers</db:title>
+<db:productname>HeaderFile</db:productname>
+<db:titleabbrev>HeaderFile Reference Documentation</db:titleabbrev>
+<db:abstract>
+<db:para>HeaderFile Reference Documentation.</db:para></db:abstract>
+</db:info>
+<db:anchor xml:id="details"/>
+<db:variablelist role="members">
+<db:varlistentry>
+<db:term><db:link xlink:href="testheader.xml" xlink:role="">&lt;TestHeader&gt;</db:link></db:term>
+<db:listitem>
+<db:para>A header file.</db:para>
+</db:listitem>
+</db:varlistentry>
+</db:variablelist>
+</db:article>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml b/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml
new file mode 100644
index 000000000..f3461fb1a
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml
@@ -0,0 +1,22 @@
+<?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>HeaderFile</db:productname>
+<db:titleabbrev>HeaderFile Reference Documentation</db:titleabbrev>
+<db:abstract>
+<db:para>A header file.</db:para>
+</db:abstract>
+</db:info>
+<db:variablelist>
+<db:varlistentry>
+<db:term>Header</db:term>
+<db:listitem>
+<db:para>TestHeader</db:para>
+</db:listitem>
+</db:varlistentry>
+</db:variablelist>
+<db:section xml:id="details">
+<db:title>Detailed Description</db:title>
+</db:section>
+</db:article>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/headerfile/headers.html b/tests/auto/qdoc/generatedoutput/expected_output/headerfile/headers.html
new file mode 100644
index 000000000..65b88eca4
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/headerfile/headers.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- testheader.cpp -->
+ <title>Headers | HeaderFile</title>
+</head>
+<body>
+<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
+<h1 class="title">Headers</h1>
+<span class="subtitle"></span>
+<!-- $$$headers-description -->
+<div class="descr"> <a name="details"></a>
+</div>
+<!-- @@@headers -->
+<div class="table"><table class="annotated">
+<tr class="odd topAlign"><td class="tblName"><p><a href="testheader.html">&lt;TestHeader&gt;</a></p></td><td class="tblDescr"><p>A header file</p></td></tr>
+</table></div>
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/headerfile/testheader.html b/tests/auto/qdoc/generatedoutput/expected_output/headerfile/testheader.html
new file mode 100644
index 000000000..f67de8a3f
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/expected_output/headerfile/testheader.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+<!-- testheader.cpp -->
+ <title>&lt;TestHeader&gt; - Test Header | HeaderFile</title>
+</head>
+<body>
+<li><a href="headers.html">Headers</a></li>
+<li>&lt;TestHeader&gt; - Test Header</li>
+<div class="sidebar">
+<div class="toc">
+<h3><a name="toc">Contents</a></h3>
+<ul>
+</ul>
+</div>
+<div class="sidebar-content" id="sidebar-content"></div></div>
+<h1 class="title">&lt;TestHeader&gt; - Test Header</h1>
+<!-- $$$<TestHeader>-brief -->
+<p>A header file. <a href="#details">More...</a></p>
+<!-- @@@<TestHeader> -->
+<div class="table"><table class="alignedsummary">
+<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &lt;TestHeader&gt;</span>
+</td></tr></table></div><ul>
+</ul>
+<a name="types"></a>
+<h2 id="types">Types</h2>
+<div class="table"><table class="alignedsummary">
+<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="testheader.html#Globals-enum">Globals</a></b> { Glo, Bal }</td></tr>
+</table></div>
+<a name="variables"></a>
+<h2 id="variables">Variables</h2>
+<div class="table"><table class="alignedsummary">
+<tr><td class="memItemLeft rightAlign topAlign"> const int </td><td class="memItemRight bottomAlign"><b><a href="testheader.html#globalVar-var">globalVar</a></b></td></tr>
+</table></div>
+<a name="functions"></a>
+<h2 id="functions">Functions</h2>
+<div class="table"><table class="alignedsummary">
+<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="testheader.html#globalFunc">globalFunc</a></b>()</td></tr>
+</table></div>
+<a name="details"></a>
+<!-- $$$<TestHeader>-description -->
+<div class="descr">
+<h2 id="details">Detailed Description</h2>
+</div>
+<!-- @@@<TestHeader> -->
+<div class="types">
+<h2>Type Documentation</h2>
+<!-- $$$Globals$$$Glo$$$Bal -->
+<h3 class="fn" id="Globals-enum"><a name="Globals-enum"></a>enum <span class="name">Globals</span></h3>
+<div class="table"><table class="valuelist"><tr><th class="tblConst">Constant</th><th class="tblVal">Value</th></tr>
+<tr><td class="topAlign"><code>Glo</code></td><td class="topAlign tblval"><code>0</code></td></tr>
+<tr><td class="topAlign"><code>Bal</code></td><td class="topAlign tblval"><code>1</code></td></tr>
+</table></div>
+<!-- @@@Globals -->
+</div>
+<div class="vars">
+<h2>Variable Documentation</h2>
+<!-- $$$globalVar -->
+<h3 class="fn" id="globalVar-var"><a name="globalVar-var"></a>const <span class="type">int</span> <span class="name">globalVar</span></h3>
+<p>Global variable.</p>
+<!-- @@@globalVar -->
+</div>
+<div class="func">
+<h2>Function Documentation</h2>
+<!-- $$$globalFunc[overload1]$$$globalFunc -->
+<h3 class="fn" id="globalFunc"><a name="globalFunc"></a><span class="type">void</span> <span class="name">globalFunc</span>()</h3>
+<p>Global function.</p>
+<!-- @@@globalFunc -->
+</div>
+</body>
+</html>
diff --git a/tests/auto/qdoc/generatedoutput/testdata/configs/headerfile.qdocconf b/tests/auto/qdoc/generatedoutput/testdata/configs/headerfile.qdocconf
new file mode 100644
index 000000000..b270556d1
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/testdata/configs/headerfile.qdocconf
@@ -0,0 +1,17 @@
+project = HeaderFile
+moduleheader = testheader.h
+
+{includepaths,sourcedirs,headerdirs} += ../headerfile
+
+sources.fileextensions = "*.cpp *.qdoc"
+headers.fileextensions = "*.h"
+
+outputformats = HTML DocBook
+HTML.nosubdirs = true
+HTML.outputsubdir = headerfile
+DocBook.nosubdirs = true
+DocBook.outputsubdir = headerfile-docbook
+
+# zero warning tolerance
+warninglimit = 0
+warninglimit.enabled = true
diff --git a/tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.cpp b/tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.cpp
new file mode 100644
index 000000000..3a85b169c
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 "testheader.h"
+
+/*!
+ \headerfile <TestHeader>
+ \title Test Header
+ \inmodule TestCPP
+ \brief A header file.
+ \ingroup headers
+*/
+
+/*!
+ \group headers
+ \title Headers
+*/
+
+/*!
+ \fn void globalFunc()
+ \brief Global function.
+ \relates <TestHeader>
+*/
+
+/*!
+ \variable globalVar
+ \brief Global variable.
+ \relates <TestHeader>
+*/
+
+/*!
+ \enum Globals
+ \relates <TestHeader>
+ \value Glo
+ \value Bal
+*/
diff --git a/tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.h b/tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.h
new file mode 100644
index 000000000..94c625157
--- /dev/null
+++ b/tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** 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
+
+void globalFunc() {};
+enum Globals { Glo, Bal };
+const int globalVar;
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
index 7cc0e67ab..1cc15a10d 100644
--- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
+++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
@@ -72,6 +72,7 @@ private slots:
void generatePhase();
void noAutoList();
void nestedMacro();
+ void headerFile();
private:
QScopedPointer<QTemporaryDir> m_outputDir;
@@ -414,13 +415,21 @@ void tst_generatedOutput::noAutoList()
"noautolist-docbook/qdoc-test-qmlmodule.xml");
}
-
void tst_generatedOutput::nestedMacro()
{
testAndCompare("testdata/configs/nestedmacro.qdocconf",
"nestedmacro/testcpp-module.html");
}
+void tst_generatedOutput::headerFile()
+{
+ testAndCompare("testdata/configs/headerfile.qdocconf",
+ "headerfile/testheader.html "
+ "headerfile/headers.html "
+ "headerfile-docbook/testheader.xml "
+ "headerfile-docbook/headers.xml");
+}
+
int main(int argc, char *argv[])
{
tst_generatedOutput tc;