summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2024-03-04 12:41:20 +0100
committerPaul Wicking <paul.wicking@qt.io>2024-03-05 14:48:21 +0100
commit35860c9c196f1f6174f7c0601edb1ed3fb5c5a64 (patch)
treeb3d0570bc9b94288d043d81aa2f648df9f3b436b
parentc2ba2298544875a6e815ba2ddc4a60d125d2ddd4 (diff)
QDoc: Warn when generating a file multiple times per project
When generating documentation, QDoc may overwrite files that exist in the output directory. This behavior is wanted; previously QDoc warned for each overwrite, making the warning count between multiple documentation builds not representable. However, users rely on QDocs traditional warning output and are unlikely to notice debug log messages. This change makes QDoc issue a warning when obtaining a file handle for an output file if that file is known to have been generated previously in the current execution. It also introduces a new environment variable `QDOC_ALL_OVERWRITES_ARE_WARNINGS`, to allow the enforcement of QDoc's past behavior of unconditionally warning instead of debug logging these events. The QDoc manual is updated accordingly. Fixes: QTBUG-121437 Pick-to: 6.6 6.5 Change-Id: I834027201197039bb4591e633bf72845e8a4343c Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io> (cherry picked from commit 54e5d595b7400730546335ffa02bf2ea95b2fcef) Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/qdoc/qdoc/doc/qdoc-warnings.qdoc13
-rw-r--r--src/qdoc/qdoc/src/qdoc/generator.cpp12
2 files changed, 23 insertions, 2 deletions
diff --git a/src/qdoc/qdoc/doc/qdoc-warnings.qdoc b/src/qdoc/qdoc/doc/qdoc-warnings.qdoc
index 22b629f75..cdd10c058 100644
--- a/src/qdoc/qdoc/doc/qdoc-warnings.qdoc
+++ b/src/qdoc/qdoc/doc/qdoc-warnings.qdoc
@@ -828,4 +828,17 @@
.qdocconf file.
See also \l{Creating Help Project Files} and \l {qhp-variable}{qhp}.
+
+ \section1 Already generated FILE for this project
+
+ While generating the documentation for a project, QDoc keeps track of the
+ file names of the files it has generated. QDoc will issue a warning when it
+ opens a file for writing if that file is known to have been generated
+ previously, in the current execution. This can happen if a \qdoccmd page
+ command uses the same name as \qdoccmd group, for example.
+
+ You can set the environment variable \c QDOC_ALL_OVERWRITES_ARE_WARNINGS to
+ unconditionally warn about all such events. This may be useful when tracking
+ down the offending definitions.
+
*/
diff --git a/src/qdoc/qdoc/src/qdoc/generator.cpp b/src/qdoc/qdoc/src/qdoc/generator.cpp
index 8f7746c67..f14f679d4 100644
--- a/src/qdoc/qdoc/src/qdoc/generator.cpp
+++ b/src/qdoc/qdoc/src/qdoc/generator.cpp
@@ -194,6 +194,9 @@ int Generator::appendSortedQmlNames(Text &text, const Node *base, const NodeList
*/
QFile *Generator::openSubPageFile(const Node *node, const QString &fileName)
{
+ if (s_outFileNames.contains(fileName))
+ node->location().warning("Already generated %1 for this project"_L1.arg(fileName));
+
QString path = outputDir() + QLatin1Char('/');
if (Generator::useOutputSubdirs() && !node->outputSubdirectory().isEmpty()
&& !outputDir().endsWith(node->outputSubdirectory())) {
@@ -204,8 +207,13 @@ QFile *Generator::openSubPageFile(const Node *node, const QString &fileName)
auto outPath = s_redirectDocumentationToDevNull ? QStringLiteral("/dev/null") : path;
auto outFile = new QFile(outPath);
- if (!s_redirectDocumentationToDevNull && outFile->exists())
- qCDebug(lcQdoc) << "Output file already exists; overwriting" << qPrintable(outFile->fileName());
+ if (!s_redirectDocumentationToDevNull && outFile->exists()) {
+ const QString warningText {"Output file already exists, overwriting %1"_L1.arg(outFile->fileName())};
+ if (qEnvironmentVariableIsSet("QDOC_ALL_OVERWRITES_ARE_WARNINGS"))
+ node->location().warning(warningText);
+ else
+ qCDebug(lcQdoc) << qUtf8Printable(warningText);
+ }
if (!outFile->open(QFile::WriteOnly | QFile::Text)) {
node->location().fatal(