summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@nokia.com>2011-08-10 10:28:04 (GMT)
committerMartin Smith <martin.smith@nokia.com>2011-08-10 10:28:04 (GMT)
commitcc997e664ab6cd9e6551ec8228d1585d2a46a3d2 (patch)
tree32f52abeeadd2278ad461cbd95304eecdbfc7ef0 /tools
parent99048b2664bd5271810ed7cae1dc0fd44a14fdac (diff)
downloadQt-cc997e664ab6cd9e6551ec8228d1585d2a46a3d2.zip
Qt-cc997e664ab6cd9e6551ec8228d1585d2a46a3d2.tar.gz
Qt-cc997e664ab6cd9e6551ec8228d1585d2a46a3d2.tar.bz2
qdoc3: Updates for QTBUG-20776 and QTBUG-20777
Task-number: QTBUG-20776, QTBUG-20777
Diffstat (limited to 'tools')
-rw-r--r--tools/qdoc3/cppcodeparser.cpp5
-rw-r--r--tools/qdoc3/htmlgenerator.cpp95
-rw-r--r--tools/qdoc3/htmlgenerator.h4
3 files changed, 86 insertions, 18 deletions
diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp
index 1536867..5efbcfd 100644
--- a/tools/qdoc3/cppcodeparser.cpp
+++ b/tools/qdoc3/cppcodeparser.cpp
@@ -47,7 +47,7 @@
#include <stdio.h>
#include <errno.h>
-
+#include <qdebug.h>
#include "codechunk.h"
#include "config.h"
#include "cppcodeparser.h"
@@ -2362,7 +2362,6 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake)
QStringList exampleFiles = Config::getFilesHere(fullPath,exampleNameFilter);
QString imagesPath = fullPath + "/images";
QStringList imageFiles = Config::getFilesHere(imagesPath,exampleImageFilter);
-
if (!exampleFiles.isEmpty()) {
// move main.cpp and to the end, if it exists
QString mainCpp;
@@ -2382,7 +2381,7 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake)
exampleFiles.append(mainCpp);
// add any qmake Qt resource files and qmake project files
- exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro qmldir");
+ exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro *.qmlproject qmldir");
}
foreach (const QString &exampleFile, exampleFiles)
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index bdb2e44..c7b6490 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -279,7 +279,7 @@ void HtmlGenerator::generateTree(const Tree *tree)
generatePageIndex(outputDir() + "/" + fileBase + ".pageindex");
helpProjectWriter->generate(myTree);
- generateManifestFile();
+ generateManifestFiles();
}
void HtmlGenerator::startText(const Node * /* relative */,
@@ -4400,43 +4400,78 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node)
return parentName.toLower() + anchorRef;
}
-void HtmlGenerator::generateManifestFile()
+/*!
+ This function outputs one or more manifest files in XML.
+ They are used by Creator.
+ */
+void HtmlGenerator::generateManifestFiles()
+{
+ generateManifestFile("examples", "example");
+ generateManifestFile("demos", "demo");
+}
+
+/*!
+ This function is called by generaqteManiferstFile(), once
+ for each manifest file to be generated. \a manifest is the
+ type of manifest file.
+ */
+void HtmlGenerator::generateManifestFile(QString manifest, QString element)
{
if (ExampleNode::exampleNodeMap.isEmpty())
return;
- QString fileName = "examples-manifest.xml";
+ QString fileName = manifest +"-manifest.xml";
QFile file(outputDir() + "/" + fileName);
if (!file.open(QFile::WriteOnly | QFile::Text))
return ;
+ bool demos = false;
+ if (manifest == "demos")
+ demos = true;
QXmlStreamWriter writer(&file);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement("instructionals");
writer.writeAttribute("module", project);
- writer.writeStartElement("examples");
+ writer.writeStartElement(manifest);
ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin();
while (i != ExampleNode::exampleNodeMap.end()) {
const ExampleNode* en = i.value();
- writer.writeStartElement("example");
+ if (demos) {
+ if (!en->name().startsWith("demos")) {
+ ++i;
+ continue;
+ }
+ }
+ else if (en->name().startsWith("demos")) {
+ ++i;
+ continue;
+ }
+ writer.writeStartElement(element);
writer.writeAttribute("name", en->title());
- QString docUrl = projectUrl + "/" + en->fileBase() + ".html";
+ //QString docUrl = projectUrl + "/" + en->fileBase() + ".html";
+ QString docUrl = "%REPLACEME%/" + 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);
+ if (file.endsWith(".pro") || file.endsWith(".qmlproject")) {
+ if (file.startsWith("demos/"))
+ file = file.mid(6);
+ writer.writeAttribute("projectPath", file);
+ break;
+ }
}
}
- writer.writeAttribute("imageUrl", projectUrl + "/" + en->imageFileName());
+ //writer.writeAttribute("imageUrl", projectUrl + "/" + en->imageFileName());
+ writer.writeAttribute("imageUrl", "%REPLACEME%/" + en->imageFileName());
+ writer.writeStartElement("description");
Text brief = en->doc().briefText();
- if (!brief.isEmpty()) {
- writer.writeStartElement("description");
- writer.writeCharacters(brief.toString());
- writer.writeEndElement(); // description
- }
+ if (!brief.isEmpty())
+ writer.writeCDATA(brief.toString());
+ else
+ writer.writeCDATA(QString("No description available"));
+ writer.writeEndElement(); // description
QStringList tags = en->title().toLower().split(" ");
if (!tags.isEmpty()) {
writer.writeStartElement("tags");
@@ -4460,6 +4495,38 @@ void HtmlGenerator::generateManifestFile()
}
writer.writeEndElement(); // tags
}
+
+ QString ename = en->name().mid(en->name().lastIndexOf('/')+1);
+ QSet<QString> usedNames;
+ foreach (const Node* child, en->childNodes()) {
+ if (child->subType() == Node::File) {
+ QString file = child->name();
+ QString fileName = file.mid(file.lastIndexOf('/')+1);
+ QString baseName = fileName;
+ if ((fileName.count(QChar('.')) > 0) &&
+ (fileName.endsWith(".cpp") ||
+ fileName.endsWith(".h") ||
+ fileName.endsWith(".qml")))
+ baseName.truncate(baseName.lastIndexOf(QChar('.')));
+ if (baseName.toLower() == ename) {
+ if (!usedNames.contains(fileName)) {
+ writer.writeStartElement("fileToOpen");
+ writer.writeCharacters(fileName);
+ writer.writeEndElement(); // fileToOpen
+ usedNames.insert(fileName);
+ }
+ }
+ else if (fileName.toLower().endsWith("main.cpp") ||
+ fileName.toLower().endsWith("main.qml")) {
+ if (!usedNames.contains(fileName)) {
+ writer.writeStartElement("fileToOpen");
+ writer.writeCharacters(fileName);
+ writer.writeEndElement(); // fileToOpen
+ usedNames.insert(fileName);
+ }
+ }
+ }
+ }
writer.writeEndElement(); // example
++i;
}
diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h
index d97d387..70508a0 100644
--- a/tools/qdoc3/htmlgenerator.h
+++ b/tools/qdoc3/htmlgenerator.h
@@ -93,7 +93,7 @@ class HtmlGenerator : public PageGenerator
virtual void terminateGenerator();
virtual QString format();
virtual void generateTree(const Tree *tree);
- void generateManifestFile();
+ void generateManifestFiles();
QString protectEnc(const QString &string);
static QString protect(const QString &string, const QString &encoding = "ISO-8859-1");
@@ -113,6 +113,8 @@ class HtmlGenerator : public PageGenerator
virtual QString linkForNode(const Node *node, const Node *relative);
virtual QString refForAtom(Atom *atom, const Node *node);
+ void generateManifestFile(QString manifest, QString element);
+
private:
enum SubTitleSize { SmallSubTitle, LargeSubTitle };
enum ExtractionMarkType {