summaryrefslogtreecommitdiff
path: root/src/qdoc/qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/qdoc/qdoc')
-rw-r--r--src/qdoc/qdoc/docbookgenerator.cpp8
-rw-r--r--src/qdoc/qdoc/generator.cpp31
-rw-r--r--src/qdoc/qdoc/generator.h3
-rw-r--r--src/qdoc/qdoc/htmlgenerator.cpp48
-rw-r--r--src/qdoc/qdoc/htmlgenerator.h2
5 files changed, 89 insertions, 3 deletions
diff --git a/src/qdoc/qdoc/docbookgenerator.cpp b/src/qdoc/qdoc/docbookgenerator.cpp
index cc75cac07..648a0a43d 100644
--- a/src/qdoc/qdoc/docbookgenerator.cpp
+++ b/src/qdoc/qdoc/docbookgenerator.cpp
@@ -2825,6 +2825,10 @@ void DocBookGenerator::generateRequisites(const Aggregate *aggregate)
generateEndRequisite();
}
+ // Status.
+ if (auto status = formatStatus(aggregate, m_qdb); status)
+ generateRequisite("Status", status.value());
+
// Write the elements as a list if not empty.
delete m_writer;
m_writer = oldWriter;
@@ -2928,6 +2932,10 @@ void DocBookGenerator::generateQmlRequisites(const QmlTypeNode *qcn)
generateEndRequisite();
}
+ // Status.
+ if (auto status = formatStatus(qcn, m_qdb); status)
+ generateRequisite("Status:", status.value());
+
m_writer->writeEndElement(); // variablelist
newLine();
}
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()) {
diff --git a/src/qdoc/qdoc/generator.h b/src/qdoc/qdoc/generator.h
index fbbff827f..6611cb7b6 100644
--- a/src/qdoc/qdoc/generator.h
+++ b/src/qdoc/qdoc/generator.h
@@ -13,6 +13,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qtextstream.h>
+#include <optional>
QT_BEGIN_NAMESPACE
@@ -198,6 +199,8 @@ protected:
QString m_sectionNumber {};
};
+std::optional<QString> formatStatus(const Node *node, QDocDatabase *qdb);
+
QT_END_NAMESPACE
#endif
diff --git a/src/qdoc/qdoc/htmlgenerator.cpp b/src/qdoc/qdoc/htmlgenerator.cpp
index 304989f9c..545541aad 100644
--- a/src/qdoc/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/qdoc/htmlgenerator.cpp
@@ -36,6 +36,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
bool HtmlGenerator::s_inUnorderedList { false };
HtmlGenerator::HtmlGenerator(FileResolver& file_resolver) : XmlGenerator(file_resolver) {}
@@ -1917,10 +1919,11 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker)
const QString instantiatedByText = "Instantiated By";
const QString qtVariableText = "qmake";
const QString cmakeText = "CMake";
+ const QString statusText = "Status";
// The order of the requisites matter
- const QStringList requisiteorder { headerText, cmakeText, qtVariableText, sinceText,
- instantiatedByText, inheritsText, inheritedBytext };
+ const QStringList requisiteorder { headerText, cmakeText, qtVariableText, sinceText,
+ instantiatedByText, inheritsText, inheritedBytext, statusText };
addIncludeFileToMap(aggregate, marker, requisites, text, headerText);
addSinceToMap(aggregate, requisites, &text, sinceText);
@@ -1939,6 +1942,9 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker)
addInheritedByToMap(requisites, &text, inheritedBytext, classe);
}
+ // Add the state description (if any) to the map
+ addStatusToMap(aggregate, requisites, text, statusText);
+
if (!requisites.isEmpty()) {
// generate the table
generateTheTable(requisiteorder, requisites, headerText, aggregate, marker);
@@ -2097,6 +2103,38 @@ void HtmlGenerator::addSinceToMap(const Aggregate *aggregate, QMap<QString, Text
/*!
* \internal
+ * Adds the status description for \a aggregate, together with a <span> element, to the \a
+ * requisites map.
+ *
+ * The span element can be used for adding CSS styling/icon associated with a specific status.
+ * The span class name is constructed by converting the description (sans \\deprecated
+ * version info) to lowercase and replacing all non-alphanum characters with hyphens. In
+ * addition, the span has a class \c status. For example,
+ * 'Tech Preview' -> class="status tech-preview"
+*/
+void HtmlGenerator::addStatusToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites,
+ Text &text, const QString &statusText) const
+{
+ auto status{formatStatus(aggregate, m_qdb)};
+ if (!status)
+ return;
+
+ QString spanClass;
+ if (aggregate->status() == Node::Deprecated)
+ spanClass = u"deprecated"_s; // Disregard any version info
+ else
+ spanClass = Utilities::canonicalizeFileName(status.value());
+
+ text.clear();
+ text << Atom(Atom::String, status.value())
+ << Atom(Atom::FormattingLeft, ATOM_FORMATTING_SPAN +
+ "class=\"status %1\""_L1.arg(spanClass))
+ << Atom(Atom::FormattingRight, ATOM_FORMATTING_SPAN);
+ requisites.insert(statusText, text);
+}
+
+/*!
+ * \internal
* Adds the includes (from the \\includefile command) to the map.
*/
void HtmlGenerator::addIncludeFileToMap(const Aggregate *aggregate, CodeMarker *marker,
@@ -2130,6 +2168,7 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker)
const QString inheritedBytext = "Inherited By:";
const QString inheritsText = "Inherits:";
const QString instantiatesText = "Instantiates:";
+ const QString statusText = "Status:";
// add the module name and version to the map
QString logicalModuleVersion;
@@ -2189,9 +2228,12 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker)
requisites.insert(inheritedBytext, text);
}
+ // Add the state description (if any) to the map
+ addStatusToMap(qcn, requisites, text, statusText);
+
// The order of the requisites matter
const QStringList requisiteorder { importText, sinceText, instantiatesText, inheritsText,
- inheritedBytext };
+ inheritedBytext, statusText };
if (!requisites.isEmpty()) {
// generate the table
diff --git a/src/qdoc/qdoc/htmlgenerator.h b/src/qdoc/qdoc/htmlgenerator.h
index 3c12ce328..4592e41d7 100644
--- a/src/qdoc/qdoc/htmlgenerator.h
+++ b/src/qdoc/qdoc/htmlgenerator.h
@@ -107,6 +107,8 @@ private:
const QString &headerText);
void addSinceToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites, Text *text,
const QString &sinceText) const;
+ void addStatusToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites, Text &text,
+ const QString &statusText) const;
void addCMakeInfoToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites, Text *text,
const QString &CMakeInfo) const;
void addQtVariableToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites, Text *text,