From a4cd6ef25df6a2a99626a0e97bfc239f68e7771f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 24 Jul 2012 14:27:37 +0200 Subject: qdoc: Fixed incorrect href attribute values in qdoc There were two fileBase() functions, but only one was correct. The wrong one was being called in some cases. Now there is only one fileBase() function, which is always called. Task nr: QTBUG-26591 Change-Id: I2c40e2152a8c7ad1bb9db256ecf1367148f0e7f6 Reviewed-by: Casper van Donderen --- src/tools/qdoc/ditaxmlgenerator.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/tools/qdoc/ditaxmlgenerator.cpp') diff --git a/src/tools/qdoc/ditaxmlgenerator.cpp b/src/tools/qdoc/ditaxmlgenerator.cpp index e309784ce1..f9506ff348 100644 --- a/src/tools/qdoc/ditaxmlgenerator.cpp +++ b/src/tools/qdoc/ditaxmlgenerator.cpp @@ -284,6 +284,29 @@ QString DitaXmlGenerator::ditaTags[] = "" }; +/*! + Composes a string to be used as an href attribute in DITA + XML. It is composed of the file name and the UUID separated + by a '#'. If this node is a class node, the file name is + taken from this node; if this node is a function node, the + file name is taken from the parent node of this node. + */ +QString DitaXmlGenerator::ditaXmlHref(Node* n) +{ + QString href; + if ((n->type() == Node::Function) || + (n->type() == Node::Property) || + (n->type() == Node::Variable)) { + href = fileBase(n->parent()); + } + else { + href = fileBase(n); + } + if (!href.endsWith(".xml") && !href.endsWith(".dita")) + href += ".dita"; + return href + QLatin1Char('#') + n->guid(); +} + void DitaXmlGenerator::debugPara(const QString& t) { writeStartTag(DT_p); @@ -4218,7 +4241,7 @@ void DitaXmlGenerator::generateIndex(const QString& fileBase, const QString& url, const QString& title) { - tree_->generateIndex(outputDir() + QLatin1Char('/') + fileBase + ".index", url, title); + tree_->generateIndex(outputDir() + QLatin1Char('/') + fileBase + ".index", url, title, this); } void DitaXmlGenerator::generateStatus(const Node* node, CodeMarker* marker) @@ -4907,7 +4930,7 @@ void DitaXmlGenerator::writeFunctions(const Section& s, FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom(); if (rfn && !rfn->isInternal()) { writeStartTag(DT_cxxFunctionReimplemented); - xmlWriter().writeAttribute("href",rfn->ditaXmlHref()); + xmlWriter().writeAttribute("href",ditaXmlHref(rfn)); writeCharacters(marker->plainFullName(rfn)); writeEndTag(); // } @@ -5299,7 +5322,7 @@ void DitaXmlGenerator::writeProperties(const Section& s, if (pn->overriddenFrom() != 0) { PropertyNode* opn = (PropertyNode*)pn->overriddenFrom(); writeStartTag(DT_cxxVariableReimplemented); - xmlWriter().writeAttribute("href",opn->ditaXmlHref()); + xmlWriter().writeAttribute("href",ditaXmlHref(opn)); writeCharacters(marker->plainFullName(opn)); writeEndTag(); // } @@ -5461,7 +5484,7 @@ void DitaXmlGenerator::writeMacros(const Section& s, if (fn->reimplementedFrom() != 0) { FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom(); writeStartTag(DT_cxxDefineReimplemented); - xmlWriter().writeAttribute("href",rfn->ditaXmlHref()); + xmlWriter().writeAttribute("href",ditaXmlHref(rfn)); writeCharacters(marker->plainFullName(rfn)); writeEndTag(); // } -- cgit v1.2.3