summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/generator.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-02-02 06:43:48 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-02-02 06:43:48 (GMT)
commit8fa689ed67583491cbfd5b8cc58860c15ec4903c (patch)
tree91585437344a5c668c860cb8432e364e3c3563bb /tools/qdoc3/generator.cpp
parent95b17fbe91eb3b1b0fcac92d8a8934769e4cd847 (diff)
parent1e7ab0e849900bacf71935f2a2150116b8dc17d1 (diff)
downloadQt-8fa689ed67583491cbfd5b8cc58860c15ec4903c.zip
Qt-8fa689ed67583491cbfd5b8cc58860c15ec4903c.tar.gz
Qt-8fa689ed67583491cbfd5b8cc58860c15ec4903c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-doc-staging into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-doc-staging: (208 commits) Replace all occurances of "Qt 4.7" with "QtQuick 1.0" Doc: Adjusted the font sizes for the offline documentation. Doc: Added a missing style sheet to the qhp manifest. Doc: Fixed the qthelp namespace for the Qt documentation. Doc: including missing pages in overviews. Doc: Fixed typo in QCoreApplication docs Fixed whitespace. Avoid hard-coding product names in page titles. Doc: Unindented a code snippet. Doc: Fixed confusing wording of a sentence. Doc: Fixed a broken link. Doc: Updated the information about commercial editions of Qt. Doc: Fixed qdoc warnings about broken links. Doc: Added preprocessor coloring. Doc: Added a link from the plugin guide to the plugin deployment guide. Doc: Fixed the syntax of QML code snippets. doc: Fixed a missing * in the docs for QML_DECLARE_TYPE Doc: Fixed missing images in qt demo Doc: Fixing typo Doc: fixing bugs and typos based on feedback ...
Diffstat (limited to 'tools/qdoc3/generator.cpp')
-rw-r--r--tools/qdoc3/generator.cpp231
1 files changed, 95 insertions, 136 deletions
diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp
index 7deca2e..276eab4 100644
--- a/tools/qdoc3/generator.cpp
+++ b/tools/qdoc3/generator.cpp
@@ -54,6 +54,7 @@
#include "quoter.h"
#include "separator.h"
#include "tokenizer.h"
+#include "ditaxmlgenerator.h"
QT_BEGIN_NAMESPACE
@@ -180,45 +181,52 @@ void Generator::initialize(const Config &config)
++e;
}
- QStringList noExts;
- QStringList scripts =
- config.getStringList(CONFIG_SCRIPTS+Config::dot+(*g)->format());
- e = scripts.begin();
- while (e != scripts.end()) {
- QString userFriendlyFilePath;
- QString filePath = Config::findFile(config.lastLocation(),
- scriptFiles,
- scriptDirs,
- *e,
- noExts,
- userFriendlyFilePath);
- if (!filePath.isEmpty())
- Config::copyFile(config.lastLocation(),
- filePath,
- userFriendlyFilePath,
- (*g)->outputDir() +
- "/scripts");
- ++e;
- }
+ // Documentation template handling
+ QString templateDir = config.getString(
+ (*g)->format() + Config::dot + CONFIG_TEMPLATEDIR);
+
+ if (!templateDir.isEmpty()) {
+ QStringList noExts;
+ QStringList searchDirs = QStringList() << templateDir;
+ QStringList scripts =
+ config.getStringList((*g)->format()+Config::dot+CONFIG_SCRIPTS);
+ e = scripts.begin();
+ while (e != scripts.end()) {
+ QString userFriendlyFilePath;
+ QString filePath = Config::findFile(config.lastLocation(),
+ scriptFiles,
+ searchDirs,
+ *e,
+ noExts,
+ userFriendlyFilePath);
+ if (!filePath.isEmpty())
+ Config::copyFile(config.lastLocation(),
+ filePath,
+ userFriendlyFilePath,
+ (*g)->outputDir() +
+ "/scripts");
+ ++e;
+ }
- QStringList styles =
- config.getStringList(CONFIG_STYLES+Config::dot+(*g)->format());
- e = styles.begin();
- while (e != styles.end()) {
- QString userFriendlyFilePath;
- QString filePath = Config::findFile(config.lastLocation(),
- styleFiles,
- styleDirs,
- *e,
- noExts,
- userFriendlyFilePath);
- if (!filePath.isEmpty())
- Config::copyFile(config.lastLocation(),
- filePath,
- userFriendlyFilePath,
- (*g)->outputDir() +
- "/style");
- ++e;
+ QStringList styles =
+ config.getStringList((*g)->format()+Config::dot+CONFIG_STYLESHEETS);
+ e = styles.begin();
+ while (e != styles.end()) {
+ QString userFriendlyFilePath;
+ QString filePath = Config::findFile(config.lastLocation(),
+ styleFiles,
+ searchDirs,
+ *e,
+ noExts,
+ userFriendlyFilePath);
+ if (!filePath.isEmpty())
+ Config::copyFile(config.lastLocation(),
+ filePath,
+ userFriendlyFilePath,
+ (*g)->outputDir() +
+ "/style");
+ ++e;
+ }
}
}
++g;
@@ -326,6 +334,7 @@ bool Generator::generateText(const Text& text,
const Node *relative,
CodeMarker *marker)
{
+ bool result = false;
if (text.firstAtom() != 0) {
int numAtoms = 0;
startText(relative, marker);
@@ -335,9 +344,9 @@ bool Generator::generateText(const Text& text,
true,
numAtoms);
endText(relative, marker);
- return true;
+ result = true;
}
- return false;
+ return result;
}
#ifdef QDOC_QML
@@ -351,24 +360,26 @@ bool Generator::generateQmlText(const Text& text,
const QString& /* qmlName */ )
{
const Atom* atom = text.firstAtom();
- if (atom == 0)
- return false;
+ bool result = false;
- startText(relative, marker);
- while (atom) {
- if (atom->type() != Atom::QmlText)
- atom = atom->next();
- else {
- atom = atom->next();
- while (atom && (atom->type() != Atom::EndQmlText)) {
- int n = 1 + generateAtom(atom, relative, marker);
- while (n-- > 0)
- atom = atom->next();
+ if (atom != 0) {
+ startText(relative, marker);
+ while (atom) {
+ if (atom->type() != Atom::QmlText)
+ atom = atom->next();
+ else {
+ atom = atom->next();
+ while (atom && (atom->type() != Atom::EndQmlText)) {
+ int n = 1 + generateAtom(atom, relative, marker);
+ while (n-- > 0)
+ atom = atom->next();
+ }
}
}
+ endText(relative, marker);
+ result = true;
}
- endText(relative, marker);
- return true;
+ return result;
}
#endif
@@ -376,25 +387,21 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
{
bool quiet = false;
- if (node->type() == Node::Function) {
-#if 0
- const FunctionNode *func = (const FunctionNode *) node;
- if (func->isOverload() && func->metaness() != FunctionNode::Ctor)
- generateOverload(node, marker);
-#endif
- }
- else if (node->type() == Node::Fake) {
+ if (node->type() == Node::Fake) {
const FakeNode *fake = static_cast<const FakeNode *>(node);
- if (fake->subType() == Node::Example)
+ if (fake->subType() == Node::Example) {
generateExampleFiles(fake, marker);
- else if ((fake->subType() == Node::File) || (fake->subType() == Node::Image))
+ }
+ else if ((fake->subType() == Node::File) || (fake->subType() == Node::Image)) {
quiet = true;
+ }
}
if (node->doc().isEmpty()) {
- if (!quiet && !node->isReimp()) // ### might be unnecessary
+ if (!quiet && !node->isReimp()) { // ### might be unnecessary
node->location().warning(tr("No documentation for '%1'")
.arg(marker->plainFullName(node)));
+ }
}
else {
if (node->type() == Node::Function) {
@@ -403,9 +410,10 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
generateReimplementedFrom(func, marker);
}
- if (!generateText(node->doc().body(), node, marker))
+ if (!generateText(node->doc().body(), node, marker)) {
if (node->isReimp())
return;
+ }
if (node->type() == Node::Enum) {
const EnumNode *enume = (const EnumNode *) node;
@@ -496,18 +504,16 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
++a;
}
}
-/* Something like this return value check should be implemented at some point. */
+ /*
+ Something like this return value check should
+ be implemented at some point.
+ */
if (func->status() > Node::Obsolete && func->returnType() == "bool"
&& func->reimplementedFrom() == 0 && !func->isOverload()) {
QString body = func->doc().body().toString();
if (!body.contains("return", Qt::CaseInsensitive))
node->doc().location().warning(tr("Undocumented return value"));
}
-#if 0
- // Now we put this at the top, before the other text.
- if (func->reimplementedFrom() != 0)
- generateReimplementedFrom(func, marker);
-#endif
}
}
@@ -518,8 +524,9 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
Quoter quoter;
Doc::quoteFromFile(fake->doc().location(), quoter, fake->name());
QString code = quoter.quoteTo(fake->location(), "", "");
- text << Atom(Atom::Code, code);
- generateText(text, fake, marker);
+ CodeMarker *codeMarker = CodeMarker::markerForFileName(fake->name());
+ text << Atom(codeMarker->atomType(), code);
+ generateText(text, fake, codeMarker);
}
}
}
@@ -667,35 +674,6 @@ void Generator::generateExampleFiles(const FakeNode *fake, CodeMarker *marker)
generateFileList(fake, marker, Node::Image, QString("Images:"));
}
-#if 0
- QList<Generator *>::ConstIterator g = generators.begin();
- while (g != generators.end()) {
- if (outputFormats.contains((*g)->format())) {
- (*g)->initializeGenerator(config);
- QStringList extraImages =
- config.getStringList(CONFIG_EXTRAIMAGES+Config::dot+(*g)->format());
- QStringList::ConstIterator e = extraImages.begin();
- while (e != extraImages.end()) {
- QString userFriendlyFilePath;
- QString filePath = Config::findFile(config.lastLocation(),
- imageFiles,
- imageDirs,
- *e,
- imgFileExts[(*g)->format()],
- userFriendlyFilePath);
- if (!filePath.isEmpty())
- Config::copyFile(config.lastLocation(),
- filePath,
- userFriendlyFilePath,
- (*g)->outputDir() +
- "/images");
- ++e;
- }
- }
- ++g;
- }
-#endif
-
QString Generator::indent(int level, const QString& markedCode)
{
if (level == 0)
@@ -706,26 +684,17 @@ QString Generator::indent(int level, const QString& markedCode)
int i = 0;
while (i < (int) markedCode.length()) {
- if (markedCode.at(i) == QLatin1Char('<')) {
- while (i < (int) markedCode.length()) {
- t += markedCode.at(i++);
- if (markedCode.at(i - 1) == QLatin1Char('>'))
- break;
- }
+ if (markedCode.at(i) == QLatin1Char('\n')) {
+ column = 0;
}
else {
- if (markedCode.at(i) == QLatin1Char('\n')) {
- column = 0;
+ if (column == 0) {
+ for (int j = 0; j < level; j++)
+ t += QLatin1Char(' ');
}
- else {
- if (column == 0) {
- for (int j = 0; j < level; j++)
- t += QLatin1Char(' ');
- }
- column++;
- }
- t += markedCode.at(i++);
+ column++;
}
+ t += markedCode.at(i++);
}
return t;
}
@@ -855,7 +824,11 @@ QMap<QString, QString>& Generator::formattingRightMap()
return fmtRightMaps[format()];
}
-QString Generator::trimmedTrailing(const QString &string)
+/*
+ Trims trailimng whitespace off the \a string and returns
+ the trimmed string.
+ */
+QString Generator::trimmedTrailing(const QString& string)
{
QString trimmed = string;
while (trimmed.length() > 0 && trimmed[trimmed.length() - 1].isSpace())
@@ -1085,20 +1058,6 @@ void Generator::generateSince(const Node *node, CodeMarker *marker)
}
}
-/*!
- No longer in use.
- */
-void Generator::generateOverload(const Node *node, CodeMarker *marker)
-{
- Text text;
- text << Atom::ParaLeft
- << "This function overloads ";
- QString t = node->name() + "()";
- text << Atom::AutoLink << t
- << Atom::ParaRight;
- generateText(text, node, marker);
-}
-
void Generator::generateReimplementedFrom(const FunctionNode *func,
CodeMarker *marker)
{
@@ -1147,8 +1106,8 @@ const Atom *Generator::generateAtomList(const Atom *atom,
if (atom->type() == Atom::FormatEndif) {
if (generate && numAtoms0 == numAtoms) {
- relative->location().warning(tr("Output format %1 not handled")
- .arg(format()));
+ relative->location().warning(tr("Output format %1 not handled %2")
+ .arg(format()).arg(outFileName()));
Atom unhandledFormatAtom(Atom::UnhandledFormat, format());
generateAtomList(&unhandledFormatAtom,
relative,