From ed73f806928760ace1d4c7c2a6327875725bcb05 Mon Sep 17 00:00:00 2001
From: Martin Smith
Date: Sat, 18 Sep 2010 13:37:32 +0200
Subject: qdoc: DITA XML generator now uses elements...
...instead of elements with the outputclass attribute
set to some h value. Also added some missing macros to
qt-ditaxml.qdocconf, but there is more to think about here.
---
src/corelib/tools/qeasingcurve.cpp | 20 +-
tools/qdoc3/ditaxmlgenerator.cpp | 354 +++++++++++++++++++----------------
tools/qdoc3/ditaxmlgenerator.h | 7 +
tools/qdoc3/generator.cpp | 72 +++----
tools/qdoc3/generator.h | 3 +-
tools/qdoc3/test/qt-ditaxml.qdocconf | 31 +++
6 files changed, 270 insertions(+), 217 deletions(-)
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 7fe9170..aee9356 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -92,14 +92,18 @@
animation.setEasingCurve(QEasingCurve::InOutQuad);
\endcode
- The ability to set an amplitude, overshoot, or period depends on the QEasingCurve type. Amplitude access
- is available to curves that behave as springs such as elastic and bounce curves. Changing the amplitude changes
- the height of the curve. Period access is only available to elastic curves and setting a higher period slows
- the rate of bounce. Only curves that have "boomerang" behaviors such as the InBack, OutBack, InOutBack, and OutInBack
- have overshoot settings. These curves will interpolate beyond the end points and return to the end point,
- acting similar to a boomerang.
-
- The \l{Easing Curves Example} contains samples of QEasingCurve types and lets you change the curve settings.
+ The ability to set an amplitude, overshoot, or period depends on
+ the QEasingCurve type. Amplitude access is available to curves
+ that behave as springs such as elastic and bounce curves. Changing
+ the amplitude changes the height of the curve. Period access is
+ only available to elastic curves and setting a higher period slows
+ the rate of bounce. Only curves that have "boomerang" behaviors
+ such as the InBack, OutBack, InOutBack, and OutInBack have
+ overshoot settings. These curves will interpolate beyond the end
+ points and return to the end point, acting similar to a boomerang.
+
+ The \l{Easing Curves Example} contains samples of QEasingCurve
+ types and lets you change the curve settings.
*/
diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp
index 90b2f06..9c70cb5 100644
--- a/tools/qdoc3/ditaxmlgenerator.cpp
+++ b/tools/qdoc3/ditaxmlgenerator.cpp
@@ -60,6 +60,9 @@ QT_BEGIN_NAMESPACE
#define COMMAND_VERSION Doc::alias("version")
int DitaXmlGenerator::id = 0;
+bool DitaXmlGenerator::inApiDesc = false;
+bool DitaXmlGenerator::inSection = false;
+bool DitaXmlGenerator::inDetailedDescription = false;
#define cxxapi_d_xref Doc::alias("cxxapi-d-xref")
#define cxxclass Doc::alias("cxxclass")
@@ -623,7 +626,10 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
skipAhead = skipAtoms(atom, Atom::BriefRight);
break;
}
- xmlWriter().writeStartElement(SHORTDESC);
+ if (inApiDesc)
+ xmlWriter().writeStartElement("p");
+ else
+ xmlWriter().writeStartElement(SHORTDESC);
if (relative->type() == Node::Property ||
relative->type() == Node::Variable) {
QString str;
@@ -655,7 +661,7 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
break;
case Atom::BriefRight:
if (relative->type() != Node::Fake) {
- xmlWriter().writeEndElement(); //
+ xmlWriter().writeEndElement(); // or
}
break;
case Atom::C:
@@ -842,19 +848,6 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
generateAnnotatedList(fake, marker, groupMembersMap);
}
}
- else if (atom->string() == "relatedinline") {
- const FakeNode *fake = static_cast(relative);
- if (fake && !fake->groupMembers().isEmpty()) {
- // Reverse the list into the original scan order.
- // Should be sorted. But on what? It may not be a
- // regular class or page definition.
- QList list;
- foreach (const Node *node, fake->groupMembers())
- list.prepend(node);
- foreach (const Node *node, list)
- generateBody(node, marker);
- }
- }
break;
case Atom::SinceList:
{
@@ -1009,10 +1002,6 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
QString text;
if (atom->next() != 0)
text = atom->next()->string();
- if (atom->type() == Atom::Image) {
- xmlWriter().writeStartElement("p");
- xmlWriter().writeAttribute("outputclass","centerAlign");
- }
if (fileName.isEmpty()) {
xmlWriter().writeStartElement("font");
xmlWriter().writeAttribute("color","red");
@@ -1021,14 +1010,23 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
xmlWriter().writeEndElement(); //
}
else {
- xmlWriter().writeStartElement("img");
- xmlWriter().writeAttribute("src",protectEnc(fileName));
- if (!text.isEmpty())
- xmlWriter().writeAttribute("alt",protectEnc(text));
- xmlWriter().writeEndElement(); //
+ xmlWriter().writeStartElement("fig");
+ xmlWriter().writeStartElement("image");
+ xmlWriter().writeAttribute("href",protectEnc(fileName));
+ if (atom->type() == Atom::InlineImage)
+ xmlWriter().writeAttribute("placement","inline");
+ else {
+ xmlWriter().writeAttribute("placement","break");
+ xmlWriter().writeAttribute("align","center");
+ }
+ if (!text.isEmpty()) {
+ xmlWriter().writeStartElement("alt");
+ xmlWriter().writeCharacters(protectEnc(text));
+ xmlWriter().writeEndElement(); //
+ }
+ xmlWriter().writeEndElement(); //
+ xmlWriter().writeEndElement(); //
}
- if (atom->type() == Atom::Image)
- xmlWriter().writeEndElement(); //
}
break;
case Atom::ImageText:
@@ -1221,7 +1219,7 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
case Atom::ParaRight:
endLink();
if (in_para) {
- xmlWriter().writeEndElement(); //
in_para = false;
}
break;
@@ -1235,23 +1233,28 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
xmlWriter().writeCharacters(atom->string());
break;
case Atom::SectionLeft:
- xmlWriter().writeStartElement("p");
+ if (inSection || inApiDesc) {
+ inApiDesc = false;
+ xmlWriter().writeEndElement(); // or
+ }
+ inSection = true;
+ xmlWriter().writeStartElement("section");
writeGuidAttribute(Doc::canonicalTitle(Text::sectionHeading(atom).toString()));
- xmlWriter().writeAttribute("outputclass","target");
- xmlWriter().writeCharacters(protectEnc(Text::sectionHeading(atom).toString()));
- xmlWriter().writeEndElement(); //
break;
case Atom::SectionRight:
- // nothing
+ if (inSection) {
+ inSection = false;
+ xmlWriter().writeEndElement(); //
+ }
break;
case Atom::SectionHeadingLeft:
- xmlWriter().writeStartElement("p");
+ xmlWriter().writeStartElement("title");
hx = "h" + QString::number(atom->string().toInt() + hOffset(relative));
xmlWriter().writeAttribute("outputclass",hx);
inSectionHeading = true;
break;
case Atom::SectionHeadingRight:
- xmlWriter().writeEndElement(); // (see case Atom::SectionHeadingLeft)
+ xmlWriter().writeEndElement(); // (see case Atom::SectionHeadingLeft)
inSectionHeading = false;
break;
case Atom::SidebarLeft:
@@ -1470,20 +1473,10 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark
writeLocation(cn);
xmlWriter().writeEndElement(); //
- xmlWriter().writeStartElement(APIDESC);
- if (!inner->doc().isEmpty()) {
- xmlWriter().writeStartElement("p");
- xmlWriter().writeAttribute("outputclass","h2");
- xmlWriter().writeCharacters("Detailed Description");
- xmlWriter().writeEndElement(); //
- generateBody(inner, marker);
- // generateAlsoList(inner, marker);
- }
-
- xmlWriter().writeEndElement(); //
-
- // not included: , , or
+ writeDetailSections(cn, marker, true, QString("Detailed Description"));
+ // zzz writeSections() gores here.
+ // not included: or
xmlWriter().writeEndElement(); //
@@ -1610,13 +1603,54 @@ void DitaXmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker
xmlWriter().writeEndElement(); //
}
+ else if (fake->subType() == Node::QmlClass) {
+ const QmlClassNode* qml_cn = static_cast(fake);
+ const ClassNode* cn = qml_cn->classNode();
+ generateQmlInherits(qml_cn, marker);
+ generateQmlInstantiates(qml_cn, marker);
+ generateBrief(qml_cn, marker);
+ generateQmlInheritedBy(qml_cn, marker);
+ sections = marker->qmlSections(qml_cn,CodeMarker::Summary,0);
+ s = sections.begin();
+ while (s != sections.end()) {
+ writeTargetAndHeader((*s).name,protectEnc((*s).name),"h2");
+ generateQmlSummary(*s,fake,marker);
+ ++s;
+ }
+
+ writeDetailSections(fake, marker, false, QString("Detailed Description"));
+
+ if (cn)
+ generateQmlText(cn->doc().body(), cn, marker, fake->name());
+
+ generateAlsoList(fake, marker);
+ //out() << "
\n";
+
+ sections = marker->qmlSections(qml_cn,CodeMarker::Detailed,0);
+ s = sections.begin();
+ while (s != sections.end()) {
+ xmlWriter().writeStartElement("p");
+ xmlWriter().writeAttribute("outputclass","h2");
+ xmlWriter().writeCharacters(protectEnc((*s).name));
+ xmlWriter().writeEndElement(); //
+ NodeList::ConstIterator m = (*s).members.begin();
+ while (m != (*s).members.end()) {
+ generateDetailedQmlMember(*m, fake, marker);
+ //out() << "
\n";
+ ++m;
+ }
+ ++s;
+ }
+ return;
+ }
if (!fake->doc().isEmpty()) {
xmlWriter().writeStartElement("body");
if (fake->subType() == Node::Module) {
- writeTargetAndHeader("details","Detailed Description","h2");
+ writeDetailSections(fake, marker, false, QString("Detailed Description"));
}
- generateBody(fake, marker);
+ else
+ writeDetailSections(fake, marker, false, QString());
generateAlsoList(fake, marker);
if (!fake->groupMembers().isEmpty()) {
@@ -1649,44 +1683,6 @@ zzz
marker);
- else if (fake->subType() == Node::QmlClass) {
- const QmlClassNode* qml_cn = static_cast(fake);
- const ClassNode* cn = qml_cn->classNode();
- generateQmlInherits(qml_cn, marker);
- generateQmlInstantiates(qml_cn, marker);
- generateBrief(qml_cn, marker);
- generateQmlInheritedBy(qml_cn, marker);
- sections = marker->qmlSections(qml_cn,CodeMarker::Summary,0);
- s = sections.begin();
- while (s != sections.end()) {
- out() << "\n";
- out() << "" << protectEnc((*s).name) << "
\n";
- generateQmlSummary(*s,fake,marker);
- ++s;
- }
-
- out() << "\n";
- out() << "" << "Detailed Description" << "
\n";
- generateBody(fake, marker);
- if (cn)
- generateQmlText(cn->doc().body(), cn, marker, fake->name());
- generateAlsoList(fake, marker);
- out() << "
\n";
-
- sections = marker->qmlSections(qml_cn,CodeMarker::Detailed,0);
- s = sections.begin();
- while (s != sections.end()) {
- out() << "" << protectEnc((*s).name) << "
\n";
- NodeList::ConstIterator m = (*s).members.begin();
- while (m != (*s).members.end()) {
- generateDetailedQmlMember(*m, fake, marker);
- out() << "
\n";
- ++m;
- }
- ++s;
- }
- return;
- }
#endif
#if 0
@@ -1880,7 +1876,7 @@ void DitaXmlGenerator::generateHeader(const Node* node, const QString& name)
outputclass = "externalpage";
break;
case Node::QmlClass:
- outputclass = "QML";
+ outputclass = "QML-class";
break;
default:
outputclass = "page";
@@ -1889,7 +1885,6 @@ void DitaXmlGenerator::generateHeader(const Node* node, const QString& name)
xmlWriter().writeDTD(doctype);
xmlWriter().writeComment(node->doc().location().fileName());
-
xmlWriter().writeStartElement(mainElement);
xmlWriter().writeAttribute("id",node->guid());
if (!outputclass.isEmpty())
@@ -2180,7 +2175,13 @@ QString DitaXmlGenerator::generateListOfAllMemberFile(const InnerNode* inner,
QString title = "List of All Members for " + inner->name();
generateHeader(inner, title);
xmlWriter().writeStartElement("body");
- generateTitle(title, Text(), SmallSubTitle, inner, marker);
+ xmlWriter().writeStartElement("section");
+ if (!title.isEmpty()) {
+ xmlWriter().writeStartElement("title");
+ xmlWriter().writeAttribute("outputclass", "h1");
+ xmlWriter().writeCharacters(protectEnc(title));
+ xmlWriter().writeEndElement(); //
+ }
xmlWriter().writeStartElement("p");
xmlWriter().writeCharacters("This is the complete list of members for ");
generateFullName(inner, 0, marker);
@@ -2189,6 +2190,7 @@ QString DitaXmlGenerator::generateListOfAllMemberFile(const InnerNode* inner,
Section section = sections.first();
generateSection(section.members, 0, marker, CodeMarker::SeparateList);
+ xmlWriter().writeEndElement(); //
xmlWriter().writeEndElement(); //