diff options
-rw-r--r-- | sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp index ebb9913cb..114ba401d 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp @@ -772,14 +772,25 @@ void QtXmlToSphinx::handleRowTag(QXmlStreamReader& reader) } } +enum ListType { BulletList, OrderedList, EnumeratedList }; + +static inline ListType webXmlListType(const QStringRef &t) +{ + if (t == QLatin1String("enum")) + return EnumeratedList; + if (t == QLatin1String("ordered")) + return OrderedList; + return BulletList; +} + void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader) { // BUG We do not support a list inside a table cell - static QString listType; + static ListType listType = BulletList; QXmlStreamReader::TokenType token = reader.tokenType(); if (token == QXmlStreamReader::StartElement) { - listType = reader.attributes().value(QLatin1String("type")).toString(); - if (listType == QLatin1String("enum")) { + listType = webXmlListType(reader.attributes().value(QLatin1String("type"))); + if (listType == EnumeratedList) { m_currentTable << (TableRow() << "Constant" << "Description"); m_tableHasHeader = true; } @@ -787,19 +798,26 @@ void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader) } else if (token == QXmlStreamReader::EndElement) { INDENT.indent++; if (!m_currentTable.isEmpty()) { - if (listType == QLatin1String("bullet")) { + switch (listType) { + case BulletList: + case OrderedList: { m_output << endl; + const char *separator = listType == BulletList ? "* " : "#. "; + const char *indent = listType == BulletList ? " " : " "; for (const TableCell &cell : m_currentTable.constFirst()) { const QVector<QStringRef> itemLines = cell.data.splitRef(QLatin1Char('\n')); - m_output << INDENT << "* " << itemLines.constFirst() << endl; + m_output << INDENT << separator << itemLines.constFirst() << endl; for (int i = 1, max = itemLines.count(); i < max; ++i) - m_output << INDENT << " " << itemLines[i] << endl; + m_output << INDENT << indent << itemLines[i] << endl; } m_output << endl; - } else if (listType == QLatin1String("enum")) { + } + break; + case EnumeratedList: m_currentTable.enableHeader(m_tableHasHeader); m_currentTable.normalize(); m_output << ensureEndl << m_currentTable; + break; } } m_currentTable.clear(); |