aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-30 18:08:24 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-06-30 18:22:20 -0300
commitaa333111a036873d2942fa949901d5634c5f44a7 (patch)
tree60fc16b53d651d60f9f4c308f4e4e20d699840ab
parent2e58a6d67c38ef627c1065fca61c3602a1eb49d0 (diff)
Implemented support to namespace.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>, Hugo Parente Lima <hugo.lima@openbossa.org>
-rw-r--r--generators/qtdoc/qtdocgenerator.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/generators/qtdoc/qtdocgenerator.cpp b/generators/qtdoc/qtdocgenerator.cpp
index 4f3a37bf..47ab8543 100644
--- a/generators/qtdoc/qtdocgenerator.cpp
+++ b/generators/qtdoc/qtdocgenerator.cpp
@@ -522,7 +522,8 @@ void QtXmlToSphinx::handleLinkTag(QXmlStreamReader& reader)
QStringList rawlinklist = l_linkref.split(".");
if (rawlinklist.size() == 1 || rawlinklist.first() == m_context) {
QString context = resolveContextForMethod(rawlinklist.last());
- l_linkref.prepend(context + '.');
+ if (!l_linkref.startsWith(context))
+ l_linkref.prepend(context + '.');
}
} else if (l_type == "function" && m_context.isEmpty()) {
l_linktag = " :func:`";
@@ -804,8 +805,20 @@ QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table)
return s;
}
-static QString getClassName(const AbstractMetaClass *cppClass) {
- return QString(cppClass->typeEntry()->qualifiedCppName()).replace("::", ".");
+static QString getClassName(const AbstractMetaClass *cppClass)
+{
+ if (!cppClass)
+ return QString();
+
+ QString scope = cppClass->name();
+ const AbstractMetaClass *context = cppClass->enclosingClass();
+ while (context) {
+ if (!context->isNamespace())
+ scope = context->name() + "." + context->name();
+ context = context->enclosingClass();
+ }
+
+ return scope;
}
static QString getFuncName(const AbstractMetaFunction *cppFunc) {
@@ -951,19 +964,15 @@ QString QtDocGenerator::parseFunctionDeclaration(const QString &doc, const Abstr
return QString();
data = data.mid(markup.size()); //remove .. method::
- data = data.mid(data.indexOf(".") + 1); //remove class name
+ data = data.mid(data.lastIndexOf(".") + 1); //remove class name
QString methName = data.mid(0, data.indexOf("("));
QString methArgs = data.mid(data.indexOf("("));
- QString scope = cppClass->name();
- QStringList splittedMethName = methName.split(".");
-
- if (splittedMethName.first() == scope) {
- splittedMethName.removeFirst();
- methName = splittedMethName.join(".");
- }
- scope.append(".");
+ QString scope = getClassName(cppClass);
+ scope += ".";
+ if (methName.startsWith(scope))
+ methName.remove(scope);
data = QString("def :meth:`%1<%2%3>` %4")
.arg(methName)
@@ -1233,11 +1242,17 @@ void QtDocGenerator::writeInjectDocumentation(QTextStream &s,
void QtDocGenerator::writeFunctionSignature(QTextStream& s, const AbstractMetaClass* cppClass, const AbstractMetaFunction* func)
{
+ QString className;
if (!func->isConstructor())
- s << getClassName(cppClass) << '.';
+ className = getClassName(cppClass) + '.';
else if (func->implementingClass() && func->implementingClass()->enclosingClass())
- s << func->implementingClass()->enclosingClass()->name() << '.';
- s << getFuncName(func) << "(" << parseArgDocStyle(cppClass, func) << ")";
+ className = getClassName(func->implementingClass()->enclosingClass()) + '.';
+
+ QString funcName = getFuncName(func);
+ if (!funcName.startsWith(className))
+ funcName = className + funcName;
+
+ s << funcName << "(" << parseArgDocStyle(cppClass, func) << ")";
}
QString QtDocGenerator::translateToPythonType(const AbstractMetaType *type, const AbstractMetaClass *cppClass)