qdoc: Better use of versions of QML modules

Now qdoc doesn't use the QML module version number
when it isn't necessary. Page names are cleaner
without appending the version number to the QML
module name.

Also reduces the number of duplicate page warnings,
but this will be updated further next time.

Task-number: QTBUG-33257
Change-Id: Iba587164532bdc819523e0666f7561ac2dbd5e52
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
This commit is contained in:
Martin Smith 2013-09-09 13:08:55 +02:00 committed by The Qt Project
parent cdc26c9316
commit 3260dfc0be
3 changed files with 44 additions and 36 deletions

View File

@ -314,34 +314,12 @@ QString Generator::fileBase(const Node *node) const
return fileBase(ncn->currentChild()); return fileBase(ncn->currentChild());
} }
if (node->hasBaseName()) { if (node->hasBaseName())
//qDebug() << "RETURNING:" << node->baseName();
return node->baseName(); return node->baseName();
}
QString base; QString base;
const Node *p = node;
forever {
const Node *pp = p->parent();
base.prepend(p->name());
if (!p->qmlModuleIdentifier().isEmpty())
base.prepend(p->qmlModuleIdentifier()+QChar('-'));
/*
To avoid file name conflicts in the html directory,
we prepend a prefix (by default, "qml-") to the file name of QML
element doc files.
*/
if ((p->subType() == Node::QmlClass) ||
(p->subType() == Node::QmlBasicType)) {
base.prepend(outputPrefix(QLatin1String("QML")));
}
if (!pp || pp->name().isEmpty() || pp->type() == Node::Document)
break;
base.prepend(QLatin1Char('-'));
p = pp;
}
if (node->type() == Node::Document) { if (node->type() == Node::Document) {
base = node->name();
if (node->subType() == Node::Collision) { if (node->subType() == Node::Collision) {
const NameCollisionNode* ncn = static_cast<const NameCollisionNode*>(node); const NameCollisionNode* ncn = static_cast<const NameCollisionNode*>(node);
if (ncn->currentChild()) if (ncn->currentChild())
@ -352,17 +330,42 @@ QString Generator::fileBase(const Node *node) const
if (base.endsWith(".html")) if (base.endsWith(".html"))
base.truncate(base.length() - 5); base.truncate(base.length() - 5);
if (node->subType() == Node::QmlModule) { if (node->isQmlNode()) {
base.prepend("qmlmodule-"); if (!node->qmlModuleName().isEmpty()) {
base.prepend(node->qmlModuleName() + QLatin1Char('-'));
/*
To avoid file name conflicts in the html directory,
we prepend a prefix (by default, "qml-") to the file name of QML
element doc files.
*/
if ((node->subType() == Node::QmlClass) || (node->subType() == Node::QmlBasicType)) {
base.prepend(outputPrefix(QLatin1String("QML")));
}
}
} }
if (node->subType() == Node::Module) { else if (node->subType() == Node::QmlModule) {
base.append("-qmlmodule");
}
else if (node->subType() == Node::Module) {
base.append("-module"); base.append("-module");
} }
if (node->isExample() || node->isExampleFile()) if (node->isExample() || node->isExampleFile()) {
base.prepend(project.toLower() + QLatin1Char('-')); base.prepend(project.toLower() + QLatin1Char('-'));
if (node->isExample()) }
if (node->isExample()) {
base.append(QLatin1String("-example")); base.append(QLatin1String("-example"));
}
}
else {
const Node *p = node;
forever {
const Node *pp = p->parent();
base.prepend(p->name());
if (!pp || pp->name().isEmpty() || pp->type() == Node::Document)
break;
base.prepend(QLatin1Char('-'));
p = pp;
}
} }
// the code below is effectively equivalent to: // the code below is effectively equivalent to:

View File

@ -190,17 +190,19 @@ DocNode* QDocDatabase::findQmlModule(const QString& name)
QStringList dotSplit; QStringList dotSplit;
QStringList blankSplit = name.split(QLatin1Char(' ')); QStringList blankSplit = name.split(QLatin1Char(' '));
QString qmid = blankSplit[0]; QString qmid = blankSplit[0];
QString qmlModuleName = qmid;
if (blankSplit.size() > 1) { if (blankSplit.size() > 1) {
dotSplit = blankSplit[1].split(QLatin1Char('.')); dotSplit = blankSplit[1].split(QLatin1Char('.'));
qmid += dotSplit[0]; qmid += dotSplit[0];
} }
DocNode* dn = 0; DocNode* dn = 0;
if (qmlModules_.contains(qmid)) if (qmlModules_.contains(qmlModuleName))
return qmlModules_.value(qmid); return qmlModules_.value(qmlModuleName);
dn = new DocNode(tree_->root(), name, Node::QmlModule, Node::OverviewPage); dn = new DocNode(tree_->root(), qmlModuleName, Node::QmlModule, Node::OverviewPage);
dn->markNotSeen(); dn->markNotSeen();
dn->setQmlModuleInfo(name); dn->setQmlModuleInfo(name);
qmlModules_.insert(qmid,dn); qmlModules_.insert(qmlModuleName,dn);
masterMap_.insert(qmlModuleName,dn);
masterMap_.insert(qmid,dn); masterMap_.insert(qmid,dn);
masterMap_.insert(dn->name(),dn); masterMap_.insert(dn->name(),dn);
return dn; return dn;
@ -923,8 +925,10 @@ const DocNode* QDocDatabase::findDocNodeByTitle(const QString& title, const Node
if (j != docNodesByTitle_.constEnd() && j.key() == i.key()) { if (j != docNodesByTitle_.constEnd() && j.key() == i.key()) {
QList<Location> internalLocations; QList<Location> internalLocations;
while (j != docNodesByTitle_.constEnd()) { while (j != docNodesByTitle_.constEnd()) {
if (j.key() == i.key() && j.value()->url().isEmpty()) if (j.key() == i.key() && j.value()->url().isEmpty()) {
internalLocations.append(j.value()->location()); internalLocations.append(j.value()->location());
break; // Just report one duplicate for now.
}
++j; ++j;
} }
if (internalLocations.size() > 0) { if (internalLocations.size() > 0) {

View File

@ -195,7 +195,8 @@ void QDocIndexFiles::readIndexSection(const QDomElement& element,
qcn->setTitle(element.attribute("title")); qcn->setTitle(element.attribute("title"));
QString qmlModuleName = element.attribute("qml-module-name"); QString qmlModuleName = element.attribute("qml-module-name");
QString qmlModuleVersion = element.attribute("qml-module-version"); QString qmlModuleVersion = element.attribute("qml-module-version");
qdb_->addToQmlModule(qmlModuleName + " " + qmlModuleVersion, qcn); if (!qmlModuleName.isEmpty())
qdb_->addToQmlModule(qmlModuleName + " " + qmlModuleVersion, qcn);
QString qmlFullBaseName = element.attribute("qml-base-type"); QString qmlFullBaseName = element.attribute("qml-base-type");
if (!qmlFullBaseName.isEmpty()) if (!qmlFullBaseName.isEmpty())
qcn->setQmlBaseName(qmlFullBaseName); qcn->setQmlBaseName(qmlFullBaseName);