summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/htmlgenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qdoc3/htmlgenerator.cpp')
-rw-r--r--tools/qdoc3/htmlgenerator.cpp199
1 files changed, 186 insertions, 13 deletions
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 52da178..e79e180 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -80,7 +80,7 @@ QString HtmlGenerator::sinceTitles[] =
" New Variables",
" New QML Elements",
" New QML Properties",
- " New QML Signals",
+ " New QML Signal Handlers",
" New QML Methods",
""
};
@@ -180,6 +180,9 @@ void HtmlGenerator::initializeGenerator(const Config &config)
pleaseGenerateMacRef = config.getBool(HtmlGenerator::format() +
Config::dot +
HTMLGENERATOR_GENERATEMACREFS);
+ noBreadCrumbs = config.getBool(HtmlGenerator::format() +
+ Config::dot +
+ HTMLGENERATOR_NOBREADCRUMBS);
project = config.getString(CONFIG_PROJECT);
@@ -276,6 +279,7 @@ void HtmlGenerator::generateTree(const Tree *tree)
generatePageIndex(outputDir() + "/" + fileBase + ".pageindex");
helpProjectWriter->generate(myTree);
+ generateManifestFiles();
}
void HtmlGenerator::startText(const Node * /* relative */,
@@ -331,8 +335,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 +771,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>";
@@ -1504,8 +1519,10 @@ void HtmlGenerator::generateBreadCrumbs(const QString &title,
const Node *node,
CodeMarker *marker)
{
+ if (noBreadCrumbs)
+ return;
+
Text breadcrumbs;
-
if (node->type() == Node::Class) {
const ClassNode *cn = static_cast<const ClassNode *>(node);
QString name = node->moduleName();
@@ -1792,7 +1809,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 +3795,6 @@ void HtmlGenerator::endLink()
inObsoleteLink = false;
}
-#ifdef QDOC_QML
-
/*!
Generates the summary for the \a section. Only used for
sections of QML element documentation.
@@ -3837,7 +3851,8 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node,
out() << "<a name=\"" + refForNode(qpn) + "\"></a>";
- if (!qpn->isWritable(myTree)) {
+ const ClassNode* cn = qpn->declarativeCppNode();
+ if (cn && !qpn->isWritable(myTree)) {
out() << "<span class=\"qmlreadonly\">read-only</span>";
}
if (qpgn->isDefault())
@@ -4266,7 +4281,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 +4288,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 +4401,165 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node)
return parentName.toLower() + anchorRef;
}
-#endif
+/*!
+ This function outputs one or more manifest files in XML.
+ They are used by Creator.
+ */
+void HtmlGenerator::generateManifestFiles()
+{
+ generateManifestFile("examples", "example");
+ generateManifestFile("demos", "demo");
+ ExampleNode::exampleNodeMap.clear();
+}
+
+/*!
+ 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 = manifest +"-manifest.xml";
+ QFile file(outputDir() + "/" + fileName);
+ if (!file.open(QFile::WriteOnly | QFile::Text))
+ return ;
+ bool demos = false;
+ if (manifest == "demos")
+ demos = true;
+
+ bool proceed = false;
+ ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin();
+ while (i != ExampleNode::exampleNodeMap.end()) {
+ const ExampleNode* en = i.value();
+ if (demos) {
+ if (en->name().startsWith("demos")) {
+ proceed = true;
+ break;
+ }
+ }
+ else if (!en->name().startsWith("demos")) {
+ proceed = true;
+ break;
+ }
+ ++i;
+ }
+ if (!proceed)
+ return;
+
+ QXmlStreamWriter writer(&file);
+ writer.setAutoFormatting(true);
+ writer.writeStartDocument();
+ writer.writeStartElement("instructionals");
+ writer.writeAttribute("module", project);
+ writer.writeStartElement(manifest);
+
+ i = ExampleNode::exampleNodeMap.begin();
+ while (i != ExampleNode::exampleNodeMap.end()) {
+ const ExampleNode* en = i.value();
+ 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 = "%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") || 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", "%REPLACEME%/" + en->imageFileName());
+ writer.writeStartElement("description");
+ Text brief = en->doc().briefText();
+ 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");
+ 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
+ }
+
+ 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");
+ if (file.startsWith("demos/"))
+ file = file.mid(6);
+ writer.writeCharacters(file);
+ 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");
+ if (file.startsWith("demos/"))
+ file = file.mid(6);
+ writer.writeCharacters(file);
+ writer.writeEndElement(); // fileToOpen
+ usedNames.insert(fileName);
+ }
+ }
+ }
+ }
+ writer.writeEndElement(); // example
+ ++i;
+ }
+
+ writer.writeEndElement(); // examples
+ writer.writeEndElement(); // instructionals
+ writer.writeEndDocument();
+ file.close();
+}
QT_END_NAMESPACE