aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-02-21 13:38:39 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-02-21 13:25:34 +0000
commitb73151cb39f323240ffe9991f8bae0dad9be486c (patch)
tree509f5b725bdddd223280b9ab4b4749585133754f /sources/shiboken2/generator
parent992bbddee3dd2c3cf9c7d691d6a0e61955c84b78 (diff)
QtDocGenerator: Ensure newline before tables
Fix warnings like: warning: Undefined substitution referenced: "Constant |Description" on tables like: *amplitude**period* +-------------------------+-----------+ |Constant |Description| +=========================+===========+ |QEasingCurve.InOutElastic| | +-------------------------+-----------+ Task-number: PYSIDE-363 Change-Id: I56cd9b73dacbfd84260c059a8916db5540029816 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 95a1d0ed7..a40f35432 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -137,6 +137,21 @@ inline QTextStream &operator<<(QTextStream &str, const escape &e)
return str;
}
+// Return last character of a QString-buffered stream.
+static QChar lastChar(const QTextStream &str)
+{
+ const QString *string = str.string();
+ Q_ASSERT(string);
+ return string->isEmpty() ? QChar() : *(string->crbegin());
+}
+
+static QTextStream &ensureEndl(QTextStream &s)
+{
+ if (lastChar(s) != QLatin1Char('\n'))
+ s << endl;
+ return s;
+}
+
static QString msgTagWarning(const QXmlStreamReader &reader, const QString &context,
const QString &tag, const QString &message)
{
@@ -467,9 +482,9 @@ void QtXmlToSphinx::handleParaTag(QXmlStreamReader& reader)
m_output << INDENT << result << endl << endl;
} else if (token == QXmlStreamReader::Characters) {
const QStringRef text = reader.text();
- if (!text.isEmpty() && INDENT.indent == 0 && !m_output.string()->isEmpty()) {
+ const QChar end = lastChar(m_output);
+ if (!text.isEmpty() && INDENT.indent == 0 && !end.isNull()) {
QChar start = text[0];
- QChar end = m_output.string()->at(m_output.string()->length() - 1);
if ((end == QLatin1Char('*') || end == QLatin1Char('`')) && start != QLatin1Char(' ') && !start.isPunct())
m_output << '\\';
}
@@ -631,7 +646,7 @@ void QtXmlToSphinx::handleTableTag(QXmlStreamReader& reader)
// write the table on m_output
m_currentTable.enableHeader(m_tableHasHeader);
m_currentTable.normalize();
- m_output << m_currentTable;
+ m_output << ensureEndl << m_currentTable;
m_currentTable.clear();
}
}
@@ -709,7 +724,7 @@ void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader)
} else if (listType == QLatin1String("enum")) {
m_currentTable.enableHeader(m_tableHasHeader);
m_currentTable.normalize();
- m_output << m_currentTable;
+ m_output << ensureEndl << m_currentTable;
}
}
m_currentTable.clear();