aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-08-25 17:10:07 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-08-25 17:10:07 -0300
commit8f941405798b67204945d7ec94ef8e63e1535877 (patch)
treecf9dea98ae90777a92fa3aab9deab02af7cddba4
parent8beba81378eb52d72864ca5adc1ba5f8e8a816cb (diff)
DocGenerator now resolves context for method references: it searchs
for the class that have implemented the method and link to its definition instead of producing a broken link to the current inheriting class documentation
-rw-r--r--docgenerator.cpp54
-rw-r--r--docgenerator.h1
2 files changed, 45 insertions, 10 deletions
diff --git a/docgenerator.cpp b/docgenerator.cpp
index 9b21ae145..455615e00 100644
--- a/docgenerator.cpp
+++ b/docgenerator.cpp
@@ -129,6 +129,38 @@ QString QtXmlToSphinx::popOutputBuffer()
return strcpy;
}
+QString QtXmlToSphinx::resolveContextForMethod(const QString& methodName)
+{
+ QString currentClass = m_context.split(".").last();
+
+ const AbstractMetaClass* metaClass = 0;
+ foreach (const AbstractMetaClass* cls, m_generator->classes()) {
+ if (cls->name() == currentClass) {
+ metaClass = cls;
+ break;
+ }
+ }
+
+ if (metaClass) {
+ QList<const AbstractMetaFunction*> funcList;
+ foreach (const AbstractMetaFunction* func, metaClass->queryFunctionsByName(methodName)) {
+ if (methodName == func->name())
+ funcList.append(func);
+ }
+
+ const AbstractMetaClass* implementingClass = 0;
+ foreach (const AbstractMetaFunction* func, funcList) {
+ implementingClass = func->implementingClass();
+ if (implementingClass->name() == currentClass)
+ break;
+ }
+
+ if (implementingClass)
+ return implementingClass->name();
+ }
+
+ return m_context;
+}
QString QtXmlToSphinx::transform(const QString& doc)
{
@@ -484,17 +516,19 @@ void QtXmlToSphinx::handleLinkTag(QXmlStreamReader& reader)
if (l_type == "function" && !m_context.isEmpty()) {
l_linktag = " :meth:`";
QStringList rawlinklist = l_linkref.split(".");
- if (rawlinklist.size() == 1 || rawlinklist.first() == m_context)
- l_linkref.prepend('~' + m_context + '.');
+ if (rawlinklist.size() == 1 || rawlinklist.first() == m_context) {
+ QString context = resolveContextForMethod(rawlinklist.last());
+ l_linkref.prepend('~' + context + '.');
+ }
} else if (l_type == "function" && m_context.isEmpty()) {
l_linktag = " :func:`";
} else if (l_type == "class") {
l_linktag = " :class:`";
QStringList rawlinklist = l_linkref.split(".");
- QStringList splitedContext = m_context.split(".");
- if (rawlinklist.size() == 1 || rawlinklist.first() == splitedContext.last()) {
- splitedContext.removeLast();
- l_linkref.prepend('~' + splitedContext.join(".") + '.');
+ QStringList splittedContext = m_context.split(".");
+ if (rawlinklist.size() == 1 || rawlinklist.first() == splittedContext.last()) {
+ splittedContext.removeLast();
+ l_linkref.prepend('~' + splittedContext.join(".") + '.');
}
} else if (l_type == "enum") {
l_linktag = " :attr:`";
@@ -949,11 +983,11 @@ QString DocGenerator::parseFunctionDeclaration(const QString &doc, const Abstrac
QString methArgs = data.mid(data.indexOf("("));
QString scope = cppClass->name();
- QStringList splitedMethName = methName.split(".");
+ QStringList splittedMethName = methName.split(".");
- if (splitedMethName.first() == scope) {
- splitedMethName.removeFirst();
- methName = splitedMethName.join(".");
+ if (splittedMethName.first() == scope) {
+ splittedMethName.removeFirst();
+ methName = splittedMethName.join(".");
}
scope.append(".");
diff --git a/docgenerator.h b/docgenerator.h
index cef7fa7a3..225b429b4 100644
--- a/docgenerator.h
+++ b/docgenerator.h
@@ -85,6 +85,7 @@ public:
}
private:
+ QString resolveContextForMethod(const QString& methodName);
QString transform(const QString& doc);
void handleHeadingTag(QXmlStreamReader& reader);