aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-11-23 08:32:15 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-11-23 13:23:30 +0100
commit42ca2d6052624445559ae44fa3f5d57ca591fb52 (patch)
tree22a5d3edda2ce0c97d24842fe818e72f90e82048
parent2cfe8433c861c3602e5e23af8d4fdfb6fd219f4d (diff)
Doumentation: Suppress nested formatting
Sphinx cannot handle nested formatting (code/bold/italic), which for example occurs in the style sheet reference table. Add a guard preventing this to QtXmlToSphinx. Task-number: PYSIDE-1112 Pick-to: 6.2 Change-Id: Ieceb3ea054719eabc2df391f51eeb0b92a304ab7 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp30
-rw-r--r--sources/shiboken6/generator/qtdoc/qtxmltosphinx.h1
2 files changed, 21 insertions, 10 deletions
diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp
index dba24f2fe..ce0f794b0 100644
--- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp
+++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp
@@ -625,12 +625,16 @@ void QtXmlToSphinx::handleItalicTag(QXmlStreamReader& reader)
{
switch (reader.tokenType()) {
case QXmlStreamReader::StartElement:
- m_insideItalic = true;
- m_output << rstItalic;
+ if (m_formattingDepth++ == 0) {
+ m_insideItalic = true;
+ m_output << rstItalic;
+ }
break;
case QXmlStreamReader::EndElement:
- m_insideItalic = false;
- m_output << rstItalicOff;
+ if (--m_formattingDepth == 0) {
+ m_insideItalic = false;
+ m_output << rstItalicOff;
+ }
break;
case QXmlStreamReader::Characters:
m_output << escape(reader.text().trimmed());
@@ -644,12 +648,16 @@ void QtXmlToSphinx::handleBoldTag(QXmlStreamReader& reader)
{
switch (reader.tokenType()) {
case QXmlStreamReader::StartElement:
- m_insideBold = true;
- m_output << rstBold;
+ if (m_formattingDepth++ == 0) {
+ m_insideBold = true;
+ m_output << rstBold;
+ }
break;
case QXmlStreamReader::EndElement:
- m_insideBold = false;
- m_output << rstBoldOff;
+ if (--m_formattingDepth == 0) {
+ m_insideBold = false;
+ m_output << rstBoldOff;
+ }
break;
case QXmlStreamReader::Characters:
m_output << escape(reader.text().trimmed());
@@ -663,10 +671,12 @@ void QtXmlToSphinx::handleArgumentTag(QXmlStreamReader& reader)
{
switch (reader.tokenType()) {
case QXmlStreamReader::StartElement:
- m_output << rstCode;
+ if (m_formattingDepth++ == 0)
+ m_output << rstCode;
break;
case QXmlStreamReader::EndElement:
- m_output << rstCodeOff;
+ if (--m_formattingDepth == 0)
+ m_output << rstCodeOff;
break;
case QXmlStreamReader::Characters:
m_output << reader.text().trimmed();
diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
index 55d6a79b1..4e9d4e2e1 100644
--- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
+++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
@@ -189,6 +189,7 @@ private:
QString m_context;
const QtXmlToSphinxDocGeneratorInterface *m_generator;
const QtXmlToSphinxParameters &m_parameters;
+ int m_formattingDepth = 0;
bool m_insideBold = false;
bool m_insideItalic = false;
QString m_lastTagName;