""
};
+/*!
+ 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)
{
writeStartTag(DT_p);
const QString& url,
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)
FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom();
if (rfn && !rfn->isInternal()) {
writeStartTag(DT_cxxFunctionReimplemented);
- xmlWriter().writeAttribute("href",rfn->ditaXmlHref());
+ xmlWriter().writeAttribute("href",ditaXmlHref(rfn));
writeCharacters(marker->plainFullName(rfn));
writeEndTag(); // </cxxFunctionReimplemented>
}
if (pn->overriddenFrom() != 0) {
PropertyNode* opn = (PropertyNode*)pn->overriddenFrom();
writeStartTag(DT_cxxVariableReimplemented);
- xmlWriter().writeAttribute("href",opn->ditaXmlHref());
+ xmlWriter().writeAttribute("href",ditaXmlHref(opn));
writeCharacters(marker->plainFullName(opn));
writeEndTag(); // </cxxVariableReimplemented>
}
if (fn->reimplementedFrom() != 0) {
FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom();
writeStartTag(DT_cxxDefineReimplemented);
- xmlWriter().writeAttribute("href",rfn->ditaXmlHref());
+ xmlWriter().writeAttribute("href",ditaXmlHref(rfn));
writeCharacters(marker->plainFullName(rfn));
writeEndTag(); // </cxxDefineReimplemented>
}
void writeTopicrefs(NodeMultiMap* nmm, const QString& navtitle, Node* headingnode = 0);
bool isDuplicate(NodeMultiMap* nmm, const QString& key, Node* node);
void debugPara(const QString& t);
+ QString ditaXmlHref(Node* n);
private:
/*
// 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() + QLatin1Char('.') + currentGenerator()->fileExtension();
+ if (!fileBase(node).isEmpty())
+ parentName = fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
else
return QString();
}
else if (node->type() == Node::Fake) {
if ((node->subType() == Node::QmlClass) ||
(node->subType() == Node::QmlBasicType)) {
- QString fb = node->fileBase();
+ QString fb = fileBase(node);
if (fb.startsWith(Generator::outputPrefix(QLatin1String("QML"))))
return fb + QLatin1Char('.') + currentGenerator()->fileExtension();
else {
mq = mq.toLower() + QLatin1Char('-');
}
return fdl+ Generator::outputPrefix(QLatin1String("QML")) + mq +
- node->fileBase() + QLatin1Char('.') + currentGenerator()->fileExtension();
+ fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
}
}
- else
- parentName = node->fileBase() + QLatin1Char('.') + currentGenerator()->fileExtension();
+ else {
+ parentName = fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
+ }
}
- else if (node->fileBase().isEmpty())
+ else if (fileBase(node).isEmpty())
return QString();
Node *parentNode = 0;
parentNode = parentNode->parent();
parentName = fullDocumentLocation(parentNode);
}
- else
+ else {
parentName = fullDocumentLocation(node->parent());
+ }
}
switch (node->type()) {
if (parentNode && !parentNode->name().isEmpty()) {
parentName.remove(QLatin1Char('.') + currentGenerator()->fileExtension());
parentName += QLatin1Char('-')
- + node->fileBase().toLower() + QLatin1Char('.') + currentGenerator()->fileExtension();
+ + fileBase(node).toLower() + QLatin1Char('.') + currentGenerator()->fileExtension();
} else {
- parentName = node->fileBase() + QLatin1Char('.') + currentGenerator()->fileExtension();
+ parentName = fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
}
break;
case Node::Function:
{
- /*
- Functions can be destructors, overloaded, or
- have associated properties.
- */
const FunctionNode *functionNode =
static_cast<const FunctionNode *>(node);
+ QLatin1Char('-') + 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;
+ }
+ /*
+ 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:
anchorRef = QLatin1Char('#') + node->name() + "-enum";
break;
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.
*/
- parentName = node->fileBase();
+ parentName = fileBase(node);
parentName.replace(QLatin1Char('/'), QLatin1Char('-')).replace(QLatin1Char('.'), QLatin1Char('-'));
parentName += QLatin1Char('.') + currentGenerator()->fileExtension();
}
virtual void initializeGenerator(const Config &config);
virtual void terminateGenerator();
+ QString fullDocumentLocation(const Node *node, bool subdir = false);
+
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_; }
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
// generator.
details << node->name();
details << node->name();
}
- details << Generator::fullDocumentLocation(node,true);
+ details << gen_->fullDocumentLocation(node,true);
return details;
}
case Node::Class:
project.keywords.append(keywordDetails(node));
- project.files.insert(Generator::fullDocumentLocation(node,true));
+ project.files.insert(gen_->fullDocumentLocation(node,true));
break;
case Node::Namespace:
project.keywords.append(keywordDetails(node));
- project.files.insert(Generator::fullDocumentLocation(node,true));
+ project.files.insert(gen_->fullDocumentLocation(node,true));
break;
case Node::Enum:
details << item.name(); // "name"
details << item.name(); // "id"
}
- details << Generator::fullDocumentLocation(node,true);
+ details << gen_->fullDocumentLocation(node,true);
project.keywords.append(details);
}
}
if (node->relates()) {
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())
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] = Generator::fullDocumentLocation(enumNode,true);
+ typedefDetails[2] = gen_->fullDocumentLocation(enumNode,true);
project.keywords.append(typedefDetails);
}
case Node::Variable:
{
- QString location = Generator::fullDocumentLocation(node,true);
+ QString location = gen_->fullDocumentLocation(node,true);
project.files.insert(location.left(location.lastIndexOf(QLatin1Char('#'))));
project.keywords.append(keywordDetails(node));
}
QStringList details;
details << keyword->string()
<< keyword->string()
- << Generator::fullDocumentLocation(node,true) +
+ << gen_->fullDocumentLocation(node,true) +
QLatin1Char('#') + Doc::canonicalTitle(keyword->string());
project.keywords.append(details);
} else
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));
}
- /*
- 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));
+ project.files.insert(gen_->fullDocumentLocation(node,true));
}
break;
}
}
}
-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)
generateProject(projects[i]);
}
void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer,
const Node *node)
{
- QString href = Generator::fullDocumentLocation(node,true);
+ QString href = gen_->fullDocumentLocation(node,true);
QString objName = node->name();
switch (node->type()) {
node = tree->findNode(QStringList("index.html"));
QString indexPath;
if (node)
- indexPath = Generator::fullDocumentLocation(node,true);
+ indexPath = gen_->fullDocumentLocation(node,true);
else
indexPath = "index.html";
writer.writeAttribute("ref", indexPath);
writer.writeAttribute("title", project.indexTitle);
- project.files.insert(Generator::fullDocumentLocation(rootNode));
+ project.files.insert(gen_->fullDocumentLocation(rootNode));
generateSections(project, writer, rootNode);
const FakeNode *page = tree->findFakeNodeByTitle(atom->string());
writer.writeStartElement("section");
- QString indexPath = Generator::fullDocumentLocation(page,true);
+ QString indexPath = gen_->fullDocumentLocation(page,true);
writer.writeAttribute("ref", indexPath);
writer.writeAttribute("title", atom->string());
project.files.insert(indexPath);
if (!name.isEmpty()) {
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("title", subproject.title);
project.files.insert(indexPath);
QT_BEGIN_NAMESPACE
class Tree;
+class Generator;
typedef QPair<QString, const Node*> QStringNodePair;
struct SubProject
class HelpProjectWriter
{
public:
- HelpProjectWriter(const Config &config, const QString &defaultFileName);
+ HelpProjectWriter(const Config &config,
+ const QString &defaultFileName,
+ Generator* g);
void addExtraFile(const QString &file);
void addExtraFiles(const QSet<QString> &files);
- void generate(const Tree *tre);
+ void generate(const Tree *t);
private:
void generateProject(HelpProject &project);
void readSelectors(SubProject &subproject, const QStringList &selectors);
const Tree *tree;
+ Generator* gen_;
QString outputDir;
QList<HelpProject> projects;
codeIndent = config.getInt(CONFIG_CODEINDENT);
helpProjectWriter = new HelpProjectWriter(config,
- project.toLower() +
- ".qhp");
+ project.toLower() + ".qhp",
+ this);
// Documentation template handling
headerScripts = config.getString(HtmlGenerator::format() + Config::dot +
const QString &url,
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)
}
writer.writeStartElement(element);
writer.writeAttribute("name", en->title());
- QString docUrl = manifestDir + en->fileBase() + ".html";
+ QString docUrl = manifestDir + fileBase(en) + ".html";
writer.writeAttribute("docUrl", docUrl);
QStringList proFiles;
foreach (const Node* child, en->childNodes()) {
return safeness_;
}
+#if 0
/*!
Returns the sanitized file name without the path.
If the the file is an html file, the html suffix
base.replace(QLatin1Char(' '), QLatin1Char('-'));
return base.toLower();
}
-
+#endif
/*!
Returns this node's Universally Unique IDentifier as a
QString. Creates the UUID first, if it has not been created.
}
/*!
- 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 it is a child of a QML class node, return a pointer to
the QML class node. Otherwise, return 0;
return qmlModuleMemberMap_.value(qmid + "::" + name);
}
+#if 0
/*!
The base file name for this kind of node has "qml_"
prepended to it.
{
return Node::fileBase();
}
-
+#endif
/*!
Record the fact that QML class \a base is inherited by
QML class \a sub.
void clearRelated() { relatesTo_ = 0; }
- virtual QString fileBase() const;
+ //virtual QString fileBase() const;
QString guid() const;
- QString ditaXmlHref();
QString extractClassName(const QString &string) const;
virtual QString qmlTypeName() const { return name_; }
virtual QString qmlModuleName() const { return qmlModuleName_; }
virtual bool isQmlNode() const { return true; }
virtual bool isQtQuickNode() const { return (qmlModuleName() == QLatin1String("QtQuick")); }
virtual ClassNode* classNode() { return cnode_; }
- virtual QString fileBase() const;
+ //virtual QString fileBase() const;
virtual void setCurrentChild();
virtual void clearCurrentChild();
virtual const ImportList* importList() const { return &importList_; }
QString href = node->outputSubdirectory();
if (!href.isEmpty())
href.append(QLatin1Char('/'));
- href.append(Generator::fullDocumentLocation(node));
+ href.append(gen_->fullDocumentLocation(node));
writer.writeAttribute("href", href);
if ((node->type() != Node::Fake) && (!node->isQmlNode()))
writer.writeAttribute("location", node->location().fileName());
void Tree::generateIndex(const QString& fileName,
const QString& url,
const QString& title,
+ Generator* g,
bool generateInternalNodes)
{
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text))
return ;
+ gen_ = g;
QXmlStreamWriter writer(&file);
writer.setAutoFormatting(true);
writer.writeStartDocument();
if (node->type() == Node::Class) {
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.
const ClassNode* classNode = static_cast<const ClassNode*>(node);
generateTagFileCompounds(writer, static_cast<const InnerNode*>(node));
} else {
writer.writeTextElement("name", node->fullDocumentName());
- writer.writeTextElement("filename", Generator::fullDocumentLocation(node,true));
+ writer.writeTextElement("filename", gen_->fullDocumentLocation(node,true));
// Recurse to write all members.
generateTagFileMembers(writer, static_cast<const InnerNode*>(node));
"virtual " + functionNode->returnType());
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("anchor", pieces[1]);
const PropertyNode* propertyNode = static_cast<const PropertyNode*>(node);
writer.writeAttribute("type", propertyNode->dataType());
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("anchor", pieces[1]);
writer.writeTextElement("arglist", "");
{
const EnumNode* enumNode = static_cast<const EnumNode*>(node);
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("arglist", "");
writer.writeEndElement(); // member
else
writer.writeAttribute("type", "");
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("anchor", pieces[1]);
writer.writeTextElement("arglist", "");
QT_BEGIN_NAMESPACE
+class Generator;
class QStringList;
class TreePrivate;
void generateIndex(const QString &fileName,
const QString &url,
const QString &title,
+ Generator* g,
bool generateInternalNodes = false);
void generateTagFileCompounds(QXmlStreamWriter &writer,
const InnerNode *inner);
const InnerNode *inner);
void generateTagFile(const QString &fileName);
void addExternalLink(const QString &url, const Node *relative);
- QString fullDocumentLocation(const Node *node) const;
void resolveQmlInheritance();
private:
private:
NamespaceNode roo;
QString vers;
+ Generator* gen_;
TreePrivate *priv;
};