diff options
author | Paul Wicking <paul.wicking@qt.io> | 2023-04-14 11:03:24 +0200 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2023-04-28 11:03:50 +0200 |
commit | 3d814edf5710367bd1e281521a1a1d232d83eef1 (patch) | |
tree | 31189ff6c7d5dfd2622cbf6ad85ff504628c4462 /src/qdoc/qdoc/docparser.cpp | |
parent | 94cbc12507c1a74df25160acf04ca4fd6db9bc25 (diff) | |
download | qttools-3d814edf5710367bd1e281521a1a1d232d83eef1.tar.gz |
QDoc: Extract method from DocParser::insertTarget
`DocParser::insertTarget` has a conditional check at the start of the
method, that, if satisfied, causes QDoc to generate a warning. The rest
of the method is contained in the else block that follows.
This patch extracts a method, `DocParser::warnAboutPreexistingTarget`,
that is responsible for issuing that warning, and modifies
`DocParser::insertTarget` to return early if the condition is
satisfied. This allows further refactoring of the latter method.
The new method is fully documented. As this new method impacts the
documentation for QDoc warnings, that is also modified in this patch.
Task-number: QTBUG-113126
Change-Id: Iba54e67862555fba71ec774261e0e0fbea638238
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/qdoc/docparser.cpp')
-rw-r--r-- | src/qdoc/qdoc/docparser.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/qdoc/qdoc/docparser.cpp b/src/qdoc/qdoc/docparser.cpp index cb6b7788e..ca17fefba 100644 --- a/src/qdoc/qdoc/docparser.cpp +++ b/src/qdoc/qdoc/docparser.cpp @@ -1293,11 +1293,24 @@ QString DocParser::detailsUnknownCommand(const QSet<QString> &metaCommandSet, co return QStringLiteral("Maybe you meant '\\%1'?").arg(best); } +/*! + \internal + + Issues a warning about the duplicate definition of a target or keyword in + at \a location. \a duplicateDefinition is the target being processed; the + already registered definition is \a previousDefinition. + */ +static void warnAboutPreexistingTarget(const Location &location, const QString &duplicateDefinition, const QString &previousDefinition) +{ + location.warning( + QStringLiteral("Duplicate target name '%1'. The previous occurrence is here: %2") + .arg(duplicateDefinition, previousDefinition)); +} + void DocParser::insertTarget(const QString &target, bool keyword) { if (m_targetMap.contains(target)) { - location().warning(QStringLiteral("Duplicate target name '%1'").arg(target)); - m_targetMap[target].warning(QStringLiteral("(The previous occurrence is here)")); + return warnAboutPreexistingTarget(location(), target, m_targetMap[target].toString()); } else { m_targetMap.insert(target, location()); m_private->constructExtra(); |