Add support for doxygen:alias feature

This allows to replace non-standard Doxygen commands with some (fixed) text
instead of just ignoring them, as was already possible with the feature
doxygen:ignore.
This commit is contained in:
Vadim Zeitlin 2017-02-01 02:06:16 +01:00
commit 751f617aac
7 changed files with 144 additions and 4 deletions

View file

@ -137,6 +137,11 @@ DoxygenParser::commandBelongs(const std::string &theCommand)
return it->second;
}
// Check if this command is defined as an alias.
if (String* const alias = Getattr(m_node, ("feature:doxygen:alias:" + theCommand).c_str())) {
return COMMAND_ALIAS;
}
// Check if this command should be ignored.
if (String* const ignore = getIgnoreFeature(theCommand)) {
// Check that no value is specified for this feature ("1" is the implicit
@ -895,6 +900,18 @@ DoxygenParser::addCommandUnique(const std::string &theCommand,
}
}
void
DoxygenParser::aliasCommand(const std::string& theCommand,
const TokenList& /* tokList */,
DoxygenEntityList &doxyList)
{
String* const alias = Getattr(m_node, ("feature:doxygen:alias:" + theCommand).c_str());
if (!alias)
return;
doxyList.push_back(DoxygenEntity("plainstd::string", Char(alias)));
}
String* DoxygenParser::getIgnoreFeature(const std::string& theCommand,
const char* argument) const
{
@ -1052,6 +1069,9 @@ DoxygenParser::addCommand(const std::string &commandString,
case COMMAND_HTML_ENTITY:
addCommandHtmlEntity(theCommand, tokList, doxyList);
break;
case COMMAND_ALIAS:
aliasCommand(commandString, tokList, doxyList);
break;
case COMMAND_IGNORE:
ignoreCommand(commandString, tokList, doxyList);
break;

View file

@ -39,6 +39,7 @@ private:
COMMANDUNIQUE,
COMMAND_HTML,
COMMAND_HTML_ENTITY,
COMMAND_ALIAS,
COMMAND_IGNORE,
END_LINE,
PARAGRAPH_END,
@ -346,6 +347,13 @@ private:
const TokenList &tokList,
DoxygenEntityList &doxyList);
/*
* Replace the given command with its predefined alias expansion.
*/
void aliasCommand(const std::string& theCommand,
const TokenList &tokList,
DoxygenEntityList &doxyList);
/*
* Simply ignore the given command, possibly with the word following it or
* until the matching end command.