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 <casper.vandonderen@nokia.com>
This commit is contained in:
parent
48d439833a
commit
a4cd6ef25d
@ -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)
|
void DitaXmlGenerator::debugPara(const QString& t)
|
||||||
{
|
{
|
||||||
writeStartTag(DT_p);
|
writeStartTag(DT_p);
|
||||||
@ -4218,7 +4241,7 @@ void DitaXmlGenerator::generateIndex(const QString& fileBase,
|
|||||||
const QString& url,
|
const QString& url,
|
||||||
const QString& title)
|
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)
|
void DitaXmlGenerator::generateStatus(const Node* node, CodeMarker* marker)
|
||||||
@ -4907,7 +4930,7 @@ void DitaXmlGenerator::writeFunctions(const Section& s,
|
|||||||
FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom();
|
FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom();
|
||||||
if (rfn && !rfn->isInternal()) {
|
if (rfn && !rfn->isInternal()) {
|
||||||
writeStartTag(DT_cxxFunctionReimplemented);
|
writeStartTag(DT_cxxFunctionReimplemented);
|
||||||
xmlWriter().writeAttribute("href",rfn->ditaXmlHref());
|
xmlWriter().writeAttribute("href",ditaXmlHref(rfn));
|
||||||
writeCharacters(marker->plainFullName(rfn));
|
writeCharacters(marker->plainFullName(rfn));
|
||||||
writeEndTag(); // </cxxFunctionReimplemented>
|
writeEndTag(); // </cxxFunctionReimplemented>
|
||||||
}
|
}
|
||||||
@ -5299,7 +5322,7 @@ void DitaXmlGenerator::writeProperties(const Section& s,
|
|||||||
if (pn->overriddenFrom() != 0) {
|
if (pn->overriddenFrom() != 0) {
|
||||||
PropertyNode* opn = (PropertyNode*)pn->overriddenFrom();
|
PropertyNode* opn = (PropertyNode*)pn->overriddenFrom();
|
||||||
writeStartTag(DT_cxxVariableReimplemented);
|
writeStartTag(DT_cxxVariableReimplemented);
|
||||||
xmlWriter().writeAttribute("href",opn->ditaXmlHref());
|
xmlWriter().writeAttribute("href",ditaXmlHref(opn));
|
||||||
writeCharacters(marker->plainFullName(opn));
|
writeCharacters(marker->plainFullName(opn));
|
||||||
writeEndTag(); // </cxxVariableReimplemented>
|
writeEndTag(); // </cxxVariableReimplemented>
|
||||||
}
|
}
|
||||||
@ -5461,7 +5484,7 @@ void DitaXmlGenerator::writeMacros(const Section& s,
|
|||||||
if (fn->reimplementedFrom() != 0) {
|
if (fn->reimplementedFrom() != 0) {
|
||||||
FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom();
|
FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom();
|
||||||
writeStartTag(DT_cxxDefineReimplemented);
|
writeStartTag(DT_cxxDefineReimplemented);
|
||||||
xmlWriter().writeAttribute("href",rfn->ditaXmlHref());
|
xmlWriter().writeAttribute("href",ditaXmlHref(rfn));
|
||||||
writeCharacters(marker->plainFullName(rfn));
|
writeCharacters(marker->plainFullName(rfn));
|
||||||
writeEndTag(); // </cxxDefineReimplemented>
|
writeEndTag(); // </cxxDefineReimplemented>
|
||||||
}
|
}
|
||||||
|
@ -503,6 +503,7 @@ private:
|
|||||||
void writeTopicrefs(NodeMultiMap* nmm, const QString& navtitle, Node* headingnode = 0);
|
void writeTopicrefs(NodeMultiMap* nmm, const QString& navtitle, Node* headingnode = 0);
|
||||||
bool isDuplicate(NodeMultiMap* nmm, const QString& key, Node* node);
|
bool isDuplicate(NodeMultiMap* nmm, const QString& key, Node* node);
|
||||||
void debugPara(const QString& t);
|
void debugPara(const QString& t);
|
||||||
|
QString ditaXmlHref(Node* n);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
|
@ -497,15 +497,15 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
|
|||||||
// The root namespace has no name - check for this before creating
|
// The root namespace has no name - check for this before creating
|
||||||
// an attribute containing the location of any documentation.
|
// an attribute containing the location of any documentation.
|
||||||
|
|
||||||
if (!node->fileBase().isEmpty())
|
if (!fileBase(node).isEmpty())
|
||||||
parentName = node->fileBase() + QLatin1Char('.') + currentGenerator()->fileExtension();
|
parentName = fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
|
||||||
else
|
else
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
else if (node->type() == Node::Fake) {
|
else if (node->type() == Node::Fake) {
|
||||||
if ((node->subType() == Node::QmlClass) ||
|
if ((node->subType() == Node::QmlClass) ||
|
||||||
(node->subType() == Node::QmlBasicType)) {
|
(node->subType() == Node::QmlBasicType)) {
|
||||||
QString fb = node->fileBase();
|
QString fb = fileBase(node);
|
||||||
if (fb.startsWith(Generator::outputPrefix(QLatin1String("QML"))))
|
if (fb.startsWith(Generator::outputPrefix(QLatin1String("QML"))))
|
||||||
return fb + QLatin1Char('.') + currentGenerator()->fileExtension();
|
return fb + QLatin1Char('.') + currentGenerator()->fileExtension();
|
||||||
else {
|
else {
|
||||||
@ -515,13 +515,14 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
|
|||||||
mq = mq.toLower() + QLatin1Char('-');
|
mq = mq.toLower() + QLatin1Char('-');
|
||||||
}
|
}
|
||||||
return fdl+ Generator::outputPrefix(QLatin1String("QML")) + mq +
|
return fdl+ Generator::outputPrefix(QLatin1String("QML")) + mq +
|
||||||
node->fileBase() + QLatin1Char('.') + currentGenerator()->fileExtension();
|
fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
parentName = node->fileBase() + QLatin1Char('.') + currentGenerator()->fileExtension();
|
parentName = fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (node->fileBase().isEmpty())
|
else if (fileBase(node).isEmpty())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
Node *parentNode = 0;
|
Node *parentNode = 0;
|
||||||
@ -534,8 +535,9 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
|
|||||||
parentNode = parentNode->parent();
|
parentNode = parentNode->parent();
|
||||||
parentName = fullDocumentLocation(parentNode);
|
parentName = fullDocumentLocation(parentNode);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
parentName = fullDocumentLocation(node->parent());
|
parentName = fullDocumentLocation(node->parent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (node->type()) {
|
switch (node->type()) {
|
||||||
@ -544,17 +546,13 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
|
|||||||
if (parentNode && !parentNode->name().isEmpty()) {
|
if (parentNode && !parentNode->name().isEmpty()) {
|
||||||
parentName.remove(QLatin1Char('.') + currentGenerator()->fileExtension());
|
parentName.remove(QLatin1Char('.') + currentGenerator()->fileExtension());
|
||||||
parentName += QLatin1Char('-')
|
parentName += QLatin1Char('-')
|
||||||
+ node->fileBase().toLower() + QLatin1Char('.') + currentGenerator()->fileExtension();
|
+ fileBase(node).toLower() + QLatin1Char('.') + currentGenerator()->fileExtension();
|
||||||
} else {
|
} else {
|
||||||
parentName = node->fileBase() + QLatin1Char('.') + currentGenerator()->fileExtension();
|
parentName = fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Node::Function:
|
case Node::Function:
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
Functions can be destructors, overloaded, or
|
|
||||||
have associated properties.
|
|
||||||
*/
|
|
||||||
const FunctionNode *functionNode =
|
const FunctionNode *functionNode =
|
||||||
static_cast<const FunctionNode *>(node);
|
static_cast<const FunctionNode *>(node);
|
||||||
|
|
||||||
@ -569,14 +567,13 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
|
|||||||
+ QLatin1Char('-') + QString::number(functionNode->overloadNumber());
|
+ QLatin1Char('-') + QString::number(functionNode->overloadNumber());
|
||||||
else
|
else
|
||||||
anchorRef = QLatin1Char('#') + functionNode->name();
|
anchorRef = QLatin1Char('#') + functionNode->name();
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Use node->name() instead of node->fileBase() as
|
|
||||||
the latter returns the name in lower-case. For
|
|
||||||
HTML anchors, we need to preserve the case.
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Use node->name() instead of fileBase(node) as
|
||||||
|
the latter returns the name in lower-case. For
|
||||||
|
HTML anchors, we need to preserve the case.
|
||||||
|
*/
|
||||||
case Node::Enum:
|
case Node::Enum:
|
||||||
anchorRef = QLatin1Char('#') + node->name() + "-enum";
|
anchorRef = QLatin1Char('#') + node->name() + "-enum";
|
||||||
break;
|
break;
|
||||||
@ -604,10 +601,10 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
|
|||||||
case Node::Fake:
|
case Node::Fake:
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Use node->fileBase() for fake nodes because they are represented
|
Use fileBase(node) for fake nodes because they are represented
|
||||||
by pages whose file names are lower-case.
|
by pages whose file names are lower-case.
|
||||||
*/
|
*/
|
||||||
parentName = node->fileBase();
|
parentName = fileBase(node);
|
||||||
parentName.replace(QLatin1Char('/'), QLatin1Char('-')).replace(QLatin1Char('.'), QLatin1Char('-'));
|
parentName.replace(QLatin1Char('/'), QLatin1Char('-')).replace(QLatin1Char('.'), QLatin1Char('-'));
|
||||||
parentName += QLatin1Char('.') + currentGenerator()->fileExtension();
|
parentName += QLatin1Char('.') + currentGenerator()->fileExtension();
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,10 @@ public:
|
|||||||
virtual void initializeGenerator(const Config &config);
|
virtual void initializeGenerator(const Config &config);
|
||||||
virtual void terminateGenerator();
|
virtual void terminateGenerator();
|
||||||
|
|
||||||
|
QString fullDocumentLocation(const Node *node, bool subdir = false);
|
||||||
|
|
||||||
static const QString& baseDir() { return baseDir_; }
|
static const QString& baseDir() { return baseDir_; }
|
||||||
static Generator *currentGenerator() { return currentGenerator_; }
|
static Generator *currentGenerator() { return currentGenerator_; }
|
||||||
static QString fullDocumentLocation(const Node *node, bool subdir = false);
|
|
||||||
static Generator *generatorForFormat(const QString& format);
|
static Generator *generatorForFormat(const QString& format);
|
||||||
static void initialize(const Config& config);
|
static void initialize(const Config& config);
|
||||||
static const QString& outputDir() { return outDir_; }
|
static const QString& outputDir() { return outDir_; }
|
||||||
|
@ -52,7 +52,10 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
HelpProjectWriter::HelpProjectWriter(const Config &config, const QString &defaultFileName)
|
HelpProjectWriter::HelpProjectWriter(const Config &config,
|
||||||
|
const QString &defaultFileName,
|
||||||
|
Generator* g)
|
||||||
|
: gen_(g)
|
||||||
{
|
{
|
||||||
// The output directory should already have been checked by the calling
|
// The output directory should already have been checked by the calling
|
||||||
// generator.
|
// generator.
|
||||||
@ -211,7 +214,7 @@ QStringList HelpProjectWriter::keywordDetails(const Node *node) const
|
|||||||
details << node->name();
|
details << node->name();
|
||||||
details << node->name();
|
details << node->name();
|
||||||
}
|
}
|
||||||
details << Generator::fullDocumentLocation(node,true);
|
details << gen_->fullDocumentLocation(node,true);
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,12 +274,12 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
|
|||||||
|
|
||||||
case Node::Class:
|
case Node::Class:
|
||||||
project.keywords.append(keywordDetails(node));
|
project.keywords.append(keywordDetails(node));
|
||||||
project.files.insert(Generator::fullDocumentLocation(node,true));
|
project.files.insert(gen_->fullDocumentLocation(node,true));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Node::Namespace:
|
case Node::Namespace:
|
||||||
project.keywords.append(keywordDetails(node));
|
project.keywords.append(keywordDetails(node));
|
||||||
project.files.insert(Generator::fullDocumentLocation(node,true));
|
project.files.insert(gen_->fullDocumentLocation(node,true));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Node::Enum:
|
case Node::Enum:
|
||||||
@ -296,7 +299,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
|
|||||||
details << item.name(); // "name"
|
details << item.name(); // "name"
|
||||||
details << item.name(); // "id"
|
details << item.name(); // "id"
|
||||||
}
|
}
|
||||||
details << Generator::fullDocumentLocation(node,true);
|
details << gen_->fullDocumentLocation(node,true);
|
||||||
project.keywords.append(details);
|
project.keywords.append(details);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,7 +331,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
|
|||||||
|
|
||||||
if (node->relates()) {
|
if (node->relates()) {
|
||||||
project.memberStatus[node->relates()].insert(node->status());
|
project.memberStatus[node->relates()].insert(node->status());
|
||||||
project.files.insert(Generator::fullDocumentLocation(node->relates(),true));
|
project.files.insert(gen_->fullDocumentLocation(node->relates(),true));
|
||||||
} else if (node->parent())
|
} else if (node->parent())
|
||||||
project.memberStatus[node->parent()].insert(node->status());
|
project.memberStatus[node->parent()].insert(node->status());
|
||||||
}
|
}
|
||||||
@ -342,7 +345,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
|
|||||||
// Use the location of any associated enum node in preference
|
// Use the location of any associated enum node in preference
|
||||||
// to that of the typedef.
|
// to that of the typedef.
|
||||||
if (enumNode)
|
if (enumNode)
|
||||||
typedefDetails[2] = Generator::fullDocumentLocation(enumNode,true);
|
typedefDetails[2] = gen_->fullDocumentLocation(enumNode,true);
|
||||||
|
|
||||||
project.keywords.append(typedefDetails);
|
project.keywords.append(typedefDetails);
|
||||||
}
|
}
|
||||||
@ -350,7 +353,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
|
|||||||
|
|
||||||
case Node::Variable:
|
case Node::Variable:
|
||||||
{
|
{
|
||||||
QString location = Generator::fullDocumentLocation(node,true);
|
QString location = gen_->fullDocumentLocation(node,true);
|
||||||
project.files.insert(location.left(location.lastIndexOf(QLatin1Char('#'))));
|
project.files.insert(location.left(location.lastIndexOf(QLatin1Char('#'))));
|
||||||
project.keywords.append(keywordDetails(node));
|
project.keywords.append(keywordDetails(node));
|
||||||
}
|
}
|
||||||
@ -370,35 +373,18 @@ bool HelpProjectWriter::generateSection(HelpProject &project,
|
|||||||
QStringList details;
|
QStringList details;
|
||||||
details << keyword->string()
|
details << keyword->string()
|
||||||
<< keyword->string()
|
<< keyword->string()
|
||||||
<< Generator::fullDocumentLocation(node,true) +
|
<< gen_->fullDocumentLocation(node,true) +
|
||||||
QLatin1Char('#') + Doc::canonicalTitle(keyword->string());
|
QLatin1Char('#') + Doc::canonicalTitle(keyword->string());
|
||||||
project.keywords.append(details);
|
project.keywords.append(details);
|
||||||
} else
|
} else
|
||||||
fakeNode->doc().location().warning(
|
fakeNode->doc().location().warning(
|
||||||
tr("Bad keyword in %1").arg(Generator::fullDocumentLocation(node,true))
|
tr("Bad keyword in %1").arg(gen_->fullDocumentLocation(node,true))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
project.keywords.append(keywordDetails(node));
|
project.keywords.append(keywordDetails(node));
|
||||||
}
|
}
|
||||||
/*
|
project.files.insert(gen_->fullDocumentLocation(node,true));
|
||||||
if (fakeNode->doc().hasTableOfContents()) {
|
|
||||||
foreach (const Atom *item, fakeNode->doc().tableOfContents()) {
|
|
||||||
QString title = Text::sectionHeading(item).toString();
|
|
||||||
if (!title.isEmpty()) {
|
|
||||||
QStringList details;
|
|
||||||
details << title
|
|
||||||
<< title
|
|
||||||
<< HtmlGenerator::fullDocumentLocation(node,true) +
|
|
||||||
QLatin1Char('#') + Doc::canonicalTitle(title);
|
|
||||||
project.keywords.append(details);
|
|
||||||
} else
|
|
||||||
fakeNode->doc().location().warning(
|
|
||||||
tr("Bad contents item in %1").arg(HtmlGenerator::fullDocumentLocation(node,true)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
project.files.insert(Generator::fullDocumentLocation(node,true));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -467,9 +453,9 @@ void HelpProjectWriter::generateSections(HelpProject &project,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpProjectWriter::generate(const Tree *tre)
|
void HelpProjectWriter::generate(const Tree *t)
|
||||||
{
|
{
|
||||||
this->tree = tre;
|
this->tree = t;
|
||||||
for (int i = 0; i < projects.size(); ++i)
|
for (int i = 0; i < projects.size(); ++i)
|
||||||
generateProject(projects[i]);
|
generateProject(projects[i]);
|
||||||
}
|
}
|
||||||
@ -477,7 +463,7 @@ void HelpProjectWriter::generate(const Tree *tre)
|
|||||||
void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer,
|
void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer,
|
||||||
const Node *node)
|
const Node *node)
|
||||||
{
|
{
|
||||||
QString href = Generator::fullDocumentLocation(node,true);
|
QString href = gen_->fullDocumentLocation(node,true);
|
||||||
QString objName = node->name();
|
QString objName = node->name();
|
||||||
|
|
||||||
switch (node->type()) {
|
switch (node->type()) {
|
||||||
@ -628,12 +614,12 @@ void HelpProjectWriter::generateProject(HelpProject &project)
|
|||||||
node = tree->findNode(QStringList("index.html"));
|
node = tree->findNode(QStringList("index.html"));
|
||||||
QString indexPath;
|
QString indexPath;
|
||||||
if (node)
|
if (node)
|
||||||
indexPath = Generator::fullDocumentLocation(node,true);
|
indexPath = gen_->fullDocumentLocation(node,true);
|
||||||
else
|
else
|
||||||
indexPath = "index.html";
|
indexPath = "index.html";
|
||||||
writer.writeAttribute("ref", indexPath);
|
writer.writeAttribute("ref", indexPath);
|
||||||
writer.writeAttribute("title", project.indexTitle);
|
writer.writeAttribute("title", project.indexTitle);
|
||||||
project.files.insert(Generator::fullDocumentLocation(rootNode));
|
project.files.insert(gen_->fullDocumentLocation(rootNode));
|
||||||
|
|
||||||
generateSections(project, writer, rootNode);
|
generateSections(project, writer, rootNode);
|
||||||
|
|
||||||
@ -671,7 +657,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
|
|||||||
|
|
||||||
const FakeNode *page = tree->findFakeNodeByTitle(atom->string());
|
const FakeNode *page = tree->findFakeNodeByTitle(atom->string());
|
||||||
writer.writeStartElement("section");
|
writer.writeStartElement("section");
|
||||||
QString indexPath = Generator::fullDocumentLocation(page,true);
|
QString indexPath = gen_->fullDocumentLocation(page,true);
|
||||||
writer.writeAttribute("ref", indexPath);
|
writer.writeAttribute("ref", indexPath);
|
||||||
writer.writeAttribute("title", atom->string());
|
writer.writeAttribute("title", atom->string());
|
||||||
project.files.insert(indexPath);
|
project.files.insert(indexPath);
|
||||||
@ -696,7 +682,7 @@ void HelpProjectWriter::generateProject(HelpProject &project)
|
|||||||
|
|
||||||
if (!name.isEmpty()) {
|
if (!name.isEmpty()) {
|
||||||
writer.writeStartElement("section");
|
writer.writeStartElement("section");
|
||||||
QString indexPath = Generator::fullDocumentLocation(tree->findFakeNodeByTitle(subproject.indexTitle),true);
|
QString indexPath = gen_->fullDocumentLocation(tree->findFakeNodeByTitle(subproject.indexTitle),true);
|
||||||
writer.writeAttribute("ref", indexPath);
|
writer.writeAttribute("ref", indexPath);
|
||||||
writer.writeAttribute("title", subproject.title);
|
writer.writeAttribute("title", subproject.title);
|
||||||
project.files.insert(indexPath);
|
project.files.insert(indexPath);
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class Tree;
|
class Tree;
|
||||||
|
class Generator;
|
||||||
typedef QPair<QString, const Node*> QStringNodePair;
|
typedef QPair<QString, const Node*> QStringNodePair;
|
||||||
|
|
||||||
struct SubProject
|
struct SubProject
|
||||||
@ -85,10 +86,12 @@ struct HelpProject
|
|||||||
class HelpProjectWriter
|
class HelpProjectWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HelpProjectWriter(const Config &config, const QString &defaultFileName);
|
HelpProjectWriter(const Config &config,
|
||||||
|
const QString &defaultFileName,
|
||||||
|
Generator* g);
|
||||||
void addExtraFile(const QString &file);
|
void addExtraFile(const QString &file);
|
||||||
void addExtraFiles(const QSet<QString> &files);
|
void addExtraFiles(const QSet<QString> &files);
|
||||||
void generate(const Tree *tre);
|
void generate(const Tree *t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void generateProject(HelpProject &project);
|
void generateProject(HelpProject &project);
|
||||||
@ -101,6 +104,7 @@ private:
|
|||||||
void readSelectors(SubProject &subproject, const QStringList &selectors);
|
void readSelectors(SubProject &subproject, const QStringList &selectors);
|
||||||
|
|
||||||
const Tree *tree;
|
const Tree *tree;
|
||||||
|
Generator* gen_;
|
||||||
|
|
||||||
QString outputDir;
|
QString outputDir;
|
||||||
QList<HelpProject> projects;
|
QList<HelpProject> projects;
|
||||||
|
@ -210,8 +210,8 @@ void HtmlGenerator::initializeGenerator(const Config &config)
|
|||||||
codeIndent = config.getInt(CONFIG_CODEINDENT);
|
codeIndent = config.getInt(CONFIG_CODEINDENT);
|
||||||
|
|
||||||
helpProjectWriter = new HelpProjectWriter(config,
|
helpProjectWriter = new HelpProjectWriter(config,
|
||||||
project.toLower() +
|
project.toLower() + ".qhp",
|
||||||
".qhp");
|
this);
|
||||||
|
|
||||||
// Documentation template handling
|
// Documentation template handling
|
||||||
headerScripts = config.getString(HtmlGenerator::format() + Config::dot +
|
headerScripts = config.getString(HtmlGenerator::format() + Config::dot +
|
||||||
@ -3838,7 +3838,7 @@ void HtmlGenerator::generateIndex(const QString &fileBase,
|
|||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &title)
|
const QString &title)
|
||||||
{
|
{
|
||||||
tree_->generateIndex(outputDir() + QLatin1Char('/') + fileBase + ".index", url, title);
|
tree_->generateIndex(outputDir() + QLatin1Char('/') + fileBase + ".index", url, title, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HtmlGenerator::generateStatus(const Node *node, CodeMarker *marker)
|
void HtmlGenerator::generateStatus(const Node *node, CodeMarker *marker)
|
||||||
@ -4318,7 +4318,7 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element)
|
|||||||
}
|
}
|
||||||
writer.writeStartElement(element);
|
writer.writeStartElement(element);
|
||||||
writer.writeAttribute("name", en->title());
|
writer.writeAttribute("name", en->title());
|
||||||
QString docUrl = manifestDir + en->fileBase() + ".html";
|
QString docUrl = manifestDir + fileBase(en) + ".html";
|
||||||
writer.writeAttribute("docUrl", docUrl);
|
writer.writeAttribute("docUrl", docUrl);
|
||||||
QStringList proFiles;
|
QStringList proFiles;
|
||||||
foreach (const Node* child, en->childNodes()) {
|
foreach (const Node* child, en->childNodes()) {
|
||||||
|
@ -505,6 +505,7 @@ Node::ThreadSafeness Node::inheritedThreadSafeness() const
|
|||||||
return safeness_;
|
return safeness_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*!
|
/*!
|
||||||
Returns the sanitized file name without the path.
|
Returns the sanitized file name without the path.
|
||||||
If the the file is an html file, the html suffix
|
If the the file is an html file, the html suffix
|
||||||
@ -520,7 +521,7 @@ QString Node::fileBase() const
|
|||||||
base.replace(QLatin1Char(' '), QLatin1Char('-'));
|
base.replace(QLatin1Char(' '), QLatin1Char('-'));
|
||||||
return base.toLower();
|
return base.toLower();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*!
|
/*!
|
||||||
Returns this node's Universally Unique IDentifier as a
|
Returns this node's Universally Unique IDentifier as a
|
||||||
QString. Creates the UUID first, if it has not been created.
|
QString. Creates the UUID first, if it has not been created.
|
||||||
@ -532,29 +533,6 @@ QString Node::guid() const
|
|||||||
return uuid_;
|
return uuid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
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 Node::ditaXmlHref()
|
|
||||||
{
|
|
||||||
QString href;
|
|
||||||
if ((type() == Function) ||
|
|
||||||
(type() == Property) ||
|
|
||||||
(type() == Variable)) {
|
|
||||||
href = parent()->fileBase();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
href = fileBase();
|
|
||||||
}
|
|
||||||
if (!href.endsWith(".xml") && !href.endsWith(".dita"))
|
|
||||||
href += ".dita";
|
|
||||||
return href + QLatin1Char('#') + guid();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
If this node is a QML class node, return a pointer to it.
|
If this node is a QML class node, return a pointer to it.
|
||||||
If it is a child of a QML class node, return a pointer to
|
If it is a child of a QML class node, return a pointer to
|
||||||
@ -2086,6 +2064,7 @@ QmlClassNode* QmlClassNode::lookupQmlTypeNode(const QString& qmid, const QString
|
|||||||
return qmlModuleMemberMap_.value(qmid + "::" + name);
|
return qmlModuleMemberMap_.value(qmid + "::" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*!
|
/*!
|
||||||
The base file name for this kind of node has "qml_"
|
The base file name for this kind of node has "qml_"
|
||||||
prepended to it.
|
prepended to it.
|
||||||
@ -2096,7 +2075,7 @@ QString QmlClassNode::fileBase() const
|
|||||||
{
|
{
|
||||||
return Node::fileBase();
|
return Node::fileBase();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*!
|
/*!
|
||||||
Record the fact that QML class \a base is inherited by
|
Record the fact that QML class \a base is inherited by
|
||||||
QML class \a sub.
|
QML class \a sub.
|
||||||
|
@ -227,9 +227,8 @@ public:
|
|||||||
|
|
||||||
void clearRelated() { relatesTo_ = 0; }
|
void clearRelated() { relatesTo_ = 0; }
|
||||||
|
|
||||||
virtual QString fileBase() const;
|
//virtual QString fileBase() const;
|
||||||
QString guid() const;
|
QString guid() const;
|
||||||
QString ditaXmlHref();
|
|
||||||
QString extractClassName(const QString &string) const;
|
QString extractClassName(const QString &string) const;
|
||||||
virtual QString qmlTypeName() const { return name_; }
|
virtual QString qmlTypeName() const { return name_; }
|
||||||
virtual QString qmlModuleName() const { return qmlModuleName_; }
|
virtual QString qmlModuleName() const { return qmlModuleName_; }
|
||||||
@ -529,7 +528,7 @@ public:
|
|||||||
virtual bool isQmlNode() const { return true; }
|
virtual bool isQmlNode() const { return true; }
|
||||||
virtual bool isQtQuickNode() const { return (qmlModuleName() == QLatin1String("QtQuick")); }
|
virtual bool isQtQuickNode() const { return (qmlModuleName() == QLatin1String("QtQuick")); }
|
||||||
virtual ClassNode* classNode() { return cnode_; }
|
virtual ClassNode* classNode() { return cnode_; }
|
||||||
virtual QString fileBase() const;
|
//virtual QString fileBase() const;
|
||||||
virtual void setCurrentChild();
|
virtual void setCurrentChild();
|
||||||
virtual void clearCurrentChild();
|
virtual void clearCurrentChild();
|
||||||
virtual const ImportList* importList() const { return &importList_; }
|
virtual const ImportList* importList() const { return &importList_; }
|
||||||
|
@ -1493,7 +1493,7 @@ bool Tree::generateIndexSection(QXmlStreamWriter& writer,
|
|||||||
QString href = node->outputSubdirectory();
|
QString href = node->outputSubdirectory();
|
||||||
if (!href.isEmpty())
|
if (!href.isEmpty())
|
||||||
href.append(QLatin1Char('/'));
|
href.append(QLatin1Char('/'));
|
||||||
href.append(Generator::fullDocumentLocation(node));
|
href.append(gen_->fullDocumentLocation(node));
|
||||||
writer.writeAttribute("href", href);
|
writer.writeAttribute("href", href);
|
||||||
if ((node->type() != Node::Fake) && (!node->isQmlNode()))
|
if ((node->type() != Node::Fake) && (!node->isQmlNode()))
|
||||||
writer.writeAttribute("location", node->location().fileName());
|
writer.writeAttribute("location", node->location().fileName());
|
||||||
@ -1928,12 +1928,14 @@ void Tree::generateIndexSections(QXmlStreamWriter& writer,
|
|||||||
void Tree::generateIndex(const QString& fileName,
|
void Tree::generateIndex(const QString& fileName,
|
||||||
const QString& url,
|
const QString& url,
|
||||||
const QString& title,
|
const QString& title,
|
||||||
|
Generator* g,
|
||||||
bool generateInternalNodes)
|
bool generateInternalNodes)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QFile::WriteOnly | QFile::Text))
|
if (!file.open(QFile::WriteOnly | QFile::Text))
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
gen_ = g;
|
||||||
QXmlStreamWriter writer(&file);
|
QXmlStreamWriter writer(&file);
|
||||||
writer.setAutoFormatting(true);
|
writer.setAutoFormatting(true);
|
||||||
writer.writeStartDocument();
|
writer.writeStartDocument();
|
||||||
@ -2006,7 +2008,7 @@ void Tree::generateTagFileCompounds(QXmlStreamWriter& writer, const InnerNode* i
|
|||||||
|
|
||||||
if (node->type() == Node::Class) {
|
if (node->type() == Node::Class) {
|
||||||
writer.writeTextElement("name", node->fullDocumentName());
|
writer.writeTextElement("name", node->fullDocumentName());
|
||||||
writer.writeTextElement("filename", Generator::fullDocumentLocation(node,true));
|
writer.writeTextElement("filename", gen_->fullDocumentLocation(node,true));
|
||||||
|
|
||||||
// Classes contain information about their base classes.
|
// Classes contain information about their base classes.
|
||||||
const ClassNode* classNode = static_cast<const ClassNode*>(node);
|
const ClassNode* classNode = static_cast<const ClassNode*>(node);
|
||||||
@ -2024,7 +2026,7 @@ void Tree::generateTagFileCompounds(QXmlStreamWriter& writer, const InnerNode* i
|
|||||||
generateTagFileCompounds(writer, static_cast<const InnerNode*>(node));
|
generateTagFileCompounds(writer, static_cast<const InnerNode*>(node));
|
||||||
} else {
|
} else {
|
||||||
writer.writeTextElement("name", node->fullDocumentName());
|
writer.writeTextElement("name", node->fullDocumentName());
|
||||||
writer.writeTextElement("filename", Generator::fullDocumentLocation(node,true));
|
writer.writeTextElement("filename", gen_->fullDocumentLocation(node,true));
|
||||||
|
|
||||||
// Recurse to write all members.
|
// Recurse to write all members.
|
||||||
generateTagFileMembers(writer, static_cast<const InnerNode*>(node));
|
generateTagFileMembers(writer, static_cast<const InnerNode*>(node));
|
||||||
@ -2143,7 +2145,7 @@ void Tree::generateTagFileMembers(QXmlStreamWriter& writer, const InnerNode* inn
|
|||||||
"virtual " + functionNode->returnType());
|
"virtual " + functionNode->returnType());
|
||||||
|
|
||||||
writer.writeTextElement("name", objName);
|
writer.writeTextElement("name", objName);
|
||||||
QStringList pieces = Generator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
|
QStringList pieces = gen_->fullDocumentLocation(node,true).split(QLatin1Char('#'));
|
||||||
writer.writeTextElement("anchorfile", pieces[0]);
|
writer.writeTextElement("anchorfile", pieces[0]);
|
||||||
writer.writeTextElement("anchor", pieces[1]);
|
writer.writeTextElement("anchor", pieces[1]);
|
||||||
|
|
||||||
@ -2182,7 +2184,7 @@ void Tree::generateTagFileMembers(QXmlStreamWriter& writer, const InnerNode* inn
|
|||||||
const PropertyNode* propertyNode = static_cast<const PropertyNode*>(node);
|
const PropertyNode* propertyNode = static_cast<const PropertyNode*>(node);
|
||||||
writer.writeAttribute("type", propertyNode->dataType());
|
writer.writeAttribute("type", propertyNode->dataType());
|
||||||
writer.writeTextElement("name", objName);
|
writer.writeTextElement("name", objName);
|
||||||
QStringList pieces = Generator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
|
QStringList pieces = gen_->fullDocumentLocation(node,true).split(QLatin1Char('#'));
|
||||||
writer.writeTextElement("anchorfile", pieces[0]);
|
writer.writeTextElement("anchorfile", pieces[0]);
|
||||||
writer.writeTextElement("anchor", pieces[1]);
|
writer.writeTextElement("anchor", pieces[1]);
|
||||||
writer.writeTextElement("arglist", "");
|
writer.writeTextElement("arglist", "");
|
||||||
@ -2194,7 +2196,7 @@ void Tree::generateTagFileMembers(QXmlStreamWriter& writer, const InnerNode* inn
|
|||||||
{
|
{
|
||||||
const EnumNode* enumNode = static_cast<const EnumNode*>(node);
|
const EnumNode* enumNode = static_cast<const EnumNode*>(node);
|
||||||
writer.writeTextElement("name", objName);
|
writer.writeTextElement("name", objName);
|
||||||
QStringList pieces = Generator::fullDocumentLocation(node).split(QLatin1Char('#'));
|
QStringList pieces = gen_->fullDocumentLocation(node).split(QLatin1Char('#'));
|
||||||
writer.writeTextElement("anchor", pieces[1]);
|
writer.writeTextElement("anchor", pieces[1]);
|
||||||
writer.writeTextElement("arglist", "");
|
writer.writeTextElement("arglist", "");
|
||||||
writer.writeEndElement(); // member
|
writer.writeEndElement(); // member
|
||||||
@ -2218,7 +2220,7 @@ void Tree::generateTagFileMembers(QXmlStreamWriter& writer, const InnerNode* inn
|
|||||||
else
|
else
|
||||||
writer.writeAttribute("type", "");
|
writer.writeAttribute("type", "");
|
||||||
writer.writeTextElement("name", objName);
|
writer.writeTextElement("name", objName);
|
||||||
QStringList pieces = Generator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
|
QStringList pieces = gen_->fullDocumentLocation(node,true).split(QLatin1Char('#'));
|
||||||
writer.writeTextElement("anchorfile", pieces[0]);
|
writer.writeTextElement("anchorfile", pieces[0]);
|
||||||
writer.writeTextElement("anchor", pieces[1]);
|
writer.writeTextElement("anchor", pieces[1]);
|
||||||
writer.writeTextElement("arglist", "");
|
writer.writeTextElement("arglist", "");
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class Generator;
|
||||||
class QStringList;
|
class QStringList;
|
||||||
class TreePrivate;
|
class TreePrivate;
|
||||||
|
|
||||||
@ -148,6 +149,7 @@ public:
|
|||||||
void generateIndex(const QString &fileName,
|
void generateIndex(const QString &fileName,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
|
Generator* g,
|
||||||
bool generateInternalNodes = false);
|
bool generateInternalNodes = false);
|
||||||
void generateTagFileCompounds(QXmlStreamWriter &writer,
|
void generateTagFileCompounds(QXmlStreamWriter &writer,
|
||||||
const InnerNode *inner);
|
const InnerNode *inner);
|
||||||
@ -155,7 +157,6 @@ public:
|
|||||||
const InnerNode *inner);
|
const InnerNode *inner);
|
||||||
void generateTagFile(const QString &fileName);
|
void generateTagFile(const QString &fileName);
|
||||||
void addExternalLink(const QString &url, const Node *relative);
|
void addExternalLink(const QString &url, const Node *relative);
|
||||||
QString fullDocumentLocation(const Node *node) const;
|
|
||||||
void resolveQmlInheritance();
|
void resolveQmlInheritance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -173,6 +174,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
NamespaceNode roo;
|
NamespaceNode roo;
|
||||||
QString vers;
|
QString vers;
|
||||||
|
Generator* gen_;
|
||||||
TreePrivate *priv;
|
TreePrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user