diff options
author | Lorn Potter <lorn.potter@nokia.com> | 2010-06-27 23:36:19 (GMT) |
---|---|---|
committer | Lorn Potter <lorn.potter@nokia.com> | 2010-06-27 23:36:19 (GMT) |
commit | 580586d63a219bd63816071426fafec63a864d0d (patch) | |
tree | 59540e07c7e56b51d5b6275e2018c4b5cdef2c1e /tools/qdoc3/ditaxmlgenerator.cpp | |
parent | 361f409d513b7360b1a6f919799cc1948835aef3 (diff) | |
parent | 59c58576efd3ceff7add46a359fd99e56a2fb279 (diff) | |
download | Qt-580586d63a219bd63816071426fafec63a864d0d.zip Qt-580586d63a219bd63816071426fafec63a864d0d.tar.gz Qt-580586d63a219bd63816071426fafec63a864d0d.tar.bz2 |
Merge branch '4.7' of git://gitorious.org/qt/qt into 4.7
Diffstat (limited to 'tools/qdoc3/ditaxmlgenerator.cpp')
-rw-r--r-- | tools/qdoc3/ditaxmlgenerator.cpp | 384 |
1 files changed, 365 insertions, 19 deletions
diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 5f10885..0135983 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -1403,19 +1403,19 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark QList<Section>::ConstIterator s; const ClassNode* cn = 0; - const NamespaceNode *namespasse = 0; + const NamespaceNode* namespasse = 0; QString title; QString rawTitle; QString fullTitle; if (inner->type() == Node::Namespace) { - namespasse = static_cast<const NamespaceNode *>(inner); + namespasse = const_cast<NamespaceNode*>(static_cast<const NamespaceNode*>(inner)); rawTitle = marker->plainName(inner); fullTitle = marker->plainFullName(inner); title = rawTitle + " Namespace"; } else if (inner->type() == Node::Class) { - cn = static_cast<const ClassNode *>(inner); + cn = const_cast<ClassNode*>(static_cast<const ClassNode*>(inner)); rawTitle = marker->plainName(inner); fullTitle = marker->plainFullName(inner); title = rawTitle + " Class Reference"; @@ -1423,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> @@ -1442,7 +1442,7 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark writer.writeEndElement(); // </cxxClassAbstract> } writeDerivations(cn, marker); - writeLocation(cn, marker); + writeLocation(cn); writer.writeEndElement(); // <cxxClassDefinition> writer.writeStartElement(APIDESC); @@ -4540,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; @@ -4552,7 +4550,7 @@ void DitaXmlGenerator::writeDerivations(const ClassNode* cn, CodeMarker* marker) } } -void DitaXmlGenerator::writeLocation(const Node* n, CodeMarker* marker) +void DitaXmlGenerator::writeLocation(const Node* n) { QString s1, s2, s3; if (n->type() == Node::Class) { @@ -4565,6 +4563,22 @@ void DitaXmlGenerator::writeLocation(const Node* n, CodeMarker* marker) s2 = CXXFUNCTIONDECLARATIONFILE; s3 = CXXFUNCTIONDECLARATIONFILELINE; } + else if (n->type() == Node::Enum) { + s1 = CXXENUMERATIONAPIITEMLOCATION; + s2 = CXXENUMERATIONDECLARATIONFILE; + s3 = CXXENUMERATIONDECLARATIONFILELINE; + } + else if (n->type() == Node::Typedef) { + s1 = CXXTYPEDEFAPIITEMLOCATION; + s2 = CXXTYPEDEFDECLARATIONFILE; + s3 = CXXTYPEDEFDECLARATIONFILELINE; + } + else if ((n->type() == Node::Property) || + (n->type() == Node::Variable)) { + s1 = CXXVARIABLEAPIITEMLOCATION; + s2 = CXXVARIABLEDECLARATIONFILE; + s3 = CXXVARIABLEDECLARATIONFILELINE; + } writer.writeStartElement(s1); writer.writeStartElement(s2); writer.writeAttribute("name","filePath"); @@ -4585,12 +4599,11 @@ void DitaXmlGenerator::writeFunctions(const Section& s, 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(); + FunctionNode* fn = const_cast<FunctionNode*>(static_cast<const FunctionNode*>(*m)); writer.writeStartElement(CXXFUNCTION); - writeGuidAttribute(name); + writer.writeAttribute("id",fn->guid()); writer.writeStartElement(APINAME); - writer.writeCharacters(name); + writer.writeCharacters(fn->name()); writer.writeEndElement(); // </apiName> generateBrief(fn,marker); writer.writeStartElement(CXXFUNCTIONDETAIL); @@ -4663,8 +4676,16 @@ void DitaXmlGenerator::writeFunctions(const Section& s, writer.writeStartElement(CXXFUNCTIONNAMELOOKUP); writer.writeCharacters(fnl); writer.writeEndElement(); // <cxxFunctionNameLookup> - - writeLocation(fn, marker); + + if (fn->isReimp() && fn->reimplementedFrom() != 0) { + FunctionNode* rfn = (FunctionNode*)fn->reimplementedFrom(); + writer.writeStartElement(CXXFUNCTIONREIMPLEMENTED); + writer.writeAttribute("href",rfn->ditaXmlHref()); + writer.writeCharacters(marker->plainFullName(rfn)); + writer.writeEndElement(); // </cxxFunctionReimplemented> + } + writeParameters(fn,marker); + writeLocation(fn); writer.writeEndElement(); // <cxxFunctionDefinition> writer.writeStartElement(APIDESC); @@ -4686,6 +4707,34 @@ void DitaXmlGenerator::writeFunctions(const Section& s, } } +void DitaXmlGenerator::writeParameters(const FunctionNode* fn, CodeMarker* marker) +{ + const QList<Parameter>& parameters = fn->parameters(); + if (!parameters.isEmpty()) { + writer.writeStartElement(CXXFUNCTIONPARAMETERS); + QList<Parameter>::ConstIterator p = parameters.begin(); + while (p != parameters.end()) { + writer.writeStartElement(CXXFUNCTIONPARAMETER); + writer.writeStartElement(CXXFUNCTIONPARAMETERDECLAREDTYPE); + writer.writeCharacters((*p).leftType()); + if (!(*p).rightType().isEmpty()) + writer.writeCharacters((*p).rightType()); + writer.writeEndElement(); // <cxxFunctionParameterDeclaredType> + writer.writeStartElement(CXXFUNCTIONPARAMETERDECLARATIONNAME); + writer.writeCharacters((*p).name()); + writer.writeEndElement(); // <cxxFunctionParameterDeclarationName> + if (!(*p).defaultValue().isEmpty()) { + writer.writeStartElement(CXXFUNCTIONPARAMETERDEFAULTVALUE); + writer.writeCharacters((*p).defaultValue()); + writer.writeEndElement(); // <cxxFunctionParameterDefaultValue> + } + writer.writeEndElement(); // <cxxFunctionParameter> + ++p; + } + writer.writeEndElement(); // <cxxFunctionParameters> + } +} + void DitaXmlGenerator::writeNestedClasses(const Section& s, const ClassNode* cn, CodeMarker* marker) @@ -4696,24 +4745,321 @@ void DitaXmlGenerator::writeEnumerations(const Section& s, const ClassNode* cn, CodeMarker* marker) { + NodeList::ConstIterator m = s.members.begin(); + while (m != s.members.end()) { + if ((*m)->type() == Node::Enum) { + const EnumNode* en = static_cast<const EnumNode*>(*m); + writer.writeStartElement(CXXENUMERATION); + writer.writeAttribute("id",en->guid()); + writer.writeStartElement(APINAME); + writer.writeCharacters(en->name()); + writer.writeEndElement(); // </apiName> + generateBrief(en,marker); + writer.writeStartElement(CXXENUMERATIONDETAIL); + writer.writeStartElement(CXXENUMERATIONDEFINITION); + writer.writeStartElement(CXXENUMERATIONACCESSSPECIFIER); + writer.writeAttribute("value",en->accessString()); + writer.writeEndElement(); // <cxxEnumerationAccessSpecifier> + + QString fq = fullQualification(en); + if (!fq.isEmpty()) { + writer.writeStartElement(CXXENUMERATIONSCOPEDNAME); + writer.writeCharacters(fq); + writer.writeEndElement(); // <cxxEnumerationScopedName> + } + const QList<EnumItem>& items = en->items(); + if (!items.isEmpty()) { + writer.writeStartElement(CXXENUMERATIONPROTOTYPE); + writer.writeCharacters(en->name()); + writer.writeCharacters(" = { "); + QList<EnumItem>::ConstIterator i = items.begin(); + while (i != items.end()) { + writer.writeCharacters((*i).name()); + if (!(*i).value().isEmpty()) { + writer.writeCharacters(" = "); + writer.writeCharacters((*i).value()); + } + ++i; + if (i != items.end()) + writer.writeCharacters(", "); + } + writer.writeCharacters(" }"); + writer.writeEndElement(); // <cxxEnumerationPrototype> + } + + writer.writeStartElement(CXXENUMERATIONNAMELOOKUP); + writer.writeCharacters(en->parent()->name() + "::" + en->name()); + writer.writeEndElement(); // <cxxEnumerationNameLookup> + + if (!items.isEmpty()) { + writer.writeStartElement(CXXENUMERATORS); + QList<EnumItem>::ConstIterator i = items.begin(); + while (i != items.end()) { + writer.writeStartElement(CXXENUMERATOR); + writer.writeStartElement(APINAME); + writer.writeCharacters((*i).name()); + writer.writeEndElement(); // </apiName> + + QString fq = fullQualification(en->parent()); + if (!fq.isEmpty()) { + writer.writeStartElement(CXXENUMERATORSCOPEDNAME); + writer.writeCharacters(fq + "::" + (*i).name()); + writer.writeEndElement(); // <cxxEnumeratorScopedName> + } + writer.writeStartElement(CXXENUMERATORPROTOTYPE); + writer.writeCharacters((*i).name()); + writer.writeEndElement(); // <cxxEnumeratorPrototype> + writer.writeStartElement(CXXENUMERATORNAMELOOKUP); + writer.writeCharacters(en->parent()->name() + "::" + (*i).name()); + writer.writeEndElement(); // <cxxEnumeratorNameLookup> + + if (!(*i).value().isEmpty()) { + writer.writeStartElement(CXXENUMERATORINITIALISER); + writer.writeAttribute("value", (*i).value()); + writer.writeEndElement(); // <cxxEnumeratorInitialiser> + } + if (!(*i).text().isEmpty()) { + writer.writeStartElement(APIDESC); + generateText((*i).text(), en, marker); + writer.writeEndElement(); // </apiDesc> + } + writer.writeEndElement(); // <cxxEnumerator> + ++i; + } + writer.writeEndElement(); // <cxxEnumerators> + } + + writeLocation(en); + writer.writeEndElement(); // <cxxEnumerationDefinition> + writer.writeStartElement(APIDESC); + + if (!en->doc().isEmpty()) { + generateBody(en, marker); + } + + writer.writeEndElement(); // </apiDesc> + writer.writeEndElement(); // </cxxEnumerationDetail> + writer.writeEndElement(); // </cxxEnumeration> + } + ++m; + } } void DitaXmlGenerator::writeTypedefs(const Section& s, const ClassNode* cn, CodeMarker* marker) { + NodeList::ConstIterator m = s.members.begin(); + while (m != s.members.end()) { + if ((*m)->type() == Node::Typedef) { + const TypedefNode* tn = static_cast<const TypedefNode*>(*m); + writer.writeStartElement(CXXTYPEDEF); + writer.writeAttribute("id",tn->guid()); + writer.writeStartElement(APINAME); + writer.writeCharacters(tn->name()); + writer.writeEndElement(); // </apiName> + generateBrief(tn,marker); + writer.writeStartElement(CXXTYPEDEFDETAIL); + writer.writeStartElement(CXXTYPEDEFDEFINITION); + writer.writeStartElement(CXXTYPEDEFACCESSSPECIFIER); + writer.writeAttribute("value",tn->accessString()); + writer.writeEndElement(); // <cxxTypedefAccessSpecifier> + + QString fq = fullQualification(tn); + if (!fq.isEmpty()) { + writer.writeStartElement(CXXTYPEDEFSCOPEDNAME); + writer.writeCharacters(fq); + writer.writeEndElement(); // <cxxTypedefScopedName> + } + writer.writeStartElement(CXXTYPEDEFNAMELOOKUP); + writer.writeCharacters(tn->parent()->name() + "::" + tn->name()); + writer.writeEndElement(); // <cxxTypedefNameLookup> + + writeLocation(tn); + writer.writeEndElement(); // <cxxTypedefDefinition> + writer.writeStartElement(APIDESC); + + if (!tn->doc().isEmpty()) { + generateBody(tn, marker); + } + + writer.writeEndElement(); // </apiDesc> + writer.writeEndElement(); // </cxxTypedefDetail> + writer.writeEndElement(); // </cxxTypedef> + } + ++m; + } +} + +void DitaXmlGenerator::writeProperties(const Section& s, + const ClassNode* cn, + CodeMarker* marker) +{ + NodeList::ConstIterator m = s.members.begin(); + while (m != s.members.end()) { + if ((*m)->type() == Node::Property) { + const PropertyNode* pn = static_cast<const PropertyNode*>(*m); + writer.writeStartElement(CXXVARIABLE); + writer.writeAttribute("id",pn->guid()); + writer.writeStartElement(APINAME); + writer.writeCharacters(pn->name()); + writer.writeEndElement(); // </apiName> + generateBrief(pn,marker); + writer.writeStartElement(CXXVARIABLEDETAIL); + writer.writeStartElement(CXXVARIABLEDEFINITION); + writer.writeStartElement(CXXVARIABLEACCESSSPECIFIER); + writer.writeAttribute("value",pn->accessString()); + writer.writeEndElement(); // <cxxVariableAccessSpecifier> + + if (!pn->qualifiedDataType().isEmpty()) { + writer.writeStartElement(CXXVARIABLEDECLAREDTYPE); + writer.writeCharacters(pn->qualifiedDataType()); + writer.writeEndElement(); // <cxxVariableDeclaredType> + } + QString fq = fullQualification(pn); + if (!fq.isEmpty()) { + writer.writeStartElement(CXXVARIABLESCOPEDNAME); + writer.writeCharacters(fq); + writer.writeEndElement(); // <cxxVariableScopedName> + } + + writer.writeStartElement(CXXVARIABLEPROTOTYPE); + writer.writeCharacters("Q_PROPERTY("); + writer.writeCharacters(pn->qualifiedDataType()); + writer.writeCharacters(" "); + writer.writeCharacters(pn->name()); + writerFunctions("READ",pn->getters()); + writerFunctions("WRITE",pn->setters()); + writerFunctions("RESET",pn->resetters()); + writerFunctions("NOTIFY",pn->notifiers()); + if (pn->isDesignable() != pn->designableDefault()) { + writer.writeCharacters(" DESIGNABLE "); + if (!pn->runtimeDesignabilityFunction().isEmpty()) + writer.writeCharacters(pn->runtimeDesignabilityFunction()); + else + writer.writeCharacters(pn->isDesignable() ? "true" : "false"); + } + if (pn->isScriptable() != pn->scriptableDefault()) { + writer.writeCharacters(" SCRIPTABLE "); + if (!pn->runtimeScriptabilityFunction().isEmpty()) + writer.writeCharacters(pn->runtimeScriptabilityFunction()); + else + writer.writeCharacters(pn->isScriptable() ? "true" : "false"); + } + if (pn->isWritable() != pn->writableDefault()) { + writer.writeCharacters(" STORED "); + writer.writeCharacters(pn->isStored() ? "true" : "false"); + } + if (pn->isUser() != pn->userDefault()) { + writer.writeCharacters(" USER "); + writer.writeCharacters(pn->isUser() ? "true" : "false"); + } + if (pn->isConstant()) + writer.writeCharacters(" CONSTANT"); + if (pn->isFinal()) + writer.writeCharacters(" FINAL"); + writer.writeCharacters(")"); + writer.writeEndElement(); // <cxxVariablePrototype> + + writer.writeStartElement(CXXVARIABLENAMELOOKUP); + writer.writeCharacters(pn->parent()->name() + "::" + pn->name()); + writer.writeEndElement(); // <cxxVariableNameLookup> + + if (pn->overriddenFrom() != 0) { + PropertyNode* opn = (PropertyNode*)pn->overriddenFrom(); + writer.writeStartElement(CXXVARIABLEREIMPLEMENTED); + writer.writeAttribute("href",opn->ditaXmlHref()); + writer.writeCharacters(marker->plainFullName(opn)); + writer.writeEndElement(); // </cxxVariableReimplemented> + } + + writeLocation(pn); + writer.writeEndElement(); // <cxxVariableDefinition> + writer.writeStartElement(APIDESC); + + if (!pn->doc().isEmpty()) { + generateBody(pn, marker); + } + + writer.writeEndElement(); // </apiDesc> + writer.writeEndElement(); // </cxxVariableDetail> + writer.writeEndElement(); // </cxxVariable> + } + ++m; + } } void DitaXmlGenerator::writeDataMembers(const Section& s, const ClassNode* cn, CodeMarker* marker) { + NodeList::ConstIterator m = s.members.begin(); + while (m != s.members.end()) { + if ((*m)->type() == Node::Variable) { + const VariableNode* vn = static_cast<const VariableNode*>(*m); + writer.writeStartElement(CXXVARIABLE); + writer.writeAttribute("id",vn->guid()); + writer.writeStartElement(APINAME); + writer.writeCharacters(vn->name()); + writer.writeEndElement(); // </apiName> + generateBrief(vn,marker); + writer.writeStartElement(CXXVARIABLEDETAIL); + writer.writeStartElement(CXXVARIABLEDEFINITION); + writer.writeStartElement(CXXVARIABLEACCESSSPECIFIER); + writer.writeAttribute("value",vn->accessString()); + writer.writeEndElement(); // <cxxVariableAccessSpecifier> + + writer.writeStartElement(CXXVARIABLEDECLAREDTYPE); + writer.writeCharacters(vn->leftType()); + if (!vn->rightType().isEmpty()) + writer.writeCharacters(vn->rightType()); + writer.writeEndElement(); // <cxxVariableDeclaredType> + + QString fq = fullQualification(vn); + if (!fq.isEmpty()) { + writer.writeStartElement(CXXVARIABLESCOPEDNAME); + writer.writeCharacters(fq); + writer.writeEndElement(); // <cxxVariableScopedName> + } + + writer.writeStartElement(CXXVARIABLEPROTOTYPE); + writer.writeCharacters(vn->leftType() + " "); + //writer.writeCharacters(vn->parent()->name() + "::" + vn->name()); + writer.writeCharacters(vn->name()); + if (!vn->rightType().isEmpty()) + writer.writeCharacters(vn->rightType()); + writer.writeEndElement(); // <cxxVariablePrototype> + + writer.writeStartElement(CXXVARIABLENAMELOOKUP); + writer.writeCharacters(vn->parent()->name() + "::" + vn->name()); + writer.writeEndElement(); // <cxxVariableNameLookup> + + writeLocation(vn); + writer.writeEndElement(); // <cxxVariableDefinition> + writer.writeStartElement(APIDESC); + + if (!vn->doc().isEmpty()) { + generateBody(vn, marker); + } + + writer.writeEndElement(); // </apiDesc> + writer.writeEndElement(); // </cxxVariableDetail> + writer.writeEndElement(); // </cxxVariable> + } + ++m; + } } -void DitaXmlGenerator::writeProperties(const Section& s, - const ClassNode* cn, - CodeMarker* marker) +void DitaXmlGenerator::writerFunctions(const QString& tag, const NodeList& nlist) { + NodeList::const_iterator n = nlist.begin(); + while (n != nlist.end()) { + writer.writeCharacters(" "); + writer.writeCharacters(tag); + writer.writeCharacters(" "); + writer.writeCharacters((*n)->name()); + ++n; + } } QT_END_NAMESPACE |