summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2023-03-31 22:01:29 +0200
committerPaul Wicking <paul.wicking@qt.io>2023-04-04 18:49:20 +0200
commit96283c032ca4d7b1e245cb54939262acc564cec9 (patch)
tree9bfd198dac9ec74e58f49de7700b8b3c8cf6556e
parent582ab22a6c0274a0d669a602aa29d2042eec5f64 (diff)
downloadqttools-96283c032ca4d7b1e245cb54939262acc564cec9.tar.gz
QDoc: Extract method from QDocIndexFiles::generateFunctionSection
QDocIndexFiles::generateFunctionSection has a lot going on. Use extract method as a step to clean up the method and introduce a level of abstraction to parts of its internals. Change-Id: If2efbfb10fcd8585c9c2298b2557ac880052a7ac Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/qdocindexfiles.cpp34
-rw-r--r--src/qdoc/qdocindexfiles.h1
2 files changed, 27 insertions, 8 deletions
diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp
index 70720a1b1..add72aeb6 100644
--- a/src/qdoc/qdocindexfiles.cpp
+++ b/src/qdoc/qdocindexfiles.cpp
@@ -1254,14 +1254,7 @@ void QDocIndexFiles::generateFunctionSection(QXmlStreamWriter &writer, FunctionN
index file, but it is not read back in by qdoc. However,
we need it for the webxml generator.
*/
- QString signature = fn->signature(false, false);
- // 'const' is already part of FunctionNode::signature()
- if (fn->isFinal())
- signature += " final";
- if (fn->isOverride())
- signature += " override";
- if (fn->isPureVirtual())
- signature += " = 0";
+ const QString signature = appendAttributesToSignature(fn);
writer.writeAttribute("signature", signature);
QStringList groups = m_qdb->groupNamesForNode(fn);
@@ -1286,6 +1279,31 @@ void QDocIndexFiles::generateFunctionSection(QXmlStreamWriter &writer, FunctionN
}
/*!
+ \internal
+
+ Constructs the signature to be written to an index file for the function
+ represented by FunctionNode \a fn.
+
+ 'const' is already part of FunctionNode::signature(), which forms the basis
+ for the signature returned by this method. The method adds, where
+ applicable, the C++ keywords "final", "override", or "= 0", to the
+ signature carried by the FunctionNode itself.
+ */
+QString QDocIndexFiles::appendAttributesToSignature(const FunctionNode *fn) const noexcept
+{
+ QString signature = fn->signature(false, false);
+
+ if (fn->isFinal())
+ signature += " final";
+ if (fn->isOverride())
+ signature += " override";
+ if (fn->isPureVirtual())
+ signature += " = 0";
+
+ return signature;
+}
+
+/*!
This function outputs a <function> element to the index file
for each FunctionNode in \a aggregate using the \a writer.
The \a aggregate has a function map that contains all the
diff --git a/src/qdoc/qdocindexfiles.h b/src/qdoc/qdocindexfiles.h
index f66980726..6148c6cd2 100644
--- a/src/qdoc/qdocindexfiles.h
+++ b/src/qdoc/qdocindexfiles.h
@@ -55,6 +55,7 @@ private:
IndexSectionWriter *post = nullptr);
void generateIndexSections(QXmlStreamWriter &writer, Node *node,
IndexSectionWriter *post = nullptr);
+ QString appendAttributesToSignature(const FunctionNode *fn) const noexcept;
private:
static QDocIndexFiles *s_qdocIndexFiles;