summaryrefslogtreecommitdiff
path: root/src/qdoc/doc.cpp
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2019-12-17 06:44:19 +0100
committerPaul Wicking <paul.wicking@qt.io>2019-12-17 09:08:20 +0100
commited6658c2c82e2d91f34d57e88b61648fb301baf4 (patch)
treebf1c298dd4b59acb55f3f3921c6b9edac407192c /src/qdoc/doc.cpp
parent9f13c865439c024364f999680ceceb296d9daeb2 (diff)
downloadqttools-ed6658c2c82e2d91f34d57e88b61648fb301baf4.tar.gz
clang-format QDoc
This patch is the result of formatting all of QDoc's source with clang-format. The clang-format style is from the qt5 super repo's _clang-format definition. The purpose is unify the style across the code, to avoid spending too much time on style related issues in reviews and cleanup patches. Future changes to QDoc can benefit from using git-clang-format in combination with the git commit hook provided in qtrepotools.git as mentioned in this email to the dev list: https://lists.qt-project.org/pipermail/development/2019-October/037682.html Change-Id: I8af6a051c8334b5f35862a4dcd3becce8ac500c2 Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'src/qdoc/doc.cpp')
-rw-r--r--src/qdoc/doc.cpp827
1 files changed, 357 insertions, 470 deletions
diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp
index 83033ca51..9929a2a2a 100644
--- a/src/qdoc/doc.cpp
+++ b/src/qdoc/doc.cpp
@@ -174,117 +174,116 @@ enum {
NOT_A_CMD
};
-static struct {
+static struct
+{
const char *english;
int no;
QString *alias;
-} cmds[] = {
- { "a", CMD_A, nullptr },
- { "annotatedlist", CMD_ANNOTATEDLIST, nullptr },
- { "b", CMD_B, nullptr },
- { "badcode", CMD_BADCODE, nullptr },
- { "bold", CMD_BOLD, nullptr },
- { "br", CMD_BR, nullptr },
- { "brief", CMD_BRIEF, nullptr },
- { "c", CMD_C, nullptr },
- { "caption", CMD_CAPTION, nullptr },
- { "code", CMD_CODE, nullptr },
- { "codeline", CMD_CODELINE, nullptr },
- { "div", CMD_DIV, nullptr},
- { "dots", CMD_DOTS, nullptr },
- { "e", CMD_E, nullptr },
- { "else", CMD_ELSE, nullptr },
- { "endcode", CMD_ENDCODE, nullptr },
- { "enddiv", CMD_ENDDIV, nullptr },
- { "endfootnote", CMD_ENDFOOTNOTE, nullptr },
- { "endif", CMD_ENDIF, nullptr },
- { "endlegalese", CMD_ENDLEGALESE, nullptr },
- { "endlink", CMD_ENDLINK, nullptr },
- { "endlist", CMD_ENDLIST, nullptr },
- { "endmapref", CMD_ENDMAPREF, nullptr },
- { "endomit", CMD_ENDOMIT, nullptr },
- { "endquotation", CMD_ENDQUOTATION, nullptr },
- { "endraw", CMD_ENDRAW, nullptr },
- { "endsection1", CMD_ENDSECTION1, nullptr }, // ### don't document for now
- { "endsection2", CMD_ENDSECTION2, nullptr }, // ### don't document for now
- { "endsection3", CMD_ENDSECTION3, nullptr }, // ### don't document for now
- { "endsection4", CMD_ENDSECTION4, nullptr }, // ### don't document for now
- { "endsidebar", CMD_ENDSIDEBAR, nullptr },
- { "endtable", CMD_ENDTABLE, nullptr },
- { "endtopicref", CMD_ENDTOPICREF, nullptr },
- { "footnote", CMD_FOOTNOTE, nullptr },
- { "generatelist", CMD_GENERATELIST, nullptr },
- { "granularity", CMD_GRANULARITY, nullptr }, // ### don't document for now
- { "header", CMD_HEADER, nullptr },
- { "hr", CMD_HR, nullptr },
- { "i", CMD_I, nullptr},
- { "if", CMD_IF, nullptr },
- { "image", CMD_IMAGE, nullptr },
- { "important", CMD_IMPORTANT, nullptr },
- { "include", CMD_INCLUDE, nullptr },
- { "inlineimage", CMD_INLINEIMAGE, nullptr },
- { "index", CMD_INDEX, nullptr }, // ### don't document for now
- { "input", CMD_INPUT, nullptr },
- { "keyword", CMD_KEYWORD, nullptr },
- { "l", CMD_L, nullptr },
- { "legalese", CMD_LEGALESE, nullptr},
- { "li", CMD_LI, nullptr},
- { "link", CMD_LINK, nullptr },
- { "list", CMD_LIST, nullptr },
- { "mapref", CMD_MAPREF, nullptr },
- { "meta", CMD_META, nullptr },
- { "newcode", CMD_NEWCODE, nullptr },
- { "note", CMD_NOTE, nullptr },
- { "o", CMD_O, nullptr },
- { "oldcode", CMD_OLDCODE, nullptr },
- { "omit", CMD_OMIT, nullptr },
- { "omitvalue", CMD_OMITVALUE, nullptr },
- { "overload", CMD_OVERLOAD, nullptr },
- { "printline", CMD_PRINTLINE, nullptr },
- { "printto", CMD_PRINTTO, nullptr },
- { "printuntil", CMD_PRINTUNTIL, nullptr },
- { "quotation", CMD_QUOTATION, nullptr },
- { "quotefile", CMD_QUOTEFILE, nullptr },
- { "quotefromfile", CMD_QUOTEFROMFILE, nullptr },
- { "quotefunction", CMD_QUOTEFUNCTION, nullptr },
- { "raw", CMD_RAW, nullptr },
- { "row", CMD_ROW, nullptr },
- { "sa", CMD_SA, nullptr },
- { "section1", CMD_SECTION1, nullptr },
- { "section2", CMD_SECTION2, nullptr },
- { "section3", CMD_SECTION3, nullptr },
- { "section4", CMD_SECTION4, nullptr },
- { "sidebar", CMD_SIDEBAR, nullptr },
- { "sincelist", CMD_SINCELIST, nullptr },
- { "skipline", CMD_SKIPLINE, nullptr },
- { "skipto", CMD_SKIPTO, nullptr },
- { "skipuntil", CMD_SKIPUNTIL, nullptr },
- { "snippet", CMD_SNIPPET, nullptr },
- { "span", CMD_SPAN, nullptr },
- { "sub", CMD_SUB, nullptr },
- { "sup", CMD_SUP, nullptr },
- { "table", CMD_TABLE, nullptr },
- { "tableofcontents", CMD_TABLEOFCONTENTS, nullptr },
- { "target", CMD_TARGET, nullptr },
- { "topicref", CMD_TOPICREF, nullptr },
- { "tt", CMD_TT, nullptr },
- { "uicontrol", CMD_UICONTROL, nullptr },
- { "underline", CMD_UNDERLINE, nullptr },
- { "unicode", CMD_UNICODE, nullptr },
- { "value", CMD_VALUE, nullptr },
- { "warning", CMD_WARNING, nullptr },
- { "qml", CMD_QML, nullptr },
- { "endqml", CMD_ENDQML, nullptr },
- { "cpp", CMD_CPP, nullptr },
- { "endcpp", CMD_ENDCPP, nullptr },
- { "qmltext", CMD_QMLTEXT, nullptr },
- { "endqmltext", CMD_ENDQMLTEXT, nullptr },
- { "cpptext", CMD_CPPTEXT, nullptr },
- { "endcpptext", CMD_ENDCPPTEXT, nullptr },
- { "js", CMD_JS, nullptr },
- { "endjs", CMD_ENDJS, nullptr},
- { nullptr, 0, nullptr }
-};
+} cmds[] = { { "a", CMD_A, nullptr },
+ { "annotatedlist", CMD_ANNOTATEDLIST, nullptr },
+ { "b", CMD_B, nullptr },
+ { "badcode", CMD_BADCODE, nullptr },
+ { "bold", CMD_BOLD, nullptr },
+ { "br", CMD_BR, nullptr },
+ { "brief", CMD_BRIEF, nullptr },
+ { "c", CMD_C, nullptr },
+ { "caption", CMD_CAPTION, nullptr },
+ { "code", CMD_CODE, nullptr },
+ { "codeline", CMD_CODELINE, nullptr },
+ { "div", CMD_DIV, nullptr },
+ { "dots", CMD_DOTS, nullptr },
+ { "e", CMD_E, nullptr },
+ { "else", CMD_ELSE, nullptr },
+ { "endcode", CMD_ENDCODE, nullptr },
+ { "enddiv", CMD_ENDDIV, nullptr },
+ { "endfootnote", CMD_ENDFOOTNOTE, nullptr },
+ { "endif", CMD_ENDIF, nullptr },
+ { "endlegalese", CMD_ENDLEGALESE, nullptr },
+ { "endlink", CMD_ENDLINK, nullptr },
+ { "endlist", CMD_ENDLIST, nullptr },
+ { "endmapref", CMD_ENDMAPREF, nullptr },
+ { "endomit", CMD_ENDOMIT, nullptr },
+ { "endquotation", CMD_ENDQUOTATION, nullptr },
+ { "endraw", CMD_ENDRAW, nullptr },
+ { "endsection1", CMD_ENDSECTION1, nullptr }, // ### don't document for now
+ { "endsection2", CMD_ENDSECTION2, nullptr }, // ### don't document for now
+ { "endsection3", CMD_ENDSECTION3, nullptr }, // ### don't document for now
+ { "endsection4", CMD_ENDSECTION4, nullptr }, // ### don't document for now
+ { "endsidebar", CMD_ENDSIDEBAR, nullptr },
+ { "endtable", CMD_ENDTABLE, nullptr },
+ { "endtopicref", CMD_ENDTOPICREF, nullptr },
+ { "footnote", CMD_FOOTNOTE, nullptr },
+ { "generatelist", CMD_GENERATELIST, nullptr },
+ { "granularity", CMD_GRANULARITY, nullptr }, // ### don't document for now
+ { "header", CMD_HEADER, nullptr },
+ { "hr", CMD_HR, nullptr },
+ { "i", CMD_I, nullptr },
+ { "if", CMD_IF, nullptr },
+ { "image", CMD_IMAGE, nullptr },
+ { "important", CMD_IMPORTANT, nullptr },
+ { "include", CMD_INCLUDE, nullptr },
+ { "inlineimage", CMD_INLINEIMAGE, nullptr },
+ { "index", CMD_INDEX, nullptr }, // ### don't document for now
+ { "input", CMD_INPUT, nullptr },
+ { "keyword", CMD_KEYWORD, nullptr },
+ { "l", CMD_L, nullptr },
+ { "legalese", CMD_LEGALESE, nullptr },
+ { "li", CMD_LI, nullptr },
+ { "link", CMD_LINK, nullptr },
+ { "list", CMD_LIST, nullptr },
+ { "mapref", CMD_MAPREF, nullptr },
+ { "meta", CMD_META, nullptr },
+ { "newcode", CMD_NEWCODE, nullptr },
+ { "note", CMD_NOTE, nullptr },
+ { "o", CMD_O, nullptr },
+ { "oldcode", CMD_OLDCODE, nullptr },
+ { "omit", CMD_OMIT, nullptr },
+ { "omitvalue", CMD_OMITVALUE, nullptr },
+ { "overload", CMD_OVERLOAD, nullptr },
+ { "printline", CMD_PRINTLINE, nullptr },
+ { "printto", CMD_PRINTTO, nullptr },
+ { "printuntil", CMD_PRINTUNTIL, nullptr },
+ { "quotation", CMD_QUOTATION, nullptr },
+ { "quotefile", CMD_QUOTEFILE, nullptr },
+ { "quotefromfile", CMD_QUOTEFROMFILE, nullptr },
+ { "quotefunction", CMD_QUOTEFUNCTION, nullptr },
+ { "raw", CMD_RAW, nullptr },
+ { "row", CMD_ROW, nullptr },
+ { "sa", CMD_SA, nullptr },
+ { "section1", CMD_SECTION1, nullptr },
+ { "section2", CMD_SECTION2, nullptr },
+ { "section3", CMD_SECTION3, nullptr },
+ { "section4", CMD_SECTION4, nullptr },
+ { "sidebar", CMD_SIDEBAR, nullptr },
+ { "sincelist", CMD_SINCELIST, nullptr },
+ { "skipline", CMD_SKIPLINE, nullptr },
+ { "skipto", CMD_SKIPTO, nullptr },
+ { "skipuntil", CMD_SKIPUNTIL, nullptr },
+ { "snippet", CMD_SNIPPET, nullptr },
+ { "span", CMD_SPAN, nullptr },
+ { "sub", CMD_SUB, nullptr },
+ { "sup", CMD_SUP, nullptr },
+ { "table", CMD_TABLE, nullptr },
+ { "tableofcontents", CMD_TABLEOFCONTENTS, nullptr },
+ { "target", CMD_TARGET, nullptr },
+ { "topicref", CMD_TOPICREF, nullptr },
+ { "tt", CMD_TT, nullptr },
+ { "uicontrol", CMD_UICONTROL, nullptr },
+ { "underline", CMD_UNDERLINE, nullptr },
+ { "unicode", CMD_UNICODE, nullptr },
+ { "value", CMD_VALUE, nullptr },
+ { "warning", CMD_WARNING, nullptr },
+ { "qml", CMD_QML, nullptr },
+ { "endqml", CMD_ENDQML, nullptr },
+ { "cpp", CMD_CPP, nullptr },
+ { "endcpp", CMD_ENDCPP, nullptr },
+ { "qmltext", CMD_QMLTEXT, nullptr },
+ { "endqmltext", CMD_ENDQMLTEXT, nullptr },
+ { "cpptext", CMD_CPPTEXT, nullptr },
+ { "endcpptext", CMD_ENDCPPTEXT, nullptr },
+ { "js", CMD_JS, nullptr },
+ { "endjs", CMD_ENDJS, nullptr },
+ { nullptr, 0, nullptr } };
typedef QHash<QString, int> QHash_QString_int;
typedef QHash<QString, Macro> QHash_QString_Macro;
@@ -296,24 +295,20 @@ Q_GLOBAL_STATIC(QHash_QString_Macro, macroHash)
class DocPrivateExtra
{
public:
- Doc::Sections granularity_;
- Doc::Sections section_; // ###
- QVector<Atom *> tableOfContents_;
- QVector<int> tableOfContentsLevels_;
- QVector<Atom *> keywords_;
- QVector<Atom *> targets_;
- QStringMultiMap metaMap_;
-
- DocPrivateExtra()
- : granularity_(Doc::Part)
- , section_(Doc::NoSection)
- { }
+ Doc::Sections granularity_;
+ Doc::Sections section_; // ###
+ QVector<Atom *> tableOfContents_;
+ QVector<int> tableOfContentsLevels_;
+ QVector<Atom *> keywords_;
+ QVector<Atom *> targets_;
+ QStringMultiMap metaMap_;
+
+ DocPrivateExtra() : granularity_(Doc::Part), section_(Doc::NoSection) {}
};
struct Shared // ### get rid of
{
- Shared()
- : count(1) { }
+ Shared() : count(1) {}
void ref() { ++count; }
bool deref() { return (--count == 0); }
@@ -323,8 +318,7 @@ struct Shared // ### get rid of
static QString cleanLink(const QString &link)
{
int colonPos = link.indexOf(':');
- if ((colonPos == -1) ||
- (!link.startsWith("file:") && !link.startsWith("mailto:")))
+ if ((colonPos == -1) || (!link.startsWith("file:") && !link.startsWith("mailto:")))
return link;
return link.mid(colonPos + 1).simplified();
}
@@ -334,8 +328,7 @@ typedef QMap<QString, ArgList> CommandMap;
class DocPrivate : public Shared
{
public:
- DocPrivate(const Location &start = Location::null,
- const Location &end = Location::null,
+ DocPrivate(const Location &start = Location::null, const Location &end = Location::null,
const QString &source = QString());
~DocPrivate();
@@ -361,9 +354,7 @@ public:
DitaRefList ditamap_;
};
-DocPrivate::DocPrivate(const Location &start,
- const Location &end,
- const QString &source)
+DocPrivate::DocPrivate(const Location &start, const Location &end, const QString &source)
: start_loc(start),
end_loc(end),
src(source),
@@ -404,9 +395,7 @@ bool DocPrivate::isEnumDocSimplifiable() const
while (atom) {
if (atom->type() == Atom::AutoLink || atom->type() == Atom::String) {
justMetColon = atom->string().endsWith(QLatin1Char(':'));
- }
- else if ((atom->type() == Atom::ListLeft) &&
- (atom->string() == ATOM_LIST_VALUE)) {
+ } else if ((atom->type() == Atom::ListLeft) && (atom->string() == ATOM_LIST_VALUE)) {
if (justMetColon || numValueTables > 0)
return false;
++numValueTables;
@@ -421,9 +410,7 @@ class DocParser
Q_DECLARE_TR_FUNCTIONS(QDoc::DocParser)
public:
- void parse(const QString &source,
- DocPrivate *docPrivate,
- const QSet<QString> &metaCommandSet,
+ void parse(const QString &source, DocPrivate *docPrivate, const QSet<QString> &metaCommandSet,
const QSet<QString> &possibleTopics);
static int endCmdFor(int cmd);
@@ -443,8 +430,7 @@ public:
private:
Location &location();
- QString detailsUnknownCommand(const QSet<QString> &metaCommandSet,
- const QString &str);
+ QString detailsUnknownCommand(const QSet<QString> &metaCommandSet, const QString &str);
void insertTarget(const QString &target, bool keyword);
void include(const QString &fileName, const QString &identifier);
void startFormat(const QString &format, int cmd);
@@ -463,8 +449,7 @@ private:
void appendToCode(const QString &code, Atom::AtomType defaultType);
void startNewPara();
void enterPara(Atom::AtomType leftType = Atom::ParaLeft,
- Atom::AtomType rightType = Atom::ParaRight,
- const QString &string = QString());
+ Atom::AtomType rightType = Atom::ParaRight, const QString &string = QString());
void leavePara();
void leaveValue();
void leaveValueList();
@@ -472,7 +457,8 @@ private:
CodeMarker *quoteFromFile();
bool expandMacro();
void expandMacro(const QString &name, const QString &def, int numParams);
- QString expandMacroToString(const QString &name, const QString &def, int numParams, const QString &matchExpr);
+ QString expandMacroToString(const QString &name, const QString &def, int numParams,
+ const QString &matchExpr);
Doc::Sections getSectioningUnit();
QString getArgument(bool verbatim = false);
QString getBracedArgument(bool verbatim);
@@ -504,12 +490,8 @@ private:
Location cachedLoc;
int cachedPos;
- DocPrivate* priv;
- enum ParagraphState {
- OutsideParagraph,
- InSingleLineParagraph,
- InMultiLineParagraph
- };
+ DocPrivate *priv;
+ enum ParagraphState { OutsideParagraph, InSingleLineParagraph, InMultiLineParagraph };
ParagraphState paraState;
bool inTableHeader;
bool inTableRow;
@@ -546,10 +528,8 @@ bool DocParser::quoting = false;
found in \a source. These metacommands are not markup text
commands. They are topic commands and related metacommands.
*/
-void DocParser::parse(const QString &source,
- DocPrivate *docPrivate,
- const QSet<QString> &metaCommandSet,
- const QSet<QString> &possibleTopics)
+void DocParser::parse(const QString &source, DocPrivate *docPrivate,
+ const QSet<QString> &metaCommandSet, const QSet<QString> &possibleTopics)
{
input_ = source;
pos = 0;
@@ -592,8 +572,7 @@ void DocParser::parse(const QString &source,
if (ch.isLetterOrNumber()) {
cmdStr += ch;
++pos;
- }
- else {
+ } else {
break;
}
}
@@ -604,31 +583,30 @@ void DocParser::parse(const QString &source,
if (input_.at(pos).isSpace()) {
skipAllSpaces();
appendChar(QLatin1Char(' '));
- }
- else {
+ } else {
appendChar(input_.at(pos++));
}
}
- }
- else {
+ } else {
// Ignore quoting atoms to make appendToCode()
// append to the correct atom.
if (!quoting || !isQuote(priv->text.lastAtom()))
lastAtom = priv->text.lastAtom();
- int cmd = cmdHash()->value(cmdStr,NOT_A_CMD);
+ int cmd = cmdHash()->value(cmdStr, NOT_A_CMD);
switch (cmd) {
case CMD_A:
enterPara();
p1 = getArgument();
- append(Atom::FormattingLeft,ATOM_FORMATTING_PARAMETER);
+ append(Atom::FormattingLeft, ATOM_FORMATTING_PARAMETER);
append(Atom::String, p1);
- append(Atom::FormattingRight,ATOM_FORMATTING_PARAMETER);
+ append(Atom::FormattingRight, ATOM_FORMATTING_PARAMETER);
priv->params.insert(p1);
break;
case CMD_BADCODE:
leavePara();
- append(Atom::CodeBad, getCode(CMD_BADCODE, marker, getMetaCommandArgument(cmdStr)));
+ append(Atom::CodeBad,
+ getCode(CMD_BADCODE, marker, getMetaCommandArgument(cmdStr)));
break;
case CMD_BR:
enterPara();
@@ -660,18 +638,19 @@ void DocParser::parse(const QString &source,
break;
case CMD_QML:
leavePara();
- append(Atom::Qml, getCode(CMD_QML,
- CodeMarker::markerForLanguage(QLatin1String("QML")),
- getMetaCommandArgument(cmdStr)));
+ append(Atom::Qml,
+ getCode(CMD_QML, CodeMarker::markerForLanguage(QLatin1String("QML")),
+ getMetaCommandArgument(cmdStr)));
break;
case CMD_QMLTEXT:
append(Atom::QmlText);
break;
case CMD_JS:
leavePara();
- append(Atom::JavaScript, getCode(CMD_JS,
- CodeMarker::markerForLanguage(QLatin1String("JavaScript")),
- getMetaCommandArgument(cmdStr)));
+ append(Atom::JavaScript,
+ getCode(CMD_JS,
+ CodeMarker::markerForLanguage(QLatin1String("JavaScript")),
+ getMetaCommandArgument(cmdStr)));
break;
case CMD_DIV:
leavePara();
@@ -764,7 +743,7 @@ void DocParser::parse(const QString &source,
case CMD_ENDLINK:
if (closeCommand(cmd)) {
if (priv->text.lastAtom()->type() == Atom::String
- && priv->text.lastAtom()->string().endsWith(QLatin1Char(' ')))
+ && priv->text.lastAtom()->string().endsWith(QLatin1Char(' ')))
priv->text.lastAtom()->chopString();
append(Atom::FormattingRight, ATOM_FORMATTING_LINK);
}
@@ -773,10 +752,8 @@ void DocParser::parse(const QString &source,
if (closeCommand(cmd)) {
leavePara();
if (openedLists.top().isStarted()) {
- append(Atom::ListItemRight,
- openedLists.top().styleString());
- append(Atom::ListRight,
- openedLists.top().styleString());
+ append(Atom::ListItemRight, openedLists.top().styleString());
+ append(Atom::ListRight, openedLists.top().styleString());
}
openedLists.pop();
}
@@ -836,13 +813,12 @@ void DocParser::parse(const QString &source,
append(Atom::SinceList, getRestOfLine().simplified());
break;
case CMD_GENERATELIST: {
- QString arg1 = getArgument();
- QString arg2 = getOptionalArgument();
- if (!arg2.isEmpty())
- arg1 += " " + arg2;
- append(Atom::GeneratedList, arg1);
- }
- break;
+ QString arg1 = getArgument();
+ QString arg2 = getOptionalArgument();
+ if (!arg2.isEmpty())
+ arg1 += " " + arg2;
+ append(Atom::GeneratedList, arg1);
+ } break;
case CMD_GRANULARITY:
priv->constructExtra();
priv->extra->granularity_ = getSectioningUnit();
@@ -855,16 +831,17 @@ void DocParser::parse(const QString &source,
} else {
if (openedCommands.contains(CMD_TABLE))
location().warning(tr("Cannot use '\\%1' within '\\%2'")
- .arg(cmdName(CMD_HEADER))
- .arg(cmdName(openedCommands.top())));
+ .arg(cmdName(CMD_HEADER))
+ .arg(cmdName(openedCommands.top())));
else
location().warning(tr("Cannot use '\\%1' outside of '\\%2'")
- .arg(cmdName(CMD_HEADER))
- .arg(cmdName(CMD_TABLE)));
+ .arg(cmdName(CMD_HEADER))
+ .arg(cmdName(CMD_TABLE)));
}
break;
case CMD_I:
- location().warning(tr("'\\i' is deprecated. Use '\\e' for italic or '\\li' for list item"));
+ location().warning(tr(
+ "'\\i' is deprecated. Use '\\e' for italic or '\\li' for list item"));
Q_FALLTHROUGH();
case CMD_E:
startFormat(ATOM_FORMATTING_ITALIC, cmd);
@@ -908,15 +885,15 @@ void DocParser::parse(const QString &source,
indexStartedPara = true;
} else {
const Atom *last = priv->text.lastAtom();
- if (indexStartedPara &&
- (last->type() != Atom::FormattingRight ||
- last->string() != ATOM_FORMATTING_INDEX))
+ if (indexStartedPara
+ && (last->type() != Atom::FormattingRight
+ || last->string() != ATOM_FORMATTING_INDEX))
indexStartedPara = false;
}
startFormat(ATOM_FORMATTING_INDEX, cmd);
break;
case CMD_KEYWORD:
- insertTarget(getRestOfLine(),true);
+ insertTarget(getRestOfLine(), true);
break;
case CMD_L:
enterPara();
@@ -926,14 +903,14 @@ void DocParser::parse(const QString &source,
p1 = getArgument();
append(p1, p2);
if (!p2.isEmpty() && !(priv->text.lastAtom()->error().isEmpty()))
- location().warning(tr("Check parameter in '[ ]' of '\\l' command: '%1', "
- "possible misspelling, or unrecognized module name")
- .arg(priv->text.lastAtom()->error()));
+ location().warning(
+ tr("Check parameter in '[ ]' of '\\l' command: '%1', "
+ "possible misspelling, or unrecognized module name")
+ .arg(priv->text.lastAtom()->error()));
if (isLeftBraceAhead()) {
currentLinkAtom = priv->text.lastAtom();
startFormat(ATOM_FORMATTING_LINK, cmd);
- }
- else {
+ } else {
append(Atom::FormattingLeft, ATOM_FORMATTING_LINK);
append(Atom::String, cleanLink(p1));
append(Atom::FormattingRight, ATOM_FORMATTING_LINK);
@@ -942,9 +919,10 @@ void DocParser::parse(const QString &source,
p1 = getArgument();
append(p1, p2);
if (!p2.isEmpty() && !(priv->text.lastAtom()->error().isEmpty()))
- location().warning(tr("Check parameter in '[ ]' of '\\l' command: '%1', "
- "possible misspelling, or unrecognized module name")
- .arg(priv->text.lastAtom()->error()));
+ location().warning(
+ tr("Check parameter in '[ ]' of '\\l' command: '%1', "
+ "possible misspelling, or unrecognized module name")
+ .arg(priv->text.lastAtom()->error()));
append(Atom::FormattingLeft, ATOM_FORMATTING_LINK);
append(Atom::String, cleanLink(p1));
append(Atom::FormattingRight, ATOM_FORMATTING_LINK);
@@ -969,8 +947,7 @@ void DocParser::parse(const QString &source,
case CMD_LIST:
if (openCommand(cmd)) {
leavePara();
- openedLists.push(OpenedList(location(),
- getOptionalArgument()));
+ openedLists.push(OpenedList(location(), getOptionalArgument()));
}
break;
case CMD_TOPICREF:
@@ -1030,9 +1007,9 @@ void DocParser::parse(const QString &source,
if (!inTableHeader && !inTableRow) {
location().warning(tr("Missing '\\%1' or '\\%2' before '\\%3'")
- .arg(cmdName(CMD_HEADER))
- .arg(cmdName(CMD_ROW))
- .arg(cmdName(CMD_LI)));
+ .arg(cmdName(CMD_HEADER))
+ .arg(cmdName(CMD_ROW))
+ .arg(cmdName(CMD_LI)));
append(Atom::TableRowLeft);
inTableRow = true;
} else if (inTableItem) {
@@ -1044,9 +1021,9 @@ void DocParser::parse(const QString &source,
inTableItem = true;
} else
location().warning(tr("Command '\\%1' outside of '\\%2' and '\\%3'")
- .arg(cmdName(cmd))
- .arg(cmdName(CMD_LIST))
- .arg(cmdName(CMD_TABLE)));
+ .arg(cmdName(cmd))
+ .arg(cmdName(CMD_LIST))
+ .arg(cmdName(CMD_TABLE)));
break;
case CMD_OLDCODE:
leavePara();
@@ -1130,7 +1107,9 @@ void DocParser::parse(const QString &source,
append(Atom::CodeQuoteArgument, slashed(marker->functionEndRegExp(p1)));
}
quoter.quoteTo(location(), cmdStr, slashed(marker->functionBeginRegExp(p1)));
- append(Atom::Code, quoter.quoteUntil(location(), cmdStr, slashed(marker->functionEndRegExp(p1))));
+ append(Atom::Code,
+ quoter.quoteUntil(location(), cmdStr,
+ slashed(marker->functionEndRegExp(p1))));
quoter.reset();
break;
}
@@ -1138,8 +1117,8 @@ void DocParser::parse(const QString &source,
leavePara();
p1 = getRestOfLine();
if (p1.isEmpty())
- location().warning(tr("Missing format name after '\\%1'")
- .arg(cmdName(CMD_RAW)));
+ location().warning(
+ tr("Missing format name after '\\%1'").arg(cmdName(CMD_RAW)));
append(Atom::FormatIf, p1);
append(Atom::RawString, untabifyEtc(getUntilEnd(cmd)));
append(Atom::FormatElse);
@@ -1151,17 +1130,17 @@ void DocParser::parse(const QString &source,
if (isLeftBraceAhead())
p1 = getArgument(true);
leaveTableRow();
- append(Atom::TableRowLeft,p1);
+ append(Atom::TableRowLeft, p1);
inTableRow = true;
} else {
if (openedCommands.contains(CMD_TABLE))
location().warning(tr("Cannot use '\\%1' within '\\%2'")
- .arg(cmdName(CMD_ROW))
- .arg(cmdName(openedCommands.top())));
+ .arg(cmdName(CMD_ROW))
+ .arg(cmdName(openedCommands.top())));
else
location().warning(tr("Cannot use '\\%1' outside of '\\%2'")
- .arg(cmdName(CMD_ROW))
- .arg(cmdName(CMD_TABLE)));
+ .arg(cmdName(CMD_ROW))
+ .arg(cmdName(CMD_TABLE)));
}
break;
case CMD_SA:
@@ -1258,7 +1237,7 @@ void DocParser::parse(const QString &source,
append(Atom::TableOfContents, p1);
break;
case CMD_TARGET:
- insertTarget(getRestOfLine(),false);
+ insertTarget(getRestOfLine(), false);
break;
case CMD_TT:
startFormat(ATOM_FORMATTING_TELETYPE, cmd);
@@ -1276,7 +1255,7 @@ void DocParser::parse(const QString &source,
uint unicodeChar = p1.toUInt(&ok, 0);
if (!ok || (unicodeChar == 0x0000) || (unicodeChar > 0xFFFE))
location().warning(tr("Invalid Unicode character '%1' specified with '%2'")
- .arg(p1, cmdName(CMD_UNICODE)));
+ .arg(p1, cmdName(CMD_UNICODE)));
else
append(Atom::String, QChar(unicodeChar));
break;
@@ -1286,7 +1265,8 @@ void DocParser::parse(const QString &source,
if (openedLists.top().style() == OpenedList::Value) {
QString p2;
p1 = getArgument();
- if (p1.startsWith(QLatin1String("[since ")) && p1.endsWith(QLatin1String("]"))) {
+ if (p1.startsWith(QLatin1String("[since "))
+ && p1.endsWith(QLatin1String("]"))) {
p2 = p1.mid(7, p1.length() - 8);
p1 = getArgument();
}
@@ -1327,32 +1307,33 @@ void DocParser::parse(const QString &source,
if (!p1.isEmpty()) {
append(Atom::ParaLeft);
append(Atom::String, "This function overloads ");
- append(Atom::AutoLink,p1);
+ append(Atom::AutoLink, p1);
append(Atom::String, ".");
append(Atom::ParaRight);
} else {
append(Atom::ParaLeft);
- append(Atom::String,"This is an overloaded function.");
+ append(Atom::String, "This is an overloaded function.");
append(Atom::ParaRight);
p1 = getMetaCommandArgument(cmdStr);
}
- priv->metaCommandMap[cmdStr].append(ArgLocPair(p1,location()));
+ priv->metaCommandMap[cmdStr].append(ArgLocPair(p1, location()));
break;
case NOT_A_CMD:
if (metaCommandSet.contains(cmdStr)) {
priv->metacommandsUsed.insert(cmdStr);
QString arg = getMetaCommandArgument(cmdStr);
- priv->metaCommandMap[cmdStr].append(ArgLocPair(arg,location()));
+ priv->metaCommandMap[cmdStr].append(ArgLocPair(arg, location()));
if (possibleTopics.contains(cmdStr)) {
if (!cmdStr.endsWith(QLatin1String("propertygroup")))
- priv->topics_.append(Topic(cmdStr,arg));
+ priv->topics_.append(Topic(cmdStr, arg));
}
} else if (macroHash()->contains(cmdStr)) {
const Macro &macro = macroHash()->value(cmdStr);
int numPendingFi = 0;
int numFormatDefs = 0;
QString matchExpr;
- for (auto it = macro.otherDefs.constBegin(); it != macro.otherDefs.constEnd(); ++it) {
+ for (auto it = macro.otherDefs.constBegin();
+ it != macro.otherDefs.constEnd(); ++it) {
if (it.key() == "match") {
matchExpr = it.value();
} else {
@@ -1372,15 +1353,12 @@ void DocParser::parse(const QString &source,
if (!macro.defaultDef.isEmpty()) {
if (numFormatDefs > 0) {
- macro.defaultDefLocation.warning(
- tr("Macro cannot have both "
- "format-specific and qdoc-"
- "syntax definitions"));
+ macro.defaultDefLocation.warning(tr("Macro cannot have both "
+ "format-specific and qdoc-"
+ "syntax definitions"));
} else {
- QString expanded = expandMacroToString(cmdStr,
- macro.defaultDef,
- macro.numParams,
- matchExpr);
+ QString expanded = expandMacroToString(cmdStr, macro.defaultDef,
+ macro.numParams, matchExpr);
input_.replace(backslashPos, endPos - backslashPos, expanded);
len = input_.length();
pos = backslashPos;
@@ -1408,15 +1386,14 @@ void DocParser::parse(const QString &source,
} else if (latin1Ch == '_' || latin1Ch == '@') {
++numStrangeSymbols;
++curPos;
- } else if ((latin1Ch == ':') &&
- (curPos < cmdStr.size() - 1) &&
- (cmdStr.at(curPos + 1) == QLatin1Char(':'))) {
+ } else if ((latin1Ch == ':') && (curPos < cmdStr.size() - 1)
+ && (cmdStr.at(curPos + 1) == QLatin1Char(':'))) {
++numStrangeSymbols;
curPos += 2;
} else if (latin1Ch == '(') {
if (curPos > 0) {
- if ((curPos < cmdStr.size() - 1) &&
- (cmdStr.at(curPos + 1) == QLatin1Char(')'))) {
+ if ((curPos < cmdStr.size() - 1)
+ && (cmdStr.at(curPos + 1) == QLatin1Char(')'))) {
++numStrangeSymbols;
pos += 2;
break;
@@ -1439,7 +1416,7 @@ void DocParser::parse(const QString &source,
// The QML and JS property group commands are no longer required
// for grouping QML and JS properties. They are allowed but ignored.
location().warning(tr("Unknown command '\\%1'").arg(cmdStr),
- detailsUnknownCommand(metaCommandSet,cmdStr));
+ detailsUnknownCommand(metaCommandSet, cmdStr));
}
enterPara();
append(Atom::UnknownCommand, cmdStr);
@@ -1471,10 +1448,9 @@ void DocParser::parse(const QString &source,
} else if (*format == ATOM_FORMATTING_LINK) {
// hack for C++ to support links like
// \l{QString::}{count()}
- if (currentLinkAtom &&
- currentLinkAtom->string().endsWith("::")) {
- QString suffix = Text::subText(currentLinkAtom,
- priv->text.lastAtom()).toString();
+ if (currentLinkAtom && currentLinkAtom->string().endsWith("::")) {
+ QString suffix =
+ Text::subText(currentLinkAtom, priv->text.lastAtom()).toString();
currentLinkAtom->appendString(suffix);
}
currentLinkAtom = nullptr;
@@ -1515,9 +1491,7 @@ void DocParser::parse(const QString &source,
} else {
if (ch.isSpace()) {
++pos;
- if ((ch == '\n') &&
- (paraState == InSingleLineParagraph ||
- isBlankLine())) {
+ if ((ch == '\n') && (paraState == InSingleLineParagraph || isBlankLine())) {
leavePara();
newWord = false;
} else {
@@ -1552,7 +1526,8 @@ void DocParser::parse(const QString &source,
} else if (latin1Ch == '_' || latin1Ch == '@') {
++numStrangeSymbols;
++pos;
- } else if (latin1Ch == ':' && pos < len - 1 && input_.at(pos + 1) == QLatin1Char(':')) {
+ } else if (latin1Ch == ':' && pos < len - 1
+ && input_.at(pos + 1) == QLatin1Char(':')) {
++numStrangeSymbols;
pos += 2;
} else if (latin1Ch == '(') {
@@ -1587,8 +1562,7 @@ void DocParser::parse(const QString &source,
appendWord(word);
else
append(Atom::AutoLink, word);
- }
- else {
+ } else {
appendWord(word);
}
}
@@ -1606,8 +1580,7 @@ void DocParser::parse(const QString &source,
if (openedCommands.top() != CMD_OMIT) {
location().warning(tr("Missing '\\%1'").arg(endCmdName(openedCommands.top())));
- }
- else if (preprocessorSkipping.count() > 0) {
+ } else if (preprocessorSkipping.count() > 0) {
location().warning(tr("Missing '\\%1'").arg(cmdName(CMD_ENDIF)));
}
@@ -1635,8 +1608,7 @@ Location &DocParser::location()
return cachedLoc;
}
-QString DocParser::detailsUnknownCommand(const QSet<QString> &metaCommandSet,
- const QString &str)
+QString DocParser::detailsUnknownCommand(const QSet<QString> &metaCommandSet, const QString &str)
{
QSet<QString> commandSet = metaCommandSet;
int i = 0;
@@ -1648,7 +1620,8 @@ QString DocParser::detailsUnknownCommand(const QSet<QString> &metaCommandSet,
if (aliasMap()->contains(str))
return tr("The command '\\%1' was renamed '\\%2' by the configuration"
" file. Use the new name.")
- .arg(str).arg((*aliasMap())[str]);
+ .arg(str)
+ .arg((*aliasMap())[str]);
QString best = nearestName(str, commandSet);
if (best.isEmpty())
@@ -1661,15 +1634,13 @@ 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)"));
- }
- else {
+ } else {
targetMap_.insert(target, location());
priv->constructExtra();
if (keyword) {
append(Atom::Keyword, target);
priv->extra->keywords_.append(priv->text.lastAtom());
- }
- else {
+ } else {
append(Atom::Target, target);
priv->extra->targets_.append(priv->text.lastAtom());
}
@@ -1685,14 +1656,11 @@ void DocParser::include(const QString &fileName, const QString &identifier)
QString filePath = Doc::config()->getIncludeFilePath(fileName);
if (filePath.isEmpty()) {
location().warning(tr("Cannot find qdoc include file '%1'").arg(fileName));
- }
- else {
+ } else {
QFile inFile(filePath);
if (!inFile.open(QFile::ReadOnly)) {
- location().warning(tr("Cannot open qdoc include file '%1'")
- .arg(userFriendlyFilePath));
- }
- else {
+ location().warning(tr("Cannot open qdoc include file '%1'").arg(userFriendlyFilePath));
+ } else {
location().push(userFriendlyFilePath);
QTextStream inStream(&inFile);
@@ -1703,15 +1671,14 @@ void DocParser::include(const QString &fileName, const QString &identifier)
input_.insert(pos, includedStuff);
len = input_.length();
openedInputs.push(pos + includedStuff.length());
- }
- else {
+ } else {
QStringList lineBuffer = includedStuff.split(QLatin1Char('\n'));
int i = 0;
int startLine = -1;
while (i < lineBuffer.size()) {
if (lineBuffer[i].startsWith("//!")) {
if (lineBuffer[i].contains(identifier)) {
- startLine = i+1;
+ startLine = i + 1;
break;
}
}
@@ -1719,31 +1686,28 @@ void DocParser::include(const QString &fileName, const QString &identifier)
}
if (startLine < 0) {
location().warning(tr("Cannot find '%1' in '%2'")
- .arg(identifier)
- .arg(userFriendlyFilePath));
+ .arg(identifier)
+ .arg(userFriendlyFilePath));
return;
-
}
QString result;
i = startLine;
do {
if (lineBuffer[i].startsWith("//!")) {
- if (i<lineBuffer.size()) {
+ if (i < lineBuffer.size()) {
if (lineBuffer[i].contains(identifier)) {
break;
}
}
- }
- else
+ } else
result += lineBuffer[i] + QLatin1Char('\n');
++i;
} while (i < lineBuffer.size());
if (result.isEmpty()) {
location().warning(tr("Empty qdoc snippet '%1' in '%2'")
- .arg(identifier)
- .arg(userFriendlyFilePath));
- }
- else {
+ .arg(identifier)
+ .arg(userFriendlyFilePath));
+ } else {
input_.insert(pos, result);
len = input_.length();
openedInputs.push(pos + result.length());
@@ -1759,8 +1723,7 @@ void DocParser::startFormat(const QString &format, int cmd)
for (const auto &item : qAsConst(pendingFormats)) {
if (item == format) {
- location().warning(tr("Cannot nest '\\%1' commands")
- .arg(cmdName(cmd)));
+ location().warning(tr("Cannot nest '\\%1' commands").arg(cmdName(cmd)));
return;
}
}
@@ -1772,8 +1735,7 @@ void DocParser::startFormat(const QString &format, int cmd)
pendingFormats.insert(braceDepth, format);
++braceDepth;
++pos;
- }
- else {
+ } else {
append(Atom::String, getArgument());
append(Atom::FormattingRight, format);
if (format == ATOM_FORMATTING_INDEX && indexStartedPara) {
@@ -1791,24 +1753,15 @@ bool DocParser::openCommand(int cmd)
if (cmd != CMD_LINK) {
if (outer == CMD_LIST) {
ok = (cmd == CMD_FOOTNOTE || cmd == CMD_LIST);
- }
- else if (outer == CMD_SIDEBAR) {
- ok = (cmd == CMD_LIST ||
- cmd == CMD_QUOTATION ||
- cmd == CMD_SIDEBAR);
- }
- else if (outer == CMD_QUOTATION) {
+ } else if (outer == CMD_SIDEBAR) {
+ ok = (cmd == CMD_LIST || cmd == CMD_QUOTATION || cmd == CMD_SIDEBAR);
+ } else if (outer == CMD_QUOTATION) {
ok = (cmd == CMD_LIST);
- }
- else if (outer == CMD_TABLE) {
- ok = (cmd == CMD_LIST ||
- cmd == CMD_FOOTNOTE ||
- cmd == CMD_QUOTATION);
- }
- else if (outer == CMD_FOOTNOTE || outer == CMD_LINK) {
+ } else if (outer == CMD_TABLE) {
+ ok = (cmd == CMD_LIST || cmd == CMD_FOOTNOTE || cmd == CMD_QUOTATION);
+ } else if (outer == CMD_FOOTNOTE || outer == CMD_LINK) {
ok = false;
- }
- else if (outer == CMD_TOPICREF)
+ } else if (outer == CMD_TOPICREF)
ok = (cmd == CMD_TOPICREF || cmd == CMD_MAPREF);
else if (outer == CMD_MAPREF)
ok = false;
@@ -1816,8 +1769,7 @@ bool DocParser::openCommand(int cmd)
if (ok) {
openedCommands.push(cmd);
- }
- else {
+ } else {
location().warning(tr("Can't use '\\%1' in '\\%2'").arg(cmdName(cmd)).arg(cmdName(outer)));
}
return ok;
@@ -1828,8 +1780,7 @@ bool DocParser::closeCommand(int endCmd)
if (endCmdFor(openedCommands.top()) == endCmd && openedCommands.size() > 1) {
openedCommands.pop();
return true;
- }
- else {
+ } else {
bool contains = false;
QStack<int> opened2 = openedCommands;
while (opened2.size() > 1) {
@@ -1843,12 +1794,11 @@ bool DocParser::closeCommand(int endCmd)
if (contains) {
while (endCmdFor(openedCommands.top()) != endCmd && openedCommands.size() > 1) {
location().warning(tr("Missing '\\%1' before '\\%2'")
- .arg(endCmdName(openedCommands.top()))
- .arg(cmdName(endCmd)));
+ .arg(endCmdName(openedCommands.top()))
+ .arg(cmdName(endCmd)));
openedCommands.pop();
}
- }
- else {
+ } else {
location().warning(tr("Unexpected '\\%1'").arg(cmdName(endCmd)));
}
return false;
@@ -1860,25 +1810,21 @@ void DocParser::startSection(Doc::Sections unit, int cmd)
leaveValueList();
if (currentSection == Doc::NoSection) {
- currentSection = (Doc::Sections) (unit);
+ currentSection = (Doc::Sections)(unit);
priv->constructExtra();
priv->extra->section_ = currentSection;
- }
- else
- endSection(unit,cmd);
+ } else
+ endSection(unit, cmd);
append(Atom::SectionLeft, QString::number(unit));
priv->constructExtra();
priv->extra->tableOfContents_.append(priv->text.lastAtom());
priv->extra->tableOfContentsLevels_.append(unit);
- enterPara(Atom::SectionHeadingLeft,
- Atom::SectionHeadingRight,
- QString::number(unit));
+ enterPara(Atom::SectionHeadingLeft, Atom::SectionHeadingRight, QString::number(unit));
currentSection = unit;
-
}
-void DocParser::endSection(int , int) // (int unit, int endCmd)
+void DocParser::endSection(int, int) // (int unit, int endCmd)
{
leavePara();
append(Atom::SectionRight, QString::number(currentSection));
@@ -1903,12 +1849,10 @@ void DocParser::parseAlso()
// hack for C++ to support links like \l{QString::}{count()}
if (target.endsWith("::"))
target += str;
- }
- else {
+ } else {
str = target;
}
- }
- else {
+ } else {
target = getArgument();
str = cleanLink(target);
if (target == QLatin1String("and") || target == QLatin1String("."))
@@ -1917,10 +1861,8 @@ void DocParser::parseAlso()
if (!skipMe) {
Text also;
- also << Atom(Atom::Link, target)
- << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
- << str
- << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
+ also << Atom(Atom::Link, target) << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
+ << str << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
priv->addAlso(also);
}
@@ -1928,8 +1870,7 @@ void DocParser::parseAlso()
if (pos < len && input_[pos] == ',') {
pos++;
skipSpacesOrOneEndl();
- }
- else if (input_[pos] != '\n') {
+ } else if (input_[pos] != '\n') {
location().warning(tr("Missing comma in '\\%1'").arg(cmdName(CMD_SA)));
}
}
@@ -1978,8 +1919,7 @@ void DocParser::appendChar(QChar ch)
if (ch == QLatin1Char(' ')) {
if (!atom->string().endsWith(QLatin1Char(' ')))
atom->appendChar(QLatin1Char(' '));
- }
- else
+ } else
atom->appendChar(ch);
}
@@ -1987,8 +1927,7 @@ void DocParser::appendWord(const QString &word)
{
if (priv->text.lastAtom()->type() != Atom::String) {
append(Atom::String, word);
- }
- else
+ } else
priv->text.lastAtom()->appendString(word);
}
@@ -2017,14 +1956,12 @@ void DocParser::startNewPara()
enterPara();
}
-void DocParser::enterPara(Atom::AtomType leftType,
- Atom::AtomType rightType,
- const QString &string)
+void DocParser::enterPara(Atom::AtomType leftType, Atom::AtomType rightType, const QString &string)
{
if (paraState == OutsideParagraph) {
- if ((priv->text.lastAtom()->type() != Atom::ListItemLeft) &&
- (priv->text.lastAtom()->type() != Atom::DivLeft)) {
+ if ((priv->text.lastAtom()->type() != Atom::ListItemLeft)
+ && (priv->text.lastAtom()->type() != Atom::DivLeft)) {
leaveValueList();
}
@@ -2035,8 +1972,7 @@ void DocParser::enterPara(Atom::AtomType leftType,
pendingParaString = string;
if (leftType == Atom::SectionHeadingLeft) {
paraState = InSingleLineParagraph;
- }
- else {
+ } else {
paraState = InMultiLineParagraph;
}
skipSpacesOrOneEndl();
@@ -2053,10 +1989,9 @@ void DocParser::leavePara()
if (priv->text.lastAtom()->type() == pendingParaLeftType) {
priv->text.stripLastAtom();
- }
- else {
- if (priv->text.lastAtom()->type() == Atom::String &&
- priv->text.lastAtom()->string().endsWith(QLatin1Char(' '))) {
+ } else {
+ if (priv->text.lastAtom()->type() == Atom::String
+ && priv->text.lastAtom()->string().endsWith(QLatin1Char(' '))) {
priv->text.lastAtom()->chopString();
}
append(pendingParaRightType, pendingParaString);
@@ -2074,8 +2009,7 @@ void DocParser::leaveValue()
if (openedLists.isEmpty()) {
openedLists.push(OpenedList(OpenedList::Value));
append(Atom::ListLeft, ATOM_LIST_VALUE);
- }
- else {
+ } else {
if (priv->text.lastAtom()->type() == Atom::Nop)
priv->text.stripLastAtom();
append(Atom::ListItemRight, ATOM_LIST_VALUE);
@@ -2085,8 +2019,7 @@ void DocParser::leaveValue()
void DocParser::leaveValueList()
{
leavePara();
- if (!openedLists.isEmpty() &&
- (openedLists.top().style() == OpenedList::Value)) {
+ if (!openedLists.isEmpty() && (openedLists.top().style() == OpenedList::Value)) {
if (priv->text.lastAtom()->type() == Atom::Nop)
priv->text.stripLastAtom();
append(Atom::ListItemRight, ATOM_LIST_VALUE);
@@ -2143,9 +2076,7 @@ bool DocParser::expandMacro()
if (macroHash()->contains(cmdStr)) {
const Macro &macro = macroHash()->value(cmdStr);
if (!macro.defaultDef.isEmpty()) {
- QString expanded = expandMacroToString(cmdStr,
- macro.defaultDef,
- macro.numParams,
+ QString expanded = expandMacroToString(cmdStr, macro.defaultDef, macro.numParams,
macro.otherDefs.value("match"));
input_.replace(backslashPos, pos - backslashPos, expanded);
len = input_.length();
@@ -2168,25 +2099,23 @@ bool DocParser::expandMacro()
return false;
}
-void DocParser::expandMacro(const QString &name,
- const QString &def,
- int numParams)
+void DocParser::expandMacro(const QString &name, const QString &def, int numParams)
{
if (numParams == 0) {
append(Atom::RawString, def);
- }
- else {
+ } else {
QStringList args;
QString rawString;
for (int i = 0; i < numParams; ++i) {
if (numParams == 1 || isLeftBraceAhead()) {
args << getArgument(true);
- }
- else {
+ } else {
location().warning(tr("Macro '\\%1' invoked with too few"
" arguments (expected %2, got %3)")
- .arg(name).arg(numParams).arg(i));
+ .arg(name)
+ .arg(numParams)
+ .arg(i));
numParams = i;
break;
}
@@ -2195,16 +2124,14 @@ void DocParser::expandMacro(const QString &name,
int j = 0;
while (j < def.size()) {
int paramNo;
- if (((paramNo = def[j].unicode()) >= 1) &&
- (paramNo <= numParams)) {
+ if (((paramNo = def[j].unicode()) >= 1) && (paramNo <= numParams)) {
if (!rawString.isEmpty()) {
append(Atom::RawString, rawString);
rawString.clear();
}
append(Atom::String, args[paramNo - 1]);
j += 1;
- }
- else {
+ } else {
rawString += def[j++];
}
}
@@ -2213,7 +2140,8 @@ void DocParser::expandMacro(const QString &name,
}
}
-QString DocParser::expandMacroToString(const QString &name, const QString &def, int numParams, const QString &matchExpr)
+QString DocParser::expandMacroToString(const QString &name, const QString &def, int numParams,
+ const QString &matchExpr)
{
QString rawString;
@@ -2224,11 +2152,12 @@ QString DocParser::expandMacroToString(const QString &name, const QString &def,
for (int i = 0; i < numParams; ++i) {
if (numParams == 1 || isLeftBraceAhead()) {
args << getArgument(true);
- }
- else {
+ } else {
location().warning(tr("Macro '\\%1' invoked with too few"
" arguments (expected %2, got %3)")
- .arg(name).arg(numParams).arg(i));
+ .arg(name)
+ .arg(numParams)
+ .arg(i));
numParams = i;
break;
}
@@ -2237,12 +2166,10 @@ QString DocParser::expandMacroToString(const QString &name, const QString &def,
int j = 0;
while (j < def.size()) {
int paramNo;
- if (((paramNo = def[j].unicode()) >= 1) &&
- (paramNo <= numParams)) {
+ if (((paramNo = def[j].unicode()) >= 1) && (paramNo <= numParams)) {
rawString += args[paramNo - 1];
j += 1;
- }
- else {
+ } else {
rawString += def[j++];
}
}
@@ -2269,20 +2196,15 @@ Doc::Sections DocParser::getSectioningUnit()
if (name == "section1") {
return Doc::Section1;
- }
- else if (name == "section2") {
+ } else if (name == "section2") {
return Doc::Section2;
- }
- else if (name == "section3") {
+ } else if (name == "section3") {
return Doc::Section3;
- }
- else if (name == "section4") {
+ } else if (name == "section4") {
return Doc::Section4;
- }
- else if (name.isEmpty()) {
+ } else if (name.isEmpty()) {
return Doc::NoSection;
- }
- else {
+ } else {
location().warning(tr("Invalid section '%1'").arg(name));
return Doc::NoSection;
}
@@ -2356,8 +2278,8 @@ QString DocParser::getArgument(bool verbatim)
int startPos = pos;
QString arg = getBracedArgument(verbatim);
if (arg.isEmpty()) {
- while ((pos < input_.length()) &&
- ((delimDepth > 0) || ((delimDepth == 0) && !input_[pos].isSpace()))) {
+ while ((pos < input_.length())
+ && ((delimDepth > 0) || ((delimDepth == 0) && !input_[pos].isSpace()))) {
switch (input_[pos].unicode()) {
case '(':
case '[':
@@ -2385,9 +2307,8 @@ QString DocParser::getArgument(bool verbatim)
}
}
endPos = pos;
- if ((arg.length() > 1) &&
- (QString(".,:;!?").indexOf(input_[pos - 1]) != -1) &&
- !arg.endsWith("...")) {
+ if ((arg.length() > 1) && (QString(".,:;!?").indexOf(input_[pos - 1]) != -1)
+ && !arg.endsWith("...")) {
arg.truncate(arg.length() - 1);
--pos;
}
@@ -2443,11 +2364,9 @@ QString DocParser::getBracketedArgument()
QString DocParser::getOptionalArgument()
{
skipSpacesOrOneEndl();
- if (pos + 1 < input_.length() && input_[pos] == '\\' &&
- input_[pos + 1].isLetterOrNumber()) {
+ if (pos + 1 < input_.length() && input_[pos] == '\\' && input_[pos + 1].isLetterOrNumber()) {
return QString();
- }
- else {
+ } else {
return getArgument();
}
}
@@ -2467,12 +2386,9 @@ QString DocParser::getRestOfLine()
if (input_[pos] == '\\' && !trailingSlash) {
trailingSlash = true;
++pos;
- while ((pos < input_.size()) &&
- input_[pos].isSpace() &&
- (input_[pos] != '\n'))
+ while ((pos < input_.size()) && input_[pos].isSpace() && (input_[pos] != '\n'))
++pos;
- }
- else {
+ } else {
trailingSlash = false;
++pos;
}
@@ -2534,8 +2450,7 @@ QString DocParser::getUntilEnd(int cmd)
if (end == -1) {
location().warning(tr("Missing '\\%1'").arg(cmdName(endCmd)));
pos = input_.length();
- }
- else {
+ } else {
t = input_.mid(pos, end - pos);
pos = end + rx.matchedLength();
}
@@ -2550,10 +2465,8 @@ QString DocParser::getCode(int cmd, CodeMarker *marker, const QString &argStr)
QStringList args = argStr.split(" ", QString::SkipEmptyParts);
int paramNo, j = 0;
while (j < code.size()) {
- if (code[j] == '\\'
- && j < code.size() - 1
- && (paramNo = code[j + 1].digitValue()) >= 1
- && paramNo <= args.size()) {
+ if (code[j] == '\\' && j < code.size() - 1 && (paramNo = code[j + 1].digitValue()) >= 1
+ && paramNo <= args.size()) {
QString p = args[paramNo - 1];
code.replace(j, 2, p);
j += qMin(1, p.size());
@@ -2624,9 +2537,7 @@ bool DocParser::isLeftBracketAhead()
*/
void DocParser::skipSpacesOnLine()
{
- while ((pos < input_.length()) &&
- input_[pos].isSpace() &&
- (input_[pos].unicode() != '\n'))
+ while ((pos < input_.length()) && input_[pos].isSpace() && (input_[pos].unicode() != '\n'))
++pos;
}
@@ -2641,8 +2552,7 @@ void DocParser::skipSpacesOrOneEndl()
if (ch == '\n') {
if (firstEndl == -1) {
firstEndl = pos;
- }
- else {
+ } else {
pos = firstEndl;
break;
}
@@ -2659,9 +2569,8 @@ void DocParser::skipAllSpaces()
void DocParser::skipToNextPreprocessorCommand()
{
- QRegExp rx("\\\\(?:" + cmdName(CMD_IF) + QLatin1Char('|') +
- cmdName(CMD_ELSE) + QLatin1Char('|') +
- cmdName(CMD_ENDIF) + ")\\b");
+ QRegExp rx("\\\\(?:" + cmdName(CMD_IF) + QLatin1Char('|') + cmdName(CMD_ELSE) + QLatin1Char('|')
+ + cmdName(CMD_ENDIF) + ")\\b");
int end = rx.indexIn(input_, pos + 1); // ### + 1 necessary?
if (end == -1)
@@ -2776,8 +2685,7 @@ int DocParser::indentLevel(const QString &str)
for (int i = 0; i < str.length(); ++i) {
if (str[i] == '\n') {
column = 0;
- }
- else {
+ } else {
if (str[i] != ' ' && column < minIndent)
minIndent = column;
++column;
@@ -2798,8 +2706,7 @@ QString DocParser::unindent(int level, const QString &str)
if (str[i] == QLatin1Char('\n')) {
t += '\n';
column = 0;
- }
- else {
+ } else {
if (column >= level)
t += str[i];
++column;
@@ -2821,9 +2728,7 @@ QString DocParser::slashed(const QString &str)
bool DocParser::isCode(const Atom *atom)
{
Atom::AtomType type = atom->type();
- return (type == Atom::Code
- || type == Atom::Qml
- || type == Atom::JavaScript);
+ return (type == Atom::Code || type == Atom::Qml || type == Atom::JavaScript);
}
/*!
@@ -2832,10 +2737,8 @@ bool DocParser::isCode(const Atom *atom)
bool DocParser::isQuote(const Atom *atom)
{
Atom::AtomType type = atom->type();
- return (type == Atom::CodeQuoteArgument
- || type == Atom::CodeQuoteCommand
- || type == Atom::SnippetCommand
- || type == Atom::SnippetIdentifier
+ return (type == Atom::CodeQuoteArgument || type == Atom::CodeQuoteCommand
+ || type == Atom::SnippetCommand || type == Atom::SnippetIdentifier
|| type == Atom::SnippetLocation);
}
@@ -2847,19 +2750,15 @@ bool DocParser::isQuote(const Atom *atom)
QML documentation, there is the case where the qdoc \e{qmlproperty}
command can appear multiple times in a qdoc comment.
*/
-Doc::Doc(const Location &start_loc,
- const Location &end_loc,
- const QString &source,
- const QSet<QString> &metaCommandSet,
- const QSet<QString> &topics)
+Doc::Doc(const Location &start_loc, const Location &end_loc, const QString &source,
+ const QSet<QString> &metaCommandSet, const QSet<QString> &topics)
{
priv = new DocPrivate(start_loc, end_loc, source);
DocParser parser;
parser.parse(source, priv, metaCommandSet, topics);
}
-Doc::Doc(const Doc &doc)
- : priv(nullptr)
+Doc::Doc(const Doc &doc) : priv(nullptr)
{
operator=(doc);
}
@@ -2890,15 +2789,14 @@ void Doc::simplifyEnumDoc()
Atom *atom = priv->text.firstAtom();
while (atom) {
- if ((atom->type() == Atom::ListLeft) &&
- (atom->string() == ATOM_LIST_VALUE)) {
- while (atom && ((atom->type() != Atom::ListRight) ||
- (atom->string() != ATOM_LIST_VALUE)))
+ if ((atom->type() == Atom::ListLeft) && (atom->string() == ATOM_LIST_VALUE)) {
+ while (atom
+ && ((atom->type() != Atom::ListRight)
+ || (atom->string() != ATOM_LIST_VALUE)))
atom = atom->next();
if (atom)
atom = atom->next();
- }
- else {
+ } else {
newText << *atom;
atom = atom->next();
}
@@ -2979,8 +2877,7 @@ Text Doc::trimmedBriefText(const QString &className) const
should be rethought.
*/
while (atom) {
- if (atom->type() == Atom::AutoLink
- || atom->type() == Atom::String) {
+ if (atom->type() == Atom::AutoLink || atom->type() == Atom::String) {
briefStr += atom->string();
} else if (atom->type() == Atom::C) {
briefStr += Generator::plainCode(atom->string());
@@ -2990,20 +2887,17 @@ Text Doc::trimmedBriefText(const QString &className) const
QStringList w = briefStr.split(QLatin1Char(' '));
if (!w.isEmpty() && w.first() == "Returns") {
- }
- else {
+ } else {
if (!w.isEmpty() && w.first() == "The")
w.removeFirst();
if (!w.isEmpty() && (w.first() == className || w.first() == classNameOnly))
w.removeFirst();
- if (!w.isEmpty() && ((w.first() == "class") ||
- (w.first() == "function") ||
- (w.first() == "macro") ||
- (w.first() == "widget") ||
- (w.first() == "namespace") ||
- (w.first() == "header")))
+ if (!w.isEmpty()
+ && ((w.first() == "class") || (w.first() == "function") || (w.first() == "macro")
+ || (w.first() == "widget") || (w.first() == "namespace")
+ || (w.first() == "header")))
w.removeFirst();
if (!w.isEmpty() && (w.first() == "is" || w.first() == "provides"))
@@ -3039,8 +2933,7 @@ Doc::Sections Doc::granularity() const
{
if (priv == nullptr || priv->extra == nullptr) {
return DocPrivateExtra().granularity_;
- }
- else {
+ } else {
return priv->extra->granularity_;
}
}
@@ -3166,9 +3059,9 @@ void Doc::initialize(const Config &config)
if (reverseAliasMap.contains(alias)) {
config.lastLocation().warning(tr("Command name '\\%1' cannot stand"
" for both '\\%2' and '\\%3'")
- .arg(alias)
- .arg(reverseAliasMap[alias])
- .arg(a));
+ .arg(alias)
+ .arg(reverseAliasMap[alias])
+ .arg(a));
} else {
reverseAliasMap.insert(alias, a);
}
@@ -3212,11 +3105,11 @@ void Doc::initialize(const Config &config)
" inconsistent number"
" of arguments (%2"
" %3, %4 %5)")
- .arg(macroName)
- .arg(f)
- .arg(m)
- .arg(other)
- .arg(macro.numParams));
+ .arg(macroName)
+ .arg(f)
+ .arg(m)
+ .arg(other)
+ .arg(macro.numParams));
silent = true;
}
if (macro.numParams < m)
@@ -3230,9 +3123,8 @@ void Doc::initialize(const Config &config)
// If any of the formats define quotinginformation, activate quoting
DocParser::quoting = config.getBool(CONFIG_QUOTINGINFORMATION);
for (const auto &format : config.getOutputFormats())
- DocParser::quoting = DocParser::quoting || config.getBool(format
- + Config::dot
- + CONFIG_QUOTINGINFORMATION);
+ DocParser::quoting = DocParser::quoting
+ || config.getBool(format + Config::dot + CONFIG_QUOTINGINFORMATION);
}
/*!
@@ -3279,8 +3171,7 @@ void Doc::trimCStyleComment(Location &location, QString &str)
break;
cleaned += ' ';
metAsterColumn = true;
- }
- else {
+ } else {
if (str[i] == '\n') {
if (!metAsterColumn)
break;
@@ -3298,24 +3189,18 @@ void Doc::trimCStyleComment(Location &location, QString &str)
str = str.mid(3, str.length() - 5);
}
-QString Doc::resolveFile(const Location &location,
- const QString &fileName,
+QString Doc::resolveFile(const Location &location, const QString &fileName,
QString *userFriendlyFilePath)
{
- const QString result = Config::findFile(location,
- DocParser::exampleFiles,
- DocParser::exampleDirs,
- fileName, userFriendlyFilePath);
- qCDebug(lcQdoc).noquote().nospace() << __FUNCTION__ << "(location="
- << location.fileName() << ':' << location.lineNo()
- << ", fileName=\"" << fileName << "\"), resolved to \""
- << result;
+ const QString result = Config::findFile(location, DocParser::exampleFiles,
+ DocParser::exampleDirs, fileName, userFriendlyFilePath);
+ qCDebug(lcQdoc).noquote().nospace()
+ << __FUNCTION__ << "(location=" << location.fileName() << ':' << location.lineNo()
+ << ", fileName=\"" << fileName << "\"), resolved to \"" << result;
return result;
}
-CodeMarker *Doc::quoteFromFile(const Location &location,
- Quoter &quoter,
- const QString &fileName)
+CodeMarker *Doc::quoteFromFile(const Location &location, Quoter &quoter, const QString &fileName)
{
quoter.reset();
@@ -3324,17 +3209,17 @@ CodeMarker *Doc::quoteFromFile(const Location &location,
QString userFriendlyFilePath;
const QString filePath = resolveFile(location, fileName, &userFriendlyFilePath);
if (filePath.isEmpty()) {
- QString details = QLatin1String("Example directories: ") + DocParser::exampleDirs.join(QLatin1Char(' '));
+ QString details = QLatin1String("Example directories: ")
+ + DocParser::exampleDirs.join(QLatin1Char(' '));
if (!DocParser::exampleFiles.isEmpty())
- details += QLatin1String(", example files: ") + DocParser::exampleFiles.join(QLatin1Char(' '));
+ details += QLatin1String(", example files: ")
+ + DocParser::exampleFiles.join(QLatin1Char(' '));
location.warning(tr("Cannot find file to quote from: '%1'").arg(fileName), details);
- }
- else {
+ } else {
QFile inFile(filePath);
if (!inFile.open(QFile::ReadOnly)) {
location.warning(tr("Cannot open file to quote from: '%1'").arg(userFriendlyFilePath));
- }
- else {
+ } else {
QTextStream inStream(&inFile);
code = DocParser::untabifyEtc(inStream.readAll());
}
@@ -3373,8 +3258,7 @@ QString Doc::canonicalTitle(const QString &title)
begun = true;
dashAppended = false;
lastAlnum = result.size();
- }
- else if (!dashAppended) {
+ } else if (!dashAppended) {
if (begun)
result += QLatin1Char('-');
dashAppended = true;
@@ -3415,6 +3299,9 @@ TopicRef::~TopicRef()
Returns a reference to the structure that will be used
for generating a DITA mao.
*/
-const DitaRefList& Doc::ditamap() const { return priv->ditamap_; }
+const DitaRefList &Doc::ditamap() const
+{
+ return priv->ditamap_;
+}
QT_END_NAMESPACE