summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3/doc.cpp
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@nokia.com>2011-01-14 13:02:57 (GMT)
committerMartin Smith <martin.smith@nokia.com>2011-01-14 13:02:57 (GMT)
commit74f63cebc430ef6634917577783dafeed9a233d5 (patch)
tree663d030b0ca0f6dba36260aa542d11c62792a7d8 /tools/qdoc3/doc.cpp
parent02d904d5983ff0597f52d8d6ec76439f81da6504 (diff)
downloadQt-74f63cebc430ef6634917577783dafeed9a233d5.zip
Qt-74f63cebc430ef6634917577783dafeed9a233d5.tar.gz
Qt-74f63cebc430ef6634917577783dafeed9a233d5.tar.bz2
qdoc: Added colorizing of individual table cells.
Diffstat (limited to 'tools/qdoc3/doc.cpp')
-rw-r--r--tools/qdoc3/doc.cpp146
1 files changed, 78 insertions, 68 deletions
diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp
index 7c3d141..36c1d94 100644
--- a/tools/qdoc3/doc.cpp
+++ b/tools/qdoc3/doc.cpp
@@ -364,6 +364,7 @@ class DocParser
void endSection(int unit, int endCmd);
void parseAlso();
void append(Atom::Type type, const QString& string = "");
+ void append(Atom::Type type, const QString& p1, const QString& p2);
void appendChar(QChar ch);
void appendWord(const QString &word);
void appendToCode(const QString &code);
@@ -467,7 +468,7 @@ void DocParser::parse(const QString& source,
CodeMarker *marker = 0;
Atom *currentLinkAtom = 0;
- QString x;
+ QString p1, p2;
QStack<bool> preprocessorSkipping;
int numPreprocessorSkipping = 0;
@@ -506,11 +507,11 @@ void DocParser::parse(const QString& source,
switch (cmd) {
case CMD_A:
enterPara();
- x = getArgument();
+ p1 = getArgument();
append(Atom::FormattingLeft,ATOM_FORMATTING_PARAMETER);
- append(Atom::String, x);
+ append(Atom::String, p1);
append(Atom::FormattingRight,ATOM_FORMATTING_PARAMETER);
- priv->params.insert(x);
+ priv->params.insert(p1);
break;
case CMD_ABSTRACT:
if (openCommand(cmd)) {
@@ -535,9 +536,9 @@ void DocParser::parse(const QString& source,
break;
case CMD_C:
enterPara();
- x = untabifyEtc(getArgument(true));
- marker = CodeMarker::markerForCode(x);
- append(Atom::C, marker->markedUpCode(x, 0, ""));
+ p1 = untabifyEtc(getArgument(true));
+ marker = CodeMarker::markerForCode(p1);
+ append(Atom::C, marker->markedUpCode(p1, 0, ""));
break;
case CMD_CAPTION:
leavePara();
@@ -560,14 +561,14 @@ void DocParser::parse(const QString& source,
break;
#endif
case CMD_DIV:
- x = getArgument(true);
+ p1 = getArgument(true);
leavePara();
- if (x.contains('=')) {
- enterPara(Atom::DivLeft, Atom::DivRight,x);
+ if (p1.contains('=')) {
+ enterPara(Atom::DivLeft, Atom::DivRight,p1);
openedCommands.push(cmd);
}
else {
- append(Atom::DivLeft, x);
+ append(Atom::DivLeft, p1);
openedCommands.push(cmd);
enterPara();
}
@@ -823,23 +824,23 @@ void DocParser::parse(const QString& source,
case CMD_L:
enterPara();
if (isLeftBraceAhead()) {
- x = getArgument();
- append(Atom::Link, x);
+ p1 = getArgument();
+ append(Atom::Link, p1);
if (isLeftBraceAhead()) {
currentLinkAtom = priv->text.lastAtom();
startFormat(ATOM_FORMATTING_LINK, cmd);
}
else {
append(Atom::FormattingLeft, ATOM_FORMATTING_LINK);
- append(Atom::String, cleanLink(x));
+ append(Atom::String, cleanLink(p1));
append(Atom::FormattingRight, ATOM_FORMATTING_LINK);
}
}
else {
- x = getArgument();
- append(Atom::Link, x);
+ p1 = getArgument();
+ append(Atom::Link, p1);
append(Atom::FormattingLeft, ATOM_FORMATTING_LINK);
- append(Atom::String, cleanLink(x));
+ append(Atom::String, cleanLink(p1));
append(Atom::FormattingRight, ATOM_FORMATTING_LINK);
}
break;
@@ -852,8 +853,8 @@ void DocParser::parse(const QString& source,
case CMD_LINK:
if (openCommand(cmd)) {
enterPara();
- x = getArgument();
- append(Atom::Link, x);
+ p1 = getArgument();
+ append(Atom::Link, p1);
append(Atom::FormattingLeft, ATOM_FORMATTING_LINK);
skipSpacesOrOneEndl();
}
@@ -867,8 +868,8 @@ void DocParser::parse(const QString& source,
break;
case CMD_META:
priv->constructExtra();
- x = getArgument();
- priv->extra->metaMap.insert(x, getRestOfLine());
+ p1 = getArgument();
+ priv->extra->metaMap.insert(p1, getRestOfLine());
break;
case CMD_NEWCODE:
location().warning(tr("Unexpected '\\%1'").arg(cmdName(CMD_NEWCODE)));
@@ -892,9 +893,13 @@ void DocParser::parse(const QString& source,
enterPara();
}
else if (openedCommands.top() == CMD_TABLE) {
- x = "1,1";
- if (isLeftBraceAhead())
- x = getArgument();
+ p1 = "1,1";
+ if (isLeftBraceAhead()) {
+ p1 = getArgument();
+ if (isLeftBraceAhead()) {
+ p2 = getArgument();
+ }
+ }
if (!inTableHeader && !inTableRow) {
location().warning(tr("Missing '\\%1' or '\\%1' before '\\%3'")
@@ -909,7 +914,7 @@ void DocParser::parse(const QString& source,
inTableItem = false;
}
- append(Atom::TableItemLeft, x);
+ append(Atom::TableItemLeft, p1, p2);
inTableItem = true;
}
else {
@@ -928,11 +933,11 @@ void DocParser::parse(const QString& source,
getUntilEnd(cmd);
break;
case CMD_OMITVALUE:
- x = getArgument();
- if (!priv->enumItemList.contains(x))
- priv->enumItemList.append(x);
- if (!priv->omitEnumItemList.contains(x))
- priv->omitEnumItemList.append(x);
+ p1 = getArgument();
+ if (!priv->enumItemList.contains(p1))
+ priv->enumItemList.append(p1);
+ if (!priv->omitEnumItemList.contains(p1))
+ priv->omitEnumItemList.append(p1);
break;
case CMD_PART:
startSection(Doc::Part, cmd);
@@ -1001,36 +1006,38 @@ void DocParser::parse(const QString& source,
case CMD_QUOTEFUNCTION:
leavePara();
marker = quoteFromFile();
- x = getRestOfLine();
+ p1 = getRestOfLine();
if (!quoting) {
quoter.quoteTo(location(), cmdStr,
- slashed(marker->functionBeginRegExp(x)));
+ slashed(marker->functionBeginRegExp(p1)));
append(Atom::Code,
quoter.quoteUntil(location(), cmdStr,
- slashed(marker->functionEndRegExp(x))));
+ slashed(marker->functionEndRegExp(p1))));
quoter.reset();
}
else {
append(Atom::CodeQuoteCommand, cmdStr);
- append(Atom::CodeQuoteArgument, slashed(marker->functionEndRegExp(x)));
+ append(Atom::CodeQuoteArgument, slashed(marker->functionEndRegExp(p1)));
}
break;
case CMD_RAW:
leavePara();
- x = getRestOfLine();
- if (x.isEmpty())
+ p1 = getRestOfLine();
+ if (p1.isEmpty())
location().warning(tr("Missing format name after '\\%1")
.arg(cmdName(CMD_RAW)));
- append(Atom::FormatIf, x);
+ append(Atom::FormatIf, p1);
append(Atom::RawString, untabifyEtc(getUntilEnd(cmd)));
append(Atom::FormatElse);
append(Atom::FormatEndif);
break;
case CMD_ROW:
if (openedCommands.top() == CMD_TABLE) {
- x = getArgument(true);
+ p1.clear();
+ if (isLeftBraceAhead())
+ p1 = getArgument(true);
leaveTableRow();
- append(Atom::TableRowLeft,x);
+ append(Atom::TableRowLeft,p1);
inTableRow = true;
}
else {
@@ -1124,22 +1131,22 @@ void DocParser::parse(const QString& source,
startFormat(ATOM_FORMATTING_SUPERSCRIPT, cmd);
break;
case CMD_TABLE:
- x = getRestOfLine();
+ p1 = getRestOfLine();
if (openCommand(cmd)) {
leavePara();
- append(Atom::TableLeft, x);
+ append(Atom::TableLeft, p1);
inTableHeader = false;
inTableRow = false;
inTableItem = false;
}
break;
case CMD_TABLEOFCONTENTS:
- x = "1";
+ p1 = "1";
if (isLeftBraceAhead())
- x = getArgument();
- x += ",";
- x += QString::number((int)getSectioningUnit());
- append(Atom::TableOfContents, x);
+ p1 = getArgument();
+ p1 += ",";
+ p1 += QString::number((int)getSectioningUnit());
+ append(Atom::TableOfContents, p1);
break;
case CMD_TARGET:
insertTarget(getRestOfLine(),false);
@@ -1152,16 +1159,16 @@ void DocParser::parse(const QString& source,
break;
case CMD_UNICODE:
enterPara();
- x = getArgument();
+ p1 = getArgument();
{
bool ok;
- uint unicodeChar = x.toUInt(&ok, 0);
+ uint unicodeChar = p1.toUInt(&ok, 0);
if (!ok ||
(unicodeChar == 0x0000) ||
(unicodeChar > 0xFFFE)) {
location().warning(tr("Invalid Unicode character '%1' specified "
"with '%2'")
- .arg(x, cmdName(CMD_UNICODE)));
+ .arg(p1, cmdName(CMD_UNICODE)));
}
else {
append(Atom::String, QChar(unicodeChar));
@@ -1171,13 +1178,13 @@ void DocParser::parse(const QString& source,
case CMD_VALUE:
leaveValue();
if (openedLists.top().style() == OpenedList::Value) {
- x = getArgument();
- if (!priv->enumItemList.contains(x))
- priv->enumItemList.append(x);
+ p1 = getArgument();
+ if (!priv->enumItemList.contains(p1))
+ priv->enumItemList.append(p1);
openedLists.top().next();
append(Atom::ListTagLeft, ATOM_LIST_VALUE);
- append(Atom::String, x);
+ append(Atom::String, p1);
append(Atom::ListTagRight, ATOM_LIST_VALUE);
append(Atom::ListItemLeft, ATOM_LIST_VALUE);
@@ -1198,13 +1205,13 @@ void DocParser::parse(const QString& source,
break;
case CMD_OVERLOAD:
priv->metacommandsUsed.insert(cmdStr);
- x.clear();
+ p1.clear();
if (!isBlankLine())
- x = getRestOfLine();
- if (!x.isEmpty()) {
+ p1 = getRestOfLine();
+ if (!p1.isEmpty()) {
append(Atom::ParaLeft);
append(Atom::String, "This function overloads ");
- append(Atom::AutoLink,x);
+ append(Atom::AutoLink,p1);
append(Atom::String, ".");
append(Atom::ParaRight);
}
@@ -1212,9 +1219,9 @@ void DocParser::parse(const QString& source,
append(Atom::ParaLeft);
append(Atom::String,"This is an overloaded function.");
append(Atom::ParaRight);
- x = getMetaCommandArgument(cmdStr);
+ p1 = getMetaCommandArgument(cmdStr);
}
- priv->metaCommandMap[cmdStr].append(x);
+ priv->metaCommandMap[cmdStr].append(p1);
break;
case NOT_A_CMD:
if (metaCommandSet.contains(cmdStr)) {
@@ -1816,9 +1823,6 @@ void DocParser::parseAlso()
}
//static bool debug = false;
-
-void DocParser::append(Atom::Type type, const QString &string)
-{
#if 0
if (type == Atom::DivLeft)
debug = true;
@@ -1827,17 +1831,23 @@ void DocParser::append(Atom::Type type, const QString &string)
if (type == Atom::DivRight)
debug = false;
#endif
+
+void DocParser::append(Atom::Type type, const QString &string)
+{
Atom::Type lastType = priv->text.lastAtom()->type();
-#ifdef QDOC_QML
- if (((lastType == Atom::Code) || (lastType == Atom::Code)) &&
-#else
- if ((lastType == Atom::Code) &&
-#endif
- priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
+ if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
priv->text.lastAtom()->chopString();
priv->text << Atom(type, string);
}
+void DocParser::append(Atom::Type type, const QString& p1, const QString& p2)
+{
+ Atom::Type lastType = priv->text.lastAtom()->type();
+ if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
+ priv->text.lastAtom()->chopString();
+ priv->text << Atom(type, p1, p2);
+}
+
void DocParser::appendChar(QChar ch)
{
if (priv->text.lastAtom()->type() != Atom::String)