From 12801a531be233eafbf81ebd579bd03b1363e30a Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 12 May 2020 22:33:25 +0200 Subject: qdoc: Fix regression in HeaderNode name handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit a4d4aad793561ee3e397595f8a1db71651bc1b1b) Reviewed-by: Topi Reiniƶ --- src/qdoc/node.cpp | 2 + .../expected_output/headerfile-docbook/headers.xml | 19 ++++++ .../headerfile-docbook/testheader.xml | 22 +++++++ .../expected_output/headerfile/headers.html | 20 ++++++ .../expected_output/headerfile/testheader.html | 72 ++++++++++++++++++++++ .../testdata/configs/headerfile.qdocconf | 17 +++++ .../testdata/headerfile/testheader.cpp | 61 ++++++++++++++++++ .../testdata/headerfile/testheader.h | 33 ++++++++++ .../qdoc/generatedoutput/tst_generatedoutput.cpp | 11 +++- 9 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/headers.xml create mode 100644 tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml create mode 100644 tests/auto/qdoc/generatedoutput/expected_output/headerfile/headers.html create mode 100644 tests/auto/qdoc/generatedoutput/expected_output/headerfile/testheader.html create mode 100644 tests/auto/qdoc/generatedoutput/testdata/configs/headerfile.qdocconf create mode 100644 tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.cpp create mode 100644 tests/auto/qdoc/generatedoutput/testdata/headerfile/testheader.h 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 @@ + + + +Headers +HeaderFile +HeaderFile Reference Documentation + +HeaderFile Reference Documentation. + + + + +<TestHeader> + +A header file. + + + + 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 @@ + + + + +HeaderFile +HeaderFile Reference Documentation + +A header file. + + + + +Header + +TestHeader + + + + +Detailed Description + + 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 @@ + + + + + + Headers | HeaderFile + + + +

Headers

+ + +
+
+ +
+ +

<TestHeader>

A header file

+ + 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 @@ + + + + + + <TestHeader> - Test Header | HeaderFile + + +
  • Headers
  • +
  • <TestHeader> - Test Header
  • + +

    <TestHeader> - Test Header

    + +

    A header file. More...

    + +
    +
    Header: #include <TestHeader> +
      +
    + +

    Types

    +
    + +
    enum Globals { Glo, Bal }
    + +

    Variables

    +
    + +
    const int globalVar
    + +

    Functions

    +
    + +
    void globalFunc()
    + + +
    +

    Detailed Description

    +
    + +
    +

    Type Documentation

    + +

    enum Globals

    +
    + + +
    ConstantValue
    Glo0
    Bal1
    + +
    +
    +

    Variable Documentation

    + +

    const int globalVar

    +

    Global variable.

    + +
    +
    +

    Function Documentation

    + +

    void globalFunc()

    +

    Global function.

    + +
    + + 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 + \title Test Header + \inmodule TestCPP + \brief A header file. + \ingroup headers +*/ + +/*! + \group headers + \title Headers +*/ + +/*! + \fn void globalFunc() + \brief Global function. + \relates +*/ + +/*! + \variable globalVar + \brief Global variable. + \relates +*/ + +/*! + \enum Globals + \relates + \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 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; -- cgit v1.2.3