diff options
author | Topi Reinio <topi.reinio@qt.io> | 2019-09-04 14:14:01 +0200 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2019-09-05 00:05:28 +0200 |
commit | 2174b1a34a0754376b77528161bf2328855cb0e7 (patch) | |
tree | 97fc366a0a59d02287cf651eed19af33349bab46 | |
parent | f51776c427b268caf348efa524264c5e25e31a18 (diff) |
Add an initial test case for C++ documentation generated by QDoc
This will be expanded later on. The minimal C++ project tests QDoc's
HTML output for a module page, namespace and class reference, and
some class members.
Change-Id: Ifabc394116b675152d3ac95dc96a46e6e9c768ec
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
9 files changed, 306 insertions, 0 deletions
diff --git a/tests/auto/qdoc/generatedoutput/TestCPP b/tests/auto/qdoc/generatedoutput/TestCPP new file mode 100644 index 000000000..50cce69ff --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/TestCPP @@ -0,0 +1 @@ +#include "testcpp.h" diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testcpp-module.html b/tests/auto/qdoc/generatedoutput/expected_output/testcpp-module.html new file mode 100644 index 000000000..92103d867 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/testcpp-module.html @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<!-- testcpp.cpp --> + <title>QDoc Test C++ Classes | TestCPP</title> +</head> +<body> +<div class="sidebar"> +<div class="toc"> +<h3><a name="toc">Contents</a></h3> +<ul> +<li class="level1"><a href="#namespaces">Namespaces</a></li> +<li class="level1"><a href="#classes">Classes</a></li> +<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 --> +<a name="namespaces"></a> +<h2 id="namespaces">Namespaces</h2> +<div class="table"><table class="annotated"> +<tr class="odd topAlign"><td class="tblName"><p><a href="testqdoc.html">TestQDoc</a></p></td><td class="tblDescr"><p>A namespace</p></td></tr> +</table></div> +<a name="classes"></a> +<h2 id="classes">Classes</h2> +<div class="table"><table class="annotated"> +<tr class="odd 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> +</table></div> +<!-- $$$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/expected_output/testqdoc-test-members.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test-members.html new file mode 100644 index 000000000..caa002a7d --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test-members.html @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<!-- testcpp.cpp --> + <title>List of All Members for Test | TestCPP</title> +</head> +<body> +<li>Test</li> +<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div> +<h1 class="title">List of All Members for Test</h1> +<p>This is the complete list of members for <a href="testqdoc-test.html">TestQDoc::Test</a>, including inherited members.</p> +<ul> +<li class="fn"><span class="name"><b><a href="testqdoc-test.html#inlineFunction">inlineFunction</a></b></span>()</li> +<li class="fn"><span class="name"><b><a href="testqdoc-test.html#someFunction">someFunction</a></b></span>(int ) : int</li> +</ul> +</body> +</html> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html new file mode 100644 index 000000000..f0ef69491 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<!-- testcpp.cpp --> + <title>Test Class | TestCPP</title> +</head> +<body> +<li>Test</li> +<div class="sidebar"> +<div class="toc"> +<h3><a name="toc">Contents</a></h3> +<ul> +<li class="level1"><a href="#public-functions">Public Functions</a></li> +<li class="level1"><a href="#details">Detailed Description</a></li> +</ul> +</div> +<div class="sidebar-content" id="sidebar-content"></div></div> +<h1 class="title">Test Class</h1> +<span class="small-subtitle">(<a href="testqdoc-test.html">TestQDoc::Test</a>)<br/></span> +<!-- $$$Test-brief --> +<p>A class in a namespace. <a href="#details">More...</a></p> +<!-- @@@Test --> +<div class="table"><table class="alignedsummary"> +<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <Test></span> +</td></tr></table></div><ul> +<li><a href="testqdoc-test-members.html">List of all members, including inherited members</a></li> +</ul> +<a name="public-functions"></a> +<h2 id="public-functions">Public Functions</h2> +<div class="table"><table class="alignedsummary"> +<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html#inlineFunction">inlineFunction</a></b>()</td></tr> +<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html#someFunction">someFunction</a></b>(int <i>v</i>)</td></tr> +</table></div> +<a name="details"></a> +<!-- $$$Test-description --> +<div class="descr"> +<h2 id="details">Detailed Description</h2> +</div> +<!-- @@@Test --> +<div class="func"> +<h2>Member Function Documentation</h2> +<!-- $$$inlineFunction[overload1]$$$inlineFunction --> +<h3 class="fn" id="inlineFunction"><a name="inlineFunction"></a><span class="type">void</span> Test::<span class="name">inlineFunction</span>()</h3> +<p>An inline function, documented using the \fn QDoc command.</p> +<!-- @@@inlineFunction --> +<!-- $$$someFunction[overload1]$$$someFunctionint --> +<h3 class="fn" id="someFunction"><a name="someFunction"></a><span class="type">int</span> Test::<span class="name">someFunction</span>(<span class="type">int</span> <i>v</i>)</h3> +<p>Function that takes a parameter <i>v</i>. Also returns the value of <i>v</i>.</p> +<!-- @@@someFunction --> +</div> +</body> +</html> diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc.html new file mode 100644 index 000000000..d46a4f5c8 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc.html @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<!-- testcpp.cpp --> + <title>TestQDoc Namespace | TestCPP</title> +</head> +<body> +<div class="sidebar"> +<div class="toc"> +<h3><a name="toc">Contents</a></h3> +<ul> +<li class="level1"><a href="#classes">Classes</a></li> +<li class="level1"><a href="#macros">Macros</a></li> +<li class="level1"><a href="#details">Detailed Description</a></li> +<li class="level2"><a href="#usage">Usage</a></li> +</ul> +</div> +<div class="sidebar-content" id="sidebar-content"></div></div> +<h1 class="title">TestQDoc Namespace</h1> +<!-- $$$TestQDoc-brief --> +<p>A namespace. <a href="#details">More...</a></p> +<!-- @@@TestQDoc --> +<div class="table"><table class="alignedsummary"> +<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <TestQDoc></span> +</td></tr></table></div><ul> +</ul> +<a name="classes"></a> +<h2 id="classes">Classes</h2> +<div class="table"><table class="alignedsummary"> +<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="testqdoc-test.html">Test</a></b></td></tr> +</table></div> +<a name="macros"></a> +<h2 id="macros">Macros</h2> +<div class="table"><table class="alignedsummary"> +<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="testqdoc.html#QDOCTEST_MACRO">QDOCTEST_MACRO</a></b></td></tr> +</table></div> +<a name="details"></a> +<!-- $$$TestQDoc-description --> +<div class="descr"> +<h2 id="details">Detailed Description</h2> +<a name="usage"></a> +<h3 id="usage">Usage</h3> +<p>This namespace is for testing QDoc output.</p> +</div> +<!-- @@@TestQDoc --> +<div class="classes"> +<h2>Classes</h2> +<h3> class <a href="testqdoc-test.html">Test</a></h3><!-- $$$Test-brief --> +<p>A class in a namespace. <a href="testqdoc-test.html#details">More...</a></p> +<!-- @@@Test --> +</div> +<div class="macros"> +<h2>Macro Documentation</h2> +<!-- $$$QDOCTEST_MACRO[overload1]$$$QDOCTEST_MACRO --> +<h3 class="fn" id="QDOCTEST_MACRO"><a name="QDOCTEST_MACRO"></a>TestQDoc::<span class="name">QDOCTEST_MACRO</span></h3> +<!-- @@@QDOCTEST_MACRO --> +</div> +</body> +</html> diff --git a/tests/auto/qdoc/generatedoutput/testcpp.cpp b/tests/auto/qdoc/generatedoutput/testcpp.cpp new file mode 100644 index 000000000..12698c9d6 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testcpp.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "testcpp.h" + +namespace TestQDoc { + +/*! + \module TestCPP + \title QDoc Test C++ Classes + \brief A test module page. +*/ + +/*! + \namespace TestQDoc + \inmodule TestCPP + \brief A namespace. + + \section1 Usage + This namespace is for testing QDoc output. +*/ + +/*! + \class TestQDoc::Test + \inmodule TestCPP + \brief A class in a namespace. +*/ + +/*! + \macro QDOCTEST_MACRO + \relates TestQDoc +*/ + +/*! + Function that takes a parameter \a v. + Also returns the value of \a v. +*/ +int Test::someFunction(int v) +{ + return v; +} + +/*! + \fn void TestQDoc::Test::inlineFunction() + + \brief An inline function, documented using the \CMDFN QDoc command. +*/ + +} // namespace TestQDoc diff --git a/tests/auto/qdoc/generatedoutput/testcpp.h b/tests/auto/qdoc/generatedoutput/testcpp.h new file mode 100644 index 000000000..46355711c --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testcpp.h @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 +#define QDOCTEST_MACRO test + +namespace TestQDoc { + +class Test { +public: + int someFunction(int v); + inline void inlineFunction() {}; +}; + +} // namespace TestQDoc diff --git a/tests/auto/qdoc/generatedoutput/testcpp.qdocconf b/tests/auto/qdoc/generatedoutput/testcpp.qdocconf new file mode 100644 index 000000000..70c226cf2 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/testcpp.qdocconf @@ -0,0 +1,7 @@ +project = TestCPP +includepaths += -I. + +headers = testcpp.h +sources = testcpp.cpp + +macro.CMDFN = \\\\fn diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp index 01134517a..103198d42 100644 --- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp +++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp @@ -38,6 +38,7 @@ private slots: void init(); void htmlFromQDocFile(); + void htmlFromCpp(); void htmlFromQml(); private: @@ -138,6 +139,15 @@ void tst_generatedOutput::htmlFromQDocFile() "qdoctests-qdocfileoutput.html"); } +void tst_generatedOutput::htmlFromCpp() +{ + testAndCompare("testcpp.qdocconf", + "testcpp-module.html " + "testqdoc-test.html " + "testqdoc-test-members.html " + "testqdoc.html"); +} + void tst_generatedOutput::htmlFromQml() { testAndCompare("testqml.qdocconf", |