diff options
-rw-r--r-- | tools/qdoc3/ditaxmlgenerator.cpp | 66 | ||||
-rw-r--r-- | tools/qdoc3/doc.cpp | 4 | ||||
-rw-r--r-- | tools/qdoc3/doc.h | 2 | ||||
-rw-r--r-- | tools/qdoc3/text.cpp | 136 | ||||
-rw-r--r-- | tools/qdoc3/text.h | 2 |
5 files changed, 108 insertions, 102 deletions
diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 27f36ff..668d6ed 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -337,8 +337,6 @@ bool DitaXmlGenerator::inLegaleseText = false; #define APIMAP Doc::alias("apiMap") #define APIITEMREF Doc::alias("apiItemRef") -#define SHORTDESC Doc::alias("shortdesc") - QString DitaXmlGenerator::sinceTitles[] = { " New Namespaces", @@ -677,7 +675,7 @@ int DitaXmlGenerator::generateAtom(const Atom *atom, CodeMarker *marker) { int skipAhead = 0; - QString hx; + QString hx, str; static bool in_para = false; QString guid, hc; @@ -710,30 +708,20 @@ int DitaXmlGenerator::generateAtom(const Atom *atom, skipAhead = skipAtoms(atom, Atom::BriefRight); break; } - if (inApiDesc || inSection) + if (inApiDesc || inSection) { xmlWriter().writeStartElement("p"); + xmlWriter().writeAttribute("outputclass","brief"); + } else { noLinks = true; - xmlWriter().writeStartElement(SHORTDESC); + xmlWriter().writeStartElement("shortdesc"); } if (relative->type() == Node::Property || relative->type() == Node::Variable) { - QString str; - atom = atom->next(); - while (atom != 0 && atom->type() != Atom::BriefRight) { - if (atom->type() == Atom::String || - atom->type() == Atom::AutoLink) - str += atom->string(); - skipAhead++; - atom = atom->next(); - } - str[0] = str[0].toLower(); - if (str.right(1) == ".") - str.truncate(str.length() - 1); xmlWriter().writeCharacters("This "); if (relative->type() == Node::Property) xmlWriter().writeCharacters("property"); - else + else if (relative->type() == Node::Variable) xmlWriter().writeCharacters("variable"); QStringList words = str.split(" "); if (!(words.first() == "contains" || words.first() == "specifies" @@ -742,14 +730,27 @@ int DitaXmlGenerator::generateAtom(const Atom *atom, xmlWriter().writeCharacters(" holds "); else xmlWriter().writeCharacters(" "); + } + if (noLinks) { + atom = atom->next(); + while (atom != 0 && atom->type() != Atom::BriefRight) { + if (atom->type() == Atom::String || + atom->type() == Atom::AutoLink) + str += atom->string(); + skipAhead++; + atom = atom->next(); + } + str[0] = str[0].toLower(); + if (str.right(1) == ".") + str.truncate(str.length() - 1); + str[0] = str[0].toUpper(); xmlWriter().writeCharacters(str + "."); } break; case Atom::BriefRight: - if (relative->type() != Node::Fake) { + if (relative->type() != Node::Fake) xmlWriter().writeEndElement(); // </shortdesc> or </p> - noLinks = false; - } + noLinks = false; break; case Atom::C: xmlWriter().writeStartElement(formattingLeftMap()[ATOM_FORMATTING_TELETYPE]); @@ -1141,8 +1142,13 @@ int DitaXmlGenerator::generateAtom(const Atom *atom, .arg(marker->plainFullName(relative))); } #if 0 - else - qDebug() << "MYLINK:" << myLink << outFileName();; + else if (noLinks) { + //xmlWriter().writeCharacters(atom->string()); + qDebug() << "MYLINK:" << myLink << outFileName() << atom->string(); + } + else { + beginLink(myLink, node, relative, marker); + } #endif beginLink(myLink, node, relative, marker); skipAhead = 1; @@ -1556,7 +1562,7 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark xmlWriter().writeStartElement(APIDESC); xmlWriter().writeAttribute("spectitle",title); - Text brief = nsn->doc().briefText(); + Text brief = nsn->doc().briefText(); // zzz if (!brief.isEmpty()) { xmlWriter().writeStartElement("p"); generateText(brief, nsn, marker); @@ -1713,7 +1719,7 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark xmlWriter().writeStartElement(APIDESC); xmlWriter().writeAttribute("spectitle",title); - Text brief = cn->doc().briefText(); + Text brief = cn->doc().briefText(); // zzz if (!brief.isEmpty()) { xmlWriter().writeStartElement("p"); generateText(brief, cn, marker); @@ -2107,7 +2113,7 @@ void DitaXmlGenerator::generateHeader(const Node* node, dtd = "dtd/cxxClass.dtd"; version = "0.6.0"; doctype = "<!DOCTYPE " + mainElement + - " PUBLIC \"-//NOKIA//DTD DITA C++ API Namespace Reference Type v" + + " PUBLIC \"-//NOKIA//DTD DITA C++ API Class Reference Type v" + version + "//EN\" \"" + dtd + "\">"; outputclass = "namespace"; } @@ -2160,13 +2166,9 @@ void DitaXmlGenerator::generateTitle(const QString& title, */ void DitaXmlGenerator::generateBrief(const Node* node, CodeMarker* marker) { - Text brief = node->doc().briefText(); + Text brief = node->doc().briefText(true); // zzz if (!brief.isEmpty()) { - noLinks = true; - xmlWriter().writeStartElement(SHORTDESC); generateText(brief, node, marker); - xmlWriter().writeEndElement(); // </shortdesc> - noLinks = false; } } @@ -2613,7 +2615,7 @@ void DitaXmlGenerator::generateAnnotatedList(const Node* relative, else { xmlWriter().writeStartElement("entry"); xmlWriter().writeStartElement("p"); - xmlWriter().writeCharacters(protectEnc(node->doc().briefText().toString())); + xmlWriter().writeCharacters(protectEnc(node->doc().briefText().toString())); // zzz xmlWriter().writeEndElement(); // </p> xmlWriter().writeEndElement(); // <entry> } diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp index 280f055..5adb282 100644 --- a/tools/qdoc3/doc.cpp +++ b/tools/qdoc3/doc.cpp @@ -2621,9 +2621,9 @@ const Text& Doc::body() const return priv == 0 ? dummy : priv->text; } -Text Doc::briefText() const +Text Doc::briefText(bool inclusive) const { - return body().subText(Atom::BriefLeft, Atom::BriefRight); + return body().subText(Atom::BriefLeft, Atom::BriefRight, 0, inclusive); } Text Doc::trimmedBriefText(const QString &className) const diff --git a/tools/qdoc3/doc.h b/tools/qdoc3/doc.h index 3e76456..cf93151 100644 --- a/tools/qdoc3/doc.h +++ b/tools/qdoc3/doc.h @@ -100,7 +100,7 @@ class Doc bool isEmpty() const; const QString& source() const; const Text& body() const; - Text briefText() const; + Text briefText(bool inclusive = false) const; Text trimmedBriefText(const QString &className) const; Text legaleseText() const; const QString& baseName() const; diff --git a/tools/qdoc3/text.cpp b/tools/qdoc3/text.cpp index 11d7edd..ecec5eb 100644 --- a/tools/qdoc3/text.cpp +++ b/tools/qdoc3/text.cpp @@ -60,10 +60,10 @@ Text::Text(const QString &str) operator<<(str); } -Text::Text( const Text& text ) +Text::Text(const Text& text) : first(0), last(0) { - operator=( text ); + operator=(text); } Text::~Text() @@ -71,41 +71,41 @@ Text::~Text() clear(); } -Text& Text::operator=( const Text& text ) +Text& Text::operator=(const Text& text) { - if ( this != &text ) { + if (this != &text) { clear(); - operator<<( text ); + operator<<(text); } return *this; } -Text& Text::operator<<( Atom::Type atomType ) +Text& Text::operator<<(Atom::Type atomType) { - return operator<<( Atom(atomType) ); + return operator<<(Atom(atomType)); } -Text& Text::operator<<( const QString& string ) +Text& Text::operator<<(const QString& string) { - return operator<<( Atom(Atom::String, string) ); + return operator<<(Atom(Atom::String, string)); } -Text& Text::operator<<( const Atom& atom ) +Text& Text::operator<<(const Atom& atom) { - if ( first == 0 ) { - first = new Atom( atom.type(), atom.string() ); + if (first == 0) { + first = new Atom(atom.type(), atom.string()); last = first; } else { - last = new Atom( last, atom.type(), atom.string() ); + last = new Atom(last, atom.type(), atom.string()); } return *this; } -Text& Text::operator<<( const Text& text ) +Text& Text::operator<<(const Text& text) { - const Atom *atom = text.firstAtom(); - while ( atom != 0 ) { - operator<<( *atom ); + const Atom* atom = text.firstAtom(); + while (atom != 0) { + operator<<(*atom); atom = atom->next(); } return *this; @@ -113,10 +113,10 @@ Text& Text::operator<<( const Text& text ) void Text::stripFirstAtom() { - if ( first != 0 ) { - if ( first == last ) + if (first != 0) { + if (first == last) last = 0; - Atom *oldFirst = first; + Atom* oldFirst = first; first = first->next(); delete oldFirst; } @@ -124,16 +124,16 @@ void Text::stripFirstAtom() void Text::stripLastAtom() { - if ( last != 0 ) { - Atom *oldLast = last; - if ( first == last ) { + if (last != 0) { + Atom* oldLast = last; + if (first == last) { first = 0; last = 0; } else { last = first; - while ( last->next() != oldLast ) + while (last->next() != oldLast) last = last->next(); - last->setNext( 0 ); + last->setNext(0); } delete oldLast; } @@ -142,9 +142,9 @@ void Text::stripLastAtom() QString Text::toString() const { QString str; - const Atom *atom = firstAtom(); - while ( atom != 0 ) { - if ( atom->type() == Atom::String || + const Atom* atom = firstAtom(); + while (atom != 0) { + if (atom->type() == Atom::String || atom->type() == Atom::AutoLink || atom->type() == Atom::GuidLink) str += atom->string(); @@ -153,50 +153,54 @@ QString Text::toString() const return str; } -Text Text::subText( Atom::Type left, Atom::Type right, const Atom *from ) const +Text Text::subText(Atom::Type left, Atom::Type right, const Atom* from, bool inclusive) const { - const Atom *begin = from ? from : firstAtom(); - const Atom *end; + const Atom* begin = from ? from : firstAtom(); + const Atom* end; - while ( begin != 0 && begin->type() != left ) - begin = begin->next(); - if ( begin != 0 ) + while (begin != 0 && begin->type() != left) begin = begin->next(); + if (begin != 0) { + if (!inclusive) + begin = begin->next(); + } end = begin; - while ( end != 0 && end->type() != right ) + while (end != 0 && end->type() != right) end = end->next(); - if ( end == 0 ) + if (end == 0) begin = 0; - return subText( begin, end ); + else if (inclusive) + end = end->next(); + return subText(begin, end); } -Text Text::sectionHeading(const Atom *sectionLeft) +Text Text::sectionHeading(const Atom* sectionLeft) { - if ( sectionLeft != 0 ) { - const Atom *begin = sectionLeft; - while ( begin != 0 && begin->type() != Atom::SectionHeadingLeft ) + if (sectionLeft != 0) { + const Atom* begin = sectionLeft; + while (begin != 0 && begin->type() != Atom::SectionHeadingLeft) begin = begin->next(); - if ( begin != 0 ) + if (begin != 0) begin = begin->next(); - const Atom *end = begin; - while ( end != 0 && end->type() != Atom::SectionHeadingRight ) + const Atom* end = begin; + while (end != 0 && end->type() != Atom::SectionHeadingRight) end = end->next(); - if ( end != 0 ) - return subText( begin, end ); + if (end != 0) + return subText(begin, end); } return Text(); } -const Atom *Text::sectionHeadingAtom(const Atom *sectionLeft) +const Atom* Text::sectionHeadingAtom(const Atom* sectionLeft) { - if ( sectionLeft != 0 ) { - const Atom *begin = sectionLeft; - while ( begin != 0 && begin->type() != Atom::SectionHeadingLeft ) + if (sectionLeft != 0) { + const Atom* begin = sectionLeft; + while (begin != 0 && begin->type() != Atom::SectionHeadingLeft) begin = begin->next(); - if ( begin != 0 ) + if (begin != 0) begin = begin->next(); return begin; @@ -206,25 +210,25 @@ const Atom *Text::sectionHeadingAtom(const Atom *sectionLeft) void Text::dump() const { - const Atom *atom = firstAtom(); - while ( atom != 0 ) { + const Atom* atom = firstAtom(); + while (atom != 0) { QString str = atom->string(); - str.replace( "\\", "\\\\" ); - str.replace( "\"", "\\\"" ); - str.replace( "\n", "\\n" ); - str.replace( QRegExp("[^\x20-\x7e]"), "?" ); - if ( !str.isEmpty() ) + str.replace("\\", "\\\\"); + str.replace("\"", "\\\""); + str.replace("\n", "\\n"); + str.replace(QRegExp("[^\x20-\x7e]"), "?"); + if (!str.isEmpty()) str = " \"" + str + "\""; - fprintf(stderr, " %-15s%s\n", atom->typeString().toLatin1().data(), str.toLatin1().data() ); + fprintf(stderr, " %-15s%s\n", atom->typeString().toLatin1().data(), str.toLatin1().data()); atom = atom->next(); } } -Text Text::subText( const Atom *begin, const Atom *end ) +Text Text::subText(const Atom* begin, const Atom* end) { Text text; - if ( begin != 0 ) { - while ( begin != end ) { + if (begin != 0) { + while (begin != end) { text << *begin; begin = begin->next(); } @@ -234,8 +238,8 @@ Text Text::subText( const Atom *begin, const Atom *end ) void Text::clear() { - while ( first != 0 ) { - Atom *atom = first; + while (first != 0) { + Atom* atom = first; first = first->next(); delete atom; } @@ -250,8 +254,8 @@ int Text::compare(const Text &text1, const Text &text2) if (text2.isEmpty()) return 1; - const Atom *atom1 = text1.firstAtom(); - const Atom *atom2 = text2.firstAtom(); + const Atom* atom1 = text1.firstAtom(); + const Atom* atom2 = text2.firstAtom(); for (;;) { if (atom1->type() != atom2->type()) diff --git a/tools/qdoc3/text.h b/tools/qdoc3/text.h index 879f6da..93428ed 100644 --- a/tools/qdoc3/text.h +++ b/tools/qdoc3/text.h @@ -73,7 +73,7 @@ class Text QString toString() const; const Atom *firstAtom() const { return first; } const Atom *lastAtom() const { return last; } - Text subText(Atom::Type left, Atom::Type right, const Atom *from = 0) const; + Text subText(Atom::Type left, Atom::Type right, const Atom *from = 0, bool inclusive = false) const; void dump() const; void clear(); |