aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.araujo@kdab.com>2020-04-16 10:24:07 -0300
committerRenato Araujo Oliveira Filho <renato.araujo@kdab.com>2020-09-02 10:48:12 -0300
commitb3b9a9714c0f1199d547854be6d2d47a9268d444 (patch)
tree0ebfb4d3e069f4caa9f717c641414119d2f4b6c0 /sources/shiboken2/generator
parent61d1a5af4e6f17da32e302023b8a4358bccf5863 (diff)
Add support for briefdescription in doxygen parse
Extract briefdescription from doxygen files and make sure to generate sphinx docs with it Change-Id: Ibd2b104a2c85de6c3db1e8a48add061c804bd489 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp30
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.h6
2 files changed, 20 insertions, 16 deletions
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index a9413607d..f7dfc5391 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Python.
@@ -1535,7 +1535,8 @@ QString QtDocGenerator::fileNameForContext(const GeneratorContext &context) cons
}
void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc,
- const AbstractMetaClass *metaClass)
+ const AbstractMetaClass *metaClass,
+ Documentation::Type docType)
{
QString metaClassName;
@@ -1543,10 +1544,10 @@ void QtDocGenerator::writeFormattedText(QTextStream &s, const Documentation &doc
metaClassName = metaClass->fullName();
if (doc.format() == Documentation::Native) {
- QtXmlToSphinx x(this, doc.value(), metaClassName);
+ QtXmlToSphinx x(this,doc.value(docType), metaClassName);
s << x;
} else {
- const QString &value = doc.value();
+ const QString &value = doc.value(docType);
const QVector<QStringRef> lines = value.splitRef(QLatin1Char('\n'));
int typesystemIndentation = std::numeric_limits<int>::max();
// check how many spaces must be removed from the beginning of each line
@@ -1631,7 +1632,7 @@ void QtDocGenerator::generateClass(QTextStream &s, const GeneratorContext &class
auto documentation = metaClass->documentation();
Documentation brief;
if (extractBrief(&documentation, &brief))
- writeFormattedText(s, brief, metaClass);
+ writeFormattedText(s, brief.value(), metaClass);
s << ".. inheritance-diagram:: " << metaClass->fullName() << Qt::endl
<< " :parts: 2" << Qt::endl << Qt::endl;
@@ -1658,7 +1659,7 @@ void QtDocGenerator::generateClass(QTextStream &s, const GeneratorContext &class
writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, metaClass, nullptr);
if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, metaClass, nullptr))
- writeFormattedText(s, documentation, metaClass);
+ writeFormattedText(s, documentation.value(), metaClass);
if (!metaClass->isNamespace())
writeConstructors(s, metaClass);
@@ -1764,7 +1765,7 @@ void QtDocGenerator::writeEnums(QTextStream& s, const AbstractMetaClass* cppClas
const AbstractMetaEnumList &enums = cppClass->enums();
for (AbstractMetaEnum *en : enums) {
s << section_title << cppClass->fullName() << '.' << en->name() << Qt::endl << Qt::endl;
- writeFormattedText(s, en->documentation(), cppClass);
+ writeFormattedText(s, en->documentation().value(), cppClass);
const auto version = versionOf(en->typeEntry());
if (!version.isNull())
s << rstVersionAdded(version);
@@ -1780,7 +1781,7 @@ void QtDocGenerator::writeFields(QTextStream& s, const AbstractMetaClass* cppCla
for (AbstractMetaField *field : fields) {
s << section_title << cppClass->fullName() << "." << field->name() << Qt::endl << Qt::endl;
//TODO: request for member ‘documentation’ is ambiguous
- writeFormattedText(s, field->AbstractMetaAttributes::documentation(), cppClass);
+ writeFormattedText(s, field->AbstractMetaAttributes::documentation().value(), cppClass);
}
}
@@ -1836,7 +1837,7 @@ void QtDocGenerator::writeConstructors(QTextStream& s, const AbstractMetaClass*
s << Qt::endl;
for (AbstractMetaFunction *func : qAsConst(lst))
- writeFormattedText(s, func->documentation(), cppClass);
+ writeFormattedText(s, func->documentation().value(), cppClass);
}
QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */,
@@ -1971,8 +1972,8 @@ bool QtDocGenerator::writeInjectDocumentation(QTextStream& s,
else
continue;
- doc.setValue(mod.code() , fmt);
- writeFormattedText(s, doc, cppClass);
+ doc.setValue(mod.code(), Documentation::Detailed, fmt);
+ writeFormattedText(s, doc.value(), cppClass);
didSomething = true;
}
}
@@ -2122,10 +2123,11 @@ void QtDocGenerator::writeFunction(QTextStream& s, const AbstractMetaClass* cppC
if (func->attributes().testFlag(AbstractMetaAttributes::Deprecated))
s << INDENT << rstDeprecationNote("function");
}
-
writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, cppClass, func);
- if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, cppClass, func))
- writeFormattedText(s, func->documentation(), cppClass);
+ if (!writeInjectDocumentation(s, TypeSystem::DocModificationReplace, cppClass, func)) {
+ writeFormattedText(s, func->documentation(), cppClass, Documentation::Brief);
+ writeFormattedText(s, func->documentation(), cppClass, Documentation::Detailed);
+ }
writeInjectDocumentation(s, TypeSystem::DocModificationAppend, cppClass, func);
}
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
index 468abd599..b0f4c2552 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt for Python.
@@ -33,6 +33,7 @@
#include <QtCore/QScopedPointer>
#include <QtCore/QTextStream>
#include <QXmlStreamReader>
+#include "abstractmetalang.h"
#include "generator.h"
#include "docparser.h"
#include "typesystem_enums.h"
@@ -261,7 +262,8 @@ private:
void writeConstructors(QTextStream &s, const AbstractMetaClass *cppClass);
void writeFormattedText(QTextStream &s, const Documentation &doc,
- const AbstractMetaClass *metaclass = nullptr);
+ const AbstractMetaClass *metaclass = nullptr,
+ Documentation::Type docType = Documentation::Detailed);
bool writeInjectDocumentation(QTextStream& s, TypeSystem::DocModificationMode mode, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func);
void writeDocSnips(QTextStream &s, const CodeSnipList &codeSnips, TypeSystem::CodeSnipPosition position, TypeSystem::Language language);