Generator::generateTree(tree);
generateCollisionPages();
+
+ QString fileBase = project.toLower().simplified().replace(" ", "-");
+ generateIndex(fileBase, projectUrl, projectDescription);
+
writeDitaMap(tree);
}
/*!
Returns "dita" for this subclass of class Generator.
*/
-QString DitaXmlGenerator::fileExtension(const Node * /* node */) const
+QString DitaXmlGenerator::fileExtension() const
{
return "dita";
}
}
/*!
- Returns true if \a format is "XML" or "HTML" .
+ Returns true if \a format is "DITAXML" or "HTML" .
*/
bool DitaXmlGenerator::canHandleFormat(const QString& format)
{
CodeMarker* marker);
virtual void generateClassLikeNode(InnerNode* inner, CodeMarker* marker);
virtual void generateFakeNode(FakeNode* fake, CodeMarker* marker);
- virtual QString fileExtension(const Node* node) const;
+ virtual QString fileExtension() const;
virtual QString guidForNode(const Node* node);
virtual QString linkForNode(const Node* node, const Node* relative);
virtual QString refForAtom(Atom* atom, const Node* node);
QT_BEGIN_NAMESPACE
QString Generator::baseDir_;
+Generator* Generator::currentGenerator_;
QStringList Generator::exampleDirs;
QStringList Generator::exampleImgExts;
QMap<QString, QMap<QString, QString> > Generator::fmtLeftMaps;
QString name = fileBase(node);
name += QLatin1Char('.');
- name += fileExtension(node);
+ name += fileExtension();
return name;
}
return fmtRightMaps[format()];
}
+/*!
+ Returns the full document location.
+ */
+QString Generator::fullDocumentLocation(const Node *node, bool subdir)
+{
+ if (!node)
+ return "";
+ if (!node->url().isEmpty())
+ return node->url();
+
+ QString parentName;
+ QString anchorRef;
+ QString fdl = "";
+
+ /*
+ If the output is being sent to subdirectories of the
+ output directory, and if the subdir parameter is set,
+ prepend the subdirectory name + '/' to the result.
+ */
+ if (subdir) {
+ fdl = node->outputSubdirectory();
+ if (!fdl.isEmpty())
+ fdl.append(QLatin1Char('/'));
+ }
+ if (node->type() == Node::Namespace) {
+
+ // The root namespace has no name - check for this before creating
+ // an attribute containing the location of any documentation.
+
+ if (!node->fileBase().isEmpty())
+ parentName = node->fileBase() + "." + currentGenerator()->fileExtension();
+ else
+ return "";
+ }
+ else if (node->type() == Node::Fake) {
+ if ((node->subType() == Node::QmlClass) ||
+ (node->subType() == Node::QmlBasicType)) {
+ QString fb = node->fileBase();
+ if (fb.startsWith(Generator::outputPrefix(QLatin1String("QML"))))
+ return fb + "." + currentGenerator()->fileExtension();
+ else {
+ QString mq = "";
+ if (!node->qmlModuleName().isEmpty()) {
+ mq = node->qmlModuleIdentifier().replace(QChar('.'),QChar('-'));
+ mq = mq.toLower() + "-";
+ }
+ return fdl+ Generator::outputPrefix(QLatin1String("QML")) + mq +
+ node->fileBase() + "." + currentGenerator()->fileExtension();
+ }
+ }
+ else
+ parentName = node->fileBase() + "." + currentGenerator()->fileExtension();
+ }
+ else if (node->fileBase().isEmpty())
+ return "";
+
+ Node *parentNode = 0;
+
+ if ((parentNode = node->relates())) {
+ parentName = fullDocumentLocation(node->relates());
+ }
+ else if ((parentNode = node->parent())) {
+ if (parentNode->subType() == Node::QmlPropertyGroup) {
+ parentNode = parentNode->parent();
+ parentName = fullDocumentLocation(parentNode);
+ }
+ else
+ parentName = fullDocumentLocation(node->parent());
+ }
+
+ switch (node->type()) {
+ case Node::Class:
+ case Node::Namespace:
+ if (parentNode && !parentNode->name().isEmpty()) {
+ parentName.remove("." + currentGenerator()->fileExtension());
+ parentName += QLatin1Char('-')
+ + node->fileBase().toLower() + "." + currentGenerator()->fileExtension();
+ } else {
+ parentName = node->fileBase() + "." + currentGenerator()->fileExtension();
+ }
+ break;
+ case Node::Function:
+ {
+ /*
+ Functions can be destructors, overloaded, or
+ have associated properties.
+ */
+ const FunctionNode *functionNode =
+ static_cast<const FunctionNode *>(node);
+
+ if (functionNode->metaness() == FunctionNode::Dtor)
+ anchorRef = "#dtor." + functionNode->name().mid(1);
+
+ else if (functionNode->associatedProperty())
+ return fullDocumentLocation(functionNode->associatedProperty());
+
+ else if (functionNode->overloadNumber() > 1)
+ anchorRef = QLatin1Char('#') + functionNode->name()
+ + "-" + QString::number(functionNode->overloadNumber());
+ else
+ 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;
+ case Node::Enum:
+ anchorRef = QLatin1Char('#') + node->name() + "-enum";
+ break;
+ case Node::Typedef:
+ anchorRef = QLatin1Char('#') + node->name() + "-typedef";
+ break;
+ case Node::Property:
+ anchorRef = QLatin1Char('#') + node->name() + "-prop";
+ break;
+ case Node::QmlProperty:
+ anchorRef = QLatin1Char('#') + node->name() + "-prop";
+ break;
+ case Node::QmlSignal:
+ anchorRef = QLatin1Char('#') + node->name() + "-signal";
+ break;
+ case Node::QmlSignalHandler:
+ anchorRef = QLatin1Char('#') + node->name() + "-signal-handler";
+ break;
+ case Node::QmlMethod:
+ anchorRef = QLatin1Char('#') + node->name() + "-method";
+ break;
+ case Node::Variable:
+ anchorRef = QLatin1Char('#') + node->name() + "-var";
+ break;
+ case Node::Fake:
+ {
+ /*
+ Use node->fileBase() for fake nodes because they are represented
+ by pages whose file names are lower-case.
+ */
+ parentName = node->fileBase();
+ parentName.replace(QLatin1Char('/'), "-").replace(".", "-");
+ parentName += "." + currentGenerator()->fileExtension();
+ }
+ break;
+ default:
+ break;
+ }
+
+ // Various objects can be compat (deprecated) or obsolete.
+ if (node->type() != Node::Class && node->type() != Node::Namespace) {
+ switch (node->status()) {
+ case Node::Compat:
+ parentName.replace("." + currentGenerator()->fileExtension(),
+ "-compat." + currentGenerator()->fileExtension());
+ break;
+ case Node::Obsolete:
+ parentName.replace("." + currentGenerator()->fileExtension(),
+ "-obsolete." + currentGenerator()->fileExtension());
+ break;
+ default:
+ ;
+ }
+ }
+
+ return fdl + parentName.toLower() + anchorRef;
+}
+
QString Generator::fullName(const Node *node,
const Node *relative,
CodeMarker *marker) const
QList<Generator *>::ConstIterator g = generators.begin();
while (g != generators.end()) {
if (outputFormats.contains((*g)->format())) {
+ currentGenerator_ = (*g);
(*g)->initializeGenerator(config);
QStringList extraImages =
config.getCleanPathList(CONFIG_EXTRAIMAGES+Config::dot+(*g)->format());
virtual void terminateGenerator();
static const QString& baseDir() { return baseDir_; }
+ static Generator *currentGenerator() { return currentGenerator_; }
+ static QString fullDocumentLocation(const Node *node, bool subdir = false);
static Generator *generatorForFormat(const QString& format);
static void initialize(const Config& config);
static const QString& outputDir() { return outDir_; }
virtual void endSubPage();
virtual void endText(const Node *relative, CodeMarker *marker);
virtual QString fileBase(const Node* node) const;
- virtual QString fileExtension(const Node* node) const = 0;
+ virtual QString fileExtension() const = 0;
virtual QString fullName(const Node *node,
const Node *relative,
CodeMarker *marker) const;
private:
static QString baseDir_;
+ static Generator* currentGenerator_;
static QStringList exampleDirs;
static QStringList exampleImgExts;
static QMap<QString, QMap<QString, QString> > fmtLeftMaps;
details << node->name();
details << node->name();
}
- details << HtmlGenerator::fullDocumentLocation(node,true);
+ details << Generator::fullDocumentLocation(node,true);
return details;
}
case Node::Class:
project.keywords.append(keywordDetails(node));
- project.files.insert(HtmlGenerator::fullDocumentLocation(node,true));
+ project.files.insert(Generator::fullDocumentLocation(node,true));
break;
case Node::Namespace:
project.keywords.append(keywordDetails(node));
- project.files.insert(HtmlGenerator::fullDocumentLocation(node,true));
+ project.files.insert(Generator::fullDocumentLocation(node,true));
break;
case Node::Enum:
details << item.name(); // "name"
details << item.name(); // "id"
}
- details << HtmlGenerator::fullDocumentLocation(node,true);
+ details << Generator::fullDocumentLocation(node,true);
project.keywords.append(details);
}
}
if (node->relates()) {
project.memberStatus[node->relates()].insert(node->status());
- project.files.insert(HtmlGenerator::fullDocumentLocation(node->relates(),true));
+ project.files.insert(Generator::fullDocumentLocation(node->relates(),true));
} else if (node->parent())
project.memberStatus[node->parent()].insert(node->status());
}
// Use the location of any associated enum node in preference
// to that of the typedef.
if (enumNode)
- typedefDetails[2] = HtmlGenerator::fullDocumentLocation(enumNode,true);
+ typedefDetails[2] = Generator::fullDocumentLocation(enumNode,true);
project.keywords.append(typedefDetails);
}
case Node::Variable:
{
- QString location = HtmlGenerator::fullDocumentLocation(node,true);
+ QString location = Generator::fullDocumentLocation(node,true);
project.files.insert(location.left(location.lastIndexOf(QLatin1Char('#'))));
project.keywords.append(keywordDetails(node));
}
QStringList details;
details << keyword->string()
<< keyword->string()
- << HtmlGenerator::fullDocumentLocation(node,true) +
+ << Generator::fullDocumentLocation(node,true) +
QLatin1Char('#') + Doc::canonicalTitle(keyword->string());
project.keywords.append(details);
} else
fakeNode->doc().location().warning(
- tr("Bad keyword in %1").arg(HtmlGenerator::fullDocumentLocation(node,true))
+ tr("Bad keyword in %1").arg(Generator::fullDocumentLocation(node,true))
);
}
}
}
}
*/
- project.files.insert(HtmlGenerator::fullDocumentLocation(node,true));
+ project.files.insert(Generator::fullDocumentLocation(node,true));
}
break;
}
void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer,
const Node *node)
{
- QString href = HtmlGenerator::fullDocumentLocation(node,true);
+ QString href = Generator::fullDocumentLocation(node,true);
QString objName = node->name();
switch (node->type()) {
node = tree->findNode(QStringList("index.html"));
QString indexPath;
if (node)
- indexPath = HtmlGenerator::fullDocumentLocation(node,true);
+ indexPath = Generator::fullDocumentLocation(node,true);
else
indexPath = "index.html";
writer.writeAttribute("ref", indexPath);
writer.writeAttribute("title", project.indexTitle);
- project.files.insert(HtmlGenerator::fullDocumentLocation(rootNode));
+ project.files.insert(Generator::fullDocumentLocation(rootNode));
generateSections(project, writer, rootNode);
const FakeNode *page = tree->findFakeNodeByTitle(atom->string());
writer.writeStartElement("section");
- QString indexPath = HtmlGenerator::fullDocumentLocation(page,true);
+ QString indexPath = Generator::fullDocumentLocation(page,true);
writer.writeAttribute("ref", indexPath);
writer.writeAttribute("title", atom->string());
project.files.insert(indexPath);
if (!name.isEmpty()) {
writer.writeStartElement("section");
- QString indexPath = HtmlGenerator::fullDocumentLocation(tree->findFakeNodeByTitle(subproject.indexTitle),true);
+ QString indexPath = Generator::fullDocumentLocation(tree->findFakeNodeByTitle(subproject.indexTitle),true);
writer.writeAttribute("ref", indexPath);
writer.writeAttribute("title", subproject.title);
project.files.insert(indexPath);
/*!
Returns "html" for this subclass of Generator.
*/
-QString HtmlGenerator::fileExtension(const Node * /* node */) const
+QString HtmlGenerator::fileExtension() const
{
return "html";
}
if (sections.isEmpty())
return QString();
- QString fileName = fileBase(inner) + "-members." + fileExtension(inner);
+ QString fileName = fileBase(inner) + "-members." + fileExtension();
beginSubPage(inner, fileName);
QString title = "List of All Members for " + inner->name();
generateHeader(title, inner, marker);
if (sections.isEmpty())
return QString();
- QString fileName = fileBase(qml_cn) + "-members." + fileExtension(qml_cn);
+ QString fileName = fileBase(qml_cn) + "-members." + fileExtension();
beginSubPage(qml_cn, fileName);
QString title = "List of All Members for " + qml_cn->name();
generateHeader(title, qml_cn, marker);
if (status == CodeMarker::Compat) {
title = "Compatibility Members for " + inner->name();
- fileName = fileBase(inner) + "-compat." + fileExtension(inner);
+ fileName = fileBase(inner) + "-compat." + fileExtension();
}
else {
title = "Obsolete Members for " + inner->name();
- fileName = fileBase(inner) + "-obsolete." + fileExtension(inner);
+ fileName = fileBase(inner) + "-obsolete." + fileExtension();
}
beginSubPage(inner, fileName);
}
}
-/*!
- Returns the full document location for HTML-based documentation.
- */
-QString HtmlGenerator::fullDocumentLocation(const Node *node, bool subdir)
-{
- if (!node)
- return "";
- if (!node->url().isEmpty())
- return node->url();
-
- QString parentName;
- QString anchorRef;
- QString fdl = "";
-
- /*
- If the output is being sent to subdirectories of the
- output directory, and if the subdir parameter is set,
- prepend the subdirectory name + '/' to the result.
- */
- if (subdir) {
- fdl = node->outputSubdirectory();
- if (!fdl.isEmpty())
- fdl.append(QLatin1Char('/'));
- }
- if (node->type() == Node::Namespace) {
-
- // The root namespace has no name - check for this before creating
- // an attribute containing the location of any documentation.
-
- if (!node->fileBase().isEmpty())
- parentName = node->fileBase() + ".html";
- else
- return "";
- }
- else if (node->type() == Node::Fake) {
- if ((node->subType() == Node::QmlClass) ||
- (node->subType() == Node::QmlBasicType)) {
- QString fb = node->fileBase();
- if (fb.startsWith(Generator::outputPrefix(QLatin1String("QML"))))
- return fb + ".html";
- else {
- QString mq = "";
- if (!node->qmlModuleName().isEmpty()) {
- mq = node->qmlModuleIdentifier().replace(QChar('.'),QChar('-'));
- mq = mq.toLower() + "-";
- }
- return fdl+ Generator::outputPrefix(QLatin1String("QML")) + mq +
- node->fileBase() + QLatin1String(".html");
- }
- }
- else
- parentName = node->fileBase() + ".html";
- }
- else if (node->fileBase().isEmpty())
- return "";
-
- Node *parentNode = 0;
-
- if ((parentNode = node->relates())) {
- parentName = fullDocumentLocation(node->relates());
- }
- else if ((parentNode = node->parent())) {
- if (parentNode->subType() == Node::QmlPropertyGroup) {
- parentNode = parentNode->parent();
- parentName = fullDocumentLocation(parentNode);
- }
- else
- parentName = fullDocumentLocation(node->parent());
- }
-
- switch (node->type()) {
- case Node::Class:
- case Node::Namespace:
- if (parentNode && !parentNode->name().isEmpty()) {
- parentName.remove(".html");
- parentName += QLatin1Char('-')
- + node->fileBase().toLower() + ".html";
- } else {
- parentName = node->fileBase() + ".html";
- }
- break;
- case Node::Function:
- {
- /*
- Functions can be destructors, overloaded, or
- have associated properties.
- */
- const FunctionNode *functionNode =
- static_cast<const FunctionNode *>(node);
-
- if (functionNode->metaness() == FunctionNode::Dtor)
- anchorRef = "#dtor." + functionNode->name().mid(1);
-
- else if (functionNode->associatedProperty())
- return fullDocumentLocation(functionNode->associatedProperty());
-
- else if (functionNode->overloadNumber() > 1)
- anchorRef = QLatin1Char('#') + functionNode->name()
- + "-" + QString::number(functionNode->overloadNumber());
- else
- 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;
- case Node::Enum:
- anchorRef = QLatin1Char('#') + node->name() + "-enum";
- break;
- case Node::Typedef:
- anchorRef = QLatin1Char('#') + node->name() + "-typedef";
- break;
- case Node::Property:
- anchorRef = QLatin1Char('#') + node->name() + "-prop";
- break;
- case Node::QmlProperty:
- anchorRef = QLatin1Char('#') + node->name() + "-prop";
- break;
- case Node::QmlSignal:
- anchorRef = QLatin1Char('#') + node->name() + "-signal";
- break;
- case Node::QmlSignalHandler:
- anchorRef = QLatin1Char('#') + node->name() + "-signal-handler";
- break;
- case Node::QmlMethod:
- anchorRef = QLatin1Char('#') + node->name() + "-method";
- break;
- case Node::Variable:
- anchorRef = QLatin1Char('#') + node->name() + "-var";
- break;
- case Node::Fake:
- {
- /*
- Use node->fileBase() for fake nodes because they are represented
- by pages whose file names are lower-case.
- */
- parentName = node->fileBase();
- parentName.replace(QLatin1Char('/'), "-").replace(".", "-");
- parentName += ".html";
- }
- break;
- default:
- break;
- }
-
- // Various objects can be compat (deprecated) or obsolete.
- if (node->type() != Node::Class && node->type() != Node::Namespace) {
- switch (node->status()) {
- case Node::Compat:
- parentName.replace(".html", "-compat.html");
- break;
- case Node::Obsolete:
- parentName.replace(".html", "-obsolete.html");
- break;
- default:
- ;
- }
- }
-
- return fdl + parentName.toLower() + anchorRef;
-}
/*!
This function outputs one or more manifest files in XML.
static QString protect(const QString &string, const QString &encoding = "ISO-8859-1");
static QString cleanRef(const QString& ref);
static QString sinceTitle(int i) { return sinceTitles[i]; }
- static QString fullDocumentLocation(const Node *node, bool subdir = false);
protected:
virtual void startText(const Node *relative, CodeMarker *marker);
CodeMarker *marker);
virtual void generateClassLikeNode(InnerNode* inner, CodeMarker* marker);
virtual void generateFakeNode(FakeNode* fake, CodeMarker* marker);
- virtual QString fileExtension(const Node *node) const;
+ virtual QString fileExtension() const;
virtual QString refForNode(const Node *node);
virtual QString linkForNode(const Node *node, const Node *relative);
virtual QString refForAtom(Atom *atom, const Node *node);
QString href = node->outputSubdirectory();
if (!href.isEmpty())
href.append(QLatin1Char('/'));
- href.append(HtmlGenerator::fullDocumentLocation(node));
+ href.append(Generator::fullDocumentLocation(node));
writer.writeAttribute("href", href);
if ((node->type() != Node::Fake) && (!node->isQmlNode()))
writer.writeAttribute("location", node->location().fileName());
if (node->type() == Node::Class) {
writer.writeTextElement("name", node->fullDocumentName());
- writer.writeTextElement("filename", HtmlGenerator::fullDocumentLocation(node,true));
+ writer.writeTextElement("filename", Generator::fullDocumentLocation(node,true));
// Classes contain information about their base classes.
const ClassNode* classNode = static_cast<const ClassNode*>(node);
generateTagFileCompounds(writer, static_cast<const InnerNode*>(node));
} else {
writer.writeTextElement("name", node->fullDocumentName());
- writer.writeTextElement("filename", HtmlGenerator::fullDocumentLocation(node,true));
+ writer.writeTextElement("filename", Generator::fullDocumentLocation(node,true));
// Recurse to write all members.
generateTagFileMembers(writer, static_cast<const InnerNode*>(node));
"virtual " + functionNode->returnType());
writer.writeTextElement("name", objName);
- QStringList pieces = HtmlGenerator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
+ QStringList pieces = Generator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
writer.writeTextElement("anchorfile", pieces[0]);
writer.writeTextElement("anchor", pieces[1]);
const PropertyNode* propertyNode = static_cast<const PropertyNode*>(node);
writer.writeAttribute("type", propertyNode->dataType());
writer.writeTextElement("name", objName);
- QStringList pieces = HtmlGenerator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
+ QStringList pieces = Generator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
writer.writeTextElement("anchorfile", pieces[0]);
writer.writeTextElement("anchor", pieces[1]);
writer.writeTextElement("arglist", "");
{
const EnumNode* enumNode = static_cast<const EnumNode*>(node);
writer.writeTextElement("name", objName);
- QStringList pieces = HtmlGenerator::fullDocumentLocation(node).split(QLatin1Char('#'));
+ QStringList pieces = Generator::fullDocumentLocation(node).split(QLatin1Char('#'));
writer.writeTextElement("anchor", pieces[1]);
writer.writeTextElement("arglist", "");
writer.writeEndElement(); // member
else
writer.writeAttribute("type", "");
writer.writeTextElement("name", objName);
- QStringList pieces = HtmlGenerator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
+ QStringList pieces = Generator::fullDocumentLocation(node,true).split(QLatin1Char('#'));
writer.writeTextElement("anchorfile", pieces[0]);
writer.writeTextElement("anchor", pieces[1]);
writer.writeTextElement("arglist", "");