From 1d17e5edf2a81a9bcea946fa03ccfe90abf37c8b Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Sat, 4 Mar 2023 22:53:17 +0000 Subject: qdoc: Display individual enum items in \sincelist output The output of \sincelist command lists enumerations introduced in a specific version, documented with \enum with an associated \since meta-command. Individual enum \value entries can also be marked with a since-clause, however, this information was missing from the generated list. Adding support for this is less than trivial because EnumItem is not a Node subclass, and the Sections class, which is responsible for distributing the entries displayed in a since-list, operates on Node instances. To work around this, * Introduce since()/setSince() to EnumItem * Resolve since info for enum values in Tree::resolveSince() * Add enum values to a dedicated map in QDocDatabase * Add enum value since attributes to .index file * Add 'New Enum Values' as a new Section entry In order to generate content for the new section, don't directly populate it; only add a single entry to mark it non-empty. Actual enum values are then fetched from the new 'since-map'. Entries in this map contain a pointer to the associated EnumNode, used for linking. Add a simple test case in generatedoutput autotest. Fixes: QTBUG-110781 Change-Id: I064446dc1e369013284ba934adeabe908754b3bb Reviewed-by: Luca Di Sera --- .../scopedenum-docbook/testqdoc-test.xml | 2 +- .../expected_output/scopedenum/testqdoc-test.html | 2 +- .../expected_output/scopedenum/whatsnew.html | 39 ++++++++++++++++++++++ .../testdata/scopedenum/scopedenum.qdoc | 9 ++++- .../qdoc/generatedoutput/tst_generatedoutput.cpp | 5 +-- 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 tests/auto/qdoc/generatedoutput/expected_output/scopedenum/whatsnew.html (limited to 'tests/auto/qdoc/generatedoutput') diff --git a/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml index b0b7d13bf..5c3cef465 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml +++ b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml @@ -171,7 +171,7 @@ -TestQDoc::Test::ScopedEnum::All +TestQDoc::Test::ScopedEnum::All (since Qt 2.0) This | That diff --git a/tests/auto/qdoc/generatedoutput/expected_output/scopedenum/testqdoc-test.html b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum/testqdoc-test.html index 66bb69623..c6f837f78 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/scopedenum/testqdoc-test.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum/testqdoc-test.html @@ -93,7 +93,7 @@ target_link_libraries(mytarget PRIVATE Qt6::QDocTest)
- +
ConstantValueDescription
TestQDoc::Test::ScopedEnum::This0x01Something
TestQDoc::Test::ScopedEnum::That0x02Something else
TestQDoc::Test::ScopedEnum::AllThis | ThatEverything
TestQDoc::Test::ScopedEnum::All (since Qt 2.0)This | ThatEverything

A scoped enum.

diff --git a/tests/auto/qdoc/generatedoutput/expected_output/scopedenum/whatsnew.html b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum/whatsnew.html new file mode 100644 index 000000000..6d6989f49 --- /dev/null +++ b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum/whatsnew.html @@ -0,0 +1,39 @@ + + + + + + New Classes and Functions | TestCPP + + + +

New Classes and Functions

+ +
+ +

New Namespaces

+
+ +
namespace TestQDoc
+

New Classes

+ +

New Enum Values

+
+ +
enum value ScopedEnum::All
+
+ + + diff --git a/tests/auto/qdoc/generatedoutput/testdata/scopedenum/scopedenum.qdoc b/tests/auto/qdoc/generatedoutput/testdata/scopedenum/scopedenum.qdoc index 625252486..775e5f81e 100644 --- a/tests/auto/qdoc/generatedoutput/testdata/scopedenum/scopedenum.qdoc +++ b/tests/auto/qdoc/generatedoutput/testdata/scopedenum/scopedenum.qdoc @@ -17,7 +17,7 @@ \value That Something else \omitvalue OmittedValue \omit Unused - This decription is omitted \endomit - \value All Everything + \value [since 2.0] All Everything \omitvalue VeryLastValue Nothing here \omitvalue UselessValue @@ -34,3 +34,10 @@ TestQDoc::Test::ClassicEnum::Howdy does not link, but TestQDoc::Test::Howdy might. */ + +/*! + \page whatsnew.html + \title New Classes and Functions + + \sincelist 2.0 +*/ diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp index e8aadeffd..3f280e948 100644 --- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp +++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp @@ -132,12 +132,12 @@ void tst_generatedOutput::compareLineByLine(const QStringList &expectedFiles) QFile expectedFile(expected); if (!expectedFile.open(QIODevice::ReadOnly)) - QFAIL("Cannot open expected data file!"); + QFAIL(qPrintable(QString("Cannot open expected data file: %1").arg(expected))); QTextStream expectedIn(&expectedFile); QFile actualFile(actual); if (!actualFile.open(QIODevice::ReadOnly)) - QFAIL("Cannot open actual data file!"); + QFAIL(qPrintable(QString("Cannot open actual data file: %1").arg(actual))); QTextStream actualIn(&actualFile); const QLatin1String delim(": "); @@ -379,6 +379,7 @@ void tst_generatedOutput::scopedEnum() testAndCompare("testdata/configs/scopedenum.qdocconf", "scopedenum/testqdoc-test.html " "scopedenum/scoped-enum-linking.html " + "scopedenum/whatsnew.html " "scopedenum-docbook/scoped-enum-linking.xml " "scopedenum-docbook/testqdoc-test.xml"); } -- cgit v1.2.1