diff -r 5dc02b23752f -r 3e2da88830cd tools/qdoc3/pagegenerator.cpp --- a/tools/qdoc3/pagegenerator.cpp Tue Jul 06 15:10:48 2010 +0300 +++ b/tools/qdoc3/pagegenerator.cpp Wed Aug 18 10:37:55 2010 +0300 @@ -45,7 +45,7 @@ #include #include - +#include #include "pagegenerator.h" #include "tree.h" @@ -68,6 +68,110 @@ endSubPage(); } +static QRegExp linkTag("(<@link node=\"([^\"]+)\">).*()"); +static QRegExp funcTag("(<@func target=\"([^\"]*)\">)(.*)()"); +static QRegExp typeTag("(<@(type|headerfile|func)(?: +[^>]*)?>)(.*)()"); +static QRegExp spanTag(""); +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:" <).*()"); + 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 " + 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. */ @@ -105,7 +209,8 @@ */ if ((p->subType() == Node::QmlClass) || (p->subType() == Node::QmlBasicType)) { - base.prepend("qml-"); + if (!base.startsWith(QLatin1String("QML:"))) + base.prepend("qml-"); } #endif if (!pp || pp->name().isEmpty() || pp->type() == Node::Fake) @@ -195,8 +300,8 @@ /*! 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;