From eb5e587af8867fa57ee764441905bdf982ab43c6 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Sat, 5 Feb 2011 22:47:10 +0100 Subject: Ensured that trailing newlines are quoted and correct atoms are used. Newlines after comments at the end of files were previously omitted. An assumption about the type code being quoted caused incorrect CSS classes to be used and extra HTML elements to be used. --- tools/qdoc3/cppcodemarker.cpp | 5 ++++- tools/qdoc3/doc.cpp | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index 752d007..e27916b 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -936,6 +936,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, int parenDepth = 0; int i = 0; int start = 0; + int finish = 0; char ch; QRegExp classRegExp("Qt?(?:[A-Z3]+[a-z][A-Za-z]*|t)"); QRegExp functionRegExp("q([A-Z][a-z]+)+"); @@ -943,7 +944,6 @@ QString CppCodeMarker::addMarkUp(const QString &in, readChar(); while (ch != EOF) { - int finish = i; QString tag; bool target = false; @@ -1120,7 +1120,10 @@ QString CppCodeMarker::addMarkUp(const QString &in, if (!tag.isEmpty()) out += QLatin1String(""); + } + if (start < code.length()) { + out += protect(code.mid(start)); } return out; diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp index 76c47a2..a730799 100644 --- a/tools/qdoc3/doc.cpp +++ b/tools/qdoc3/doc.cpp @@ -369,6 +369,7 @@ class DocParser void appendChar(QChar ch); void appendWord(const QString &word); void appendToCode(const QString &code); + void appendToCode(const QString &code, Atom::Type defaultType); void startNewPara(); void enterPara(Atom::Type leftType = Atom::ParaLeft, Atom::Type rightType = Atom::ParaRight, @@ -1112,9 +1113,8 @@ void DocParser::parse(const QString& source, append(Atom::SnippetIdentifier, identifier); } else { - Doc::quoteFromFile(location(),quoter,snippet); - appendToCode(quoter.quoteSnippet(location(), - identifier)); + marker = Doc::quoteFromFile(location(),quoter,snippet); + appendToCode(quoter.quoteSnippet(location(), identifier), marker->atomType()); } } break; @@ -1855,7 +1855,7 @@ void DocParser::appendToCode(const QString& markedCode) { Atom::Type lastType = priv->text.lastAtom()->type(); #ifdef QDOC_QML - if (lastType != Atom::Qml) + if (lastType != Atom::Qml && lastType != Atom::Code && lastType != Atom::JavaScript) append(Atom::Qml); #else if (lastType != Atom::Code) @@ -1864,6 +1864,15 @@ void DocParser::appendToCode(const QString& markedCode) priv->text.lastAtom()->appendString(markedCode); } +void DocParser::appendToCode(const QString &markedCode, Atom::Type defaultType) +{ + Atom::Type lastType = priv->text.lastAtom()->type(); + if (lastType != Atom::Qml && lastType != Atom::Code && lastType != Atom::JavaScript) + append(defaultType, markedCode); + else + priv->text.lastAtom()->appendString(markedCode); +} + void DocParser::startNewPara() { leavePara(); -- cgit v0.12