summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/generator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/qdoc/generator.cpp')
-rw-r--r--src/tools/qdoc/generator.cpp78
1 files changed, 58 insertions, 20 deletions
diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp
index 889f0f55ca..5583600bf6 100644
--- a/src/tools/qdoc/generator.cpp
+++ b/src/tools/qdoc/generator.cpp
@@ -97,7 +97,9 @@ QStringList Generator::styleDirs;
QStringList Generator::styleFiles;
bool Generator::debugging_ = false;
bool Generator::noLinkErrors_ = false;
+bool Generator::redirectDocumentationToDevNull_ = false;
Generator::Passes Generator::qdocPass_ = Both;
+bool Generator::useOutputSubdirs_ = true;
void Generator::setDebugSegfaultFlag(bool b)
{
@@ -263,14 +265,17 @@ void Generator::writeOutFileNames()
void Generator::beginSubPage(const InnerNode* node, const QString& fileName)
{
QString path = outputDir() + QLatin1Char('/');
- if (!node->outputSubdirectory().isEmpty())
+ if (Generator::useOutputSubdirs() && !node->outputSubdirectory().isEmpty())
path += node->outputSubdirectory() + QLatin1Char('/');
path += fileName;
- Generator::debugSegfault("Writing: " + path);
- outFileNames.insert(fileName,fileName);
- QFile* outFile = new QFile(path);
+
+ QFile* outFile = new QFile(redirectDocumentationToDevNull_ ? QStringLiteral("/dev/null") : path);
+ if (outFile->exists())
+ node->location().error(tr("HTML file already exists; overwriting %1").arg(outFile->fileName()));
if (!outFile->open(QFile::WriteOnly))
node->location().fatal(tr("Cannot open output file '%1'").arg(outFile->fileName()));
+ Generator::debugSegfault("Writing: " + path);
+ outFileNames.insert(fileName,fileName);
QTextStream* out = new QTextStream(outFile);
#ifndef QT_NO_TEXTCODEC
@@ -299,14 +304,22 @@ QString Generator::fileBase(const Node *node) const
node = node->relates();
else if (!node->isInnerNode())
node = node->parent();
- if (node->subType() == Node::QmlPropertyGroup) {
+ if (node->type() == Node::QmlPropertyGroup) {
node = node->parent();
}
- QString base = node->doc().baseName();
- if (!base.isEmpty())
- return base;
+ if (node->type() == Node::Document && node->subType() == Node::Collision) {
+ const NameCollisionNode* ncn = static_cast<const NameCollisionNode*>(node);
+ if (ncn->currentChild())
+ return fileBase(ncn->currentChild());
+ }
+
+ if (node->hasBaseName()) {
+ //qDebug() << "RETURNING:" << node->baseName();
+ return node->baseName();
+ }
+ QString base;
const Node *p = node;
forever {
@@ -345,6 +358,11 @@ QString Generator::fileBase(const Node *node) const
if (node->subType() == Node::Module) {
base.append("-module");
}
+ if (node->isExample() || node->isExampleFile())
+ base.prepend(project.toLower() + QLatin1Char('-'));
+ if (node->isExample())
+ base.append(QLatin1String("-example"));
+
}
// the code below is effectively equivalent to:
@@ -375,6 +393,8 @@ QString Generator::fileBase(const Node *node) const
}
while (res.endsWith(QLatin1Char('-')))
res.chop(1);
+ Node* n = const_cast<Node*>(node);
+ n->setBaseName(res);
return res;
}
@@ -407,7 +427,7 @@ QMap<QString, QString>& Generator::formattingRightMap()
/*!
Returns the full document location.
*/
-QString Generator::fullDocumentLocation(const Node *node, bool subdir)
+QString Generator::fullDocumentLocation(const Node *node, bool useSubdir)
{
if (!node)
return QString();
@@ -419,11 +439,11 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
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 the useSubdir parameter is set, then the output is
+ being sent to subdirectories of the output directory.
+ Prepend the subdirectory name + '/' to the result.
*/
- if (subdir) {
+ if (useSubdir) {
fdl = node->outputSubdirectory();
if (!fdl.isEmpty())
fdl.append(QLatin1Char('/'));
@@ -467,7 +487,7 @@ QString Generator::fullDocumentLocation(const Node *node, bool subdir)
parentName = fullDocumentLocation(node->relates());
}
else if ((parentNode = node->parent())) {
- if (parentNode->subType() == Node::QmlPropertyGroup) {
+ if (parentNode->type() == Node::QmlPropertyGroup) {
parentNode = parentNode->parent();
parentName = fullDocumentLocation(parentNode);
}
@@ -933,6 +953,8 @@ void Generator::generateInnerNode(InnerNode* node)
{
if (!node->url().isNull())
return;
+ if (node->isIndexNode())
+ return;
if (node->type() == Node::Document) {
DocNode* docNode = static_cast<DocNode*>(node);
@@ -940,13 +962,13 @@ void Generator::generateInnerNode(InnerNode* node)
return;
if (docNode->subType() == Node::Image)
return;
- if (docNode->subType() == Node::QmlPropertyGroup)
- return;
if (docNode->subType() == Node::Page) {
if (node->count() > 0)
qDebug("PAGE %s HAS CHILDREN", qPrintable(docNode->title()));
}
}
+ else if (node->type() == Node::QmlPropertyGroup)
+ return;
/*
Obtain a code marker for the source file.
@@ -1099,7 +1121,10 @@ void Generator::generateSince(const Node *node, CodeMarker *marker)
if (project.isEmpty())
text << "version";
else
- text << project;
+ text << Atom(Atom::Link, project)
+ << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
+ << Atom(Atom::String, project)
+ << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
text << " " << since[0];
} else {
// Reconstruct the <project> <version> string.
@@ -1474,7 +1499,12 @@ QString Generator::indent(int level, const QString& markedCode)
void Generator::initialize(const Config &config)
{
+
+ if (config.getBool(QString("HTML.nosubdirs")))
+ resetUseOutputSubdirs();
+
outputFormats = config.getOutputFormats();
+ redirectDocumentationToDevNull_ = config.getBool(CONFIG_REDIRECTDOCUMENTATIONTODEVNULL);
if (!outputFormats.isEmpty()) {
outDir_ = config.getOutputDir();
if (outDir_.isEmpty()) {
@@ -1487,7 +1517,7 @@ void Generator::initialize(const Config &config)
QDir dirInfo;
if (dirInfo.exists(outDir_)) {
- if (!runGenerateOnly()) {
+ if (!runGenerateOnly() && Generator::useOutputSubdirs()) {
if (!Config::removeDirContents(outDir_))
config.lastLocation().error(tr("Cannot empty output directory '%1'").arg(outDir_));
}
@@ -1907,8 +1937,6 @@ QString Generator::typeString(const Node *node)
switch (node->subType()) {
case Node::QmlClass:
return "type";
- case Node::QmlPropertyGroup:
- return "property group";
case Node::QmlBasicType:
return "type";
default:
@@ -1923,6 +1951,16 @@ QString Generator::typeString(const Node *node)
return "function";
case Node::Property:
return "property";
+ case Node::QmlPropertyGroup:
+ return "property group";
+ case Node::QmlProperty:
+ return "QML property";
+ case Node::QmlSignal:
+ return "QML signal";
+ case Node::QmlSignalHandler:
+ return "QML signal handler";
+ case Node::QmlMethod:
+ return "QML method";
default:
return "documentation";
}