summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@nokia.com>2011-07-15 11:29:46 (GMT)
committerMartin Smith <martin.smith@nokia.com>2011-07-15 11:29:46 (GMT)
commitc70a0e817aa771f8a6cf5d6e60ab40161382bdb3 (patch)
tree58e52a8582c1540dc027584905243308e970b4e2
parentfa4c5540bd0fd9f8bb7238c1d947f0763b8607e1 (diff)
downloadQt-c70a0e817aa771f8a6cf5d6e60ab40161382bdb3.zip
Qt-c70a0e817aa771f8a6cf5d6e60ab40161382bdb3.tar.gz
Qt-c70a0e817aa771f8a6cf5d6e60ab40161382bdb3.tar.bz2
Phase 1 of QTBUG-20412, the XML manifest file
-rw-r--r--doc/src/examples/addressbook.qdoc2
-rw-r--r--tools/qdoc3/codemarker.cpp2
-rw-r--r--tools/qdoc3/codeparser.cpp3
-rw-r--r--tools/qdoc3/cppcodemarker.cpp2
-rw-r--r--tools/qdoc3/cppcodeparser.cpp8
-rw-r--r--tools/qdoc3/doc.cpp4
-rw-r--r--tools/qdoc3/generator.h4
-rw-r--r--tools/qdoc3/htmlgenerator.cpp96
-rw-r--r--tools/qdoc3/htmlgenerator.h1
-rw-r--r--tools/qdoc3/node.cpp18
-rw-r--r--tools/qdoc3/node.h25
11 files changed, 141 insertions, 24 deletions
diff --git a/doc/src/examples/addressbook.qdoc b/doc/src/examples/addressbook.qdoc
index 114c22b..f19582d 100644
--- a/doc/src/examples/addressbook.qdoc
+++ b/doc/src/examples/addressbook.qdoc
@@ -29,7 +29,7 @@
\example itemviews/addressbook
\title Address Book Example
- The address book example shows how to use proxy models to display
+ \brief The address book example shows how to use proxy models to display
different views onto data from a single model.
\image addressbook-example.png Screenshot of the Address Book example
diff --git a/tools/qdoc3/codemarker.cpp b/tools/qdoc3/codemarker.cpp
index 614419e..705ef6c 100644
--- a/tools/qdoc3/codemarker.cpp
+++ b/tools/qdoc3/codemarker.cpp
@@ -76,7 +76,7 @@ CodeMarker::~CodeMarker()
A code market performs no initialization by default. Marker-specific
initialization is performed in subclasses.
*/
-void CodeMarker::initializeMarker(const Config &config)
+void CodeMarker::initializeMarker(const Config& ) // config
{
}
diff --git a/tools/qdoc3/codeparser.cpp b/tools/qdoc3/codeparser.cpp
index c7a8912..9ab5f82 100644
--- a/tools/qdoc3/codeparser.cpp
+++ b/tools/qdoc3/codeparser.cpp
@@ -287,6 +287,9 @@ void CodeParser::processCommonMetaCommand(const Location &location,
FakeNode *fake = static_cast<FakeNode *>(node);
fake->setTitle(arg);
nameToTitle.insert(fake->name(),arg);
+ if (fake->subType() == Node::Example) {
+
+ }
}
else
location.warning(tr("Ignored '\\%1'").arg(COMMAND_TITLE));
diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp
index 585d6ce..e439fff 100644
--- a/tools/qdoc3/cppcodemarker.cpp
+++ b/tools/qdoc3/cppcodemarker.cpp
@@ -878,6 +878,7 @@ static const char * const keywordTable[] = {
"signals", "slots", "emit", 0
};
+#if 0
static QString untabified(const QString &in)
{
QString res;
@@ -897,6 +898,7 @@ static QString untabified(const QString &in)
return res;
}
+#endif
/*
@char
diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp
index 6f5baa0..1536867 100644
--- a/tools/qdoc3/cppcodeparser.cpp
+++ b/tools/qdoc3/cppcodeparser.cpp
@@ -704,7 +704,7 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc,
if (command == COMMAND_CLASS) {
if (paths.size() > 1) {
if (!paths[1].endsWith(".h")) {
- ClassNode*cnode = static_cast<ClassNode*>(node);
+ ClassNode* cnode = static_cast<ClassNode*>(node);
cnode->setQmlElement(paths[1]);
}
}
@@ -712,9 +712,9 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc,
return node;
}
else if (command == COMMAND_EXAMPLE) {
- FakeNode *fake = new FakeNode(tre->root(), arg, Node::Example);
- createExampleFileNodes(fake);
- return fake;
+ ExampleNode* en = new ExampleNode(tre->root(), arg);
+ createExampleFileNodes(en);
+ return en;
}
else if (command == COMMAND_EXTERNALPAGE) {
return new FakeNode(tre->root(), arg, Node::ExternalPage);
diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp
index 479931d..f0c4264 100644
--- a/tools/qdoc3/doc.cpp
+++ b/tools/qdoc3/doc.cpp
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QSet<QString>, null_Set_QString)
Q_GLOBAL_STATIC(QStringList, null_QStringList)
Q_GLOBAL_STATIC(QList<Text>, null_QList_Text)
-Q_GLOBAL_STATIC(QStringMap, null_QStringMap)
+//Q_GLOBAL_STATIC(QStringMap, null_QStringMap)
Q_GLOBAL_STATIC(QStringMultiMap, null_QStringMultiMap)
struct Macro
@@ -1861,7 +1861,7 @@ void DocParser::startSection(Doc::Sections unit, int cmd)
}
-void DocParser::endSection(int unit, int endCmd)
+void DocParser::endSection(int , int) // (int unit, int endCmd)
{
leavePara();
append(Atom::SectionRight, QString::number(currentSection));
diff --git a/tools/qdoc3/generator.h b/tools/qdoc3/generator.h
index e5e9747..d4fe76f 100644
--- a/tools/qdoc3/generator.h
+++ b/tools/qdoc3/generator.h
@@ -57,6 +57,10 @@
QT_BEGIN_NAMESPACE
+typedef QMap<QString, NodeMultiMap> NewSinceMaps;
+typedef QMap<Node*, NodeMultiMap> ParentMaps;
+typedef QMap<QString, NodeMap> NewClassMaps;
+
class ClassNode;
class Config;
class CodeMarker;
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 52da178..a64518d 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -276,6 +276,7 @@ void HtmlGenerator::generateTree(const Tree *tree)
generatePageIndex(outputDir() + "/" + fileBase + ".pageindex");
helpProjectWriter->generate(myTree);
+ generateManifestFile();
}
void HtmlGenerator::startText(const Node * /* relative */,
@@ -331,8 +332,10 @@ int HtmlGenerator::generateAtom(const Atom *atom,
break;
case Atom::BriefLeft:
if (relative->type() == Node::Fake) {
- skipAhead = skipAtoms(atom, Atom::BriefRight);
- break;
+ if (relative->subType() != Node::Example) {
+ skipAhead = skipAtoms(atom, Atom::BriefRight);
+ break;
+ }
}
out() << "<p>";
@@ -765,6 +768,15 @@ int HtmlGenerator::generateAtom(const Atom *atom,
out() << " alt=\"" << protectEnc(text) << "\"";
out() << " />";
helpProjectWriter->addExtraFile(fileName);
+ if ((relative->type() == Node::Fake) &&
+ (relative->subType() == Node::Example)) {
+ const ExampleNode* cen = static_cast<const ExampleNode*>(relative);
+ if (cen->imageFileName().isEmpty()) {
+ ExampleNode* en = const_cast<ExampleNode*>(cen);
+ en->setImageFileName(fileName);
+ ExampleNode::exampleNodeMap.insert(en->title(),en);
+ }
+ }
}
if (atom->type() == Atom::Image)
out() << "</p>";
@@ -1792,7 +1804,6 @@ void HtmlGenerator::generateTableOfContents(const Node *node,
toc = node->doc().tableOfContents();
if (toc.isEmpty() && !sections && (node->subType() != Node::Module))
return;
- bool debug = false;
QStringList sectionNumber;
int detailsBase = 0;
@@ -3779,8 +3790,6 @@ void HtmlGenerator::endLink()
inObsoleteLink = false;
}
-#ifdef QDOC_QML
-
/*!
Generates the summary for the \a section. Only used for
sections of QML element documentation.
@@ -4266,7 +4275,6 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node)
return "";
}
else if (node->type() == Node::Fake) {
-#ifdef QDOC_QML
if ((node->subType() == Node::QmlClass) ||
(node->subType() == Node::QmlBasicType)) {
QString fb = node->fileBase();
@@ -4274,9 +4282,9 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node)
return fb + ".html";
else
return Generator::outputPrefix(QLatin1String("QML")) + node->fileBase() + QLatin1String(".html");
- } else
-#endif
- parentName = node->fileBase() + ".html";
+ }
+ else
+ parentName = node->fileBase() + ".html";
}
else if (node->fileBase().isEmpty())
return "";
@@ -4387,6 +4395,74 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node)
return parentName.toLower() + anchorRef;
}
-#endif
+void HtmlGenerator::generateManifestFile()
+{
+ if (ExampleNode::exampleNodeMap.isEmpty())
+ return;
+ QString fileName = "examples-manifest.xml";
+ QFile file(outputDir() + "/" + fileName);
+ if (!file.open(QFile::WriteOnly | QFile::Text))
+ return ;
+
+ QXmlStreamWriter writer(&file);
+ writer.setAutoFormatting(true);
+ writer.writeStartDocument();
+ writer.writeStartElement("instructionals");
+ writer.writeAttribute("module", project);
+ writer.writeStartElement("examples");
+
+ ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin();
+ while (i != ExampleNode::exampleNodeMap.end()) {
+ const ExampleNode* en = i.value();
+ writer.writeStartElement("example");
+ writer.writeAttribute("name", en->title());
+ QString docUrl = projectUrl + "/" + en->fileBase() + ".html";
+ writer.writeAttribute("docUrl", docUrl);
+ foreach (const Node* child, en->childNodes()) {
+ if (child->subType() == Node::File) {
+ QString file = child->name();
+ if (file.endsWith(".pro"))
+ writer.writeAttribute("projectPath", "./" + file);
+ }
+ }
+ writer.writeAttribute("imageUrl", projectUrl + "/" + en->imageFileName());
+ Text brief = en->doc().briefText();
+ if (!brief.isEmpty()) {
+ writer.writeStartElement("description");
+ writer.writeCharacters(brief.toString());
+ writer.writeEndElement(); // description
+ }
+ QStringList tags = en->title().toLower().split(" ");
+ if (!tags.isEmpty()) {
+ writer.writeStartElement("tags");
+ bool wrote_one = false;
+ for (int n=0; n<tags.size(); ++n) {
+ QString tag = tags.at(n);
+ if (tag.at(0).isDigit())
+ continue;
+ if (tag.at(0) == '-')
+ continue;
+ if (tag.startsWith("example"))
+ continue;
+ if (tag.startsWith("chapter"))
+ continue;
+ if (tag.endsWith(":"))
+ tag.chop(1);
+ if (n>0 && wrote_one)
+ writer.writeCharacters(",");
+ writer.writeCharacters(tag);
+ wrote_one = true;
+ }
+ writer.writeEndElement(); // tags
+ }
+ writer.writeEndElement(); // example
+ ++i;
+ }
+
+ writer.writeEndElement(); // examples
+ writer.writeEndElement(); // instructionals
+ writer.writeEndDocument();
+ file.close();
+}
QT_END_NAMESPACE
diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h
index 70ec0b7..153a9cf 100644
--- a/tools/qdoc3/htmlgenerator.h
+++ b/tools/qdoc3/htmlgenerator.h
@@ -93,6 +93,7 @@ class HtmlGenerator : public PageGenerator
virtual void terminateGenerator();
virtual QString format();
virtual void generateTree(const Tree *tree);
+ void generateManifestFile();
QString protectEnc(const QString &string);
static QString protect(const QString &string, const QString &encoding = "ISO-8859-1");
diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp
index 683c210..e14b08d 100644
--- a/tools/qdoc3/node.cpp
+++ b/tools/qdoc3/node.cpp
@@ -39,10 +39,6 @@
**
****************************************************************************/
-/*
- node.cpp
-*/
-
#include "node.h"
#include "tree.h"
#include "codemarker.h"
@@ -51,6 +47,8 @@
QT_BEGIN_NAMESPACE
+ExampleNodeMap ExampleNode::exampleNodeMap;
+
/*!
\class Node
\brief The Node class is a node in the Tree.
@@ -1062,6 +1060,16 @@ QString FakeNode::subTitle() const
}
/*!
+ The constructor calls the FakeNode constructor with
+ \a parent, \a name, and Node::Example.
+ */
+ExampleNode::ExampleNode(InnerNode* parent, const QString& name)
+ : FakeNode(parent, name, Node::Example)
+{
+ // nothing
+}
+
+/*!
\class EnumNode
*/
@@ -1683,6 +1691,7 @@ bool QmlPropertyNode::fromTrool(Trool troolean, bool defaultValue)
}
}
+#if 0
static QString valueType(const QString &n)
{
if (n == "QPoint")
@@ -1713,6 +1722,7 @@ static QString valueType(const QString &n)
return "QDeclarativeFontValueType";
return QString();
}
+#endif
/*!
Returns true if a QML property or attached property is
diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h
index e1e9440..2887923 100644
--- a/tools/qdoc3/node.h
+++ b/tools/qdoc3/node.h
@@ -58,7 +58,13 @@
QT_BEGIN_NAMESPACE
+class Node;
class InnerNode;
+class ExampleNode;
+
+typedef QMap<QString, const Node*> NodeMap;
+typedef QMultiMap<QString, Node*> NodeMultiMap;
+typedef QMap<QString, const ExampleNode*> ExampleNodeMap;
class Node
{
@@ -380,8 +386,10 @@ class FakeNode : public InnerNode
virtual QString title() const;
virtual QString fullTitle() const;
virtual QString subTitle() const;
+ virtual QString imageFileName() const { return QString(); }
const NodeList &groupMembers() const { return gr; }
virtual QString nameForLists() const { return title(); }
+ virtual void setImageFileName(const QString& ) { }
private:
SubType sub;
@@ -390,7 +398,21 @@ class FakeNode : public InnerNode
NodeList gr;
};
-#ifdef QDOC_QML
+class ExampleNode : public FakeNode
+{
+ public:
+ ExampleNode(InnerNode* parent, const QString& name);
+ virtual ~ExampleNode() { }
+ virtual QString imageFileName() const { return imageFileName_; }
+ virtual void setImageFileName(const QString& ifn) { imageFileName_ = ifn; }
+
+ public:
+ static ExampleNodeMap exampleNodeMap;
+
+ private:
+ QString imageFileName_;
+};
+
class QmlClassNode : public FakeNode
{
public:
@@ -482,7 +504,6 @@ class QmlPropertyNode : public LeafNode
Trool wri;
bool att;
};
-#endif
class EnumItem
{