From a5570bbf9af05fa33cfcc9f167786e8d2ca1e32e Mon Sep 17 00:00:00 2001
From: Martin Smith
Date: Wed, 30 Jul 2014 13:44:15 +0200
Subject: [PATCH] qdoc: Remove all collision node stuff from qdoc
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Now that the qdoc link command has ability to tell qdoc which module
contains a link target or whether to link to a QML or CPP entity,
collision pages should no longer be necessary. In fact, qdoc hasn't
been generating any collisions for some time. This task removes all
the collision node code from qdoc.
Task-number: QTBUG-40506
Change-Id: I34d1980ca1c0fe4bb5ad27dd4b00e61fa7e6e335
Reviewed-by: Topi Reiniƶ
---
src/tools/qdoc/cppcodemarker.cpp | 3 +-
src/tools/qdoc/cppcodeparser.cpp | 46 -------
src/tools/qdoc/ditaxmlgenerator.cpp | 171 ++------------------------
src/tools/qdoc/ditaxmlgenerator.h | 1 -
src/tools/qdoc/generator.cpp | 149 +++++++----------------
src/tools/qdoc/generator.h | 2 -
src/tools/qdoc/helpprojectwriter.cpp | 3 +-
src/tools/qdoc/htmlgenerator.cpp | 120 +------------------
src/tools/qdoc/htmlgenerator.h | 1 -
src/tools/qdoc/node.cpp | 173 +--------------------------
src/tools/qdoc/node.h | 22 ----
src/tools/qdoc/qdocdatabase.cpp | 14 +--
src/tools/qdoc/qdocdatabase.h | 6 -
src/tools/qdoc/qdocindexfiles.cpp | 15 +--
src/tools/qdoc/tree.cpp | 55 +--------
src/tools/qdoc/tree.h | 2 -
16 files changed, 72 insertions(+), 711 deletions(-)
diff --git a/src/tools/qdoc/cppcodemarker.cpp b/src/tools/qdoc/cppcodemarker.cpp
index af2ff76405..715e7daa6e 100644
--- a/src/tools/qdoc/cppcodemarker.cpp
+++ b/src/tools/qdoc/cppcodemarker.cpp
@@ -410,8 +410,7 @@ QString CppCodeMarker::markedUpEnumValue(const QString &enumValue, const Node *r
QString fullName;
while (node->parent()) {
fullName.prepend(markedUpName(node));
- if (node->parent() == relative || node->parent()->name().isEmpty() ||
- node->parent()->isCollisionNode())
+ if (node->parent() == relative || node->parent()->name().isEmpty())
break;
fullName.prepend("<@op>::@op>");
node = node->parent();
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp
index df11ee5b24..be061dbd62 100644
--- a/src/tools/qdoc/cppcodeparser.cpp
+++ b/src/tools/qdoc/cppcodeparser.cpp
@@ -497,27 +497,12 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
ptype = Node::DitaMapPage;
}
- /*
- Search for a node with the same name. If there is one,
- then there is a collision, so create a collision node
- and make the existing node a child of the collision
- node, and then create the new Page node and make
- it a child of the collision node as well. Return the
- collision node.
-
- If there is no collision, just create a new Page
- node and return that one.
- */
- NameCollisionNode* ncn = qdb_->checkForCollision(args[0]);
DocNode* dn = 0;
if (ptype == Node::DitaMapPage)
dn = new DitaMapNode(qdb_->primaryTreeRoot(), args[0]);
else
dn = new DocNode(qdb_->primaryTreeRoot(), args[0], Node::Page, ptype);
dn->setLocation(doc.startLocation());
- if (ncn) {
- ncn->addCollision(dn);
- }
return dn;
}
else if (command == COMMAND_DITAMAP) {
@@ -549,40 +534,9 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc,
classNode = qdb_->findClassNode(names[1].split("::"));
}
- /*
- Search for a node with the same name. If there is one,
- then there is a collision, so create a collision node
- and make the existing node a child of the collision
- node, and then create the new QML class node and make
- it a child of the collision node as well. Return the
- collision node.
-
- If there is no collision, just create a new QML class
- node and return that one.
- */
- NameCollisionNode* ncn = qdb_->checkForCollision(names[0]);
QmlClassNode* qcn = new QmlClassNode(qdb_->primaryTreeRoot(), names[0]);
qcn->setClassNode(classNode);
qcn->setLocation(doc.startLocation());
-#if 0
- // to be removed if \qmltype and \instantiates work ok
- if (isParsingCpp() || isParsingQdoc()) {
- qcn->requireCppClass();
- if (names.size() < 2) {
- QString msg = "C++ class name not specified for class documented as "
- "QML type: '\\qmlclass " + arg.first + " '";
- doc.startLocation().warning(tr(msg.toLatin1().data()));
- }
- else if (!classNode) {
- QString msg = "C++ class not found in any .h file for class documented "
- "as QML type: '\\qmlclass " + arg.first + "'";
- doc.startLocation().warning(tr(msg.toLatin1().data()));
- }
- }
-#endif
- if (ncn) {
- ncn->addCollision(qcn);
- }
return qcn;
}
else if (command == COMMAND_QMLBASICTYPE) {
diff --git a/src/tools/qdoc/ditaxmlgenerator.cpp b/src/tools/qdoc/ditaxmlgenerator.cpp
index 83d89d0187..9cc44d7000 100644
--- a/src/tools/qdoc/ditaxmlgenerator.cpp
+++ b/src/tools/qdoc/ditaxmlgenerator.cpp
@@ -671,10 +671,8 @@ GuidMap* DitaXmlGenerator::lookupGuidMap(const QString& fileName)
*/
void DitaXmlGenerator::generateDocs()
{
- if (!runPrepareOnly()) {
+ if (!runPrepareOnly())
Generator::generateDocs();
- generateCollisionPages();
- }
if (!runGenerateOnly()) {
QString fileBase = project.toLower().simplified().replace(QLatin1Char(' '), QLatin1Char('-'));
@@ -2275,10 +2273,6 @@ void DitaXmlGenerator::generateDocNode(DocNode* dn, CodeMarker* marker)
QList::const_iterator s;
QString fullTitle = dn->fullTitle();
- if (dn->subType() == Node::Collision) {
- fullTitle = "Name Collision: " + fullTitle;
- }
-
generateHeader(dn, fullTitle);
generateBrief(dn, marker); //
writeProlog(dn);
@@ -2553,9 +2547,6 @@ void DitaXmlGenerator::generateHeader(const Node* node, const QString& name)
case Node::ExternalPage: // not used
outputclass = "externalpage";
break;
- case Node::Collision:
- outputclass = "collision";
- break;
default:
outputclass = "page";
}
@@ -5277,27 +5268,16 @@ DitaXmlGenerator::generateInnerNode(InnerNode* node)
*/
CodeMarker *marker = CodeMarker::markerForFileName(node->location().filePath());
if (node->parent() != 0) {
- /*
- Skip name collision nodes here and process them
- later in generateCollisionPages(). Each one is
- appended to a list for later.
- */
- if (node->isCollisionNode()) {
- NameCollisionNode* ncn = static_cast(node);
- collisionNodes.append(const_cast(ncn));
- }
- else {
- if (!node->name().endsWith(".ditamap"))
- beginSubPage(node, fileName(node));
- if (node->isNamespace() || node->isClass() || node->isQmlType() || node->isHeaderFile())
- generateClassLikeNode(node, marker);
- else if (node->isDocNode())
- generateDocNode(static_cast(node), marker);
- else if (node->isQmlBasicType())
- generateQmlBasicTypePage(static_cast(node), marker);
- if (!node->name().endsWith(".ditamap"))
- endSubPage();
- }
+ if (!node->name().endsWith(".ditamap"))
+ beginSubPage(node, fileName(node));
+ if (node->isNamespace() || node->isClass() || node->isQmlType() || node->isHeaderFile())
+ generateClassLikeNode(node, marker);
+ else if (node->isDocNode())
+ generateDocNode(static_cast(node), marker);
+ else if (node->isQmlBasicType())
+ generateQmlBasicTypePage(static_cast(node), marker);
+ if (!node->name().endsWith(".ditamap"))
+ endSubPage();
}
NodeList::ConstIterator c = node->childNodes().constBegin();
@@ -5363,13 +5343,6 @@ Node* DitaXmlGenerator::collectNodesByTypeAndSubtype(const InnerNode* parent)
QString message;
for (int i=0; iisCollisionNode()) {
- const DocNode* fake = static_cast(child);
- Node* n = collectNodesByTypeAndSubtype(fake);
- if (n)
- rootPageNode = n;
- continue;
- }
if (!child || child->isInternal() || child->doc().isEmpty() || child->isIndexNode())
continue;
@@ -5428,10 +5401,6 @@ Node* DitaXmlGenerator::collectNodesByTypeAndSubtype(const InnerNode* parent)
if (!isDuplicate(nodeSubtypeMaps[Node::ExternalPage],child->title(),child))
nodeSubtypeMaps[Node::ExternalPage]->insert(child->title(),child);
break;
- case Node::Collision:
- if (!isDuplicate(nodeSubtypeMaps[Node::Collision],child->title(),child))
- nodeSubtypeMaps[Node::Collision]->insert(child->title(),child);
- break;
default:
break;
}
@@ -6029,122 +5998,4 @@ QString DitaXmlGenerator::stripMarkup(const QString& src) const
return text;
}
-/*!
- We delayed generation of the collision pages until now, after
- all the other pages have been generated. We do this because we might
- encounter a link command that tries to link to a target on a QML
- type page, but the link doesn't specify the module identifer
- for the QML type, and the QML type name without a module
- identifier is ambiguous. When such a link is found, qdoc can't find
- the target, so it appends the target to the NameCollisionNode. After
- the tree has been traversed and all these ambiguous links have been
- added to the name collision nodes, this function is called. The list
- of collision nodes is traversed here, and the collision page for
- each collision is generated. The collision page will not only
- disambiguate links to the QML type pages, but it will also disambiguate
- links to properties, section headers, etc.
- */
-void DitaXmlGenerator::generateCollisionPages()
-{
- if (collisionNodes.isEmpty())
- return;
-
- for (int i=0; ichildNodes();
- if (!nl.isEmpty()) {
- NodeList::ConstIterator it = nl.constBegin();
- while (it != nl.constEnd()) {
- if (!(*it)->isInternal())
- collisions.append(*it);
- ++it;
- }
- }
- if (collisions.size() <= 1)
- continue;
-
- beginSubPage(ncn, Generator::fileName(ncn));
- QString fullTitle = ncn->fullTitle();
- QString ditaTitle = fullTitle;
- CodeMarker* marker = CodeMarker::markerForFileName(ncn->location().filePath());
- if (ncn->isQmlNode()) {
- // Replace the marker with a QML code marker.
- if (ncn->isQmlNode())
- marker = CodeMarker::markerForLanguage(QLatin1String("QML"));
- }
-
- generateHeader(ncn, ditaTitle);
- writeProlog(ncn);
- writeStartTag(DT_body);
- enterSection(QString(), QString());
-
- NodeMap nm;
- for (int i=0; iqmlModuleName().isEmpty())
- t = n->qmlModuleName() + QLatin1Char(' ');
- t += protectEnc(fullTitle);
- nm.insertMulti(t,n);
- }
- generateAnnotatedList(ncn, marker, nm);
-
- QList targets;
- if (!ncn->linkTargets().isEmpty()) {
- QMap::ConstIterator t = ncn->linkTargets().constBegin();
- while (t != ncn->linkTargets().constEnd()) {
- int count = 0;
- for (int i=0; i(collisions.at(i));
- if (n->findChildNode(t.key(), Node::DontCare)) {
- ++count;
- if (count > 1) {
- targets.append(t.key());
- break;
- }
- }
- }
- ++t;
- }
- }
- if (!targets.isEmpty()) {
- QList::ConstIterator t = targets.constBegin();
- while (t != targets.constEnd()) {
- writeStartTag(DT_p);
- writeGuidAttribute(Doc::canonicalTitle(*t));
- xmlWriter().writeAttribute("outputclass","h2");
- writeCharacters(protectEnc(*t));
- writeEndTag(); //
- writeStartTag(DT_ul);
- for (int i=0; i(collisions.at(i));
- Node* p = n->findChildNode(*t, Node::DontCare);
- if (p) {
- QString link = linkForNode(p,0);
- QString label;
- if (!n->qmlModuleName().isEmpty())
- label = n->qmlModuleName() + "::";
- label += n->name() + "::" + p->name();
- writeStartTag(DT_li);
- writeStartTag(DT_xref);
- xmlWriter().writeAttribute("href", link);
- writeCharacters(protectEnc(label));
- writeEndTag(); //
- writeEndTag(); //
- }
- }
- writeEndTag(); //
- ++t;
- }
- }
- leaveSection(); //
- writeEndTag(); //