diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-04-06 22:29:48 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-04-07 09:51:00 +0000 |
commit | b1b320c8b834c7821981e43744d15784f2bbb76b (patch) | |
tree | 950ca01a6fe43254903418c4d0ed2599f5bfe253 | |
parent | b680bac4cca6a4597a0cf9e0b0918af27df00034 (diff) |
shiboken6: Fix module TOC generation
Change b60cdf97b41ab6db977c5acd96d491003a5a046d introduced
a bug in that the .rst doc files were generated with lower case file
names. This upset the fancy toc formatter. As a drive-by, fix
empty columns.
Change-Id: Ic4600b5bd7a9152cce2b74ed502acbc71b8df891
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
5 files changed, 19 insertions, 9 deletions
diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp index 739b2de65..20a293c16 100644 --- a/sources/shiboken6/generator/generator.cpp +++ b/sources/shiboken6/generator/generator.cpp @@ -411,14 +411,15 @@ bool Generator::handleOption(const QString & key, const QString & /* value */) QString Generator::fileNameForContextHelper(const GeneratorContext &context, const QString &suffix, - bool useQualifiedName) + FileNameFlags flags) { if (!context.forSmartPointer()) { const AbstractMetaClass *metaClass = context.metaClass(); - QString fileNameBase = useQualifiedName - ? metaClass->qualifiedCppName().toLower() - : metaClass->name().toLower(); + QString fileNameBase = flags.testFlag(FileNameFlag::UnqualifiedName) + ? metaClass->name() : metaClass->qualifiedCppName(); + if (!flags.testFlag(FileNameFlag::KeepCase)) + fileNameBase = fileNameBase.toLower(); fileNameBase.replace(u"::"_qs, u"_"_qs); return fileNameBase + suffix; } diff --git a/sources/shiboken6/generator/generator.h b/sources/shiboken6/generator/generator.h index c1320ce19..864f0b7ea 100644 --- a/sources/shiboken6/generator/generator.h +++ b/sources/shiboken6/generator/generator.h @@ -200,6 +200,12 @@ public: }; Q_DECLARE_FLAGS(Options, Option) + enum FileNameFlag { + UnqualifiedName = 0x1, + KeepCase = 0x2 + }; + Q_DECLARE_FLAGS(FileNameFlags, FileNameFlag) + Generator(); virtual ~Generator(); @@ -259,7 +265,7 @@ protected: /// Helper for determining the file name static QString fileNameForContextHelper(const GeneratorContext &context, const QString &suffix, - bool useQualifiedName = true); + FileNameFlags flags = {}); /// Returns all primitive types found by APIExtractor static PrimitiveTypeEntryList primitiveTypes(); @@ -375,6 +381,8 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::Options) +Q_DECLARE_OPERATORS_FOR_FLAGS(Generator::FileNameFlags) + using GeneratorPtr = QSharedPointer<Generator>; using Generators = QList<GeneratorPtr>; diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp index 951561c85..859151eb8 100644 --- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp @@ -130,7 +130,8 @@ bool QtDocGenerator::shouldGenerate(const TypeEntry *te) const QString QtDocGenerator::fileNameForContext(const GeneratorContext &context) const { return fileNameForContextHelper(context, fileNameSuffix(), - false /* qualified */); + FileNameFlag::UnqualifiedName + | FileNameFlag::KeepCase); } void QtDocGenerator::writeFormattedBriefText(TextStream &s, const Documentation &doc, @@ -752,7 +753,7 @@ static void writeFancyToc(TextStream& s, const QStringList& items) const QString entry = QLatin1String("* :doc:`") + item + QLatin1Char('`'); row << QtXmlToSphinx::TableCell(entry); } - if (!row.isEmpty()) + if (row.size() > 1) table.appendRow(row); } diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 61f1679ed..166d8ed1a 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -215,7 +215,7 @@ CppGenerator::CppGenerator() = default; QString CppGenerator::fileNameForContext(const GeneratorContext &context) const { - return fileNameForContextHelper(context, u"_wrapper.cpp"_qs, true /* qualified */); + return fileNameForContextHelper(context, u"_wrapper.cpp"_qs); } static bool isInplaceAdd(const AbstractMetaFunctionCPtr &func) diff --git a/sources/shiboken6/generator/shiboken/headergenerator.cpp b/sources/shiboken6/generator/shiboken/headergenerator.cpp index 8513a8e89..b878269eb 100644 --- a/sources/shiboken6/generator/shiboken/headergenerator.cpp +++ b/sources/shiboken6/generator/shiboken/headergenerator.cpp @@ -49,7 +49,7 @@ QString HeaderGenerator::headerFileNameForContext(const GeneratorContext &context) { - return fileNameForContextHelper(context, u"_wrapper.h"_qs, true /* qualified */); + return fileNameForContextHelper(context, u"_wrapper.h"_qs); } QString HeaderGenerator::fileNameForContext(const GeneratorContext &context) const |