diff options
author | Topi Reinio <topi.reinio@qt.io> | 2023-04-18 20:44:37 +0000 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2023-04-24 18:39:34 +0000 |
commit | 046447a6fa686ed076a7df8d27b00abe0811750b (patch) | |
tree | c9c37c295dea71830be609d765a61965e2eb9727 /src/qdoc/qdoc/generator.cpp | |
parent | edf1e91454b1354bc3da718b2fe76930f894ff77 (diff) | |
download | qttools-046447a6fa686ed076a7df8d27b00abe0811750b.tar.gz |
qdoc: Add status information to the requisites table for types
QDoc provides various ways to document the status of an entity;
\deprecated, \preliminary, and \modulestate commands. These
commands produce a brief sentence describing the status, however,
for C++ and QML types, a logical place for this information is
also the 'requisites' table at the start of the page.
Having the status information in the table makes it more
apparent for the reader that they're looking at documentation
for a deprecated or preliminary type. For HTML generator, this
commit also adds a <span> element that allows additional
visuals via CSS (e.g. an icon) for a specific status.
Pick-to: 6.5
Fixes: QTBUG-113026
Change-Id: If38a6d51631277a0d98b2cb702acf2598b694643
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
Diffstat (limited to 'src/qdoc/qdoc/generator.cpp')
-rw-r--r-- | src/qdoc/qdoc/generator.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/qdoc/qdoc/generator.cpp b/src/qdoc/qdoc/generator.cpp index f5df13087..174cb9c8f 100644 --- a/src/qdoc/qdoc/generator.cpp +++ b/src/qdoc/qdoc/generator.cpp @@ -1106,6 +1106,37 @@ QString Generator::formatSince(const Node *node) return node->since(); } +/*! + \internal + Returns a string representing status information of a \a node. + + If a status description is returned, it is one of: + \list + \li 'Deprecated [since <version>]' (\\deprecated [<version>]), + \li 'Preliminary' (\\preliminary), or + \li The description adopted from associated module's state: + \c {\modulestate {<description>}}. + \endlist + + Otherwise, returns \c std::nullopt. +*/ +std::optional<QString> formatStatus(const Node *node, QDocDatabase *qdb) +{ + QString status; + + if (node->status() == Node::Deprecated) { + status = u"Deprecated"_s; + if (const auto since = node->deprecatedSince(); !since.isEmpty()) + status += " since %1"_L1.arg(since); + } else if (node->status() == Node::Preliminary) { + status = u"Preliminary"_s; + } else if (const auto collection = qdb->getModuleNode(node); collection) { + status = collection->state(); + } + + return status.isEmpty() ? std::nullopt : std::optional(status); +} + void Generator::generateSince(const Node *node, CodeMarker *marker) { if (!node->since().isEmpty()) { |