Give warnings for unknown Doxygen commands in Doxygen parser.

Silently ignoring unknown Doxygen commands is not a reasonable default
behaviour, it's simple enough to turn off the warning if the command is really
supposed to be just ignored, but it's too easy to not notice a real problem if
it isn't.

Turn WARN_DOXYGEN_UNKNOWN_COMMAND on by default and add a test to the errors
test suite checking that it is indeed given.
This commit is contained in:
Vadim Zeitlin 2014-08-22 22:44:55 +02:00
commit a1d7930835
5 changed files with 39 additions and 7 deletions

View file

@ -1028,11 +1028,22 @@ bool DoxygenParser::addDoxyCommand(DoxygenParser::TokenList &tokList,
tokList.push_back(Token(COMMAND, cmd));
return true;
} else {
// Unknown commands are ignored, because they are
// also ignored by Doxygen - see test doxygen_misc_constructs.h, f. backslashB().
// This differs from original implementation in this class. Uncomment
// the line below to put unknown commands to output.
// tokList.push_back(Token(PLAINSTRING, cmd));
// This function is called for the special Doxygen commands, but also for
// HTML commands (or anything that looks like them, actually) and entities.
// We don't recognize all of those, so just ignore them and pass them
// through, but warn about unknown Doxygen commands as ignoring them will
// often result in wrong output being generated.
const char ch = *cmd.begin();
if (ch != '<' && ch != '&') {
// Before calling printListError() we must ensure that m_tokenListIt used
// by it is valid.
const TokenListCIt itSave = m_tokenListIt;
m_tokenListIt = m_tokenList.end();
printListError(WARN_DOXYGEN_UNKNOWN_COMMAND, "unknown command \"" + cmd + '"');
m_tokenListIt = itSave;
}
}
return false;
@ -1431,5 +1442,5 @@ void DoxygenParser::printListError(int warningType, const std::string &message)
}
Swig_warning(warningType, m_fileName.c_str(), curLine,
"Doxygen parser warning: %s. \n", message.c_str());
"Doxygen parser warning: %s.\n", message.c_str());
}