From 12ac485add4a4c7db5996dcd51400e90ea44ef23 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 8 Sep 2010 15:18:09 +0200 Subject: qdoc: Generate xml for more kinds of pages. Not complete. --- tools/qdoc3/atom.cpp | 26 ++++---- tools/qdoc3/ditaxmlgenerator.cpp | 136 ++++++++++++++++++++++++++------------- tools/qdoc3/generator.cpp | 13 ++-- 3 files changed, 114 insertions(+), 61 deletions(-) diff --git a/tools/qdoc3/atom.cpp b/tools/qdoc3/atom.cpp index 88f44ea..6f1602e 100644 --- a/tools/qdoc3/atom.cpp +++ b/tools/qdoc3/atom.cpp @@ -241,25 +241,25 @@ static const struct { { 0, 0 } }; -/*! \fn Atom::Atom( Type type, const QString& string ) +/*! \fn Atom::Atom(Type type, const QString& string) Constructs an atom (\a type, \a string) outside of any atom list. */ -/*! \fn Atom( Atom *prev, Type type, const QString& string ) +/*! \fn Atom(Atom *prev, Type type, const QString& string) Constructs an atom (\a type, \a string) that follows \a prev in \a prev's atom list. */ -/*! \fn void Atom::appendChar( QChar ch ) +/*! \fn void Atom::appendChar(QChar ch) Appends \a ch to the string parameter of this atom. \also string() */ -/*! \fn void Atom::appendString( const QString& string ) +/*! \fn void Atom::appendString(const QString& string) Appends \a string to the string parameter of this atom. @@ -316,18 +316,18 @@ QString Atom::typeString() const { static bool deja = false; - if ( !deja ) { + if (!deja) { int i = 0; - while ( atms[i].english != 0 ) { - if ( atms[i].no != i ) - Location::internalError( tr("atom %1 missing").arg(i) ); + while (atms[i].english != 0) { + if (atms[i].no != i) + Location::internalError(tr("atom %1 missing").arg(i)); i++; } deja = true; } int i = (int) type(); - if ( i < 0 || i > (int) Last ) + if (i < 0 || i > (int) Last) return QLatin1String("Invalid"); return QLatin1String(atms[i].english); } @@ -346,10 +346,10 @@ QString Atom::typeString() const void Atom::dump() const { QString str = string(); - str.replace( "\\", "\\\\" ); - str.replace( "\"", "\\\"" ); - str.replace( "\n", "\\n" ); - str.replace( QRegExp("[^\x20-\x7e]"), "?" ); + str.replace("\\", "\\\\"); + str.replace("\"", "\\\""); + str.replace("\n", "\\n"); + str.replace(QRegExp("[^\x20-\x7e]"), "?"); if (!str.isEmpty()) str = " \"" + str + "\""; fprintf(stderr, diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 93fd523..d2b20a6 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -579,7 +579,7 @@ int DitaXmlGenerator::generateAtom(const Atom *atom, QString hx; static bool in_para = false; QString guid, hc; - + switch (atom->type()) { case Atom::AbstractLeft: break; @@ -1530,8 +1530,8 @@ void DitaXmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker /* NOTE: For now we only handle \page elements. */ - if (fake->subType() != Node::Page) - return; + //if (fake->subType() != Node::Page) + //return; if (fake->subType() == Node::File && !fake->subTitle().isEmpty()) { subTitleSize = SmallSubTitle; @@ -1542,28 +1542,56 @@ void DitaXmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker htmlTitle = fullTitle; } - generateHeader(fake); - - if (fake->subType() == Node::Page) { - writer.writeStartElement("topic"); - writer.writeAttribute("id",fake->guid()); - writer.writeStartElement("title"); - writer.writeCharacters(fullTitle); - writer.writeEndElement(); // + QString outputclass; + switch (fake->subType()) { + case Node::Page: + outputclass = "page"; + break; + case Node::Group: + outputclass = "group"; + break; + case Node::Example: + outputclass = "example"; + break; + case Node::HeaderFile: + outputclass = "header"; + break; + case Node::File: + outputclass = "file"; + break; + case Node::Image: + outputclass = "image"; + break; + case Node::Module: + outputclass = "module"; + break; + case Node::ExternalPage: + outputclass = "externalpage"; + break; + case Node::QmlClass: + outputclass = "QML"; + break; + default: + return; + } - generateBrief(fake, marker); // + generateHeader(fake); + + writer.writeStartElement("topic"); + writer.writeAttribute("id",fake->guid()); + writer.writeAttribute("outputclass",outputclass); + writer.writeStartElement("title"); + writer.writeCharacters(fullTitle); + writer.writeEndElement(); // + + generateBrief(fake, marker); // - if (!fake->doc().isEmpty()) { - writer.writeStartElement("body"); - writer.writeStartElement("p"); - writer.writeAttribute("outputclass","h2"); - writer.writeCharacters("Detailed Description"); - writer.writeEndElement(); //

- generateBody(fake, marker); - writer.writeEndElement(); // - } - writer.writeEndElement(); // + if (!fake->doc().isEmpty()) { + writer.writeStartElement("body"); + generateBody(fake, marker); + writer.writeEndElement(); // } + writer.writeEndElement(); // } #if 0 @@ -1837,11 +1865,23 @@ void DitaXmlGenerator::generateHeader(const Node* node) version + "//EN\" \"" + dtd + "\">"; } else if (node->type() == Node::Fake) { - if (node->subType() == Node::Page) { + switch (node->subType()) { + case Node::Page: + case Node::Group: + case Node::Example: + case Node::HeaderFile: + case Node::File: + case Node::Image: + case Node::Module: + case Node::ExternalPage: + case Node::QmlClass: element = "topic"; dtd = "dtd/topic.dtd"; doctype = ""; + break; + default: + break; } } @@ -2300,11 +2340,11 @@ void DitaXmlGenerator::generateAnnotatedList(const Node* relative, normally you let it figure it out itself by looking at the name of the first and last classes in \a classMap. */ -void DitaXmlGenerator::generateCompactList(const Node *relative, - CodeMarker *marker, - const NodeMap &classMap, - bool includeAlphabet, - QString commonPrefix) +void DitaXmlGenerator::generateCompactList(const Node* relative, + CodeMarker* marker, + const NodeMap& classMap, + bool includeAlphabet, + QString commonPrefix) { const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_' @@ -2519,42 +2559,50 @@ void DitaXmlGenerator::generateCompactList(const Node *relative, writer.writeEndElement(); //

} -void DitaXmlGenerator::generateFunctionIndex(const Node *relative, - CodeMarker *marker) +void DitaXmlGenerator::generateFunctionIndex(const Node* relative, + CodeMarker* marker) { - out() << "

"; + writer.writeStartElement("p"); + writer.writeAttribute("outputclass","centerAlign functionIndex"); + writer.writeStartElement("b"); for (int i = 0; i < 26; i++) { QChar ch('a' + i); - out() << QString("%2 ").arg(ch).arg(ch.toUpper()); + writer.writeStartElement("xref"); + writer.writeAttribute("href",QString("#%1").arg(ch)); + writer.writeCharacters(QString(ch.toUpper())); + writer.writeEndElement(); // } - out() << "

\n"; + writer.writeEndElement(); // + writer.writeEndElement(); //

char nextLetter = 'a'; char currentLetter; - out() << "
    \n"; + writer.writeStartElement("ul"); QMap::ConstIterator f = funcIndex.begin(); while (f != funcIndex.end()) { - out() << "
  • "; - out() << protectEnc(f.key()) << ":"; - + writer.writeStartElement("li"); currentLetter = f.key()[0].unicode(); while (islower(currentLetter) && currentLetter >= nextLetter) { - out() << QString("").arg(nextLetter); + writer.writeStartElement("p"); + writeGuidAttribute(QString(nextLetter)); + writer.writeAttribute("outputclass","target"); + writer.writeCharacters(QString(nextLetter)); + writer.writeEndElement(); //

    nextLetter++; } + writer.writeCharacters(protectEnc(f.key())); + writer.writeCharacters(":"); NodeMap::ConstIterator s = (*f).begin(); while (s != (*f).end()) { - out() << " "; generateFullName((*s)->parent(), relative, marker, *s); ++s; } - out() << "
  • "; - out() << "\n"; + writer.writeEndElement(); // ++f; } - out() << "
\n"; + writer.writeEndElement(); // } void DitaXmlGenerator::generateLegaleseList(const Node *relative, @@ -3596,7 +3644,7 @@ void DitaXmlGenerator::findAllSince(const InnerNode *node) } } -void DitaXmlGenerator::findAllFunctions(const InnerNode *node) +void DitaXmlGenerator::findAllFunctions(const InnerNode* node) { NodeList::ConstIterator c = node->childNodes().begin(); while (c != node->childNodes().end()) { @@ -3605,7 +3653,7 @@ void DitaXmlGenerator::findAllFunctions(const InnerNode *node) findAllFunctions(static_cast(*c)); } else if ((*c)->type() == Node::Function) { - const FunctionNode *func = static_cast(*c); + const FunctionNode* func = static_cast(*c); if ((func->status() > Node::Obsolete) && (func->metaness() != FunctionNode::Ctor) && (func->metaness() != FunctionNode::Dtor)) { diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp index 7f39be2..eee998a 100644 --- a/tools/qdoc3/generator.cpp +++ b/tools/qdoc3/generator.cpp @@ -54,6 +54,7 @@ #include "quoter.h" #include "separator.h" #include "tokenizer.h" +#include "ditaxmlgenerator.h" QT_BEGIN_NAMESPACE @@ -385,16 +386,19 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) } else if (node->type() == Node::Fake) { const FakeNode *fake = static_cast(node); - if (fake->subType() == Node::Example) + if (fake->subType() == Node::Example) { generateExampleFiles(fake, marker); - else if ((fake->subType() == Node::File) || (fake->subType() == Node::Image)) + } + else if ((fake->subType() == Node::File) || (fake->subType() == Node::Image)) { quiet = true; + } } if (node->doc().isEmpty()) { - if (!quiet && !node->isReimp()) // ### might be unnecessary + if (!quiet && !node->isReimp()) { // ### might be unnecessary node->location().warning(tr("No documentation for '%1'") .arg(marker->plainFullName(node))); + } } else { if (node->type() == Node::Function) { @@ -403,9 +407,10 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) generateReimplementedFrom(func, marker); } - if (!generateText(node->doc().body(), node, marker)) + if (!generateText(node->doc().body(), node, marker)) { if (node->isReimp()) return; + } if (node->type() == Node::Enum) { const EnumNode *enume = (const EnumNode *) node; -- cgit v0.12