summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@qt.io>2025-12-08 12:07:46 +0100
committerDavid Boddie <david.boddie@qt.io>2025-12-10 14:50:54 +0100
commit2a15e5e8d48ea540db86fc068de4a56549541c67 (patch)
treea56f24be22d31e3f6ed4e00551bbc9817e2a353b
parent9d2dbcd652560448f2c6e979d15390a6e3f50108 (diff)
QDoc: Adjust order of overloads to more closely match summaries
The order of overloaded functions in detailed sections tends to differ from that in the lists of functions on some API reference pages. This can lead to confusion when navigating between overloads or searching for a suitable overload. This change imposes some additional order on sorting of functions, based on the overload number. It does not guarantee that the order will exactly match the summary list, but it will be closer to it. Change-Id: I499ac8a22168d252cbaf6a5d8eb5e76fe7090807 Reviewed-by: Topi Reinio <topi.reinio@qt.io>
-rw-r--r--src/qdoc/qdoc/src/qdoc/node.cpp12
-rw-r--r--src/qdoc/qdoc/src/qdoc/node.h1
-rw-r--r--src/qdoc/qdoc/src/qdoc/sections.cpp4
-rw-r--r--src/qdoc/qdoc/src/qdoc/sharedcommentnode.h2
4 files changed, 17 insertions, 2 deletions
diff --git a/src/qdoc/qdoc/src/qdoc/node.cpp b/src/qdoc/qdoc/src/qdoc/node.cpp
index 650178910..2173815d1 100644
--- a/src/qdoc/qdoc/src/qdoc/node.cpp
+++ b/src/qdoc/qdoc/src/qdoc/node.cpp
@@ -132,6 +132,18 @@ bool Node::nodeNameLessThan(const Node *n1, const Node *n2)
return false;
}
+bool Node::nodeNameOverloadLessThan(const Node *n1, const Node *n2)
+{
+ if (n1->isFunction() && n2->isFunction()) {
+ const auto *f1 = static_cast<const FunctionNode *>(n1);
+ const auto *f2 = static_cast<const FunctionNode *>(n2);
+
+ LT_RETURN_IF_NOT_EQUAL(f1->overloadNumber(), f2->overloadNumber());
+ }
+
+ return nodeNameLessThan(n1, n2);
+}
+
/*!
Returns \c true if node \a n1 is less than node \a n2 when comparing
the sort keys, defined with
diff --git a/src/qdoc/qdoc/src/qdoc/node.h b/src/qdoc/qdoc/src/qdoc/node.h
index ff30a6d2a..e02ad06f0 100644
--- a/src/qdoc/qdoc/src/qdoc/node.h
+++ b/src/qdoc/qdoc/src/qdoc/node.h
@@ -279,6 +279,7 @@ public:
static QString nodeTypeString(NodeType t);
[[nodiscard]] static bool nodeLessThan(const Node *first, const Node *second);
[[nodiscard]] static bool nodeNameLessThan(const Node *first, const Node *second);
+ [[nodiscard]] static bool nodeNameOverloadLessThan(const Node *first, const Node *second);
[[nodiscard]] static bool nodeSortKeyOrNameLessThan(const Node *n1, const Node *n2);
[[nodiscard]] NodeContext createContext() const;
diff --git a/src/qdoc/qdoc/src/qdoc/sections.cpp b/src/qdoc/qdoc/src/qdoc/sections.cpp
index f0962ab73..215afc2b8 100644
--- a/src/qdoc/qdoc/src/qdoc/sections.cpp
+++ b/src/qdoc/qdoc/src/qdoc/sections.cpp
@@ -670,8 +670,10 @@ void Sections::buildStdRefPageSections()
*/
void Sections::distributeNodeInSummaryVector(SectionVector &sv, Node *n)
{
- if (n->isSharedCommentNode())
+ if (n->isSharedCommentNode()) {
+ static_cast<SharedCommentNode *>(n)->sort();
return;
+ }
if (n->isFunction()) {
auto *fn = static_cast<FunctionNode *>(n);
if (fn->isRelatedNonmember()) {
diff --git a/src/qdoc/qdoc/src/qdoc/sharedcommentnode.h b/src/qdoc/qdoc/src/qdoc/sharedcommentnode.h
index 96c54e059..c8f229ad4 100644
--- a/src/qdoc/qdoc/src/qdoc/sharedcommentnode.h
+++ b/src/qdoc/qdoc/src/qdoc/sharedcommentnode.h
@@ -37,7 +37,7 @@ public:
node->setSharedCommentNode(this);
setGenus(node->genus());
}
- void sort() { std::sort(m_collective.begin(), m_collective.end(), Node::nodeNameLessThan); }
+ void sort() { std::sort(m_collective.begin(), m_collective.end(), Node::nodeNameOverloadLessThan); }
[[nodiscard]] const QList<Node *> &collective() const { return m_collective; }
void setOverloadFlags();
void setRelatedNonmember(bool value) override;