diff options
author | Martin Smith <martin.smith@qt.io> | 2018-10-08 14:36:21 +0200 |
---|---|---|
committer | Martin Smith <martin.smith@qt.io> | 2018-10-23 14:15:35 +0000 |
commit | 876ded011508fff3cb029f3a4b7545364c9eaeff (patch) | |
tree | bac29a16d48c66b2011830e2ef1a6f00a3a81f73 | |
parent | c4d02e5cea9f8657bd74f1f724d048de5c0142b1 (diff) |
qdoc: support \generatelist <groupname>
qdoc now supports the command shown in the subject line. It generates
a simple bullet list showing all the members of the named group. Each
member of the group is shown as a link to the title of the page.
Change-Id: I080ff5c03440ea7e16a54b9821acb9b72b2ba95e
Reviewed-by: Martin Smith <martin.smith@qt.io>
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 32 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index ec92d4316..027b011be 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -779,6 +779,14 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark } else if (atom->string() == QLatin1String("related")) { generateList(relative, marker, "related"); + } else { + const CollectionNode* cn = qdb_->getCollectionNode(atom->string(), Node::Group); + if (cn) { + if (!generateGroupList(const_cast<CollectionNode*>(cn))) + relative->location().warning(QString("'\\generatelist \1' group is empty").arg(atom->string())); + } else { + relative->location().warning(QString("'\\generatelist \1' no such group").arg(atom->string())); + } } break; case Atom::SinceList: @@ -3102,6 +3110,30 @@ void HtmlGenerator::generateQmlItem(const Node *node, out() << highlightedCode(marked, relative, false, Node::QML); } +/*! + This function generates a simple bullet list for the members + of collection node \a {cn}. The collection node must be a group + and must not be empty. If it is empty, nothing is output, and + false is returned. Otherewise, the list is generated and true is returned. + */ +bool HtmlGenerator::generateGroupList(CollectionNode* cn) +{ + qdb_->mergeCollections(cn); + if (cn->members().isEmpty()) + return false; + out() << "<ul>\n"; + foreach (const Node* node, cn->members()) { + out() << "<li>" + << "<a href=\"#" + << Doc::canonicalTitle(node->title()) + << "\">" + << node->title() + << "</a></li>\n"; + } + out() << "</ul>\n"; + return true; +} + void HtmlGenerator::generateList(const Node* relative, CodeMarker* marker, const QString& selector) { CNMap cnm; diff --git a/src/qdoc/htmlgenerator.h b/src/qdoc/htmlgenerator.h index 8d50d0e22..731a12ac3 100644 --- a/src/qdoc/htmlgenerator.h +++ b/src/qdoc/htmlgenerator.h @@ -145,6 +145,7 @@ private: QString commonPrefix); void generateFunctionIndex(const Node *relative); void generateLegaleseList(const Node *relative, CodeMarker *marker); + bool generateGroupList(CollectionNode* cn); void generateList(const Node* relative, CodeMarker* marker, const QString& selector); void generateSectionList(const Section& section, const Node *relative, |