summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/pagegenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qdoc3/pagegenerator.cpp')
-rw-r--r--tools/qdoc3/pagegenerator.cpp131
1 files changed, 120 insertions, 11 deletions
diff --git a/tools/qdoc3/pagegenerator.cpp b/tools/qdoc3/pagegenerator.cpp
index a001c10..37dc191 100644
--- a/tools/qdoc3/pagegenerator.cpp
+++ b/tools/qdoc3/pagegenerator.cpp
@@ -43,10 +43,9 @@
pagegenerator.cpp
*/
-#include <QtCore>
#include <qfile.h>
#include <qfileinfo.h>
-
+#include <qdebug.h>
#include "pagegenerator.h"
#include "tree.h"
@@ -69,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.
*/
@@ -77,7 +180,7 @@ void PageGenerator::generateTree(const Tree *tree, CodeMarker *marker)
generateInnerNode(tree->root(), marker);
}
-QString PageGenerator::fileBase(const Node *node)
+QString PageGenerator::fileBase(const Node *node) const
{
if (node->relates())
node = node->relates();
@@ -104,8 +207,10 @@ QString PageGenerator::fileBase(const Node *node)
we prepend "qml-" to the file name of QML element doc
files.
*/
- if (p->subType() == Node::QmlClass) {
- base.prepend("qml-");
+ if ((p->subType() == Node::QmlClass) ||
+ (p->subType() == Node::QmlBasicType)) {
+ if (!base.startsWith(QLatin1String("QML:")))
+ base.prepend("qml-");
}
#endif
if (!pp || pp->name().isEmpty() || pp->type() == Node::Fake)
@@ -152,7 +257,7 @@ QString PageGenerator::fileBase(const Node *node)
return res;
}
-QString PageGenerator::fileName(const Node *node)
+QString PageGenerator::fileName(const Node *node) const
{
if (!node->url().isEmpty())
return node->url();
@@ -176,7 +281,7 @@ void PageGenerator::beginSubPage(const Location& location,
location.fatal(tr("Cannot open output file '%1'")
.arg(outFile->fileName()));
QTextStream *out = new QTextStream(outFile);
- out->setCodec("ISO-8859-1");
+ out->setCodec(outputCodec);
outStreamStack.push(out);
}
@@ -195,8 +300,8 @@ QTextStream &PageGenerator::out()
/*!
Recursive writing of html files from the root \a node.
*/
-void PageGenerator::generateInnerNode(const InnerNode *node,
- CodeMarker *marker)
+void
+PageGenerator::generateInnerNode(const InnerNode* node, CodeMarker* marker)
{
if (!node->url().isNull())
return;
@@ -205,10 +310,14 @@ void PageGenerator::generateInnerNode(const InnerNode *node,
const FakeNode *fakeNode = static_cast<const FakeNode *>(node);
if (fakeNode->subType() == Node::ExternalPage)
return;
-#ifdef QDOC_QML
+ if (fakeNode->subType() == Node::Image)
+ return;
if (fakeNode->subType() == Node::QmlPropertyGroup)
return;
-#endif
+ if (fakeNode->subType() == Node::Page) {
+ if (node->count() > 0)
+ qDebug("PAGE %s HAS CHILDREN", qPrintable(fakeNode->title()));
+ }
}
if (node->parent() != 0) {