From a2c432e97818ec16ead9be0d0aee3e43cf10929e Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 28 Jul 2014 14:21:37 +0200 Subject: qdoc: Allow choice of linking to QML or CPP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update enables using QML or CPP as the parameter in square brackets for the \l command. You will use this when, for example, there exist both a C++ class named QWidget and a QML type named QWidget and your \l {QWidget} links to the wrong one. Suppose you write \l {QWidget} expecting it to link to the QML type named QWidget, but it links to the C++ class named QWidget. Then write this instead: \l [QML] {QWidget} Or if you wrote \l {QWidget} expecting it to link to the C++ class, but it links to the QML type, write this instead: \l [CPP] {QWidget} A qdoc warning is printed if qdoc can not recognize the parameter in square brackets. There will be a further update to complete this task for implementing the other type of parameter that can be in the square brackets. Task-number: QTBUG-39221 Change-Id: I5dd85478f968025ecbe337a8aabcc31d8b12a86d Reviewed-by: Topi Reiniƶ --- src/tools/qdoc/qdocindexfiles.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/tools/qdoc/qdocindexfiles.cpp') diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp index 4531ce8eeaf..ba09bfea3b5 100644 --- a/src/tools/qdoc/qdocindexfiles.cpp +++ b/src/tools/qdoc/qdocindexfiles.cpp @@ -471,15 +471,18 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element, location = Location(parent->name().toLower() + ".html"); } else if (element.nodeName() == "keyword") { - qdb_->insertTarget(name, TargetRec::Keyword, current, 1); + QString title = element.attribute("title"); + qdb_->insertTarget(name, title, TargetRec::Keyword, current, 1); return; } else if (element.nodeName() == "target") { - qdb_->insertTarget(name, TargetRec::Target, current, 2); + QString title = element.attribute("title"); + qdb_->insertTarget(name, title, TargetRec::Target, current, 2); return; } else if (element.nodeName() == "contents") { - qdb_->insertTarget(name, TargetRec::Contents, current, 3); + QString title = element.attribute("title"); + qdb_->insertTarget(name, title, TargetRec::Contents, current, 3); return; } else @@ -1202,18 +1205,26 @@ bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer, external = true; } foreach (const Atom* target, node->doc().targets()) { - QString targetName = target->string(); - if (!external) - targetName = Doc::canonicalTitle(targetName); + QString title = target->string(); + QString name = Doc::canonicalTitle(title); writer.writeStartElement("target"); - writer.writeAttribute("name", targetName); + if (!external) + writer.writeAttribute("name", name); + else + writer.writeAttribute("name", title); + if (name != title) + writer.writeAttribute("title", title); writer.writeEndElement(); // target } } if (node->doc().hasKeywords()) { foreach (const Atom* keyword, node->doc().keywords()) { + QString title = keyword->string(); + QString name = Doc::canonicalTitle(title); writer.writeStartElement("keyword"); - writer.writeAttribute("name", Doc::canonicalTitle(keyword->string())); + writer.writeAttribute("name", name); + if (name != title) + writer.writeAttribute("title", title); writer.writeEndElement(); // keyword } } -- cgit v1.2.3