Support doxygen \param[] commands
Recognize \param[in], \param[out], and \param[in,out]. Currently they
are all treated the same as \param, but the information is now
available for inclusion in the translated comments. This is done
using new utility functions getBaseCommand and getEndOfWordCommand,
which will also generalize to treatment of code command options,
e.g. \code{.py}. Preliminary treatment of the extended version of
\code is already in place in these functions.
Added examples of all three new \param commands to the
doxygen_translate_all_tags test and updated the python and java
expected output.
This commit is contained in:
parent
87bf8ae7aa
commit
eb11c025c7
7 changed files with 50 additions and 9 deletions
|
|
@ -34,6 +34,30 @@ std::set<std::string> DoxygenParser::doxygenSectionIndicators;
|
|||
const int TOKENSPERLINE = 8; //change this to change the printing behaviour of the token list
|
||||
const std::string END_HTML_TAG_MARK("/");
|
||||
|
||||
std::string getBaseCommand(const std::string &cmd) {
|
||||
if (cmd.substr(0,5) == "param")
|
||||
return "param";
|
||||
else if (cmd.substr(0,4) == "code")
|
||||
return "code";
|
||||
else
|
||||
return cmd;
|
||||
}
|
||||
|
||||
// Find the first position beyond the word command. Extra logic is
|
||||
// used to avoid putting the characters "," and "." in
|
||||
// DOXYGEN_WORD_CHARS.
|
||||
static size_t getEndOfWordCommand(const std::string &line, size_t pos) {
|
||||
size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos);
|
||||
if (line.substr(pos, 6) == "param[")
|
||||
// include ",", which can appear in param[in,out]
|
||||
endOfWordPos = line.find_first_not_of(string(DOXYGEN_WORD_CHARS)+ ",", pos);
|
||||
else if (line.substr(pos, 5) == "code{")
|
||||
// include ".", which can appear in e.g. code{.py}
|
||||
endOfWordPos = line.find_first_not_of(string(DOXYGEN_WORD_CHARS)+ ".", pos);
|
||||
return endOfWordPos;
|
||||
}
|
||||
|
||||
|
||||
DoxygenParser::DoxygenParser(bool noisy) : noisy(noisy) {
|
||||
fillTables();
|
||||
}
|
||||
|
|
@ -118,7 +142,7 @@ void DoxygenParser::printTree(const DoxygenEntityList &rootList) {
|
|||
}
|
||||
|
||||
DoxygenParser::DoxyCommandEnum DoxygenParser::commandBelongs(const std::string &theCommand) {
|
||||
DoxyCommandsMapIt it = doxygenCommands.find(stringToLower(theCommand));
|
||||
DoxyCommandsMapIt it = doxygenCommands.find(stringToLower(getBaseCommand(theCommand)));
|
||||
|
||||
if (it != doxygenCommands.end()) {
|
||||
return it->second;
|
||||
|
|
@ -312,7 +336,7 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph(const TokenList &to
|
|||
|
||||
} else if (endOfParagraph->m_tokenType == COMMAND) {
|
||||
|
||||
if (isSectionIndicator(endOfParagraph->m_tokenString)) {
|
||||
if (isSectionIndicator(getBaseCommand(endOfParagraph->m_tokenString))) {
|
||||
return endOfParagraph;
|
||||
} else {
|
||||
endOfParagraph++;
|
||||
|
|
@ -1154,7 +1178,7 @@ bool DoxygenParser::processEscapedChars(size_t &pos, const std::string &line) {
|
|||
*/
|
||||
void DoxygenParser::processWordCommands(size_t &pos, const std::string &line) {
|
||||
pos++;
|
||||
size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos);
|
||||
size_t endOfWordPos = getEndOfWordCommand(line, pos);
|
||||
|
||||
string cmd = line.substr(pos, endOfWordPos - pos);
|
||||
addDoxyCommand(m_tokenList, cmd);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@
|
|||
|
||||
#include "doxyentity.h"
|
||||
|
||||
// Utility function to return the base part of a command that may
|
||||
// include options, e.g. param[in] -> param
|
||||
std::string getBaseCommand(const std::string &cmd);
|
||||
|
||||
|
||||
class DoxygenParser {
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ std::string JavaDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) {
|
|||
void JavaDocConverter::translateEntity(DoxygenEntity &tag, std::string &translatedComment) {
|
||||
|
||||
std::map<std::string, std::pair<tagHandler, std::string> >::iterator it;
|
||||
it = tagHandlers.find(tag.typeOfEntity);
|
||||
it = tagHandlers.find(getBaseCommand(tag.typeOfEntity));
|
||||
|
||||
if (it != tagHandlers.end()) {
|
||||
(this->*(it->second.first))(tag, translatedComment, it->second.second);
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ std::string PyDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) {
|
|||
void PyDocConverter::translateEntity(DoxygenEntity &doxyEntity, std::string &translatedComment) {
|
||||
// check if we have needed handler and call it
|
||||
std::map<std::string, std::pair<tagHandler, std::string> >::iterator it;
|
||||
it = tagHandlers.find(doxyEntity.typeOfEntity);
|
||||
it = tagHandlers.find(getBaseCommand(doxyEntity.typeOfEntity));
|
||||
if (it != tagHandlers.end())
|
||||
(this->*(it->second.first)) (doxyEntity, translatedComment, it->second.second);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue