diff options
author | Topi Reinio <topi.reinio@qt.io> | 2020-03-27 12:58:49 +0100 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2020-03-29 20:20:28 +0200 |
commit | 739e404eee420257f217001c5df753585b8a9031 (patch) | |
tree | 42d655ec93a81154a5a07ce46b099044622df870 | |
parent | 24b8e654a0d6485d447da54ba017a1eb9ec3f22d (diff) |
qdoc: Fix regression in resolved example file paths
A recent refactoring of code related to generation of example file
lists caused a regression; if the parameter passed to an \example
command contained subdirectories, e.g.
\example tutorials/gettingstarted
only the immediate example directory ('gettingstarted' above) was
recorded in generated example lists and manifest files.
Ensure that the file paths are prefixed with the full example
location, and add a test to cover this.
Fixes: QTBUG-83130
Change-Id: I061dcf6cd4e94a2c65e5a50a39f379759d7cd06f
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
7 files changed, 49 insertions, 2 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index 065032024..5248c990d 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -813,8 +813,7 @@ void CppCodeParser::setExampleFileLists(ExampleNode *en) QLatin1String("*.qrc *.pro *.qmlproject *.pyproject CMakeLists.txt qmldir")); } - exampleDir.cdUp(); - int pathLen = exampleDir.path().size() + 1; + const int pathLen = exampleDir.path().size() - en->name().size(); for (auto &file : exampleFiles) file = file.mid(pathLen); for (auto &file : imageFiles) diff --git a/tests/auto/qdoc/generatedoutput/expected_output/demos-manifest.xml b/tests/auto/qdoc/generatedoutput/expected_output/demos-manifest.xml new file mode 100644 index 000000000..d83906f44 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/demos-manifest.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<instructionals module="Test"> + <demos> + <demo name="Demo" docUrl="qthelp://org.qt-project.test.001/test/test-demos-demo-example.html" projectPath="test/demos/demo/demo.pro" isTest="true"> + <description><![CDATA[No description available]]></description> + <tags>demo,test</tags> + </demo> + </demos> +</instructionals> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/test.qhp b/tests/auto/qdoc/generatedoutput/expected_output/test.qhp index 459892df1..387e018ae 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/test.qhp +++ b/tests/auto/qdoc/generatedoutput/expected_output/test.qhp @@ -9,6 +9,7 @@ <section ref="uicomponents-qmlmodule.html" title="Test"> <section ref="qdoc-test-qmlmodule.html" title=""/> <section ref="test-cmaketest-example.html" title="CMake Example Project"/> + <section ref="test-demos-demo-example.html" title="Demo"/> <section ref="testcpp-module.html" title="QDoc Test C++ Classes"/> <section ref="test-componentset-example.html" title="QML Documentation Example"/> <section ref="uicomponents-qmlmodule.html" title="UI Components"/> @@ -128,6 +129,7 @@ <file>test-componentset-progressbar-qml.html</file> <file>test-componentset-switch-qml.html</file> <file>test-componentset-tabwidget-qml.html</file> + <file>test-demos-demo-example.html</file> <file>testcpp-module.html</file> <file>testqdoc-test-members.html</file> <file>testqdoc-test-obsolete.html</file> diff --git a/tests/auto/qdoc/generatedoutput/testdata/configs/examples-qhp.qdocconf b/tests/auto/qdoc/generatedoutput/testdata/configs/examples-qhp.qdocconf index a1ed619a3..11695289e 100644 --- a/tests/auto/qdoc/generatedoutput/testdata/configs/examples-qhp.qdocconf +++ b/tests/auto/qdoc/generatedoutput/testdata/configs/examples-qhp.qdocconf @@ -4,6 +4,8 @@ version = 0.0.1 examplesinstallpath = test +exampledirs += ../examples + # Configure .qhp generation qhp.projects = Test diff --git a/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/demo.pro b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/demo.pro new file mode 100644 index 000000000..dbe8ff3c0 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/demo.pro @@ -0,0 +1,2 @@ +TEMPLATE = aux +message("Nothing to see here.") diff --git a/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc new file mode 100644 index 000000000..08b609126 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testdata/examples/demos/demo/doc/src/demo.qdoc @@ -0,0 +1,32 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/*! + \example demos/demo + \title Demo +*/ diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp index 7bf8b3210..40fcdfcac 100644 --- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp +++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp @@ -295,6 +295,7 @@ void tst_generatedOutput::examplesManifestXmlAndQhp() { testAndCompare("testdata/configs/examples-qhp.qdocconf", "examples-manifest.xml " + "demos-manifest.xml " "test.qhp"); } |