diff options
author | Martin Smith <martin.smith@digia.com> | 2014-03-19 15:12:07 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-31 21:05:23 +0200 |
commit | 2ea15849a09208ac19d189acdc51c313b64a0b3a (patch) | |
tree | 630825cea808fcd38e39a257754b8dffd72307a5 /src/tools/qdoc/ditaxmlgenerator.cpp | |
parent | 900c150a07f627c20ad68ec59253196d9960b034 (diff) |
qdoc: \l{Qt::Window} links to the wrong page
kThis update fixes a bug introduced by the extensive changes
for QTBUG-35377. The name Qt represents two namespaces, one
in C++ and one in QML. The name "Window" is used in both of
them, so the link \l{Qt::Window} would cause a collision in
the single tree qdoc. In the multiple tree qdoc, there is
no collision, but in this case the link should have gone to
the C++ page and it went to the QML page instead. The fix
involved correcting the way qdoc searches for link targets.
Task-number: QTBUG-37633
Change-Id: Ib9b209eced937a0be0d3299f300ebf22b2776012
Reviewed-by: Martin Smith <martin.smith@digia.com>
Diffstat (limited to 'src/tools/qdoc/ditaxmlgenerator.cpp')
-rw-r--r-- | src/tools/qdoc/ditaxmlgenerator.cpp | 125 |
1 files changed, 64 insertions, 61 deletions
diff --git a/src/tools/qdoc/ditaxmlgenerator.cpp b/src/tools/qdoc/ditaxmlgenerator.cpp index 8ac1b1ef82..90661d80e0 100644 --- a/src/tools/qdoc/ditaxmlgenerator.cpp +++ b/src/tools/qdoc/ditaxmlgenerator.cpp @@ -3389,68 +3389,71 @@ void DitaXmlGenerator::writeText(const QString& markedCode, const Node* relative for (int k = 0; k != 6; ++k) { if (parseArg(src, markTags[k], &i, n, &arg, &par1)) { const Node* n = 0; - if (k == 0) { // <@link> - if (!text.isEmpty()) { - writeCharacters(text); - text.clear(); - } - n = CodeMarker::nodeForString(par1.toString()); - QString link = linkForNode(n, relative); - addLink(link, arg); - } - else if (k == 4) { // <@param> - if (!text.isEmpty()) { - writeCharacters(text); - text.clear(); - } - writeStartTag(DT_i); - //writeCharacters(" " + arg.toString()); - writeCharacters(arg.toString()); - writeEndTag(); // </i> - } - else if (k == 5) { // <@extra> - if (!text.isEmpty()) { - writeCharacters(text); - text.clear(); - } - writeStartTag(DT_tt); - writeCharacters(arg.toString()); - writeEndTag(); // </tt> - } - else { - if (!text.isEmpty()) { - writeCharacters(text); - text.clear(); - } - par1 = QStringRef(); - QString link; - n = qdb_->resolveTarget(arg.toString(), relative); - if (n && n->subType() == Node::QmlBasicType) { - if (relative && relative->subType() == Node::QmlClass) { - link = linkForNode(n,relative); - addLink(link, arg); + switch (k) { + case 0: // <@link> + if (!text.isEmpty()) { + writeCharacters(text); + text.clear(); } - else { - writeCharacters(arg.toString()); + n = CodeMarker::nodeForString(par1.toString()); + addLink(linkForNode(n, relative), arg); + break; + case 4: // <@param> + if (!text.isEmpty()) { + writeCharacters(text); + text.clear(); } - } - else { - // (zzz) Is this correct for all cases? - link = linkForNode(n,relative); - addLink(link, arg); - } - } + writeStartTag(DT_i); + //writeCharacters(" " + arg.toString()); + writeCharacters(arg.toString()); + writeEndTag(); // </i> + break; + case 5: // <@extra> + if (!text.isEmpty()) { + writeCharacters(text); + text.clear(); + } + writeStartTag(DT_tt); + writeCharacters(arg.toString()); + writeEndTag(); // </tt> + break; + case 3: + if (!text.isEmpty()) { + writeCharacters(text); + text.clear(); + } + par1 = QStringRef(); + n = qdb_->resolveFunctionTarget(arg.toString(), relative); + addLink(linkForNode(n, relative), arg); + break; + case 1: + case 2: + default: + if (!text.isEmpty()) { + writeCharacters(text); + text.clear(); + } + par1 = QStringRef(); + n = qdb_->resolveType(arg.toString(), relative); + if (n && n->subType() == Node::QmlBasicType) { + if (relative && relative->subType() == Node::QmlClass) + addLink(linkForNode(n, relative), arg); + else + writeCharacters(arg.toString()); + } + else + addLink(linkForNode(n, relative), arg); // (zzz) Is this correct for all cases? + break; + } // switch break; } } } - else { + else text += src.at(i++); - } } - if (!text.isEmpty()) { + if (!text.isEmpty()) writeCharacters(text); - } } void DitaXmlGenerator::generateLink(const Atom* atom, CodeMarker* marker) @@ -3830,18 +3833,18 @@ QString DitaXmlGenerator::getLink(const Atom* atom, const Node* relative, const QString ref; QString first = path.first().trimmed(); - if (first.isEmpty()) { + if (first.isEmpty()) *node = relative; - } - else if (first.endsWith(".html")) { + else if (first.endsWith(".html")) *node = qdb_->findNodeByNameAndType(QStringList(first), Node::Document, Node::NoSubType); - } + else if (first.endsWith("()")) // The target is a C++ function or QML method. + *node = qdb_->resolveFunctionTarget(first, relative); else { *node = qdb_->resolveTarget(first, relative); + if (!(*node)) + *node = qdb_->findDocNodeByTitle(first); if (!*node) - *node = qdb_->findDocNodeByTitle(first, relative); - if (!*node) - *node = qdb_->findUnambiguousTarget(first, ref, relative); + *node = qdb_->findUnambiguousTarget(first, ref); } if (*node) { @@ -4601,7 +4604,7 @@ void DitaXmlGenerator::replaceTypesWithLinks(const Node* n, const InnerNode* par } i += 2; if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) { - const Node* tn = qdb_->resolveTarget(arg.toString(), parent); + const Node* tn = qdb_->resolveType(arg.toString(), parent); if (tn) { //Do not generate a link from a C++ function to a QML Basic Type (such as int) if (n->type() == Node::Function && tn->subType() == Node::QmlBasicType) |