diff options
Diffstat (limited to 'src/tools/qdoc/generator.cpp')
-rw-r--r-- | src/tools/qdoc/generator.cpp | 125 |
1 files changed, 66 insertions, 59 deletions
diff --git a/src/tools/qdoc/generator.cpp b/src/tools/qdoc/generator.cpp index 2ff4df9bd7..99dec06233 100644 --- a/src/tools/qdoc/generator.cpp +++ b/src/tools/qdoc/generator.cpp @@ -259,7 +259,7 @@ void Generator::writeOutFileNames() Attaches a QTextStream to the created file, which is written to all over the place using out(). */ -void Generator::beginSubPage(const InnerNode* node, const QString& fileName) +void Generator::beginSubPage(const Aggregate* node, const QString& fileName) { QString path = outputDir() + QLatin1Char('/'); if (Generator::useOutputSubdirs() && !node->outputSubdirectory().isEmpty() && @@ -281,7 +281,7 @@ void Generator::beginSubPage(const InnerNode* node, const QString& fileName) out->setCodec(outputCodec); #endif outStreamStack.push(out); - const_cast<InnerNode*>(node)->setOutputFileName(fileName); + const_cast<Aggregate*>(node)->setOutputFileName(fileName); } /*! @@ -300,7 +300,7 @@ QString Generator::fileBase(const Node *node) const { if (node->relates()) node = node->relates(); - else if (!node->isInnerNode()) + else if (!node->isAggregate()) node = node->parent(); if (node->type() == Node::QmlPropertyGroup) { node = node->parent(); @@ -697,12 +697,12 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) if (node->type() == Node::Document) { const DocumentNode *dn = static_cast<const DocumentNode *>(node); - if ((dn->subType() == Node::File) || (dn->subType() == Node::Image)) { + if ((dn->docSubtype() == Node::File) || (dn->docSubtype() == Node::Image)) { quiet = true; } } if (node->doc().isEmpty()) { - if (!node->isWrapper() && !quiet && !node->isReimp()) { // ### might be unnecessary + if (!node->isWrapper() && !quiet && !node->isReimplemented()) { // ### might be unnecessary node->location().warning(tr("No documentation for '%1'").arg(node->plainFullName())); } } @@ -714,7 +714,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) } if (!generateText(node->doc().body(), node, marker)) { - if (node->isReimp()) + if (node->isReimplemented()) return; } @@ -800,7 +800,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) } } } - if (needWarning && !func->isReimp()) + if (needWarning && !func->isReimplemented()) node->doc().location().warning( tr("Undocumented parameter '%1' in %2") .arg(*a).arg(node->plainFullName())); @@ -826,7 +826,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) if (dn->isExample()) { generateExampleFiles(dn, marker); } - else if (dn->subType() == Node::File) { + else if (dn->docSubtype() == Node::File) { Text text; Quoter quoter; Doc::quoteFromFile(dn->doc().location(), quoter, dn->name()); @@ -838,7 +838,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) } } -void Generator::generateClassLikeNode(InnerNode* /* classe */, CodeMarker* /* marker */) +void Generator::generateClassLikeNode(Aggregate* /* classe */, CodeMarker* /* marker */) { } @@ -867,7 +867,7 @@ void Generator::generateCollectionNode(CollectionNode* , CodeMarker* ) */ void Generator::generateFileList(const DocumentNode* dn, CodeMarker* marker, - Node::SubType subtype, + Node::DocSubtype subtype, const QString& tag) { int count = 0; @@ -878,7 +878,7 @@ void Generator::generateFileList(const DocumentNode* dn, << Atom(Atom::ListLeft, openedList.styleString()); foreach (const Node* child, dn->childNodes()) { - if (child->subType() == subtype) { + if (child->docSubtype() == subtype) { ++count; QString file = child->name(); if (subtype == Node::Image) { @@ -892,16 +892,10 @@ void Generator::generateFileList(const DocumentNode* dn, exampleImgExts, userFriendlyFilePath); userFriendlyFilePath.truncate(userFriendlyFilePath.lastIndexOf('/')); - QString imgOutDir = outDir_ + "/images/used-in-examples/" + userFriendlyFilePath; if (!dirInfo.mkpath(imgOutDir)) - dn->location().fatal(tr("Cannot create output directory '%1'") - .arg(imgOutDir)); - - QString imgOutName = Config::copyFile(dn->location(), - srcPath, - file, - imgOutDir); + dn->location().fatal(tr("Cannot create output directory '%1'").arg(imgOutDir)); + Config::copyFile(dn->location(), srcPath, file, imgOutDir); } } @@ -977,7 +971,7 @@ void Generator::generateInherits(const ClassNode *classe, CodeMarker *marker) /*! Recursive writing of HTML files from the root \a node. */ -void Generator::generateInnerNode(InnerNode* node) +void Generator::generateAggregate(Aggregate* node) { if (!node->url().isNull()) return; @@ -988,11 +982,11 @@ void Generator::generateInnerNode(InnerNode* node) if (node->isDocumentNode()) { DocumentNode* docNode = static_cast<DocumentNode*>(node); - if (docNode->subType() == Node::ExternalPage) + if (docNode->docSubtype() == Node::ExternalPage) return; - if (docNode->subType() == Node::Image) + if (docNode->docSubtype() == Node::Image) return; - if (docNode->subType() == Node::Page) { + if (docNode->docSubtype() == Node::Page) { if (node->count() > 0) qDebug("PAGE %s HAS CHILDREN", qPrintable(docNode->title())); } @@ -1062,8 +1056,8 @@ void Generator::generateInnerNode(InnerNode* node) int i = 0; while (i < node->childNodes().count()) { Node *c = node->childNodes().at(i); - if (c->isInnerNode() && c->access() != Node::Private) { - generateInnerNode((InnerNode*)c); + if (c->isAggregate() && c->access() != Node::Private) { + generateAggregate((Aggregate*)c); } ++i; } @@ -1072,7 +1066,7 @@ void Generator::generateInnerNode(InnerNode* node) /*! Generate a list of maintainers in the output */ -void Generator::generateMaintainerList(const InnerNode* node, CodeMarker* marker) +void Generator::generateMaintainerList(const Aggregate* node, CodeMarker* marker) { QStringList sl = getMetadataElements(node,"maintainer"); @@ -1197,7 +1191,8 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker) Text text; switch (node->status()) { - case Node::Commendable: + case Node::Active: + // Do nothing. break; case Node::Preliminary: text << Atom::ParaLeft @@ -1210,19 +1205,19 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker) break; case Node::Deprecated: text << Atom::ParaLeft; - if (node->isInnerNode()) + if (node->isAggregate()) text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD); text << "This " << typeString(node) << " is deprecated."; - if (node->isInnerNode()) + if (node->isAggregate()) text << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD); text << Atom::ParaRight; break; case Node::Obsolete: text << Atom::ParaLeft; - if (node->isInnerNode()) + if (node->isAggregate()) text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD); text << "This " << typeString(node) << " is obsolete."; - if (node->isInnerNode()) + if (node->isAggregate()) text << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD); text << " It is provided to keep old source code working. " << "We strongly advise against " @@ -1230,7 +1225,7 @@ void Generator::generateStatus(const Node *node, CodeMarker *marker) break; case Node::Compat: // reimplemented in HtmlGenerator subclass - if (node->isInnerNode()) { + if (node->isAggregate()) { text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD) << "This " @@ -1329,8 +1324,8 @@ void Generator::generateThreadSafeness(const Node *node, CodeMarker *marker) << Atom(Atom::FormattingRight,ATOM_FORMATTING_BOLD) << " "; - if (node->isInnerNode()) { - const InnerNode* innerNode = static_cast<const InnerNode*>(node); + if (node->isAggregate()) { + const Aggregate* innerNode = static_cast<const Aggregate*>(node); text << "All functions in this " << typeString(node) << " are "; @@ -1434,7 +1429,7 @@ void Generator::generateThreadSafeness(const Node *node, CodeMarker *marker) */ void Generator::generateDocs() { - generateInnerNode(qdb_->primaryTreeRoot()); + generateAggregate(qdb_->primaryTreeRoot()); } Generator *Generator::generatorForFormat(const QString& format) @@ -1457,7 +1452,7 @@ Generator *Generator::generatorForFormat(const QString& format) i.e. Once you call this function for a particular \a t, you consume \a t. */ -QString Generator::getMetadataElement(const InnerNode* inner, const QString& t) +QString Generator::getMetadataElement(const Aggregate* inner, const QString& t) { QString s; QStringMultiMap& metaTagMap = const_cast<QStringMultiMap&>(inner->doc().metaTagMap()); @@ -1478,7 +1473,7 @@ QString Generator::getMetadataElement(const InnerNode* inner, const QString& t) having the key \a t are erased. i.e. Once you call this function for a particular \a t, you consume \a t. */ -QStringList Generator::getMetadataElements(const InnerNode* inner, const QString& t) +QStringList Generator::getMetadataElements(const Aggregate* inner, const QString& t) { QStringList s; QStringMultiMap& metaTagMap = const_cast<QStringMultiMap&>(inner->doc().metaTagMap()); @@ -1573,12 +1568,6 @@ void Generator::initialize(const Config &config) if (!dirInfo.exists(outDir_ + "/images") && !dirInfo.mkdir(outDir_ + "/images")) config.lastLocation().fatal(tr("Cannot create images directory '%1'").arg(outDir_ + "/images")); - if (!dirInfo.exists(outDir_ + "/images/used-in-examples") && !dirInfo.mkdir(outDir_ + "/images/used-in-examples")) - config.lastLocation().fatal(tr("Cannot create images used in examples directory '%1'").arg(outDir_ + "/images/used-in-examples")); - if (!dirInfo.exists(outDir_ + "/scripts") && !dirInfo.mkdir(outDir_ + "/scripts")) - config.lastLocation().fatal(tr("Cannot create scripts directory '%1'").arg(outDir_ + "/scripts")); - if (!dirInfo.exists(outDir_ + "/style") && !dirInfo.mkdir(outDir_ + "/style")) - config.lastLocation().fatal(tr("Cannot create style directory '%1'").arg(outDir_ + "/style")); } imageFiles = config.getCanonicalPathList(CONFIG_IMAGES); @@ -1617,23 +1606,41 @@ void Generator::initialize(const Config &config) // Documentation template handling QStringList scripts = config.getCanonicalPathList((*g)->format()+Config::dot+CONFIG_SCRIPTS, true); - e = scripts.constBegin(); - while (e != scripts.constEnd()) { - QString filePath = *e; - if (!filePath.isEmpty()) - Config::copyFile(config.lastLocation(), filePath, filePath, - (*g)->outputDir() + "/scripts"); - ++e; + if (!scripts.isEmpty()) { + QDir dirInfo; + if (!dirInfo.exists(outDir_ + "/scripts") && !dirInfo.mkdir(outDir_ + "/scripts")) { + config.lastLocation().fatal(tr("Cannot create scripts directory '%1'") + .arg(outDir_ + "/scripts")); + } + else { + e = scripts.constBegin(); + while (e != scripts.constEnd()) { + QString filePath = *e; + if (!filePath.isEmpty()) + Config::copyFile(config.lastLocation(), filePath, filePath, + (*g)->outputDir() + "/scripts"); + ++e; + } + } } QStringList styles = config.getCanonicalPathList((*g)->format()+Config::dot+CONFIG_STYLESHEETS, true); - e = styles.constBegin(); - while (e != styles.constEnd()) { - QString filePath = *e; - if (!filePath.isEmpty()) - Config::copyFile(config.lastLocation(), filePath, filePath, - (*g)->outputDir() + "/style"); - ++e; + if (!styles.isEmpty()) { + QDir dirInfo; + if (!dirInfo.exists(outDir_ + "/style") && !dirInfo.mkdir(outDir_ + "/style")) { + config.lastLocation().fatal(tr("Cannot create style directory '%1'") + .arg(outDir_ + "/style")); + } + else { + e = styles.constBegin(); + while (e != styles.constEnd()) { + QString filePath = *e; + if (!filePath.isEmpty()) + Config::copyFile(config.lastLocation(), filePath, filePath, + (*g)->outputDir() + "/style"); + ++e; + } + } } } ++g; @@ -1715,7 +1722,7 @@ void Generator::initializeGenerator(const Config& config) singleExec_ = config.getBool(CONFIG_SINGLEEXEC); } -bool Generator::matchAhead(const Atom *atom, Atom::Type expectedAtomType) +bool Generator::matchAhead(const Atom *atom, Atom::AtomType expectedAtomType) { return atom->next() != 0 && atom->next()->type() == expectedAtomType; } @@ -1862,7 +1869,7 @@ void Generator::singularPlural(Text& text, const NodeList& nodes) text << " are"; } -int Generator::skipAtoms(const Atom *atom, Atom::Type type) const +int Generator::skipAtoms(const Atom *atom, Atom::AtomType type) const { int skipAhead = 0; atom = atom->next(); |