summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/ditaxmlgenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qdoc3/ditaxmlgenerator.cpp')
-rw-r--r--tools/qdoc3/ditaxmlgenerator.cpp240
1 files changed, 221 insertions, 19 deletions
diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp
index 197bc13..e80f948 100644
--- a/tools/qdoc3/ditaxmlgenerator.cpp
+++ b/tools/qdoc3/ditaxmlgenerator.cpp
@@ -501,19 +501,18 @@ QString DitaXmlGenerator::format()
}
/*!
- Create a new GUID, write it to the XML stream
- as an "id" attribute, and return it.
+ Calls lookupGuid() to get a GUID for \a text, then writes
+ it to the XML stream as an "id" attribute, and returns it.
*/
QString DitaXmlGenerator::writeGuidAttribute(QString text)
{
- QString guid = QUuid::createUuid().toString();
- name2guidMap.insert(text,guid);
+ QString guid = lookupGuid(text);
writer.writeAttribute("id",guid);
return guid;
}
/*!
- Looks up \a text in the GUID map. It it finds \a text,
+ Looks up \a text in the GUID map. If it finds \a text,
it returns the associated GUID. Otherwise it inserts
\a text into the map with a new GUID, and it returns
the new GUID.
@@ -1424,7 +1423,7 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark
generateHeader(inner);
writer.writeStartElement(CXXCLASS);
- writeGuidAttribute(fullTitle);
+ writer.writeAttribute("id",cn->guid());
writer.writeStartElement(APINAME);
writer.writeCharacters(fullTitle);
writer.writeEndElement(); // </apiName>
@@ -1436,6 +1435,12 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark
writer.writeStartElement(CXXCLASSACCESSSPECIFIER);
writer.writeAttribute("value",inner->accessString());
writer.writeEndElement(); // <cxxClassAccessSpecifier>
+ if (cn->isAbstract()) {
+ writer.writeStartElement(CXXCLASSABSTRACT);
+ writer.writeAttribute("name","abstract");
+ writer.writeAttribute("value","abstract");
+ writer.writeEndElement(); // </cxxClassAbstract>
+ }
writeDerivations(cn, marker);
writeLocation(cn, marker);
writer.writeEndElement(); // <cxxClassDefinition>
@@ -1452,6 +1457,26 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark
writer.writeEndElement(); // </apiDesc>
writer.writeEndElement(); // </cxxClassDetail>
+
+ sections = marker->sections(inner, CodeMarker::Detailed, CodeMarker::Okay);
+ s = sections.begin();
+ while (s != sections.end()) {
+ if ((*s).name == "Member Function Documentation") {
+ writeFunctions((*s),cn,marker);
+ }
+ else if ((*s).name == "Member Type Documentation") {
+ writeNestedClasses((*s),cn,marker);
+ writeEnumerations((*s),cn,marker);
+ writeTypedefs((*s),cn,marker);
+ }
+ else if ((*s).name == "Member Variable Documentation") {
+ writeDataMembers((*s),cn,marker);
+ }
+ else if ((*s).name == "Property Documentation") {
+ writeProperties((*s),cn,marker);
+ }
+ ++s;
+ }
writer.writeEndElement(); // </cxxClass>
}
@@ -4475,6 +4500,31 @@ void DitaXmlGenerator::generatePageIndex(const QString& fileName, CodeMarker* ma
#endif
+/*!
+ Return the full qualification of the node \a n, but without
+ the name of \a n itself. e.g. A::B::C
+ */
+QString DitaXmlGenerator::fullQualification(const Node* n)
+{
+ QString fq;
+ InnerNode* in = n->parent();
+ while (in) {
+ if ((in->type() == Node::Class) ||
+ (in->type() == Node::Namespace)) {
+ if (in->name().isEmpty())
+ break;
+ if (fq.isEmpty())
+ fq = in->name();
+ else
+ fq = in->name() + "::" + fq;
+ }
+ else
+ break;
+ in = in->parent();
+ }
+ return fq;
+}
+
void DitaXmlGenerator::writeDerivations(const ClassNode* cn, CodeMarker* marker)
{
QList<RelatedClass>::ConstIterator r;
@@ -4490,10 +4540,8 @@ void DitaXmlGenerator::writeDerivations(const ClassNode* cn, CodeMarker* marker)
writer.writeAttribute("value",(*r).accessString());
writer.writeEndElement(); // </cxxClassDerivationAccessSpecifier>
writer.writeStartElement(CXXCLASSBASECLASS);
- QString fullTitle = marker->plainFullName((*r).node);
- QString guid = lookupGuid(fullTitle);
- writer.writeAttribute("href",guid);
- writer.writeCharacters(fullTitle);
+ writer.writeAttribute("href",(*r).node->ditaXmlHref());
+ writer.writeCharacters(marker->plainFullName((*r).node));
writer.writeEndElement(); // </cxxClassBaseClass>
writer.writeEndElement(); // </cxxClassDerivation>
++r;
@@ -4502,19 +4550,173 @@ void DitaXmlGenerator::writeDerivations(const ClassNode* cn, CodeMarker* marker)
}
}
-void DitaXmlGenerator::writeLocation(const ClassNode* cn, CodeMarker* marker)
+void DitaXmlGenerator::writeLocation(const Node* n, CodeMarker* marker)
{
- writer.writeStartElement(CXXCLASSAPIITEMLOCATION);
- writer.writeStartElement(CXXCLASSDECLARATIONFILE);
+ QString s1, s2, s3;
+ if (n->type() == Node::Class) {
+ s1 = CXXCLASSAPIITEMLOCATION;
+ s2 = CXXCLASSDECLARATIONFILE;
+ s3 = CXXCLASSDECLARATIONFILELINE;
+ }
+ else if (n->type() == Node::Function) {
+ s1 = CXXFUNCTIONAPIITEMLOCATION;
+ s2 = CXXFUNCTIONDECLARATIONFILE;
+ s3 = CXXFUNCTIONDECLARATIONFILELINE;
+ }
+ writer.writeStartElement(s1);
+ writer.writeStartElement(s2);
writer.writeAttribute("name","filePath");
- writer.writeAttribute("value",cn->location().filePath());
- writer.writeEndElement(); // </cxxClassDeclarationFile>
- writer.writeStartElement(CXXCLASSDECLARATIONFILELINE);
+ writer.writeAttribute("value",n->location().filePath());
+ writer.writeEndElement(); // </cxx<s2>DeclarationFile>
+ writer.writeStartElement(s3);
writer.writeAttribute("name","lineNumber");
QString lineNr;
- writer.writeAttribute("value",lineNr.setNum(cn->location().lineNo()));
- writer.writeEndElement(); // </cxxClassDeclarationFileLine>
- writer.writeEndElement(); // </cxxClassApiItemLocation>
+ writer.writeAttribute("value",lineNr.setNum(n->location().lineNo()));
+ writer.writeEndElement(); // </cxx<s3>DeclarationFileLine>
+ writer.writeEndElement(); // </cxx<s1>ApiItemLocation>
+}
+
+void DitaXmlGenerator::writeFunctions(const Section& s,
+ const ClassNode* cn,
+ CodeMarker* marker)
+{
+ NodeList::ConstIterator m = s.members.begin();
+ while (m != s.members.end()) {
+ if ((*m)->type() == Node::Function) {
+ const FunctionNode* fn = reinterpret_cast<const FunctionNode*>(*m);
+ QString name = fn->name();
+ writer.writeStartElement(CXXFUNCTION);
+ writeGuidAttribute(name);
+ writer.writeStartElement(APINAME);
+ writer.writeCharacters(name);
+ writer.writeEndElement(); // </apiName>
+ generateBrief(fn,marker);
+ writer.writeStartElement(CXXFUNCTIONDETAIL);
+ writer.writeStartElement(CXXFUNCTIONDEFINITION);
+ writer.writeStartElement(CXXFUNCTIONACCESSSPECIFIER);
+ writer.writeAttribute("value",fn->accessString());
+ writer.writeEndElement(); // <cxxFunctionAccessSpecifier>
+
+ if (fn->isStatic()) {
+ writer.writeStartElement(CXXFUNCTIONSTORAGECLASSSPECIFIERSTATIC);
+ writer.writeAttribute("name","static");
+ writer.writeAttribute("value","static");
+ writer.writeEndElement(); // <cxxFunctionStorageClassSpecifierStatic>
+ }
+
+ if (fn->isConst()) {
+ writer.writeStartElement(CXXFUNCTIONCONST);
+ writer.writeAttribute("name","const");
+ writer.writeAttribute("value","const");
+ writer.writeEndElement(); // <cxxFunctionConst>
+ }
+
+ if (fn->virtualness() != FunctionNode::NonVirtual) {
+ writer.writeStartElement(CXXFUNCTIONVIRTUAL);
+ writer.writeAttribute("name","virtual");
+ writer.writeAttribute("value","virtual");
+ writer.writeEndElement(); // <cxxFunctionVirtual>
+ if (fn->virtualness() == FunctionNode::PureVirtual) {
+ writer.writeStartElement(CXXFUNCTIONPUREVIRTUAL);
+ writer.writeAttribute("name","pure virtual");
+ writer.writeAttribute("value","pure virtual");
+ writer.writeEndElement(); // <cxxFunctionPureVirtual>
+ }
+ }
+
+ if (fn->name() == cn->name()) {
+ writer.writeStartElement(CXXFUNCTIONCONSTRUCTOR);
+ writer.writeAttribute("name","constructor");
+ writer.writeAttribute("value","constructor");
+ writer.writeEndElement(); // <cxxFunctionConstructor>
+ }
+ else if (fn->name()[0] == QChar('~')) {
+ writer.writeStartElement(CXXFUNCTIONDESTRUCTOR);
+ writer.writeAttribute("name","destructor");
+ writer.writeAttribute("value","destructor");
+ writer.writeEndElement(); // <cxxFunctionDestructor>
+ }
+ else {
+ writer.writeStartElement(CXXFUNCTIONDECLAREDTYPE);
+ writer.writeCharacters(fn->returnType());
+ writer.writeEndElement(); // <cxxFunctionDeclaredType>
+ }
+ QString fq = fullQualification(fn);
+ if (!fq.isEmpty()) {
+ writer.writeStartElement(CXXFUNCTIONSCOPEDNAME);
+ writer.writeCharacters(fq);
+ writer.writeEndElement(); // <cxxFunctionScopedName>
+ }
+ writer.writeStartElement(CXXFUNCTIONPROTOTYPE);
+ writer.writeCharacters(fn->signature(true));
+ writer.writeEndElement(); // <cxxFunctionPrototype>
+
+ QString fnl = fn->signature(false);
+ int idx = fnl.indexOf(' ');
+ if (idx < 0)
+ idx = 0;
+ else
+ ++idx;
+ fnl = fn->parent()->name() + "::" + fnl.mid(idx);
+ writer.writeStartElement(CXXFUNCTIONNAMELOOKUP);
+ writer.writeCharacters(fnl);
+ writer.writeEndElement(); // <cxxFunctionNameLookup>
+
+ //writer.writeStartElement(CXXFUNCTIONREIMPLEMENTED);
+ //writer.writeAttribute("href", zzz);
+ //writer.writeCharacters();
+ //writer.writeEndElement(); // </cxxFunctionReimplemented>
+
+ writeLocation(fn, marker);
+ writer.writeEndElement(); // <cxxFunctionDefinition>
+ writer.writeStartElement(APIDESC);
+
+ if (!fn->doc().isEmpty()) {
+ generateBody(fn, marker);
+ // generateAlsoList(inner, marker);
+ }
+
+ writer.writeEndElement(); // </apiDesc>
+ writer.writeEndElement(); // </cxxFunctionDetail>
+ writer.writeEndElement(); // </cxxFunction>
+
+ if (fn->metaness() == FunctionNode::Ctor ||
+ fn->metaness() == FunctionNode::Dtor ||
+ fn->overloadNumber() != 1) {
+ }
+ }
+ ++m;
+ }
+}
+
+void DitaXmlGenerator::writeNestedClasses(const Section& s,
+ const ClassNode* cn,
+ CodeMarker* marker)
+{
+}
+
+void DitaXmlGenerator::writeEnumerations(const Section& s,
+ const ClassNode* cn,
+ CodeMarker* marker)
+{
+}
+
+void DitaXmlGenerator::writeTypedefs(const Section& s,
+ const ClassNode* cn,
+ CodeMarker* marker)
+{
+}
+
+void DitaXmlGenerator::writeDataMembers(const Section& s,
+ const ClassNode* cn,
+ CodeMarker* marker)
+{
+}
+
+void DitaXmlGenerator::writeProperties(const Section& s,
+ const ClassNode* cn,
+ CodeMarker* marker)
+{
}
QT_END_NAMESPACE