diff options
author | Sune Vuorela <sune@vuorela.dk> | 2016-06-13 20:37:42 +0200 |
---|---|---|
committer | Sune Vuorela <sune@vuorela.dk> | 2016-06-14 19:40:39 +0000 |
commit | 5b8f8c801a958568772079b2f1b7b67bcdc81bc1 (patch) | |
tree | 0ba0cfa6218655570c2bed8fd9aa2d9d4b70b85b | |
parent | c477b67636962007e32aa2cbd170a5c2e0e6b899 (diff) | |
download | qttools-5b8f8c801a958568772079b2f1b7b67bcdc81bc1.tar.gz |
Less randomization in output of qdoc.
There is a lot of random order going on in the output. It makes doing
two runs of documentation hard to compare, because things comes in different order.
It should be easier to debug the output now that lines and elements are written
in a sorted order.
There are still some way towards reproducible qdoc.
Change-Id: Ia3f64d5463cc812e13c25ca84c47906c75093f26
Reviewed-by: David Faure <david.faure@kdab.com>
-rw-r--r-- | src/qdoc/helpprojectwriter.cpp | 27 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/qdocindexfiles.cpp | 6 |
3 files changed, 31 insertions, 6 deletions
diff --git a/src/qdoc/helpprojectwriter.cpp b/src/qdoc/helpprojectwriter.cpp index 96524100f..035f781a6 100644 --- a/src/qdoc/helpprojectwriter.cpp +++ b/src/qdoc/helpprojectwriter.cpp @@ -46,6 +46,14 @@ QT_BEGIN_NAMESPACE +// helper for sorting Node's based on their name +// once we can use C++11, this function can be moved +// to where it is actually used inside as a lambda function. +static bool nodeNameLessThan(const Node *first, const Node *second) +{ + return first->name() < second->name(); +} + HelpProjectWriter::HelpProjectWriter(const Config &config, const QString &defaultFileName, Generator* g) @@ -689,7 +697,9 @@ void HelpProjectWriter::generateProject(HelpProject &project) for (it = project.customFilters.constBegin(); it != project.customFilters.constEnd(); ++it) { writer.writeStartElement("customFilter"); writer.writeAttribute("name", it.key()); - foreach (const QString &filter, it.value()) + QStringList sortedAttributes = it.value().toList(); + sortedAttributes.sort(); + foreach (const QString &filter, sortedAttributes) writer.writeTextElement("filterAttribute", filter); writer.writeEndElement(); // customFilter } @@ -698,7 +708,9 @@ void HelpProjectWriter::generateProject(HelpProject &project) writer.writeStartElement("filterSection"); // Write filterAttribute elements. - foreach (const QString &filterName, project.filterAttributes) + QStringList sortedFilterAttributes = project.filterAttributes.toList(); + sortedFilterAttributes.sort(); + foreach (const QString &filterName, sortedFilterAttributes) writer.writeTextElement("filterAttribute", filterName); writer.writeStartElement("toc"); @@ -816,7 +828,11 @@ void HelpProjectWriter::generateProject(HelpProject &project) } // No contents/nextpage links found, write all nodes unsorted if (!contentsFound) { - foreach (const Node *node, subproject.nodes) + QList<const Node*> subnodes = subproject.nodes.values(); + + std::sort(subnodes.begin(), subnodes.end(), nodeNameLessThan); + + foreach (const Node *node, subnodes) writeNode(project, writer, node); } } @@ -832,6 +848,7 @@ void HelpProjectWriter::generateProject(HelpProject &project) writer.writeEndElement(); // toc writer.writeStartElement("keywords"); + std::sort(project.keywords.begin(), project.keywords.end()); foreach (const QStringList &details, project.keywords) { writer.writeStartElement("keyword"); writer.writeAttribute("name", details[0]); @@ -848,7 +865,9 @@ void HelpProjectWriter::generateProject(HelpProject &project) QSet<QString> files = QSet<QString>::fromList(gen_->outputFileNames()); files.unite(project.files); files.unite(project.extraFiles); - foreach (const QString &usedFile, files) { + QStringList sortedFiles = files.toList(); + sortedFiles.sort(); + foreach (const QString &usedFile, sortedFiles) { if (!usedFile.isEmpty()) writer.writeTextElement("file", usedFile); } diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index 02384c962..d3b65de3a 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -4604,7 +4604,9 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString if (!tags.isEmpty()) { writer.writeStartElement("tags"); bool wrote_one = false; - foreach (const QString &tag, tags) { + QStringList sortedTags = tags.toList(); + sortedTags.sort(); + foreach (const QString &tag, sortedTags) { if (wrote_one) writer.writeCharacters(","); writer.writeCharacters(tag); diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp index c8439d39d..421e75569 100644 --- a/src/qdoc/qdocindexfiles.cpp +++ b/src/qdoc/qdocindexfiles.cpp @@ -1018,7 +1018,11 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, baseStrings.insert(n->fullName()); } if (!baseStrings.isEmpty()) - writer.writeAttribute("bases", QStringList(baseStrings.toList()).join(QLatin1Char(','))); + { + QStringList baseStringsAsList = baseStrings.toList(); + baseStringsAsList.sort(); + writer.writeAttribute("bases", baseStringsAsList.join(QLatin1Char(','))); + } if (!node->physicalModuleName().isEmpty()) writer.writeAttribute("module", node->physicalModuleName()); if (!classNode->groupNames().isEmpty()) |