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/htmlgenerator.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/htmlgenerator.cpp')
-rw-r--r-- | src/tools/qdoc/htmlgenerator.cpp | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index ec430d0951..ceed09a7cf 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -320,6 +320,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark if (!inLink_ && !inContents_ && !inSectionHeading_) { const Node *node = 0; QString link = getLink(atom, relative, &node); + QDocDatabase::debug = false; if (!link.isEmpty()) { beginLink(link, node, relative); generateLink(atom, marker); @@ -3188,7 +3189,7 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, if (src.at(i) == charLangle && src.at(i + 1) == charAt) { i += 2; if (parseArg(src, funcTag, &i, srcSize, &arg, &par1)) { - const Node* n = qdb_->resolveTarget(par1.toString(), relative); + const Node* n = qdb_->resolveFunctionTarget(par1.toString(), relative); QString link = linkForNode(n, relative); addLink(link, arg, &html); par1 = QStringRef(); @@ -3228,20 +3229,18 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode, } else if (parseArg(src, headerTag, &i, srcSize, &arg, &par1)) { par1 = QStringRef(); - const Node* n = qdb_->resolveTarget(arg.toString(), relative); - addLink(linkForNode(n,relative), arg, &html); - handled = true; - } -#if 0 - // Apparently, this clause was never used. - // <@func> is taken out above. - else if (parseArg(src, funcTag, &i, srcSize, &arg, &par1)) { - par1 = QStringRef(); - const Node* n = qdb_->resolveTarget(arg.toString(), relative); - addLink(linkForNode(n,relative), arg, &html); + if (arg.at(0) == QChar('&')) + html += arg.toString(); + else { + // zzz resolveClassTarget() + const Node* n = qdb_->resolveTarget(arg.toString(), relative); + if (n) + addLink(linkForNode(n,relative), arg, &html); + else + html += arg.toString(); + } handled = true; } -#endif if (!handled) { html += charLangle; html += charAt; @@ -3763,45 +3762,35 @@ QString HtmlGenerator::getLink(const Atom *atom, const Node *relative, const Nod *node = 0; inObsoleteLink = false; - if (atom->string().contains(QLatin1Char(':')) && - (atom->string().startsWith("file:") - || atom->string().startsWith("http:") - || atom->string().startsWith("https:") - || atom->string().startsWith("ftp:") - || atom->string().startsWith("mailto:"))) { - - link = atom->string(); + if (atom->string().contains(QLatin1Char(':')) && (atom->string().startsWith("file:") || + atom->string().startsWith("http:") || + atom->string().startsWith("https:") || + atom->string().startsWith("ftp:") || + atom->string().startsWith("mailto:"))) { + link = atom->string(); // It's some kind of protocol. } else { QStringList path; - if (atom->string().contains('#')) { - path = atom->string().split('#'); - } - else { - path.append(atom->string()); - } + if (atom->string().contains('#')) + path = atom->string().split('#'); // The target is in the html file. + else + path.append(atom->string()); // It's a general case target. QString ref; QString first = path.first().trimmed(); - if (first.isEmpty()) { + if (first.isEmpty()) *node = relative; - } - else if (first.endsWith(".html")) { - /* - This is not a recursive search. That's ok in - this case, because we are searching for a page - node, which must be a direct child of the tree - root. - */ + else if (first.endsWith(".html")) // The target is an html file. *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_->resolveTarget(first, relative); - if (!(*node)) - *node = qdb_->findDocNodeByTitle(first, relative); + *node = qdb_->findDocNodeByTitle(first); if (!(*node)) { - *node = qdb_->findUnambiguousTarget(first, ref, relative); + *node = qdb_->findUnambiguousTarget(first, ref); if (*node && !(*node)->url().isEmpty() && !ref.isEmpty()) { QString final = (*node)->url() + "#" + ref; return final; |