qdoc: Insert targets for function and enum nodes read from the index
QDoc wrote \target and \keyword information into the index file properly, but did not read them back in. This was because the code for handling enum and function elements read their own child elements (without handling targets), and marked the remaining children to be skipped. This commit fixes the issue by refactoring the code for inserting targets into a new function and calling it from relevant places. Change-Id: I85d7b26ce54620daec35b19e447d1a065515b863 Task-number: QTBUG-48687 Reviewed-by: Martin Smith <martin.smith@digia.com>
This commit is contained in:
parent
798128856c
commit
ee634611d4
@ -463,10 +463,15 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
|
||||
location = Location(parent->name().toLower() + ".html");
|
||||
|
||||
while (reader.readNextStartElement()) {
|
||||
QXmlStreamAttributes childAttributes = reader.attributes();
|
||||
if (reader.name() == QLatin1String("value")) {
|
||||
QXmlStreamAttributes childAttributes = reader.attributes();
|
||||
|
||||
EnumItem item(childAttributes.value(QLatin1String("name")).toString(), childAttributes.value(QLatin1String("value")).toString());
|
||||
enumNode->addItem(item);
|
||||
} else if (reader.name() == QLatin1String("keyword")) {
|
||||
insertTarget(TargetRec::Keyword, childAttributes, enumNode);
|
||||
} else if (reader.name() == QLatin1String("target")) {
|
||||
insertTarget(TargetRec::Target, childAttributes, enumNode);
|
||||
}
|
||||
reader.skipCurrentElement();
|
||||
}
|
||||
@ -552,8 +557,8 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
|
||||
*/
|
||||
|
||||
while (reader.readNextStartElement()) {
|
||||
QXmlStreamAttributes childAttributes = reader.attributes();
|
||||
if (reader.name() == QLatin1String("parameter")) {
|
||||
QXmlStreamAttributes childAttributes = reader.attributes();
|
||||
// Do not use the default value for the parameter; it is not
|
||||
// required, and has been known to cause problems.
|
||||
Parameter parameter(childAttributes.value(QLatin1String("left")).toString(),
|
||||
@ -561,6 +566,10 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
|
||||
childAttributes.value(QLatin1String("name")).toString(),
|
||||
QString()); // childAttributes.value(QLatin1String("default"))
|
||||
functionNode->addParameter(parameter);
|
||||
} else if (reader.name() == QLatin1String("keyword")) {
|
||||
insertTarget(TargetRec::Keyword, childAttributes, functionNode);
|
||||
} else if (reader.name() == QLatin1String("target")) {
|
||||
insertTarget(TargetRec::Target, childAttributes, functionNode);
|
||||
}
|
||||
reader.skipCurrentElement();
|
||||
}
|
||||
@ -581,18 +590,15 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
|
||||
location = Location(parent->name().toLower() + ".html");
|
||||
}
|
||||
else if (elementName == QLatin1String("keyword")) {
|
||||
QString title = attributes.value(QLatin1String("title")).toString();
|
||||
qdb_->insertTarget(name, title, TargetRec::Keyword, current, 1);
|
||||
insertTarget(TargetRec::Keyword, attributes, current);
|
||||
goto done;
|
||||
}
|
||||
else if (elementName == QLatin1String("target")) {
|
||||
QString title = attributes.value(QLatin1String("title")).toString();
|
||||
qdb_->insertTarget(name, title, TargetRec::Target, current, 2);
|
||||
insertTarget(TargetRec::Target, attributes, current);
|
||||
goto done;
|
||||
}
|
||||
else if (elementName == QLatin1String("contents")) {
|
||||
QString title = attributes.value(QLatin1String("title")).toString();
|
||||
qdb_->insertTarget(name, title, TargetRec::Contents, current, 3);
|
||||
insertTarget(TargetRec::Contents, attributes, current);
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
@ -702,6 +708,30 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader& reader,
|
||||
}
|
||||
}
|
||||
|
||||
void QDocIndexFiles::insertTarget(TargetRec::TargetType type,
|
||||
const QXmlStreamAttributes &attributes,
|
||||
Node *node)
|
||||
{
|
||||
int priority;
|
||||
switch (type) {
|
||||
case TargetRec::Keyword:
|
||||
priority = 1;
|
||||
break;
|
||||
case TargetRec::Target:
|
||||
priority = 2;
|
||||
break;
|
||||
case TargetRec::Contents:
|
||||
priority = 3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
QString name = attributes.value(QLatin1String("name")).toString();
|
||||
QString title = attributes.value(QLatin1String("title")).toString();
|
||||
qdb_->insertTarget(name, title, type, node, priority);
|
||||
}
|
||||
|
||||
/*!
|
||||
This function tries to resolve class inheritance immediately
|
||||
after the index file is read. It is not always possible to
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define QDOCINDEXFILES_H
|
||||
|
||||
#include "node.h"
|
||||
#include "tree.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -43,6 +44,7 @@ class Generator;
|
||||
class QStringList;
|
||||
class QDocDatabase;
|
||||
class QXmlStreamWriter;
|
||||
class QXmlStreamAttributes;
|
||||
|
||||
class QDocIndexFiles
|
||||
{
|
||||
@ -64,6 +66,7 @@ class QDocIndexFiles
|
||||
|
||||
void readIndexFile(const QString& path);
|
||||
void readIndexSection(QXmlStreamReader &reader, Node* current, const QString& indexUrl);
|
||||
void insertTarget(TargetRec::TargetType type, const QXmlStreamAttributes &attributes, Node *node);
|
||||
void resolveIndex();
|
||||
void resolveRelates();
|
||||
bool generateIndexSection(QXmlStreamWriter& writer, Node* node, bool generateInternalNodes = false);
|
||||
|
Loading…
Reference in New Issue
Block a user