summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qdoc/clangcodeparser.cpp29
-rw-r--r--src/qdoc/cppcodemarker.cpp13
-rw-r--r--src/qdoc/parameters.cpp6
3 files changed, 23 insertions, 25 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index bc894ccdf..b3df03cf6 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -880,8 +880,8 @@ void ClangVisitor::readParameterNamesAndAttributes(FunctionNode *fn, CXCursor cu
}
return CXChildVisit_Continue;
});
- ++i;
}
+ ++i;
}
return CXChildVisit_Continue;
});
@@ -1602,9 +1602,9 @@ Node *ClangCodeParser::parseFnArg(const Location &location, const QString &fnArg
not be found. Return 0 in that case.
*/
if (fnArg.startsWith('[')) {
- int end = fnArg.indexOf(QChar(']', 0));
- if (end > 1) {
- QString tag = fnArg.left(end + 1);
+ int tagEnd = fnArg.indexOf(QChar(']', 0));
+ if (tagEnd > 1) {
+ QString tag = fnArg.left(++tagEnd);
fnNode = qdb_->findFunctionNodeForTag(tag);
if (!fnNode) {
location.error(
@@ -1613,11 +1613,12 @@ Node *ClangCodeParser::parseFnArg(const Location &location, const QString &fnArg
} else {
/*
The function node was found. Use the formal
- parameter names from the \FN command, because
+ parameter names from the \fn command, because
they will be the names used in the documentation.
*/
+ QString fnSignature = fnArg.mid(tagEnd);
FunctionNode *fn = static_cast<FunctionNode *>(fnNode);
- QStringList leftParenSplit = fnArg.split('(');
+ QStringList leftParenSplit = fnSignature.mid(fnSignature.indexOf(fn->name())).split('(');
if (leftParenSplit.size() > 1) {
QStringList rightParenSplit = leftParenSplit[1].split(')');
if (rightParenSplit.size() > 0) {
@@ -1627,16 +1628,14 @@ Node *ClangCodeParser::parseFnArg(const Location &location, const QString &fnArg
Parameters &parameters = fn->parameters();
if (parameters.count() == commaSplit.size()) {
for (int i = 0; i < parameters.count(); ++i) {
- QStringList blankSplit = commaSplit[i].split(' ');
- if (blankSplit.size() > 0) {
+ QStringList blankSplit = commaSplit[i].split(' ', Qt::SkipEmptyParts);
+ if (blankSplit.size() > 1) {
QString pName = blankSplit.last();
- int j = 0;
- while (j < pName.length() && !pName.at(j).isLetter())
- ++j;
- if (j > 0)
- pName = pName.mid(j);
- if (!pName.isEmpty() && pName != parameters[i].name())
- parameters[i].setName(pName);
+ // Remove any non-letters from the start of parameter name
+ auto it = std::find_if(std::begin(pName), std::end(pName),
+ [](const QChar &c) { return c.isLetter(); });
+ parameters[i].setName(
+ pName.remove(0, std::distance(std::begin(pName), it)));
}
}
}
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index 3f3eedab2..341b8b651 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -143,15 +143,10 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, const Node * /* relati
QString name = parameters.at(i).name();
QString type = parameters.at(i).type();
QString value = parameters.at(i).defaultValue();
- QString paramName;
- if (!name.isEmpty()) {
- synopsis += typified(type, true);
- paramName = name;
- } else {
- paramName = type;
- }
- if (style != Section::AllMembers || name.isEmpty())
- synopsis += "<@param>" + protect(paramName) + "</@param>";
+ bool trailingSpace = style != Section::AllMembers && !name.isEmpty();
+ synopsis += typified(type, trailingSpace);
+ if (style != Section::AllMembers && !name.isEmpty())
+ synopsis += "<@param>" + protect(name) + "</@param>";
if (style != Section::AllMembers && !value.isEmpty())
synopsis += " = " + protect(value);
}
diff --git a/src/qdoc/parameters.cpp b/src/qdoc/parameters.cpp
index 84cbdce31..2a5443100 100644
--- a/src/qdoc/parameters.cpp
+++ b/src/qdoc/parameters.cpp
@@ -61,8 +61,12 @@ QRegularExpression Parameters::varComment_("^/\\*\\s*([a-zA-Z_0-9]+)\\s*\\*/$");
QString Parameter::signature(bool includeValue) const
{
QString p = type_;
- if (!p.endsWith(QChar('*')) && !p.endsWith(QChar('&')) && !p.endsWith(QChar(' ')))
+ if (!p.endsWith(QChar('*')) &&
+ !p.endsWith(QChar('&')) &&
+ !p.endsWith(QChar(' ')) &&
+ !name_.isEmpty()) {
p += QLatin1Char(' ');
+ }
p += name_;
if (includeValue && !defaultValue_.isEmpty())
p += " = " + defaultValue_;