diff options
| author | Martin Smith <martin.smith@digia.com> | 2014-05-23 13:26:36 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-01 13:40:53 +0200 |
| commit | 46959875cf7ddeb9bbcee883e4bfaef63992b870 (patch) | |
| tree | 727c786536dbd21b28eaa8fcaf429259c97f6dc1 /src/tools/qdoc/qdocindexfiles.cpp | |
| parent | bb794270ec6cffb5f95bd7d18056b9e7bede7baa (diff) | |
qdoc: Give documenter more control of linking
This update is preparation for implementing the actual task
described in the bug. To implement it required converting
the QML type node and the QML basic type node to be first
order tree nodes instead of subtypes of the documentation
node. This cleans up a lot of messy logic in some places.
It was also necessary to split the getLink() function in the
html output generator into two functions, one still called
getLink(), which handles the \l command, and one called
qetAutoLink() which is called for generating auto links.
This should make qdoc run faster.
The basic infrastructure was also added for parsing the
string in the square brackets for the \l command.
There will be a further update to complete this task.
Note that some autolinks might not be generated due to
this change. I haven't seen any yet, but I believe there
will be some. This can be fixed later, if it is a problem.
Task-number: QTBUG-39221
Change-Id: I8135229984398408205ba901b9ef95ceac74683c
Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com>
Diffstat (limited to 'src/tools/qdoc/qdocindexfiles.cpp')
| -rw-r--r-- | src/tools/qdoc/qdocindexfiles.cpp | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp index be8184b596d..25f6b8eec94 100644 --- a/src/tools/qdoc/qdocindexfiles.cpp +++ b/src/tools/qdoc/qdocindexfiles.cpp @@ -206,8 +206,7 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element, abstract = true; node->setAbstract(abstract); } - else if ((element.nodeName() == "qmlclass") || - ((element.nodeName() == "page") && (element.attribute("subtype") == "qmlclass"))) { + else if (element.nodeName() == "qmlclass") { QmlClassNode* qcn = new QmlClassNode(parent, name); qcn->setTitle(element.attribute("title")); QString qmlModuleName = element.attribute("qml-module-name"); @@ -260,11 +259,11 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element, if (element.attribute("writable") == "false") readonly = true; QmlPropertyNode* qpn = 0; - if (parent->type() == Node::Document) { + if (parent->isQmlType()) { QmlClassNode* qcn = static_cast<QmlClassNode*>(parent); qpn = new QmlPropertyNode(qcn, name, type, attached); } - else if (parent->type() == Node::QmlPropertyGroup) { + else if (parent->isQmlPropertyGroup()) { QmlPropertyGroupNode* qpgn = static_cast<QmlPropertyGroupNode*>(parent); qpn = new QmlPropertyNode(qpgn, name, type, attached); } @@ -332,14 +331,6 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element, subtype = Node::ExternalPage; ptype = Node::ArticlePage; } - else if (attr == "qmlclass") { - subtype = Node::QmlClass; - ptype = Node::ApiPage; - } - else if (attr == "qmlbasictype") { - subtype = Node::QmlBasicType; - ptype = Node::ApiPage; - } else return; @@ -614,7 +605,7 @@ void QDocIndexFiles::resolveIndex() foreach (pair, basesList_) { foreach (const QString& base, pair.second.split(QLatin1Char(','))) { QStringList basePath = base.split(QString("::")); - Node* n = qdb_->findNodeByNameAndType(basePath, Node::Class, Node::NoSubType); + Node* n = qdb_->findClassNode(basePath); if (n) pair.first->addResolvedBaseClass(Node::Public, static_cast<ClassNode*>(n)); else @@ -661,17 +652,20 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, case Node::Class: nodeName = "class"; break; - case Node::Document: - nodeName = "page"; - if (node->subType() == Node::QmlClass) { + case Node::QmlType: + { nodeName = "qmlclass"; QmlModuleNode* qmn = node->qmlModule(); if (qmn) qmlModuleName = qmn->qmlModuleName(); qmlFullBaseName = node->qmlFullBaseName(); } - else if (node->subType() == Node::QmlBasicType) - nodeName = "qmlbasictype"; + break; + case Node::QmlBasicType: + nodeName = "qmlbasictype"; + break; + case Node::Document: + nodeName = "page"; break; case Node::Group: nodeName = "group"; @@ -755,10 +749,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, QXmlStreamAttributes attributes; - if ((node->type() != Node::Document) && - (node->type() != Node::Group) && - (node->type() != Node::Module) && - (node->type() != Node::QmlModule)) { + if (!node->isDocNode() && !node->isGroup() && !node->isModule() && !node->isQmlModule()) { QString threadSafety; switch (node->threadSafeness()) { case Node::NonReentrant: @@ -843,10 +834,7 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, writer.writeAttribute("href", href); writer.writeAttribute("status", status); - if ((node->type() != Node::Document) && - (node->type() != Node::Group) && - (node->type() != Node::Module) && - (node->type() != Node::QmlModule)) { + if (!node->isDocNode() && !node->isGroup() && !node->isModule() && !node->isQmlModule()) { writer.writeAttribute("access", access); if (node->isAbstract()) writer.writeAttribute("abstract", "true"); @@ -896,6 +884,18 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, writer.writeAttribute("brief", brief); } break; + case Node::QmlType: + { + const QmlClassNode* qcn = static_cast<const QmlClassNode*>(node); + writer.writeAttribute("title", qcn->title()); + writer.writeAttribute("fulltitle", qcn->fullTitle()); + writer.writeAttribute("subtitle", qcn->subTitle()); + if (!qcn->groupNames().isEmpty()) + writer.writeAttribute("groups", qcn->groupNames().join(",")); + if (!brief.isEmpty()) + writer.writeAttribute("brief", brief); + } + break; case Node::Document: { /* @@ -923,12 +923,6 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, case Node::ExternalPage: writer.writeAttribute("subtype", "externalpage"); break; - case Node::QmlClass: - //writer.writeAttribute("subtype", "qmlclass"); - break; - case Node::QmlBasicType: - //writer.writeAttribute("subtype", "qmlbasictype"); - break; default: break; } @@ -1289,7 +1283,7 @@ bool compareNodes(const Node* n1, const Node* n2) return false; } - if (n1->type() == Node::Document && n2->type() == Node::Document) { + if (n1->isDocNode() && n2->isDocNode()) { const DocNode* f1 = static_cast<const DocNode*>(n1); const DocNode* f2 = static_cast<const DocNode*>(n2); if (f1->fullTitle() < f2->fullTitle()) |
