summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-11 16:48:09 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-03-13 20:32:11 +0000
commitd41b912b73f82eb42bb7710ff831e676f4c7e51f (patch)
tree5fbe4b0baf8280dc4d3a42febb50e2b99f217059
parent166a9ca4c0a07af94ea72d767ca0e9dd28552786 (diff)
shiboken: Generate deprecation information for functions and classes
Add a deprecation note to deprecated functions and classes. There is a standard deprecated directive, but it takes the version as a mandatory parameter, which we are unable to obtain from Clang. Change-Id: Ice27b297fbd86def41d99b0f3505551ed301077f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp4
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp12
2 files changed, 16 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 5940aa86..95f8048c 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -1285,6 +1285,8 @@ void AbstractMetaFunction::formatDebugVerbose(QDebug &d) const
d << " [userAdded]";
if (m_explicit)
d << " [explicit]";
+ if (attributes().testFlag(AbstractMetaAttributes::Deprecated))
+ d << " [deprecated]";
if (m_pointerOperator)
d << " [operator->]";
if (m_isCallOperator)
@@ -2637,6 +2639,8 @@ QDebug operator<<(QDebug d, const AbstractMetaClass *ac)
d << '"' << ac->fullName() << '"';
if (ac->attributes() & AbstractMetaAttributes::FinalCppClass)
d << " [final]";
+ if (ac->attributes().testFlag(AbstractMetaAttributes::Deprecated))
+ d << " [deprecated]";
if (ac->m_baseClass)
d << ", inherits \"" << ac->m_baseClass->name() << '"';
if (ac->m_templateBaseClass)
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index c22abd6a..c9e1eb02 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -190,6 +190,12 @@ static QTextStream &operator<<(QTextStream &s, const rstVersionAdded &v)
return s;
}
+static QByteArray rstDeprecationNote(const char *what)
+{
+ return QByteArrayLiteral(".. note:: This ")
+ + what + QByteArrayLiteral(" is deprecated.\n\n");
+}
+
// RST anchor string: Anything else but letters, numbers, '_' or '.' replaced by '-'
static inline bool isValidRstLabelChar(QChar c)
{
@@ -1594,6 +1600,8 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex
const auto version = versionOf(metaClass->typeEntry());
if (!version.isNull())
s << rstVersionAdded(version);
+ if (metaClass->attributes().testFlag(AbstractMetaAttributes::Deprecated))
+ s << rstDeprecationNote("class");
writeFunctionList(s, metaClass);
@@ -1760,6 +1768,8 @@ void QtDocGenerator::writeConstructors(QTextStream& s, const AbstractMetaClass*
const auto version = versionOf(func->typeEntry());
if (!version.isNull())
s << indent1 << rstVersionAdded(version);
+ if (func->attributes().testFlag(AbstractMetaAttributes::Deprecated))
+ s << indent1 << rstDeprecationNote("constructor");
const AbstractMetaArgumentList &arguments = func->arguments();
for (AbstractMetaArgument *arg : arguments) {
@@ -2044,6 +2054,8 @@ void QtDocGenerator::writeFunction(QTextStream& s, const AbstractMetaClass* cppC
const auto version = versionOf(func->typeEntry());
if (!version.isNull())
s << INDENT << rstVersionAdded(version);
+ if (func->attributes().testFlag(AbstractMetaAttributes::Deprecated))
+ s << INDENT << rstDeprecationNote("function");
}
writeInjectDocumentation(s, TypeSystem::DocModificationPrepend, cppClass, func);