summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-11-29 18:57:56 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-11-29 18:57:56 (GMT)
commit755f2907ee4bc2b632237409c1d1d77b343aaa2a (patch)
treec149c041436154b2be55b561b3a5cb73dbd29f39 /tools
parent344c3ad32bd36ad67731aa3171103a6c5e2f93e0 (diff)
downloadQt-755f2907ee4bc2b632237409c1d1d77b343aaa2a.zip
Qt-755f2907ee4bc2b632237409c1d1d77b343aaa2a.tar.gz
Qt-755f2907ee4bc2b632237409c1d1d77b343aaa2a.tar.bz2
Removed unnecessary include, fixed whitespace.
Diffstat (limited to 'tools')
-rw-r--r--tools/qdoc3/doc.cpp937
1 files changed, 468 insertions, 469 deletions
diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp
index be16c59..4152207 100644
--- a/tools/qdoc3/doc.cpp
+++ b/tools/qdoc3/doc.cpp
@@ -48,7 +48,6 @@
#include "text.h"
#include "tokenizer.h"
#include <qdatetime.h>
-#include <qdebug.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qhash.h>
@@ -225,13 +224,13 @@ class DocPrivateExtra
QStringMap metaMap;
DocPrivateExtra()
- : granularity(Doc::Part) { }
+ : granularity(Doc::Part) { }
};
struct Shared // ### get rid of
{
Shared()
- : count(1) { }
+ : count(1) { }
void ref() { ++count; }
bool deref() { return (--count == 0); }
@@ -301,7 +300,7 @@ void DocPrivate::addAlso(const Text& also)
void DocPrivate::constructExtra()
{
if (extra == 0)
- extra = new DocPrivateExtra;
+ extra = new DocPrivateExtra;
}
bool DocPrivate::isEnumDocSimplifiable() const
@@ -350,7 +349,7 @@ class DocParser
private:
Location& location();
QString detailsUnknownCommand(const QSet<QString>& metaCommandSet,
- const QString& str);
+ const QString& str);
void checkExpiry(const QString& date);
void insertBaseName(const QString &baseName);
void insertTarget(const QString& target, bool keyword);
@@ -367,8 +366,8 @@ class DocParser
void appendToCode(const QString &code);
void startNewPara();
void enterPara(Atom::Type leftType = Atom::ParaLeft,
- Atom::Type rightType = Atom::ParaRight,
- const QString& string = "");
+ Atom::Type rightType = Atom::ParaRight,
+ const QString& string = "");
void leavePara();
void leaveValue();
void leaveValueList();
@@ -547,7 +546,7 @@ void DocParser::parse(const QString& source,
leavePara();
append(Atom::Code, getCode(CMD_CODE, marker));
break;
-#ifdef QDOC_QML
+#ifdef QDOC_QML
case CMD_QML:
leavePara();
append(Atom::Qml, getCode(CMD_QML, marker));
@@ -555,7 +554,7 @@ void DocParser::parse(const QString& source,
case CMD_QMLTEXT:
append(Atom::QmlText);
break;
-#endif
+#endif
case CMD_CODELINE:
{
if (!quoting) {
@@ -1465,35 +1464,35 @@ void DocParser::checkExpiry(const QString& date)
QRegExp ymd("(\\d{4})(?:-(\\d{2})(?:-(\\d{2})))");
if (ymd.exactMatch(date)) {
- int y = ymd.cap(1).toInt();
- int m = ymd.cap(2).toInt();
- int d = ymd.cap(3).toInt();
-
- if (m == 0)
- m = 1;
- if (d == 0)
- d = 1;
- QDate expiryDate(y, m, d);
- if (expiryDate.isValid()) {
- int days = expiryDate.daysTo(QDate::currentDate());
- if (days == 0) {
- location().warning(tr("Documentation expires today"));
- }
+ int y = ymd.cap(1).toInt();
+ int m = ymd.cap(2).toInt();
+ int d = ymd.cap(3).toInt();
+
+ if (m == 0)
+ m = 1;
+ if (d == 0)
+ d = 1;
+ QDate expiryDate(y, m, d);
+ if (expiryDate.isValid()) {
+ int days = expiryDate.daysTo(QDate::currentDate());
+ if (days == 0) {
+ location().warning(tr("Documentation expires today"));
+ }
else if (days == 1) {
- location().warning(tr("Documentation expired yesterday"));
- }
+ location().warning(tr("Documentation expired yesterday"));
+ }
else if (days >= 2) {
- location().warning(tr("Documentation expired %1 days ago")
- .arg(days));
- }
- }
+ location().warning(tr("Documentation expired %1 days ago")
+ .arg(days));
+ }
+ }
else {
- location().warning(tr("Date '%1' invalid").arg(date));
- }
+ location().warning(tr("Date '%1' invalid").arg(date));
+ }
}
else {
- location().warning(tr("Date '%1' not in YYYY-MM-DD format")
- .arg(date));
+ location().warning(tr("Date '%1' not in YYYY-MM-DD format")
+ .arg(date));
}
}
@@ -1501,34 +1500,34 @@ void DocParser::insertBaseName(const QString &baseName)
{
priv->constructExtra();
if (currentSectioningUnit == priv->extra->sectioningUnit) {
- priv->extra->baseName = baseName;
+ priv->extra->baseName = baseName;
}
else {
- Atom *atom = priv->text.firstAtom();
- Atom *sectionLeft = 0;
+ Atom *atom = priv->text.firstAtom();
+ Atom *sectionLeft = 0;
- int delta = currentSectioningUnit - priv->extra->sectioningUnit;
+ int delta = currentSectioningUnit - priv->extra->sectioningUnit;
- while (atom != 0) {
- if (atom->type() == Atom::SectionLeft &&
- atom->string().toInt() == delta)
- sectionLeft = atom;
- atom = atom->next();
- }
- if (sectionLeft != 0)
- (void) new Atom(sectionLeft, Atom::BaseName, baseName);
+ while (atom != 0) {
+ if (atom->type() == Atom::SectionLeft &&
+ atom->string().toInt() == delta)
+ sectionLeft = atom;
+ atom = atom->next();
+ }
+ if (sectionLeft != 0)
+ (void) new Atom(sectionLeft, Atom::BaseName, baseName);
}
}
void DocParser::insertTarget(const QString &target, bool keyword)
{
if (targetMap.contains(target)) {
- location().warning(tr("Duplicate target name '%1'").arg(target));
- targetMap[target].warning(tr("(The previous occurrence is here)"));
+ location().warning(tr("Duplicate target name '%1'").arg(target));
+ targetMap[target].warning(tr("(The previous occurrence is here)"));
}
else {
- targetMap.insert(target, location());
- append(Atom::Target, target);
+ targetMap.insert(target, location());
+ append(Atom::Target, target);
priv->constructExtra();
if (keyword)
priv->extra->keywords.append(priv->text.lastAtom());
@@ -1540,8 +1539,8 @@ void DocParser::insertTarget(const QString &target, bool keyword)
void DocParser::include(const QString& fileName)
{
if (location().depth() > 16)
- location().fatal(tr("Too many nested '\\%1's")
- .arg(cmdName(CMD_INCLUDE)));
+ location().fatal(tr("Too many nested '\\%1's")
+ .arg(cmdName(CMD_INCLUDE)));
QString userFriendlyFilePath;
// ### use current directory?
@@ -1551,25 +1550,25 @@ void DocParser::include(const QString& fileName)
fileName,
userFriendlyFilePath);
if (filePath.isEmpty()) {
- location().warning(tr("Cannot find leaf file '%1'").arg(fileName));
+ location().warning(tr("Cannot find leaf file '%1'").arg(fileName));
}
else {
- QFile inFile(filePath);
- if (!inFile.open(QFile::ReadOnly)) {
- location().warning(tr("Cannot open leaf file '%1'")
- .arg(userFriendlyFilePath));
- }
+ QFile inFile(filePath);
+ if (!inFile.open(QFile::ReadOnly)) {
+ location().warning(tr("Cannot open leaf file '%1'")
+ .arg(userFriendlyFilePath));
+ }
else {
- location().push(userFriendlyFilePath);
+ location().push(userFriendlyFilePath);
- QTextStream inStream(&inFile);
- QString includedStuff = inStream.readAll();
- inFile.close();
+ QTextStream inStream(&inFile);
+ QString includedStuff = inStream.readAll();
+ inFile.close();
- in.insert(pos, includedStuff);
- len = in.length();
- openedInputs.push(pos + includedStuff.length());
- }
+ in.insert(pos, includedStuff);
+ len = in.length();
+ openedInputs.push(pos + includedStuff.length());
+ }
}
}
@@ -1579,29 +1578,29 @@ void DocParser::startFormat(const QString& format, int cmd)
QMap<int, QString>::ConstIterator f = pendingFormats.begin();
while (f != pendingFormats.end()) {
- if (*f == format) {
- location().warning(tr("Cannot nest '\\%1' commands")
- .arg(cmdName(cmd)));
- return;
- }
- ++f;
+ if (*f == format) {
+ location().warning(tr("Cannot nest '\\%1' commands")
+ .arg(cmdName(cmd)));
+ return;
+ }
+ ++f;
}
append(Atom::FormattingLeft, format);
if (isLeftBraceAhead()) {
- skipSpacesOrOneEndl();
- pendingFormats.insert(braceDepth, format);
- ++braceDepth;
- ++pos;
+ skipSpacesOrOneEndl();
+ pendingFormats.insert(braceDepth, format);
+ ++braceDepth;
+ ++pos;
}
else {
- append(Atom::String, getArgument());
- append(Atom::FormattingRight, format);
- if (format == ATOM_FORMATTING_INDEX && indexStartedPara) {
- skipAllSpaces();
- indexStartedPara = false;
- }
+ append(Atom::String, getArgument());
+ append(Atom::FormattingRight, format);
+ if (format == ATOM_FORMATTING_INDEX && indexStartedPara) {
+ skipAllSpaces();
+ indexStartedPara = false;
+ }
}
}
@@ -1612,37 +1611,37 @@ bool DocParser::openCommand(int cmd)
if (cmd != CMD_LINK) {
if (outer == CMD_LIST) {
- ok = (cmd == CMD_FOOTNOTE || cmd == CMD_LIST);
+ ok = (cmd == CMD_FOOTNOTE || cmd == CMD_LIST);
}
else if (outer == CMD_ABSTRACT) {
- ok = (cmd == CMD_LIST ||
+ ok = (cmd == CMD_LIST ||
cmd == CMD_QUOTATION ||
cmd == CMD_TABLE);
}
else if (outer == CMD_SIDEBAR) {
- ok = (cmd == CMD_LIST ||
+ ok = (cmd == CMD_LIST ||
cmd == CMD_QUOTATION ||
cmd == CMD_SIDEBAR);
}
else if (outer == CMD_QUOTATION) {
- ok = (cmd == CMD_LIST);
+ ok = (cmd == CMD_LIST);
}
else if (outer == CMD_TABLE) {
- ok = (cmd == CMD_LIST ||
+ ok = (cmd == CMD_LIST ||
cmd == CMD_FOOTNOTE ||
cmd == CMD_QUOTATION);
}
else if (outer == CMD_FOOTNOTE || outer == CMD_LINK) {
- ok = false;
+ ok = false;
}
}
if (ok) {
- openedCommands.push(cmd);
+ openedCommands.push(cmd);
}
else {
- location().warning(tr("Cannot use '\\%1' within '\\%2'")
- .arg(cmdName(cmd)).arg(cmdName(outer)));
+ location().warning(tr("Cannot use '\\%1' within '\\%2'")
+ .arg(cmdName(cmd)).arg(cmdName(outer)));
}
return ok;
}
@@ -1650,33 +1649,33 @@ bool DocParser::openCommand(int cmd)
bool DocParser::closeCommand(int endCmd)
{
if (endCmdFor(openedCommands.top()) == endCmd && openedCommands.size() > 1) {
- openedCommands.pop();
- return true;
+ openedCommands.pop();
+ return true;
}
else {
- bool contains = false;
- QStack<int> opened2 = openedCommands;
- while (opened2.size() > 1) {
- if (endCmdFor(opened2.top()) == endCmd) {
- contains = true;
- break;
- }
- opened2.pop();
- }
-
- if (contains) {
- while (endCmdFor(openedCommands.top()) != endCmd && openedCommands.size() > 1) {
- location().warning(tr("Missing '\\%1' before '\\%2'")
- .arg(endCmdName(openedCommands.top()))
- .arg(cmdName(endCmd)));
- openedCommands.pop();
- }
- }
+ bool contains = false;
+ QStack<int> opened2 = openedCommands;
+ while (opened2.size() > 1) {
+ if (endCmdFor(opened2.top()) == endCmd) {
+ contains = true;
+ break;
+ }
+ opened2.pop();
+ }
+
+ if (contains) {
+ while (endCmdFor(openedCommands.top()) != endCmd && openedCommands.size() > 1) {
+ location().warning(tr("Missing '\\%1' before '\\%2'")
+ .arg(endCmdName(openedCommands.top()))
+ .arg(cmdName(endCmd)));
+ openedCommands.pop();
+ }
+ }
else {
- location().warning(tr("Unexpected '\\%1'")
- .arg(cmdName(endCmd)));
- }
- return false;
+ location().warning(tr("Unexpected '\\%1'")
+ .arg(cmdName(endCmd)));
+ }
+ return false;
}
}
@@ -1685,32 +1684,32 @@ void DocParser::startSection(Doc::SectioningUnit unit, int cmd)
leavePara();
if (currentSectioningUnit == Doc::Book) {
- currentSectioningUnit = (Doc::SectioningUnit) (unit - 1);
- priv->constructExtra();
- priv->extra->sectioningUnit = currentSectioningUnit;
+ currentSectioningUnit = (Doc::SectioningUnit) (unit - 1);
+ priv->constructExtra();
+ priv->extra->sectioningUnit = currentSectioningUnit;
}
if (unit <= priv->extra->sectioningUnit) {
- location().warning(tr("Unexpected '\\%1' in this documentation")
- .arg(cmdName(cmd)));
+ location().warning(tr("Unexpected '\\%1' in this documentation")
+ .arg(cmdName(cmd)));
}
else if (unit - currentSectioningUnit > 1) {
- location().warning(tr("Unexpected '\\%1' at this point")
- .arg(cmdName(cmd)));
+ location().warning(tr("Unexpected '\\%1' at this point")
+ .arg(cmdName(cmd)));
}
else {
- if (currentSectioningUnit >= unit)
- endSection(unit, cmd);
+ if (currentSectioningUnit >= unit)
+ endSection(unit, cmd);
- int delta = unit - priv->extra->sectioningUnit;
- append(Atom::SectionLeft, QString::number(delta));
+ int delta = unit - priv->extra->sectioningUnit;
+ append(Atom::SectionLeft, QString::number(delta));
priv->constructExtra();
priv->extra->tableOfContents.append(priv->text.lastAtom());
priv->extra->tableOfContentsLevels.append(unit);
- enterPara(Atom::SectionHeadingLeft,
+ enterPara(Atom::SectionHeadingLeft,
Atom::SectionHeadingRight,
QString::number(delta));
- currentSectioningUnit = unit;
+ currentSectioningUnit = unit;
}
}
@@ -1719,20 +1718,20 @@ void DocParser::endSection(int unit, int endCmd)
leavePara();
if (unit < priv->extra->sectioningUnit) {
- location().warning(tr("Unexpected '\\%1' in this documentation")
- .arg(cmdName(endCmd)));
+ location().warning(tr("Unexpected '\\%1' in this documentation")
+ .arg(cmdName(endCmd)));
}
else if (unit > currentSectioningUnit) {
- location().warning(tr("Unexpected '\\%1' at this point")
- .arg(cmdName(endCmd)));
+ location().warning(tr("Unexpected '\\%1' at this point")
+ .arg(cmdName(endCmd)));
}
else {
- while (currentSectioningUnit >= unit) {
- int delta = currentSectioningUnit - priv->extra->sectioningUnit;
- append(Atom::SectionRight, QString::number(delta));
- currentSectioningUnit =
- (Doc::SectioningUnit) (currentSectioningUnit - 1);
- }
+ while (currentSectioningUnit >= unit) {
+ int delta = currentSectioningUnit - priv->extra->sectioningUnit;
+ append(Atom::SectionRight, QString::number(delta));
+ currentSectioningUnit =
+ (Doc::SectioningUnit) (currentSectioningUnit - 1);
+ }
}
}
@@ -1821,10 +1820,10 @@ void DocParser::appendChar(QChar ch)
void DocParser::appendWord(const QString &word)
{
if (priv->text.lastAtom()->type() != Atom::String) {
- append(Atom::String, word);
+ append(Atom::String, word);
}
else
- priv->text.lastAtom()->appendString(word);
+ priv->text.lastAtom()->appendString(word);
}
void DocParser::appendToCode(const QString& markedCode)
@@ -1832,10 +1831,10 @@ void DocParser::appendToCode(const QString& markedCode)
Atom::Type lastType = priv->text.lastAtom()->type();
#ifdef QDOC_QML
if (lastType != Atom::Qml)
- append(Atom::Qml);
+ append(Atom::Qml);
#else
if (lastType != Atom::Code)
- append(Atom::Code);
+ append(Atom::Code);
#endif
priv->text.lastAtom()->appendString(markedCode);
}
@@ -1853,44 +1852,44 @@ void DocParser::enterPara(Atom::Type leftType,
if (paraState == OutsidePara) {
if (priv->text.lastAtom()->type() != Atom::ListItemLeft)
leaveValueList();
- append(leftType, string);
- indexStartedPara = false;
- pendingParaLeftType = leftType;
- pendingParaRightType = rightType;
- pendingParaString = string;
- if (
- leftType == Atom::SectionHeadingLeft) {
- paraState = InsideSingleLinePara;
- }
+ append(leftType, string);
+ indexStartedPara = false;
+ pendingParaLeftType = leftType;
+ pendingParaRightType = rightType;
+ pendingParaString = string;
+ if (
+ leftType == Atom::SectionHeadingLeft) {
+ paraState = InsideSingleLinePara;
+ }
else {
- paraState = InsideMultiLinePara;
- }
- skipSpacesOrOneEndl();
+ paraState = InsideMultiLinePara;
+ }
+ skipSpacesOrOneEndl();
}
}
void DocParser::leavePara()
{
if (paraState != OutsidePara) {
- if (!pendingFormats.isEmpty()) {
- location().warning(tr("Missing '}'"));
- pendingFormats.clear();
- }
-
- if (priv->text.lastAtom()->type() == pendingParaLeftType) {
- priv->text.stripLastAtom();
- }
+ if (!pendingFormats.isEmpty()) {
+ location().warning(tr("Missing '}'"));
+ pendingFormats.clear();
+ }
+
+ if (priv->text.lastAtom()->type() == pendingParaLeftType) {
+ priv->text.stripLastAtom();
+ }
else {
- if (priv->text.lastAtom()->type() == Atom::String &&
- priv->text.lastAtom()->string().endsWith(" ")) {
- priv->text.lastAtom()->chopString();
- }
- append(pendingParaRightType, pendingParaString);
- }
- paraState = OutsidePara;
- indexStartedPara = false;
- pendingParaRightType = Atom::Nop;
- pendingParaString = "";
+ if (priv->text.lastAtom()->type() == Atom::String &&
+ priv->text.lastAtom()->string().endsWith(" ")) {
+ priv->text.lastAtom()->chopString();
+ }
+ append(pendingParaRightType, pendingParaString);
+ }
+ paraState = OutsidePara;
+ indexStartedPara = false;
+ pendingParaRightType = Atom::Nop;
+ pendingParaString = "";
}
}
@@ -1898,13 +1897,13 @@ void DocParser::leaveValue()
{
leavePara();
if (openedLists.isEmpty()) {
- openedLists.push(OpenedList(OpenedList::Value));
- append(Atom::ListLeft, ATOM_LIST_VALUE);
+ openedLists.push(OpenedList(OpenedList::Value));
+ append(Atom::ListLeft, ATOM_LIST_VALUE);
}
else {
if (priv->text.lastAtom()->type() == Atom::Nop)
priv->text.stripLastAtom();
- append(Atom::ListItemRight, ATOM_LIST_VALUE);
+ append(Atom::ListItemRight, ATOM_LIST_VALUE);
}
}
@@ -1915,9 +1914,9 @@ void DocParser::leaveValueList()
(openedLists.top().style() == OpenedList::Value)) {
if (priv->text.lastAtom()->type() == Atom::Nop)
priv->text.stripLastAtom();
- append(Atom::ListItemRight, ATOM_LIST_VALUE);
- append(Atom::ListRight, ATOM_LIST_VALUE);
- openedLists.pop();
+ append(Atom::ListItemRight, ATOM_LIST_VALUE);
+ append(Atom::ListRight, ATOM_LIST_VALUE);
+ openedLists.pop();
}
}
@@ -1948,43 +1947,43 @@ void DocParser::expandMacro(const QString &name,
int numParams)
{
if (numParams == 0) {
- append(Atom::RawString, def);
+ append(Atom::RawString, def);
}
else {
- QStringList args;
- QString rawString;
+ QStringList args;
+ QString rawString;
- for (int i = 0; i < numParams; i++) {
- if (numParams == 1 || isLeftBraceAhead()) {
- args << getArgument(true);
- }
+ for (int i = 0; i < numParams; i++) {
+ if (numParams == 1 || isLeftBraceAhead()) {
+ args << getArgument(true);
+ }
else {
- location().warning(tr("Macro '\\%1' invoked with too few"
- " arguments (expected %2, got %3)")
- .arg(name).arg(numParams).arg(i));
- break;
- }
- }
-
- int j = 0;
- while (j < def.size()) {
- int paramNo;
- if ((def[j] == '\\') && (j < def.size() - 1) &&
+ location().warning(tr("Macro '\\%1' invoked with too few"
+ " arguments (expected %2, got %3)")
+ .arg(name).arg(numParams).arg(i));
+ break;
+ }
+ }
+
+ int j = 0;
+ while (j < def.size()) {
+ int paramNo;
+ if ((def[j] == '\\') && (j < def.size() - 1) &&
((paramNo = def[j + 1].digitValue()) >= 1) &&
(paramNo <= numParams)) {
- if (!rawString.isEmpty()) {
- append(Atom::RawString, rawString);
- rawString = "";
- }
- append(Atom::String, args[paramNo - 1]);
- j += 2;
- }
+ if (!rawString.isEmpty()) {
+ append(Atom::RawString, rawString);
+ rawString = "";
+ }
+ append(Atom::String, args[paramNo - 1]);
+ j += 2;
+ }
else {
- rawString += def[j++];
- }
- }
- if (!rawString.isEmpty())
- append(Atom::RawString, rawString);
+ rawString += def[j++];
+ }
+ }
+ if (!rawString.isEmpty())
+ append(Atom::RawString, rawString);
}
}
@@ -1993,29 +1992,29 @@ Doc::SectioningUnit DocParser::getSectioningUnit()
QString name = getOptionalArgument();
if (name == "part") {
- return Doc::Part;
+ return Doc::Part;
}
else if (name == "chapter") {
- return Doc::Chapter;
+ return Doc::Chapter;
}
else if (name == "section1") {
- return Doc::Section1;
+ return Doc::Section1;
}
else if (name == "section2") {
- return Doc::Section2;
+ return Doc::Section2;
}
else if (name == "section3") {
- return Doc::Section3;
+ return Doc::Section3;
}
else if (name == "section4") {
- return Doc::Section4;
+ return Doc::Section4;
}
else if (name.isEmpty()) {
- return Doc::Section4;
+ return Doc::Section4;
}
else {
- location().warning(tr("Invalid sectioning unit '%1'").arg(name));
- return Doc::Book;
+ location().warning(tr("Invalid sectioning unit '%1'").arg(name));
+ return Doc::Book;
}
}
@@ -2032,115 +2031,115 @@ QString DocParser::getArgument(bool verbatim)
Typically, an argument ends at the next white-space. However,
braces can be used to group words:
- {a few words}
+ {a few words}
Also, opening and closing parentheses have to match. Thus,
- printf("%d\n", x)
+ printf("%d\n", x)
is an argument too, although it contains spaces. Finally,
trailing punctuation is not included in an argument, nor is 's.
*/
if (pos < (int) in.length() && in[pos] == '{') {
- pos++;
- while (pos < (int) in.length() && delimDepth >= 0) {
- switch (in[pos].unicode()) {
- case '{':
- delimDepth++;
- arg += "{";
- pos++;
- break;
- case '}':
- delimDepth--;
- if (delimDepth >= 0)
- arg += "}";
- pos++;
- break;
- case '\\':
- if (verbatim) {
- arg += in[pos];
- pos++;
- }
+ pos++;
+ while (pos < (int) in.length() && delimDepth >= 0) {
+ switch (in[pos].unicode()) {
+ case '{':
+ delimDepth++;
+ arg += "{";
+ pos++;
+ break;
+ case '}':
+ delimDepth--;
+ if (delimDepth >= 0)
+ arg += "}";
+ pos++;
+ break;
+ case '\\':
+ if (verbatim) {
+ arg += in[pos];
+ pos++;
+ }
else {
- pos++;
- if (pos < (int) in.length()) {
- if (in[pos].isLetterOrNumber())
- break;
- arg += in[pos];
- if (in[pos].isSpace()) {
- skipAllSpaces();
- }
+ pos++;
+ if (pos < (int) in.length()) {
+ if (in[pos].isLetterOrNumber())
+ break;
+ arg += in[pos];
+ if (in[pos].isSpace()) {
+ skipAllSpaces();
+ }
else {
- pos++;
- }
- }
- }
- break;
- default:
- arg += in[pos];
- pos++;
- }
- }
- if (delimDepth > 0)
- location().warning(tr("Missing '}'"));
+ pos++;
+ }
+ }
+ }
+ break;
+ default:
+ arg += in[pos];
+ pos++;
+ }
+ }
+ if (delimDepth > 0)
+ location().warning(tr("Missing '}'"));
}
else {
- while (pos < in.length() &&
+ while (pos < in.length() &&
((delimDepth > 0) ||
((delimDepth == 0) &&
!in[pos].isSpace()))) {
- switch (in[pos].unicode()) {
- case '(':
- case '[':
- case '{':
- delimDepth++;
- arg += in[pos];
- pos++;
- break;
- case ')':
- case ']':
- case '}':
- delimDepth--;
- if (pos == startPos || delimDepth >= 0) {
- arg += in[pos];
- pos++;
- }
- break;
- case '\\':
- if (verbatim) {
- arg += in[pos];
- pos++;
- }
+ switch (in[pos].unicode()) {
+ case '(':
+ case '[':
+ case '{':
+ delimDepth++;
+ arg += in[pos];
+ pos++;
+ break;
+ case ')':
+ case ']':
+ case '}':
+ delimDepth--;
+ if (pos == startPos || delimDepth >= 0) {
+ arg += in[pos];
+ pos++;
+ }
+ break;
+ case '\\':
+ if (verbatim) {
+ arg += in[pos];
+ pos++;
+ }
else {
- pos++;
- if (pos < (int) in.length()) {
- if (in[pos].isLetterOrNumber())
- break;
- arg += in[pos];
- if (in[pos].isSpace()) {
- skipAllSpaces();
- }
+ pos++;
+ if (pos < (int) in.length()) {
+ if (in[pos].isLetterOrNumber())
+ break;
+ arg += in[pos];
+ if (in[pos].isSpace()) {
+ skipAllSpaces();
+ }
else {
- pos++;
- }
- }
- }
- break;
- default:
- arg += in[pos];
- pos++;
- }
- }
- if ((arg.length() > 1) &&
+ pos++;
+ }
+ }
+ }
+ break;
+ default:
+ arg += in[pos];
+ pos++;
+ }
+ }
+ if ((arg.length() > 1) &&
(QString(".,:;!?").indexOf(in[pos - 1]) != -1) &&
!arg.endsWith("...")) {
- arg.truncate(arg.length() - 1);
- pos--;
- }
- if (arg.length() > 2 && in.mid(pos - 2, 2) == "'s") {
- arg.truncate(arg.length() - 2);
- pos -= 2;
- }
+ arg.truncate(arg.length() - 1);
+ pos--;
+ }
+ if (arg.length() > 2 && in.mid(pos - 2, 2) == "'s") {
+ arg.truncate(arg.length() - 2);
+ pos -= 2;
+ }
}
return arg.simplified();
}
@@ -2149,11 +2148,11 @@ QString DocParser::getOptionalArgument()
{
skipSpacesOrOneEndl();
if (pos + 1 < (int) in.length() && in[pos] == '\\' &&
- in[pos + 1].isLetterOrNumber()) {
- return "";
+ in[pos + 1].isLetterOrNumber()) {
+ return "";
}
else {
- return getArgument();
+ return getArgument();
}
}
@@ -2216,7 +2215,7 @@ QString DocParser::getMetaCommandArgument(const QString &cmdStr)
else if (in.at(pos) == ')')
--parenDepth;
- ++pos;
+ ++pos;
}
if (pos == in.size() && parenDepth > 0) {
pos = begin;
@@ -2236,12 +2235,12 @@ QString DocParser::getUntilEnd(int cmd)
int end = rx.indexIn(in, pos);
if (end == -1) {
- location().warning(tr("Missing '\\%1'").arg(cmdName(endCmd)));
- pos = in.length();
+ location().warning(tr("Missing '\\%1'").arg(cmdName(endCmd)));
+ pos = in.length();
}
else {
- t = in.mid(pos, end - pos);
- pos = end + rx.matchedLength();
+ t = in.mid(pos, end - pos);
+ pos = end + rx.matchedLength();
}
return t;
}
@@ -2271,9 +2270,9 @@ bool DocParser::isBlankLine()
int i = pos;
while (i < len && in[i].isSpace()) {
- if (in[i] == '\n')
- return true;
- i++;
+ if (in[i] == '\n')
+ return true;
+ i++;
}
return false;
}
@@ -2284,10 +2283,10 @@ bool DocParser::isLeftBraceAhead()
int i = pos;
while (i < len && in[i].isSpace() && numEndl < 2) {
- // ### bug with '\\'
- if (in[i] == '\n')
- numEndl++;
- i++;
+ // ### bug with '\\'
+ if (in[i] == '\n')
+ numEndl++;
+ i++;
}
return numEndl < 2 && i < len && in[i] == '{';
}
@@ -2297,31 +2296,31 @@ void DocParser::skipSpacesOnLine()
while ((pos < in.length()) &&
in[pos].isSpace() &&
(in[pos].unicode() != '\n'))
- ++pos;
+ ++pos;
}
void DocParser::skipSpacesOrOneEndl()
{
int firstEndl = -1;
while (pos < (int) in.length() && in[pos].isSpace()) {
- QChar ch = in[pos];
- if (ch == '\n') {
- if (firstEndl == -1) {
- firstEndl = pos;
- }
+ QChar ch = in[pos];
+ if (ch == '\n') {
+ if (firstEndl == -1) {
+ firstEndl = pos;
+ }
else {
- pos = firstEndl;
- break;
- }
- }
- pos++;
+ pos = firstEndl;
+ break;
+ }
+ }
+ pos++;
}
}
void DocParser::skipAllSpaces()
{
while (pos < len && in[pos].isSpace())
- pos++;
+ pos++;
}
void DocParser::skipToNextPreprocessorCommand()
@@ -2332,62 +2331,62 @@ void DocParser::skipToNextPreprocessorCommand()
int end = rx.indexIn(in, pos + 1); // ### + 1 necessary?
if (end == -1)
- pos = in.length();
+ pos = in.length();
else
- pos = end;
+ pos = end;
}
int DocParser::endCmdFor(int cmd)
{
switch (cmd) {
case CMD_ABSTRACT:
- return CMD_ENDABSTRACT;
+ return CMD_ENDABSTRACT;
case CMD_BADCODE:
- return CMD_ENDCODE;
+ return CMD_ENDCODE;
case CMD_CHAPTER:
- return CMD_ENDCHAPTER;
+ return CMD_ENDCHAPTER;
case CMD_CODE:
- return CMD_ENDCODE;
+ return CMD_ENDCODE;
#ifdef QDOC_QML
case CMD_QML:
- return CMD_ENDQML;
+ return CMD_ENDQML;
case CMD_QMLTEXT:
- return CMD_ENDQMLTEXT;
+ return CMD_ENDQMLTEXT;
#endif
case CMD_FOOTNOTE:
- return CMD_ENDFOOTNOTE;
+ return CMD_ENDFOOTNOTE;
case CMD_LEGALESE:
return CMD_ENDLEGALESE;
case CMD_LINK:
return CMD_ENDLINK;
case CMD_LIST:
- return CMD_ENDLIST;
+ return CMD_ENDLIST;
case CMD_NEWCODE:
return CMD_ENDCODE;
case CMD_OLDCODE:
return CMD_NEWCODE;
case CMD_OMIT:
- return CMD_ENDOMIT;
+ return CMD_ENDOMIT;
case CMD_PART:
- return CMD_ENDPART;
+ return CMD_ENDPART;
case CMD_QUOTATION:
- return CMD_ENDQUOTATION;
+ return CMD_ENDQUOTATION;
case CMD_RAW:
return CMD_ENDRAW;
case CMD_SECTION1:
- return CMD_ENDSECTION1;
+ return CMD_ENDSECTION1;
case CMD_SECTION2:
- return CMD_ENDSECTION2;
+ return CMD_ENDSECTION2;
case CMD_SECTION3:
- return CMD_ENDSECTION3;
+ return CMD_ENDSECTION3;
case CMD_SECTION4:
- return CMD_ENDSECTION4;
+ return CMD_ENDSECTION4;
case CMD_SIDEBAR:
- return CMD_ENDSIDEBAR;
+ return CMD_ENDSIDEBAR;
case CMD_TABLE:
- return CMD_ENDTABLE;
+ return CMD_ENDTABLE;
default:
- return cmd;
+ return cmd;
}
}
@@ -2441,14 +2440,14 @@ int DocParser::indentLevel(const QString& str)
int column = 0;
for (int i = 0; i < (int) str.length(); i++) {
- if (str[i] == '\n') {
- column = 0;
- }
+ if (str[i] == '\n') {
+ column = 0;
+ }
else {
- if (str[i] != ' ' && column < minIndent)
- minIndent = column;
- column++;
- }
+ if (str[i] != ' ' && column < minIndent)
+ minIndent = column;
+ column++;
+ }
}
return minIndent;
}
@@ -2456,21 +2455,21 @@ int DocParser::indentLevel(const QString& str)
QString DocParser::unindent(int level, const QString& str)
{
if (level == 0)
- return str;
+ return str;
QString t;
int column = 0;
for (int i = 0; i < (int) str.length(); i++) {
if (str[i] == QLatin1Char('\n')) {
- t += '\n';
- column = 0;
- }
+ t += '\n';
+ column = 0;
+ }
else {
- if (column >= level)
- t += str[i];
- column++;
- }
+ if (column >= level)
+ t += str[i];
+ column++;
+ }
}
return t;
}
@@ -2508,15 +2507,15 @@ Doc::Doc(const Doc& doc)
Doc::~Doc()
{
if (priv && priv->deref())
- delete priv;
+ delete priv;
}
Doc &Doc::operator=(const Doc& doc)
{
if (doc.priv)
- doc.priv->ref();
+ doc.priv->ref();
if (priv && priv->deref())
- delete priv;
+ delete priv;
priv = doc.priv;
return *this;
}
@@ -2683,18 +2682,18 @@ Text Doc::trimmedBriefText(const QString &className) const
whats = w.join(" ");
if (whats.endsWith("."))
- whats.truncate(whats.length() - 1);
+ whats.truncate(whats.length() - 1);
if (whats.isEmpty()) {
- location().warning(
+ location().warning(
tr("Nonstandard wording in '\\%1' text for '%2' (expected more text)")
.arg(COMMAND_BRIEF).arg(className));
- standardWording = false;
+ standardWording = false;
}
else
- whats[0] = whats[0].toUpper();
+ whats[0] = whats[0].toUpper();
- // ### move this once \brief is abolished for properties
+ // ### move this once \brief is abolished for properties
if (standardWording)
resultText << whats;
}
@@ -2704,29 +2703,29 @@ Text Doc::trimmedBriefText(const QString &className) const
Text Doc::legaleseText() const
{
if (priv == 0 || !priv->hasLegalese)
- return Text();
+ return Text();
else
- return body().subText(Atom::LegaleseLeft, Atom::LegaleseRight);
+ return body().subText(Atom::LegaleseLeft, Atom::LegaleseRight);
}
const QString& Doc::baseName() const
{
static QString null;
if (priv == 0 || priv->extra == 0) {
- return null;
+ return null;
}
else {
- return priv->extra->baseName;
+ return priv->extra->baseName;
}
}
Doc::SectioningUnit Doc::granularity() const
{
if (priv == 0 || priv->extra == 0) {
- return DocPrivateExtra().granularity;
+ return DocPrivateExtra().granularity;
}
else {
- return priv->extra->granularity;
+ return priv->extra->granularity;
}
}
@@ -2822,80 +2821,80 @@ void Doc::initialize(const Config& config)
QSet<QString> commands = config.subVars(CONFIG_ALIAS);
QSet<QString>::ConstIterator c = commands.begin();
while (c != commands.end()) {
- QString alias = config.getString(CONFIG_ALIAS + Config::dot + *c);
- if (reverseAliasMap.contains(alias)) {
- config.lastLocation().warning(tr("Command name '\\%1' cannot stand"
- " for both '\\%2' and '\\%3'")
- .arg(alias)
- .arg(reverseAliasMap[alias])
- .arg(*c));
- }
+ QString alias = config.getString(CONFIG_ALIAS + Config::dot + *c);
+ if (reverseAliasMap.contains(alias)) {
+ config.lastLocation().warning(tr("Command name '\\%1' cannot stand"
+ " for both '\\%2' and '\\%3'")
+ .arg(alias)
+ .arg(reverseAliasMap[alias])
+ .arg(*c));
+ }
else {
- reverseAliasMap.insert(alias, *c);
- }
- aliasMap()->insert(*c, alias);
- ++c;
+ reverseAliasMap.insert(alias, *c);
+ }
+ aliasMap()->insert(*c, alias);
+ ++c;
}
int i = 0;
while (cmds[i].english) {
- cmds[i].alias = new QString(alias(cmds[i].english));
- cmdHash()->insert(*cmds[i].alias, cmds[i].no);
+ cmds[i].alias = new QString(alias(cmds[i].english));
+ cmdHash()->insert(*cmds[i].alias, cmds[i].no);
- if (cmds[i].no != i)
- Location::internalError(tr("command %1 missing").arg(i));
- i++;
+ if (cmds[i].no != i)
+ Location::internalError(tr("command %1 missing").arg(i));
+ i++;
}
QSet<QString> macroNames = config.subVars(CONFIG_MACRO);
QSet<QString>::ConstIterator n = macroNames.begin();
while (n != macroNames.end()) {
- QString macroDotName = CONFIG_MACRO + Config::dot + *n;
- Macro macro;
- macro.numParams = -1;
- macro.defaultDef = config.getString(macroDotName);
- if (!macro.defaultDef.isEmpty()) {
- macro.defaultDefLocation = config.lastLocation();
- macro.numParams = Config::numParams(macro.defaultDef);
- }
- bool silent = false;
-
- QSet<QString> formats = config.subVars(macroDotName);
- QSet<QString>::ConstIterator f = formats.begin();
- while (f != formats.end()) {
- QString def = config.getString(macroDotName + Config::dot + *f);
- if (!def.isEmpty()) {
- macro.otherDefs.insert(*f, def);
- int m = Config::numParams(macro.defaultDef);
- if (macro.numParams == -1) {
- macro.numParams = m;
- }
+ QString macroDotName = CONFIG_MACRO + Config::dot + *n;
+ Macro macro;
+ macro.numParams = -1;
+ macro.defaultDef = config.getString(macroDotName);
+ if (!macro.defaultDef.isEmpty()) {
+ macro.defaultDefLocation = config.lastLocation();
+ macro.numParams = Config::numParams(macro.defaultDef);
+ }
+ bool silent = false;
+
+ QSet<QString> formats = config.subVars(macroDotName);
+ QSet<QString>::ConstIterator f = formats.begin();
+ while (f != formats.end()) {
+ QString def = config.getString(macroDotName + Config::dot + *f);
+ if (!def.isEmpty()) {
+ macro.otherDefs.insert(*f, def);
+ int m = Config::numParams(macro.defaultDef);
+ if (macro.numParams == -1) {
+ macro.numParams = m;
+ }
else if (macro.numParams != m) {
- if (!silent) {
- QString other = tr("default");
- if (macro.defaultDef.isEmpty())
- other = macro.otherDefs.begin().key();
- config.lastLocation().warning(tr("Macro '\\%1' takes"
- " inconsistent number"
- " of arguments (%2"
- " %3, %4 %5)")
- .arg(*n)
- .arg(*f)
- .arg(m)
- .arg(other)
- .arg(macro.numParams));
- silent = true;
- }
- if (macro.numParams < m)
- macro.numParams = m;
- }
- }
- ++f;
- }
-
- if (macro.numParams != -1)
- macroHash()->insert(*n, macro);
- ++n;
+ if (!silent) {
+ QString other = tr("default");
+ if (macro.defaultDef.isEmpty())
+ other = macro.otherDefs.begin().key();
+ config.lastLocation().warning(tr("Macro '\\%1' takes"
+ " inconsistent number"
+ " of arguments (%2"
+ " %3, %4 %5)")
+ .arg(*n)
+ .arg(*f)
+ .arg(m)
+ .arg(other)
+ .arg(macro.numParams));
+ silent = true;
+ }
+ if (macro.numParams < m)
+ macro.numParams = m;
+ }
+ }
+ ++f;
+ }
+
+ if (macro.numParams != -1)
+ macroHash()->insert(*n, macro);
+ ++n;
}
}
@@ -2935,27 +2934,27 @@ void Doc::trimCStyleComment(Location& location, QString& str)
int i;
for (i = 0; i < (int) str.length(); i++) {
- if (m.columnNo() == asterColumn) {
- if (str[i] != '*')
- break;
- cleaned += ' ';
- metAsterColumn = true;
- }
+ if (m.columnNo() == asterColumn) {
+ if (str[i] != '*')
+ break;
+ cleaned += ' ';
+ metAsterColumn = true;
+ }
else {
- if (str[i] == '\n') {
- if (!metAsterColumn)
- break;
- metAsterColumn = false;
- }
- cleaned += str[i];
- }
- m.advance(str[i]);
+ if (str[i] == '\n') {
+ if (!metAsterColumn)
+ break;
+ metAsterColumn = false;
+ }
+ cleaned += str[i];
+ }
+ m.advance(str[i]);
}
if (cleaned.length() == str.length())
- str = cleaned;
+ str = cleaned;
for (int i = 0; i < 3; i++)
- location.advance(str[i]);
+ location.advance(str[i]);
str = str.mid(3, str.length() - 5);
}
@@ -2971,19 +2970,19 @@ CodeMarker *Doc::quoteFromFile(const Location &location,
QString filePath = Config::findFile(location,
DocParser::exampleFiles,
DocParser::exampleDirs,
- fileName, userFriendlyFilePath);
+ fileName, userFriendlyFilePath);
if (filePath.isEmpty()) {
- location.warning(tr("Cannot find example file '%1'").arg(fileName));
+ location.warning(tr("Cannot find example file '%1'").arg(fileName));
}
else {
- QFile inFile(filePath);
- if (!inFile.open(QFile::ReadOnly)) {
- location.warning(tr("Cannot open example file '%1'").arg(userFriendlyFilePath));
- }
+ QFile inFile(filePath);
+ if (!inFile.open(QFile::ReadOnly)) {
+ location.warning(tr("Cannot open example file '%1'").arg(userFriendlyFilePath));
+ }
else {
- QTextStream inStream(&inFile);
- code = DocParser::untabifyEtc(inStream.readAll());
- }
+ QTextStream inStream(&inFile);
+ code = DocParser::untabifyEtc(inStream.readAll());
+ }
}
QString dirPath = QFileInfo(filePath).path();