summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@nokia.com>2010-05-31 13:53:44 (GMT)
committerMartin Smith <martin.smith@nokia.com>2010-05-31 13:53:44 (GMT)
commite79086f1a90a733cb06fd50773dbcabde0481988 (patch)
treef8286aab0c4f216ce834d7b7f55b0e8ed8486f37
parentc3795b027a54a123eb3ced4190843ca616f5435c (diff)
downloadQt-e79086f1a90a733cb06fd50773dbcabde0481988.zip
Qt-e79086f1a90a733cb06fd50773dbcabde0481988.tar.gz
Qt-e79086f1a90a733cb06fd50773dbcabde0481988.tar.bz2
qdoc: Added DITA XML generator
At the moment, it is just like the HTML generator, but with a different class name.
-rw-r--r--tools/qdoc3/pagegenerator.cpp106
-rw-r--r--tools/qdoc3/pagegenerator.h11
-rw-r--r--tools/qdoc3/qdoc3.pro2
3 files changed, 116 insertions, 3 deletions
diff --git a/tools/qdoc3/pagegenerator.cpp b/tools/qdoc3/pagegenerator.cpp
index f0f14fe..13c83a8 100644
--- a/tools/qdoc3/pagegenerator.cpp
+++ b/tools/qdoc3/pagegenerator.cpp
@@ -45,7 +45,7 @@
#include <qfile.h>
#include <qfileinfo.h>
-
+#include <qdebug.h>
#include "pagegenerator.h"
#include "tree.h"
@@ -68,6 +68,110 @@ PageGenerator::~PageGenerator()
endSubPage();
}
+static QRegExp linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)");
+static QRegExp funcTag("(<@func target=\"([^\"]*)\">)(.*)(</@func>)");
+static QRegExp typeTag("(<@(type|headerfile|func)(?: +[^>]*)?>)(.*)(</@\\2>)");
+static QRegExp spanTag("</@(?:comment|preprocessor|string|char)>");
+static QRegExp unknownTag("</?@[^>]*>");
+
+bool PageGenerator::parseArg(const QString& src,
+ const QString& tag,
+ int* pos,
+ int n,
+ QStringRef* contents,
+ QStringRef* par1,
+ bool debug)
+{
+#define SKIP_CHAR(c) \
+ if (debug) \
+ qDebug() << "looking for " << c << " at " << QString(src.data() + i, n - i); \
+ if (i >= n || src[i] != c) { \
+ if (debug) \
+ qDebug() << " char '" << c << "' not found"; \
+ return false; \
+ } \
+ ++i;
+
+
+#define SKIP_SPACE \
+ while (i < n && src[i] == ' ') \
+ ++i;
+
+ int i = *pos;
+ int j = i;
+
+ // assume "<@" has been parsed outside
+ //SKIP_CHAR('<');
+ //SKIP_CHAR('@');
+
+ if (tag != QStringRef(&src, i, tag.length())) {
+ if (0 && debug)
+ qDebug() << "tag " << tag << " not found at " << i;
+ return false;
+ }
+
+ if (debug)
+ qDebug() << "haystack:" << src << "needle:" << tag << "i:" <<i;
+
+ // skip tag
+ i += tag.length();
+
+ // parse stuff like: linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)");
+ if (par1) {
+ SKIP_SPACE;
+ // read parameter name
+ j = i;
+ while (i < n && src[i].isLetter())
+ ++i;
+ if (src[i] == '=') {
+ if (debug)
+ qDebug() << "read parameter" << QString(src.data() + j, i - j);
+ SKIP_CHAR('=');
+ SKIP_CHAR('"');
+ // skip parameter name
+ j = i;
+ while (i < n && src[i] != '"')
+ ++i;
+ *par1 = QStringRef(&src, j, i - j);
+ SKIP_CHAR('"');
+ SKIP_SPACE;
+ } else {
+ if (debug)
+ qDebug() << "no optional parameter found";
+ }
+ }
+ SKIP_SPACE;
+ SKIP_CHAR('>');
+
+ // find contents up to closing "</@tag>
+ j = i;
+ for (; true; ++i) {
+ if (i + 4 + tag.length() > n)
+ return false;
+ if (src[i] != '<')
+ continue;
+ if (src[i + 1] != '/')
+ continue;
+ if (src[i + 2] != '@')
+ continue;
+ if (tag != QStringRef(&src, i + 3, tag.length()))
+ continue;
+ if (src[i + 3 + tag.length()] != '>')
+ continue;
+ break;
+ }
+
+ *contents = QStringRef(&src, j, i - j);
+
+ i += tag.length() + 4;
+
+ *pos = i;
+ if (debug)
+ qDebug() << " tag " << tag << " found: pos now: " << i;
+ return true;
+#undef SKIP_CHAR
+}
+
/*!
This function is recursive.
*/
diff --git a/tools/qdoc3/pagegenerator.h b/tools/qdoc3/pagegenerator.h
index 7ab7e5e..1aa24a1 100644
--- a/tools/qdoc3/pagegenerator.h
+++ b/tools/qdoc3/pagegenerator.h
@@ -80,10 +80,17 @@ class PageGenerator : public Generator
QString naturalLanguage;
QString outputEncoding;
- QTextCodec *outputCodec;
+ QTextCodec* outputCodec;
+ bool parseArg(const QString& src,
+ const QString& tag,
+ int* pos,
+ int n,
+ QStringRef* contents,
+ QStringRef* par1 = 0,
+ bool debug = false);
private:
- QStack<QTextStream *> outStreamStack;
+ QStack<QTextStream*> outStreamStack;
};
QT_END_NAMESPACE
diff --git a/tools/qdoc3/qdoc3.pro b/tools/qdoc3/qdoc3.pro
index 81ff93a..5bedc29 100644
--- a/tools/qdoc3/qdoc3.pro
+++ b/tools/qdoc3/qdoc3.pro
@@ -37,6 +37,7 @@ HEADERS += apigenerator.h \
cppcodeparser.h \
cpptoqsconverter.h \
dcfsection.h \
+ ditaxmlgenerator.h \
doc.h \
editdistance.h \
generator.h \
@@ -81,6 +82,7 @@ SOURCES += apigenerator.cpp \
cppcodeparser.cpp \
cpptoqsconverter.cpp \
dcfsection.cpp \
+ ditaxmlgenerator.cpp \
doc.cpp \
editdistance.cpp \
generator.cpp \