summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibaut Cuvelier <cuvelier.thibaut@gmail.com>2022-07-22 02:25:26 +0200
committerPaul Wicking <paul.wicking@qt.io>2022-11-04 12:47:49 +0100
commit4ccb0dffab80e8128c5738aa453518abd8045daa (patch)
tree34acc7b6eff70ad0dbbbe1ca4644c4f44ff90bc7
parent2c71bb2979220588d46337be6d5879bbb7012eaf (diff)
downloadqttools-4ccb0dffab80e8128c5738aa453518abd8045daa.tar.gz
In ATOM_LIST_VALUE, don't generate two columns when only one is filled
The DocBook file is not valid in this case. HTML is not nice to see either (like in https://doc.qt.io/qt-6/qtquickcontrols2-material.html): a column is empty. This doesn't fix the HTML output, though. Change-Id: I5c3c6ce4caeeabf1bea959aad4e8269204d41b60 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r--src/qdoc/docbookgenerator.cpp10
-rw-r--r--src/qdoc/xmlgenerator.cpp21
-rw-r--r--src/qdoc/xmlgenerator.h1
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml1
-rw-r--r--tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml1
5 files changed, 28 insertions, 6 deletions
diff --git a/src/qdoc/docbookgenerator.cpp b/src/qdoc/docbookgenerator.cpp
index 9ef3810bc..4e429e440 100644
--- a/src/qdoc/docbookgenerator.cpp
+++ b/src/qdoc/docbookgenerator.cpp
@@ -666,19 +666,21 @@ qsizetype DocBookGenerator::generateAtom(const Atom *atom, const Node *relative)
m_threeColumnEnumValueTable = isThreeColumnEnumValueTable(atom);
if (m_threeColumnEnumValueTable && relative->nodeType() == Node::Enum) {
- // If not in \enum topic, skip the value column
+ // With three columns, if not in \enum topic, skip the value column
m_writer->writeTextElement(dbNamespace, "th", "Value");
newLine();
}
- m_writer->writeTextElement(dbNamespace, "th", "Description");
- newLine();
+ if (!isOneColumnValueTable(atom)) {
+ m_writer->writeTextElement(dbNamespace, "th", "Description");
+ newLine();
+ }
m_writer->writeEndElement(); // tr
newLine();
m_writer->writeEndElement(); // thead
newLine();
- } else {
+ } else { // No recognized list type.
m_writer->writeStartElement(dbNamespace, "orderedlist");
if (atom->next() != nullptr && atom->next()->string().toInt() > 1)
diff --git a/src/qdoc/xmlgenerator.cpp b/src/qdoc/xmlgenerator.cpp
index 5df638b97..ff74ce2e4 100644
--- a/src/qdoc/xmlgenerator.cpp
+++ b/src/qdoc/xmlgenerator.cpp
@@ -39,6 +39,27 @@ bool XmlGenerator::isThreeColumnEnumValueTable(const Atom *atom)
}
/*!
+ Determines whether the list atom should be shown with just one column (value).
+ */
+bool XmlGenerator::isOneColumnValueTable(const Atom *atom)
+{
+ if (atom->type() != Atom::ListLeft || atom->string() != ATOM_LIST_VALUE)
+ return false;
+
+ while (atom && atom->type() != Atom::ListTagRight)
+ atom = atom->next();
+
+ if (atom) {
+ if (!matchAhead(atom, Atom::ListItemLeft))
+ return false;
+ if (!atom->next())
+ return false;
+ return matchAhead(atom->next(), Atom::ListItemRight);
+ }
+ return false;
+}
+
+/*!
Header offset depending on the type of the node
*/
int XmlGenerator::hOffset(const Node *node)
diff --git a/src/qdoc/xmlgenerator.h b/src/qdoc/xmlgenerator.h
index f791185a5..5f7ba67fd 100644
--- a/src/qdoc/xmlgenerator.h
+++ b/src/qdoc/xmlgenerator.h
@@ -24,6 +24,7 @@ protected:
static bool hasBrief(const Node *node);
static bool isThreeColumnEnumValueTable(const Atom *atom);
+ static bool isOneColumnValueTable(const Atom *atom);
static int hOffset(const Node *node);
static void rewritePropertyBrief(const Atom *atom, const Node *relative);
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml b/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml
index 13dbe6aab..5131d74b6 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml
+++ b/tests/auto/qdoc/generatedoutput/expected_output/headerfile-docbook/testheader.xml
@@ -41,7 +41,6 @@
<db:thead>
<db:tr>
<db:th>Constant</db:th>
-<db:th>Description</db:th>
</db:tr>
</db:thead>
<db:tr>
diff --git a/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml
index 16caf5a24..319ec6f3e 100644
--- a/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml
+++ b/tests/auto/qdoc/generatedoutput/expected_output/scopedenum-docbook/testqdoc-test.xml
@@ -76,7 +76,6 @@
<db:thead>
<db:tr>
<db:th>Constant</db:th>
-<db:th>Description</db:th>
</db:tr>
</db:thead>
<db:tr>