Beautify doxygen source code
Just whitespace changes
This commit is contained in:
parent
73c585b994
commit
658eb26e19
11 changed files with 477 additions and 925 deletions
|
|
@ -21,7 +21,9 @@ const char *sectionIndicators[] = {
|
|||
"exception", "if", "ifnot", "invariant", "note", "par", "param",
|
||||
"tparam", "post", "pre", "remarks", "remark", "result", "return",
|
||||
"returns", "retval", "sa", "see", "since", "test", "throw", "throws",
|
||||
"todo", "version", "warning", "xrefitem"};
|
||||
"todo", "version", "warning", "xrefitem"
|
||||
};
|
||||
|
||||
const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionIndicators);
|
||||
|
||||
/* All of the doxygen commands divided up by how they are parsed */
|
||||
|
|
@ -31,7 +33,9 @@ const char *simpleCommands[] = {
|
|||
"endcond",
|
||||
"callgraph", "callergraph", "showinitializer", "hideinitializer", "internal",
|
||||
"nosubgrouping", "public", "publicsection", "private", "privatesection",
|
||||
"protected", "protectedsection", "tableofcontents"};
|
||||
"protected", "protectedsection", "tableofcontents"
|
||||
};
|
||||
|
||||
const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands);
|
||||
|
||||
const char *commandWords[] = {
|
||||
|
|
@ -39,52 +43,72 @@ const char *commandWords[] = {
|
|||
"namespace", "relatesalso", "anchor", "dontinclude", "include",
|
||||
"includelineno", "copydoc", "copybrief", "copydetails", "verbinclude",
|
||||
"htmlinclude", "extends", "implements", "memberof", "related", "relatedalso",
|
||||
"cite"};
|
||||
"cite"
|
||||
};
|
||||
|
||||
const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords);
|
||||
|
||||
const char *commandLines[] = {
|
||||
"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip",
|
||||
"until", "property"};
|
||||
"until", "property"
|
||||
};
|
||||
|
||||
const int commandLinesSize = sizeof(commandLines) / sizeof(*commandLines);
|
||||
|
||||
const char *commandParagraph[] = {
|
||||
"partofdescription", "result", "return", "returns", "remarks", "remark",
|
||||
"since", "test", "sa", "see", "pre", "post", "details", "invariant",
|
||||
"deprecated", "date", "note", "warning", "version", "todo", "bug",
|
||||
"attention", "brief", "author", "authors", "copyright", "short"};
|
||||
"attention", "brief", "author", "authors", "copyright", "short"
|
||||
};
|
||||
|
||||
const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph);
|
||||
|
||||
const char *commandEndCommands[] = {
|
||||
CMD_HTML_ONLY, "latexonly", "manonly", "xmlonly", "link", "rtfonly"};
|
||||
CMD_HTML_ONLY, "latexonly", "manonly", "xmlonly", "link", "rtfonly"
|
||||
};
|
||||
|
||||
const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands);
|
||||
|
||||
const char *commandWordParagraphs[] = {
|
||||
"param", "tparam", "throw", "throws", "retval", "exception", "example"};
|
||||
"param", "tparam", "throw", "throws", "retval", "exception", "example"
|
||||
};
|
||||
|
||||
const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs);
|
||||
|
||||
const char *commandWordLines[] = {
|
||||
"page", "subsection", "subsubsection", "section", "paragraph", "defgroup",
|
||||
"snippet", "mainpage"};
|
||||
"snippet", "mainpage"
|
||||
};
|
||||
|
||||
const int commandWordLinesSize = sizeof(commandWordLines) / sizeof(*commandWordLines);
|
||||
|
||||
const char *commandWordOWordOWords[] = {
|
||||
"category", "class", "protocol", "interface", "struct", "union"};
|
||||
"category", "class", "protocol", "interface", "struct", "union"
|
||||
};
|
||||
|
||||
const int commandWordOWordOWordsSize = sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords);
|
||||
|
||||
const char *commandOWords[] = {
|
||||
"dir", "file", "cond"};
|
||||
"dir", "file", "cond"
|
||||
};
|
||||
|
||||
const int commandOWordsSize = sizeof(commandOWords) / sizeof(*commandOWords);
|
||||
|
||||
const char *commandErrorThrowings[] = {
|
||||
"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header",
|
||||
"headerfilestd::list", "inherit", "l", "postheader", "endcode", "enddot", "endmsc", "endhtmlonly",
|
||||
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else",
|
||||
"endrtfonly"};
|
||||
"endrtfonly"
|
||||
};
|
||||
|
||||
const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings);
|
||||
|
||||
const char *commandUniques[] = {
|
||||
"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li",
|
||||
"if", "ifnot", "elseif", "else", "mscfile", "code", CMD_VERBATIM, "f{", "f[", "f$", "dot", "msc"};
|
||||
"if", "ifnot", "elseif", "else", "mscfile", "code", CMD_VERBATIM, "f{", "f[", "f$", "dot", "msc"
|
||||
};
|
||||
|
||||
const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques);
|
||||
|
||||
// These HTML commands are transformed when producing output in other formats.
|
||||
|
|
@ -103,27 +127,30 @@ const int commandHtmlSize = sizeof(commandHtml) / sizeof(*commandHtml);
|
|||
|
||||
// Only entities which are translatable to plain text are used here. Others
|
||||
// are copied unchanged to output.
|
||||
const char *commandHtmlEntities[] = { "©", "&trade", "®", // (C), (TM), (R)
|
||||
"<", // less-than symbol
|
||||
">", // greater-than symbol
|
||||
"&", // ampersand
|
||||
"&apos", // single quotation mark (straight)
|
||||
""", // double quotation mark (straight)
|
||||
"&lsquo", // left single quotation mark
|
||||
"&rsquo", // right single quotation mark
|
||||
"&ldquo", // left double quotation mark
|
||||
"&rdquo", // right double quotation mark
|
||||
"&ndash", // n-dash (for numeric ranges, e.g. 2–8)
|
||||
"&mdash", // --
|
||||
" ", //
|
||||
"×", // x
|
||||
"&minus", // -
|
||||
"&sdot", // .
|
||||
"&sim", // ~
|
||||
"&le", // <=
|
||||
"&ge", // >=
|
||||
"&larr", // <--
|
||||
"&rarr" // -->
|
||||
const char *commandHtmlEntities[] = {
|
||||
"©", // (C)
|
||||
"&trade", // (TM)
|
||||
"®", // (R)
|
||||
"<", // less-than symbol
|
||||
">", // greater-than symbol
|
||||
"&", // ampersand
|
||||
"&apos", // single quotation mark (straight)
|
||||
""", // double quotation mark (straight)
|
||||
"&lsquo", // left single quotation mark
|
||||
"&rsquo", // right single quotation mark
|
||||
"&ldquo", // left double quotation mark
|
||||
"&rdquo", // right double quotation mark
|
||||
"&ndash", // n-dash (for numeric ranges, e.g. 2–8)
|
||||
"&mdash", // --
|
||||
" ", //
|
||||
"×", // x
|
||||
"&minus", // -
|
||||
"&sdot", // .
|
||||
"&sim", // ~
|
||||
"&le", // <=
|
||||
"&ge", // >=
|
||||
"&larr", // <--
|
||||
"&rarr" // -->
|
||||
};
|
||||
|
||||
const int commandHtmlEntitiesSize = sizeof(commandHtmlEntities) / sizeof(*commandHtmlEntities);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,8 @@
|
|||
|
||||
using std::cout;
|
||||
|
||||
DoxygenEntity::DoxygenEntity(const std::string &typeEnt) :
|
||||
typeOfEntity(typeEnt),
|
||||
isLeaf(true)
|
||||
{}
|
||||
DoxygenEntity::DoxygenEntity(const std::string &typeEnt):typeOfEntity(typeEnt), isLeaf(true) {
|
||||
}
|
||||
|
||||
|
||||
/* Basic node for commands that have
|
||||
|
|
@ -27,23 +25,15 @@ DoxygenEntity::DoxygenEntity(const std::string &typeEnt) :
|
|||
* example: \b word
|
||||
* OR holding a std::string
|
||||
*/
|
||||
DoxygenEntity::DoxygenEntity(const std::string &typeEnt,
|
||||
const std::string ¶m1) :
|
||||
typeOfEntity(typeEnt),
|
||||
data(param1),
|
||||
isLeaf(true)
|
||||
{}
|
||||
DoxygenEntity::DoxygenEntity(const std::string &typeEnt, const std::string ¶m1) : typeOfEntity(typeEnt), data(param1), isLeaf(true) {
|
||||
}
|
||||
|
||||
|
||||
/* Nonterminal node
|
||||
* contains
|
||||
*/
|
||||
DoxygenEntity::DoxygenEntity(const std::string &typeEnt,
|
||||
const DoxygenEntityList &entList) :
|
||||
typeOfEntity(typeEnt),
|
||||
isLeaf(false),
|
||||
entityList(entList)
|
||||
{}
|
||||
DoxygenEntity::DoxygenEntity(const std::string &typeEnt, const DoxygenEntityList &entList) : typeOfEntity(typeEnt), isLeaf(false), entityList(entList) {
|
||||
}
|
||||
|
||||
|
||||
void DoxygenEntity::printEntity(int level) const {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
class DoxygenEntity;
|
||||
|
||||
typedef std::list <DoxygenEntity> DoxygenEntityList;
|
||||
typedef std::list<DoxygenEntity> DoxygenEntityList;
|
||||
typedef DoxygenEntityList::iterator DoxygenEntityListIt;
|
||||
typedef DoxygenEntityList::const_iterator DoxygenEntityListCIt;
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
DoxygenEntity(const std::string &typeEnt);
|
||||
DoxygenEntity(const std::string &typeEnt, const std::string ¶m1);
|
||||
DoxygenEntity(const std::string & typeEnt, const DoxygenEntityList &entList);
|
||||
DoxygenEntity(const std::string &typeEnt, const DoxygenEntityList &entList);
|
||||
|
||||
void printEntity(int level) const;
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -52,14 +52,12 @@ private:
|
|||
class Token {
|
||||
public:
|
||||
DoxyCommandEnum m_tokenType;
|
||||
std::string m_tokenString; /* the data , such as param for @param */
|
||||
|
||||
Token(DoxyCommandEnum tType, std::string tString) :
|
||||
m_tokenType(tType),
|
||||
m_tokenString(tString) {}
|
||||
std::string m_tokenString; /* the data , such as param for @param */
|
||||
|
||||
Token(DoxyCommandEnum tType, std::string tString) : m_tokenType(tType), m_tokenString(tString) {
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
|
||||
switch (m_tokenType) {
|
||||
case END_LINE:
|
||||
return "{END OF LINE}";
|
||||
|
|
@ -96,7 +94,7 @@ private:
|
|||
bool m_isVerbatimText; // used to handle \htmlonly and \verbatim commands
|
||||
bool m_isInQuotedString;
|
||||
|
||||
Node* m_node;
|
||||
Node *m_node;
|
||||
std::string m_fileName;
|
||||
int m_fileLineNo;
|
||||
|
||||
|
|
@ -104,17 +102,17 @@ private:
|
|||
* Return the end command for a command appearing in "ignore" feature or empty
|
||||
* string if this is a simple command and not a block one.
|
||||
*/
|
||||
std::string getIgnoreFeatureEndCommand(const std::string& theCommand) const;
|
||||
std::string getIgnoreFeatureEndCommand(const std::string &theCommand) const;
|
||||
|
||||
/*
|
||||
* Helper for getting the value of doxygen:ignore feature or its argument.
|
||||
*/
|
||||
String* getIgnoreFeature(const std::string& theCommand, const char* argument = NULL) const;
|
||||
String *getIgnoreFeature(const std::string &theCommand, const char *argument = NULL) const;
|
||||
|
||||
/*
|
||||
* Whether to print lots of debug info during parsing
|
||||
*/
|
||||
bool noisy;
|
||||
/*
|
||||
* Whether to print lots of debug info during parsing
|
||||
*/
|
||||
bool noisy;
|
||||
|
||||
/*
|
||||
*Changes a std::string to all lower case
|
||||
|
|
@ -136,7 +134,7 @@ private:
|
|||
/*
|
||||
*prints the parse tree
|
||||
*/
|
||||
void printTree(const std::list <DoxygenEntity> &rootList);
|
||||
void printTree(const std::list<DoxygenEntity> &rootList);
|
||||
|
||||
/**
|
||||
* Returns true if the next token is end of line token. This is important
|
||||
|
|
@ -190,8 +188,7 @@ private:
|
|||
* up til the command specified is encountered
|
||||
*/
|
||||
//TODO check that this behaves properly for formulas
|
||||
std::string getStringTilEndCommand(const std::string &theCommand,
|
||||
const TokenList &tokList);
|
||||
std::string getStringTilEndCommand(const std::string &theCommand, const TokenList &tokList);
|
||||
|
||||
/*
|
||||
* Returns the end of a Paragraph as an iterator-
|
||||
|
|
@ -205,8 +202,7 @@ private:
|
|||
* encounter of the same command. Example of this behaviour is \arg.
|
||||
* If no end is encountered, returns the last token of the std::list.
|
||||
*/
|
||||
TokenListCIt getEndOfSection(const std::string &theCommand,
|
||||
const TokenList &tokList);
|
||||
TokenListCIt getEndOfSection(const std::string &theCommand, const TokenList &tokList);
|
||||
|
||||
/*
|
||||
* This method is for returning the end of a specific form of doxygen command
|
||||
|
|
@ -215,14 +211,12 @@ private:
|
|||
* progressTilEndCommand("endcode", tokenList);
|
||||
* If the end is never encountered, it returns the end of the std::list.
|
||||
*/
|
||||
TokenListCIt getEndCommand(const std::string &theCommand,
|
||||
const TokenList &tokList);
|
||||
TokenListCIt getEndCommand(const std::string &theCommand, const TokenList &tokList);
|
||||
/*
|
||||
* A special method for commands such as \arg that end at the end of a
|
||||
* paragraph OR when another \arg is encountered
|
||||
//TODO getTilAnyCommand
|
||||
TokenListCIt getTilAnyCommand(const std::string &theCommand,
|
||||
const TokenList &tokList);
|
||||
TokenListCIt getTilAnyCommand(const std::string &theCommand, const TokenList &tokList);
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -241,8 +235,7 @@ private:
|
|||
* Plain commands, such as newline etc, they contain no other data
|
||||
* \n \\ \@ \& \$ \# \< \> \%
|
||||
*/
|
||||
void addSimpleCommand(const std::string &theCommand,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addSimpleCommand(const std::string &theCommand, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* CommandWord
|
||||
* Format: @command <word>
|
||||
|
|
@ -251,9 +244,7 @@ private:
|
|||
* "relates", "namespace", "relatesalso","anchor", "dontinclude", "include",
|
||||
* "includelineno"
|
||||
*/
|
||||
void addCommandWord(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandWord(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* CommandLine
|
||||
* Format: @command (line)
|
||||
|
|
@ -261,9 +252,7 @@ private:
|
|||
* "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip",
|
||||
* "until", "property"
|
||||
*/
|
||||
void addCommandLine(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandLine(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* CommandParagraph
|
||||
* Format: @command {paragraph}
|
||||
|
|
@ -272,9 +261,7 @@ private:
|
|||
* "details", "invariant", "deprecated", "date", "note", "warning",
|
||||
* "version", "todo", "bug", "attention", "brief", "arg", "author"
|
||||
*/
|
||||
void addCommandParagraph(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandParagraph(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* Command EndCommand
|
||||
* Format: @command and ends at @endcommand
|
||||
|
|
@ -284,96 +271,70 @@ private:
|
|||
* "link"
|
||||
* Returns 1 if success, 0 if the endcommand is never encountered.
|
||||
*/
|
||||
void addCommandEndCommand(const std::string &theCommand,
|
||||
const TokenList & tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandEndCommand(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* CommandWordParagraph
|
||||
* Format: @command <word> {paragraph}
|
||||
* Commands such as param
|
||||
* "param", "tparam", "throw", "throws", "retval", "exception"
|
||||
*/
|
||||
void addCommandWordParagraph(const std::string &theCommand,
|
||||
const TokenList & tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandWordParagraph(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* CommandWordLine
|
||||
* Format: @command <word> (line)
|
||||
* Commands such as param
|
||||
* "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"
|
||||
*/
|
||||
void addCommandWordLine(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandWordLine(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* Command Word Optional Word Optional Word
|
||||
* Format: @command <word> [<header-file>] [<header-name>]
|
||||
* Commands such as class
|
||||
* "category", "class", "protocol", "interface", "struct", "union"
|
||||
*/
|
||||
void addCommandWordOWordOWord(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandWordOWordOWord(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
/*
|
||||
* Command Optional Word
|
||||
* Format: @command [<word>]
|
||||
* Commands such as dir
|
||||
* "dir", "file", "cond"
|
||||
*/
|
||||
void addCommandOWord(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandOWord(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
|
||||
/*
|
||||
* Commands that should not be encountered (such as PHP only)
|
||||
* goes til the end of line then returns
|
||||
*/
|
||||
void addCommandErrorThrow(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandErrorThrow(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
|
||||
void addCommandHtml(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandHtml(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
|
||||
void addCommandHtmlEntity(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandHtmlEntity(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
|
||||
/*
|
||||
*Adds the unique commands- different process for each unique command
|
||||
*/
|
||||
void addCommandUnique(const std::string &theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommandUnique(const std::string &theCommand, 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);
|
||||
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.
|
||||
*/
|
||||
void ignoreCommand(const std::string& theCommand,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void ignoreCommand(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
|
||||
/*
|
||||
* The actual "meat" of the doxygen parser. Calls the correct addCommand...()
|
||||
* function.
|
||||
*/
|
||||
void addCommand(const std::string &commandString,
|
||||
const TokenList &tokList,
|
||||
DoxygenEntityList &doxyList);
|
||||
void addCommand(const std::string &commandString, const TokenList &tokList, DoxygenEntityList &doxyList);
|
||||
|
||||
DoxygenEntityList parse(TokenListCIt endParsingIndex, const TokenList &tokList, bool root = false);
|
||||
|
||||
DoxygenEntityList parse(TokenListCIt endParsingIndex,
|
||||
const TokenList &tokList,
|
||||
bool root = false);
|
||||
|
||||
/*
|
||||
* Fill static doxygenCommands and sectionIndicators containers
|
||||
*/
|
||||
|
|
@ -391,9 +352,7 @@ private:
|
|||
/** Processes comment outside \htmlonly and \verbatim commands. */
|
||||
size_t processNormalComment(size_t pos, const std::string &line);
|
||||
|
||||
void tokenizeDoxygenComment(const std::string &doxygenComment,
|
||||
const std::string &fileName,
|
||||
int fileLine);
|
||||
void tokenizeDoxygenComment(const std::string &doxygenComment, const std::string &fileName, int fileLine);
|
||||
void printList();
|
||||
void printListError(int warningType, const std::string &message);
|
||||
|
||||
|
|
@ -407,8 +366,7 @@ private:
|
|||
public:
|
||||
DoxygenParser(bool noisy = false);
|
||||
virtual ~DoxygenParser();
|
||||
DoxygenEntityList createTree(Node* node, String* documentation);
|
||||
DoxygenEntityList createTree(Node *node, String *documentation);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,8 @@
|
|||
|
||||
#include "DoxygenTranslator.h"
|
||||
|
||||
DoxygenTranslator::DoxygenTranslator(int flags) :
|
||||
m_flags(flags),
|
||||
parser((flags & debug_parser) != 0)
|
||||
{}
|
||||
DoxygenTranslator::DoxygenTranslator(int flags) : m_flags(flags), parser((flags &debug_parser) != 0) {
|
||||
}
|
||||
|
||||
|
||||
DoxygenTranslator::~DoxygenTranslator() {
|
||||
|
|
@ -35,11 +33,11 @@ String *DoxygenTranslator::getDoxygenComment(Node *node) {
|
|||
|
||||
|
||||
String *DoxygenTranslator::getDocumentation(Node *node) {
|
||||
|
||||
|
||||
if (!hasDocumentation(node)) {
|
||||
return NewString("");
|
||||
}
|
||||
|
||||
|
||||
return makeDocumentation(node);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,12 +78,12 @@ protected:
|
|||
* Returns the documentation formatted for a target language.
|
||||
*/
|
||||
virtual String *makeDocumentation(Node *node) = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Prints the details of a parsed entity list to stdout (for debugging).
|
||||
*/
|
||||
void printTree(const DoxygenEntityList &entityList);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
#include <vector>
|
||||
#include <list>
|
||||
#include "../../Modules/swigmod.h"
|
||||
#define APPROX_LINE_LENGTH 64 //characters per line allowed
|
||||
#define TAB_SIZE 8 //current tab size in spaces
|
||||
#define APPROX_LINE_LENGTH 64 // characters per line allowed
|
||||
#define TAB_SIZE 8 // current tab size in spaces
|
||||
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag
|
||||
|
||||
// define static tables, they are filled in JavaDocConverter's constructor
|
||||
|
|
@ -26,8 +26,7 @@ using std::string;
|
|||
using std::list;
|
||||
using std::vector;
|
||||
|
||||
void JavaDocConverter::fillStaticTables()
|
||||
{
|
||||
void JavaDocConverter::fillStaticTables() {
|
||||
if (tagHandlers.size()) // fill only once
|
||||
return;
|
||||
|
||||
|
|
@ -99,15 +98,13 @@ void JavaDocConverter::fillStaticTables()
|
|||
tagHandlers["invariant"] = make_pair(&JavaDocConverter::handleParagraph, "");
|
||||
tagHandlers["latexonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
|
||||
tagHandlers["manonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
|
||||
tagHandlers["partofdescription"] = make_pair(
|
||||
&JavaDocConverter::handleParagraph, "");
|
||||
tagHandlers["partofdescription"] = make_pair(&JavaDocConverter::handleParagraph, "");
|
||||
tagHandlers["rtfonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
|
||||
tagHandlers["short"] = make_pair(&JavaDocConverter::handleParagraph, "");
|
||||
tagHandlers["xmlonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
|
||||
// these commands are kept as-is, they are supported by JavaDoc
|
||||
tagHandlers["author"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
tagHandlers["authors"] = make_pair(&JavaDocConverter::handleTagSame,
|
||||
"author");
|
||||
tagHandlers["authors"] = make_pair(&JavaDocConverter::handleTagSame, "author");
|
||||
tagHandlers["deprecated"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
tagHandlers["exception"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
tagHandlers["package"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
|
|
@ -116,8 +113,7 @@ void JavaDocConverter::fillStaticTables()
|
|||
tagHandlers["ref"] = make_pair(&JavaDocConverter::handleTagRef, "");
|
||||
tagHandlers["result"] = make_pair(&JavaDocConverter::handleTagSame, "return");
|
||||
tagHandlers["return"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
tagHandlers["returns"] = make_pair(&JavaDocConverter::handleTagSame,
|
||||
"return");
|
||||
tagHandlers["returns"] = make_pair(&JavaDocConverter::handleTagSame, "return");
|
||||
//tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
//tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSame, "see");
|
||||
tagHandlers["since"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
|
|
@ -126,104 +122,77 @@ void JavaDocConverter::fillStaticTables()
|
|||
tagHandlers["version"] = make_pair(&JavaDocConverter::handleTagSame, "");
|
||||
// these commands have special handlers
|
||||
tagHandlers["code"] = make_pair(&JavaDocConverter::handleTagExtended, "code");
|
||||
tagHandlers["cond"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"Conditional comment: ");
|
||||
tagHandlers["copyright"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"Copyright: ");
|
||||
tagHandlers["cond"] = make_pair(&JavaDocConverter::handleTagMessage, "Conditional comment: ");
|
||||
tagHandlers["copyright"] = make_pair(&JavaDocConverter::handleTagMessage, "Copyright: ");
|
||||
tagHandlers["else"] = make_pair(&JavaDocConverter::handleTagIf, "Else: ");
|
||||
tagHandlers["elseif"] = make_pair(&JavaDocConverter::handleTagIf,
|
||||
"Else if: ");
|
||||
tagHandlers["endcond"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"End of conditional comment.");
|
||||
tagHandlers["elseif"] = make_pair(&JavaDocConverter::handleTagIf, "Else if: ");
|
||||
tagHandlers["endcond"] = make_pair(&JavaDocConverter::handleTagMessage, "End of conditional comment.");
|
||||
// space in second arg prevents Javadoc to treat '@ example' as command. File name of
|
||||
// example is still informative to user.
|
||||
tagHandlers["example"] = make_pair(&JavaDocConverter::handleTagSame,
|
||||
" example");
|
||||
tagHandlers["example"] = make_pair(&JavaDocConverter::handleTagSame, " example");
|
||||
tagHandlers["if"] = make_pair(&JavaDocConverter::handleTagIf, "If: ");
|
||||
tagHandlers["ifnot"] = make_pair(&JavaDocConverter::handleTagIf, "If not: ");
|
||||
tagHandlers["image"] = make_pair(&JavaDocConverter::handleTagImage, "");
|
||||
tagHandlers["link"] = make_pair(&JavaDocConverter::handleTagLink, "");
|
||||
tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSee, "");
|
||||
tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSee, "");
|
||||
tagHandlers["note"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"Note: ");
|
||||
tagHandlers["note"] = make_pair(&JavaDocConverter::handleTagMessage, "Note: ");
|
||||
tagHandlers["overload"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"This is an overloaded member function, provided for"
|
||||
" convenience. It differs from the above function only in what"
|
||||
" argument(s) it accepts.");
|
||||
"This is an overloaded member function, provided for"
|
||||
" convenience. It differs from the above function only in what" " argument(s) it accepts.");
|
||||
tagHandlers["par"] = make_pair(&JavaDocConverter::handleTagPar, "");
|
||||
tagHandlers["remark"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"Remarks: ");
|
||||
tagHandlers["remarks"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"Remarks: ");
|
||||
tagHandlers["todo"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"TODO: ");
|
||||
tagHandlers["verbatim"] = make_pair(&JavaDocConverter::handleTagExtended,
|
||||
"literal");
|
||||
tagHandlers["remark"] = make_pair(&JavaDocConverter::handleTagMessage, "Remarks: ");
|
||||
tagHandlers["remarks"] = make_pair(&JavaDocConverter::handleTagMessage, "Remarks: ");
|
||||
tagHandlers["todo"] = make_pair(&JavaDocConverter::handleTagMessage, "TODO: ");
|
||||
tagHandlers["verbatim"] = make_pair(&JavaDocConverter::handleTagExtended, "literal");
|
||||
|
||||
// \f commands output literal Latex formula, which is still better than nothing.
|
||||
tagHandlers["f$"] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
|
||||
tagHandlers["f["] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
|
||||
tagHandlers["f{"] = make_pair(&JavaDocConverter::handleTagVerbatim, "");
|
||||
|
||||
tagHandlers["warning"] = make_pair(&JavaDocConverter::handleTagMessage,
|
||||
"Warning: ");
|
||||
tagHandlers["warning"] = make_pair(&JavaDocConverter::handleTagMessage, "Warning: ");
|
||||
// this command just prints it's contents
|
||||
// (it is internal command of swig's parser, contains plain text)
|
||||
tagHandlers["plainstd::string"] = make_pair(
|
||||
&JavaDocConverter::handlePlainString, "");
|
||||
tagHandlers["plainstd::endl"] = make_pair(&JavaDocConverter::handleNewLine,
|
||||
"");
|
||||
tagHandlers["plainstd::string"] = make_pair(&JavaDocConverter::handlePlainString, "");
|
||||
tagHandlers["plainstd::endl"] = make_pair(&JavaDocConverter::handleNewLine, "");
|
||||
tagHandlers["n"] = make_pair(&JavaDocConverter::handleNewLine, "");
|
||||
|
||||
// HTML tags
|
||||
tagHandlers["<a"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<a");
|
||||
tagHandlers["<b"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<b");
|
||||
tagHandlers["<blockquote"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<blockquote");
|
||||
tagHandlers["<body"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<body");
|
||||
tagHandlers["<blockquote"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<blockquote");
|
||||
tagHandlers["<body"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<body");
|
||||
tagHandlers["<br"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<br");
|
||||
tagHandlers["<center"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<center");
|
||||
tagHandlers["<caption"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<caption");
|
||||
tagHandlers["<code"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<code");
|
||||
tagHandlers["<center"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<center");
|
||||
tagHandlers["<caption"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<caption");
|
||||
tagHandlers["<code"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<code");
|
||||
tagHandlers["<dd"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dd");
|
||||
tagHandlers["<dfn"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dfn");
|
||||
tagHandlers["<div"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<div");
|
||||
tagHandlers["<dl"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dl");
|
||||
tagHandlers["<dt"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<dt");
|
||||
tagHandlers["<em"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<em");
|
||||
tagHandlers["<form"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<form");
|
||||
tagHandlers["<form"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<form");
|
||||
tagHandlers["<hr"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<hr");
|
||||
tagHandlers["<h1"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h1");
|
||||
tagHandlers["<h2"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h2");
|
||||
tagHandlers["<h3"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<h3");
|
||||
tagHandlers["<i"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<i");
|
||||
tagHandlers["<input"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<input");
|
||||
tagHandlers["<input"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<input");
|
||||
tagHandlers["<img"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<img");
|
||||
tagHandlers["<li"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<li");
|
||||
tagHandlers["<meta"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<meta");
|
||||
tagHandlers["<multicol"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<multicol");
|
||||
tagHandlers["<meta"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<meta");
|
||||
tagHandlers["<multicol"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<multicol");
|
||||
tagHandlers["<ol"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<ol");
|
||||
tagHandlers["<p"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<p");
|
||||
tagHandlers["<pre"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<pre");
|
||||
tagHandlers["<small"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<small");
|
||||
tagHandlers["<span"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<span");
|
||||
tagHandlers["<strong"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<strong");
|
||||
tagHandlers["<small"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<small");
|
||||
tagHandlers["<span"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<span");
|
||||
tagHandlers["<strong"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<strong");
|
||||
tagHandlers["<sub"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<sub");
|
||||
tagHandlers["<sup"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<sup");
|
||||
tagHandlers["<table"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag,
|
||||
"<table");
|
||||
tagHandlers["<table"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<table");
|
||||
tagHandlers["<td"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<td");
|
||||
tagHandlers["<th"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<th");
|
||||
tagHandlers["<tr"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<tr");
|
||||
|
|
@ -233,50 +202,33 @@ void JavaDocConverter::fillStaticTables()
|
|||
tagHandlers["<var"] = make_pair(&JavaDocConverter::handleDoxyHtmlTag, "<var");
|
||||
|
||||
// HTML entities
|
||||
tagHandlers["©"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"©");
|
||||
tagHandlers["&trade"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&trade");
|
||||
tagHandlers["©"] = make_pair(&JavaDocConverter::handleHtmlEntity, "©");
|
||||
tagHandlers["&trade"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&trade");
|
||||
tagHandlers["®"] = make_pair(&JavaDocConverter::handleHtmlEntity, "®");
|
||||
tagHandlers["<"] = make_pair(&JavaDocConverter::handleHtmlEntity, "<");
|
||||
tagHandlers[">"] = make_pair(&JavaDocConverter::handleHtmlEntity, ">");
|
||||
tagHandlers["&"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&");
|
||||
tagHandlers["&apos"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&apos");
|
||||
tagHandlers["""] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
""");
|
||||
tagHandlers["&lsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&lsquo");
|
||||
tagHandlers["&rsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&rsquo");
|
||||
tagHandlers["&ldquo"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&ldquo");
|
||||
tagHandlers["&rdquo"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&rdquo");
|
||||
tagHandlers["&ndash"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&ndash");
|
||||
tagHandlers["&mdash"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&mdash");
|
||||
tagHandlers[" "] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
" ");
|
||||
tagHandlers["×"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"×");
|
||||
tagHandlers["&minus"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&minus");
|
||||
tagHandlers["&sdot"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&sdot");
|
||||
tagHandlers["&apos"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&apos");
|
||||
tagHandlers["""] = make_pair(&JavaDocConverter::handleHtmlEntity, """);
|
||||
tagHandlers["&lsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&lsquo");
|
||||
tagHandlers["&rsquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&rsquo");
|
||||
tagHandlers["&ldquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&ldquo");
|
||||
tagHandlers["&rdquo"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&rdquo");
|
||||
tagHandlers["&ndash"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&ndash");
|
||||
tagHandlers["&mdash"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&mdash");
|
||||
tagHandlers[" "] = make_pair(&JavaDocConverter::handleHtmlEntity, " ");
|
||||
tagHandlers["×"] = make_pair(&JavaDocConverter::handleHtmlEntity, "×");
|
||||
tagHandlers["&minus"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&minus");
|
||||
tagHandlers["&sdot"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&sdot");
|
||||
tagHandlers["&sim"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&sim");
|
||||
tagHandlers["&le"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&le");
|
||||
tagHandlers["&ge"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&ge");
|
||||
tagHandlers["&larr"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&larr");
|
||||
tagHandlers["&rarr"] = make_pair(&JavaDocConverter::handleHtmlEntity,
|
||||
"&rarr");
|
||||
tagHandlers["&larr"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&larr");
|
||||
tagHandlers["&rarr"] = make_pair(&JavaDocConverter::handleHtmlEntity, "&rarr");
|
||||
}
|
||||
|
||||
JavaDocConverter::JavaDocConverter(int flags) :
|
||||
DoxygenTranslator(flags)
|
||||
{
|
||||
DoxygenTranslator(flags) {
|
||||
fillStaticTables();
|
||||
}
|
||||
|
||||
|
|
@ -288,11 +240,9 @@ JavaDocConverter::JavaDocConverter(int flags) :
|
|||
* which results in short lines. To be useful, this function should have much
|
||||
* better algorithm.
|
||||
*/
|
||||
std::string JavaDocConverter::formatCommand(std::string unformattedLine,
|
||||
int indent)
|
||||
{
|
||||
std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) {
|
||||
std::string formattedLines;
|
||||
return unformattedLine; // currently disabled
|
||||
return unformattedLine; // currently disabled
|
||||
int lastPosition = 0;
|
||||
int i = 0;
|
||||
int isFirstLine = 1;
|
||||
|
|
@ -310,12 +260,10 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine,
|
|||
if (!isFirstLine)
|
||||
for (int j = 0; j < indent; j++) {
|
||||
formattedLines.append("\t");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
isFirstLine = 0;
|
||||
}
|
||||
formattedLines.append(
|
||||
unformattedLine.substr(lastPosition, i - lastPosition + 1));
|
||||
formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1));
|
||||
formattedLines.append("\n *");
|
||||
|
||||
}
|
||||
|
|
@ -326,9 +274,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine,
|
|||
formattedLines.append("\t");
|
||||
}
|
||||
}
|
||||
formattedLines.append(
|
||||
unformattedLine.substr(lastPosition,
|
||||
unformattedLine.length() - lastPosition));
|
||||
formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition));
|
||||
}
|
||||
|
||||
return formattedLines;
|
||||
|
|
@ -341,8 +287,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine,
|
|||
* true - parameters are copied to output regardless of presence in
|
||||
* function params list.
|
||||
*/
|
||||
bool JavaDocConverter::paramExists(std::string param)
|
||||
{
|
||||
bool JavaDocConverter::paramExists(std::string param) {
|
||||
|
||||
if (GetFlag(currentNode, "feature:doxygen:nostripparams")) {
|
||||
return true;
|
||||
|
|
@ -352,7 +297,7 @@ bool JavaDocConverter::paramExists(std::string param)
|
|||
|
||||
for (Parm *p = plist; p;) {
|
||||
|
||||
if (Getattr(p, "name") && Char (Getattr(p, "name")) == param) {
|
||||
if (Getattr(p, "name") && Char(Getattr(p, "name")) == param) {
|
||||
return true;
|
||||
}
|
||||
/* doesn't seem to work always: in some cases (especially for 'self' parameters)
|
||||
|
|
@ -367,16 +312,14 @@ bool JavaDocConverter::paramExists(std::string param)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string JavaDocConverter::translateSubtree(DoxygenEntity &doxygenEntity)
|
||||
{
|
||||
std::string JavaDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) {
|
||||
std::string translatedComment;
|
||||
|
||||
if (doxygenEntity.isLeaf) {
|
||||
return translatedComment;
|
||||
}
|
||||
|
||||
for (DoxygenEntityListIt p = doxygenEntity.entityList.begin();
|
||||
p != doxygenEntity.entityList.end(); p++) {
|
||||
for (DoxygenEntityListIt p = doxygenEntity.entityList.begin(); p != doxygenEntity.entityList.end(); p++) {
|
||||
|
||||
translateEntity(*p, translatedComment);
|
||||
translateSubtree(*p);
|
||||
|
|
@ -388,9 +331,7 @@ std::string JavaDocConverter::translateSubtree(DoxygenEntity &doxygenEntity)
|
|||
/**
|
||||
* Checks if a handler for the given tag exists, and calls it.
|
||||
*/
|
||||
void JavaDocConverter::translateEntity(DoxygenEntity &tag,
|
||||
std::string &translatedComment)
|
||||
{
|
||||
void JavaDocConverter::translateEntity(DoxygenEntity &tag, std::string &translatedComment) {
|
||||
|
||||
std::map<std::string, std::pair<tagHandler, std::string> >::iterator it;
|
||||
it = tagHandlers.find(tag.typeOfEntity);
|
||||
|
|
@ -405,35 +346,24 @@ void JavaDocConverter::translateEntity(DoxygenEntity &tag,
|
|||
}
|
||||
|
||||
|
||||
void JavaDocConverter::handleTagAnchor(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &)
|
||||
{
|
||||
void JavaDocConverter::handleTagAnchor(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
translatedComment += "<a id=\"" + translateSubtree(tag) + "\"></a>";
|
||||
}
|
||||
|
||||
|
||||
void JavaDocConverter::handleTagHtml(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleTagHtml(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
if (tag.entityList.size()) { // do not include empty tags
|
||||
std::string tagData = translateSubtree(tag);
|
||||
// wrap the thing, ignoring whitespace
|
||||
size_t wsPos = tagData.find_last_not_of("\n\t ");
|
||||
if (wsPos != std::string::npos)
|
||||
translatedComment += "<" + arg + ">" + tagData.substr(0, wsPos + 1) + "</"
|
||||
+ arg + ">" + tagData.substr(wsPos + 1);
|
||||
translatedComment += "<" + arg + ">" + tagData.substr(0, wsPos + 1) + "</" + arg + ">" + tagData.substr(wsPos + 1);
|
||||
else
|
||||
translatedComment += "<" + arg + ">" + translateSubtree(tag) + "</" + arg
|
||||
+ "> ";
|
||||
translatedComment += "<" + arg + ">" + translateSubtree(tag) + "</" + arg + "> ";
|
||||
}
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
if (htmlTagArgs == "/") {
|
||||
// end html tag, for example "</ul>
|
||||
|
|
@ -443,18 +373,12 @@ void JavaDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleHtmlEntity(DoxygenEntity&,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, std::string &arg) {
|
||||
// html entities can be preserved for Java
|
||||
translatedComment += arg + ';';
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleNewLine(DoxygenEntity&,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleNewLine(DoxygenEntity &, std::string &translatedComment, std::string &) {
|
||||
// <br> tag is added, because otherwise to much text is joined
|
||||
// into same paragraph by javadoc. For example, doxy list:
|
||||
// - item one
|
||||
|
|
@ -466,10 +390,7 @@ void JavaDocConverter::handleNewLine(DoxygenEntity&,
|
|||
translatedComment += "<br>\n * ";
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagChar(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
// escape it if we need to, else just print
|
||||
if (arg.size())
|
||||
translatedComment += arg;
|
||||
|
|
@ -478,57 +399,37 @@ void JavaDocConverter::handleTagChar(DoxygenEntity& tag,
|
|||
}
|
||||
|
||||
// handles tags which are the same in Doxygen and Javadoc.
|
||||
void JavaDocConverter::handleTagSame(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
if (arg.size())
|
||||
tag.typeOfEntity = arg;
|
||||
translatedComment += formatCommand(
|
||||
std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2);
|
||||
translatedComment += formatCommand(std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2);
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleParagraph(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
translatedComment += formatCommand(translateSubtree(tag), 0);
|
||||
}
|
||||
|
||||
void JavaDocConverter::handlePlainString(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
translatedComment += tag.data;
|
||||
// if (tag.data.size() && tag.data[tag.data.size()-1] != ' ')
|
||||
// translatedComment += " ";
|
||||
// translatedComment += " ";
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagVerbatim(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
translatedComment += arg + " ";
|
||||
for (DoxygenEntityListCIt it = tag.entityList.begin();
|
||||
it != tag.entityList.end(); it++) {
|
||||
for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) {
|
||||
translatedComment += it->data;
|
||||
}
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagExtended(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
std::string dummy;
|
||||
translatedComment += "{@" + arg + " ";
|
||||
handleParagraph(tag, translatedComment, dummy);
|
||||
translatedComment += "}";
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagIf(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
std::string dummy;
|
||||
translatedComment += arg;
|
||||
if (tag.entityList.size()) {
|
||||
|
|
@ -538,19 +439,13 @@ void JavaDocConverter::handleTagIf(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagMessage(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg)
|
||||
{
|
||||
void JavaDocConverter::handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) {
|
||||
std::string dummy;
|
||||
translatedComment += formatCommand(arg, 0);
|
||||
handleParagraph(tag, translatedComment, dummy);
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagImage(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
if (tag.entityList.size() < 2)
|
||||
return;
|
||||
|
||||
|
|
@ -577,10 +472,7 @@ void JavaDocConverter::handleTagImage(DoxygenEntity& tag,
|
|||
translatedComment += "/>";
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagPar(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
std::string dummy;
|
||||
translatedComment += "<p";
|
||||
if (tag.entityList.size()) {
|
||||
|
|
@ -593,10 +485,7 @@ void JavaDocConverter::handleTagPar(DoxygenEntity& tag,
|
|||
}
|
||||
|
||||
|
||||
void JavaDocConverter::handleTagParam(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
std::string dummy;
|
||||
|
||||
if (!tag.entityList.size())
|
||||
|
|
@ -611,10 +500,7 @@ void JavaDocConverter::handleTagParam(DoxygenEntity& tag,
|
|||
}
|
||||
|
||||
|
||||
void JavaDocConverter::handleTagRef(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleTagRef(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
std::string dummy;
|
||||
if (!tag.entityList.size())
|
||||
return;
|
||||
|
|
@ -632,19 +518,17 @@ void JavaDocConverter::handleTagRef(DoxygenEntity& tag,
|
|||
}
|
||||
|
||||
|
||||
string JavaDocConverter::convertLink(string linkObject)
|
||||
{
|
||||
string JavaDocConverter::convertLink(string linkObject) {
|
||||
if (GetFlag(currentNode, "feature:doxygen:nolinktranslate"))
|
||||
return linkObject;
|
||||
// find the params in function in linkObject (if any)
|
||||
size_t lbracePos = linkObject.find('(', 0);
|
||||
size_t rbracePos = linkObject.find(')', 0);
|
||||
if (lbracePos == string::npos || rbracePos == string::npos
|
||||
|| lbracePos >= rbracePos)
|
||||
if (lbracePos == string::npos || rbracePos == string::npos || lbracePos >= rbracePos)
|
||||
return "";
|
||||
|
||||
string paramsStr = linkObject.substr(lbracePos + 1,
|
||||
rbracePos - lbracePos - 1);
|
||||
rbracePos - lbracePos - 1);
|
||||
// strip the params, to fill them later
|
||||
string additionalObject = linkObject.substr(rbracePos + 1, string::npos);
|
||||
linkObject = linkObject.substr(0, lbracePos);
|
||||
|
|
@ -679,7 +563,7 @@ string JavaDocConverter::convertLink(string linkObject)
|
|||
SwigType_add_qualifier(swigType, "const");
|
||||
|
||||
// handle pointers, references and arrays
|
||||
for (int j = (int) params[i].size() - 1; j >= 0; j--) {
|
||||
for (int j = (int)params[i].size() - 1; j >= 0; j--) {
|
||||
// skip all the [...] blocks, write 'p.' for every of it
|
||||
if (paramStr[j] == ']') {
|
||||
while (j >= 0 && paramStr[j] != '[')
|
||||
|
|
@ -699,8 +583,7 @@ string JavaDocConverter::convertLink(string linkObject)
|
|||
typeNameStart = 0;
|
||||
else
|
||||
typeNameStart++;
|
||||
Append(swigType,
|
||||
paramStr.substr(typeNameStart, j - typeNameStart + 1).c_str());
|
||||
Append(swigType, paramStr.substr(typeNameStart, j - typeNameStart + 1).c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -708,11 +591,10 @@ string JavaDocConverter::convertLink(string linkObject)
|
|||
// make dummy param list, to lookup typemaps for it
|
||||
Parm *dummyParam = NewParm(swigType, "", 0);
|
||||
Swig_typemap_attach_parms("jstype", dummyParam, NULL);
|
||||
Language::instance()->replaceSpecialVariables(0,
|
||||
Getattr(dummyParam, "tmap:jstype"), dummyParam);
|
||||
Language::instance()->replaceSpecialVariables(0, Getattr(dummyParam, "tmap:jstype"), dummyParam);
|
||||
|
||||
//Swig_print(dummyParam, 1);
|
||||
linkObject += Char (Getattr(dummyParam, "tmap:jstype"));
|
||||
linkObject += Char(Getattr(dummyParam, "tmap:jstype"));
|
||||
if (i != params.size() - 1)
|
||||
linkObject += ",";
|
||||
|
||||
|
|
@ -724,10 +606,7 @@ string JavaDocConverter::convertLink(string linkObject)
|
|||
return linkObject + additionalObject;
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagLink(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
std::string dummy;
|
||||
if (!tag.entityList.size())
|
||||
return;
|
||||
|
|
@ -743,10 +622,7 @@ void JavaDocConverter::handleTagLink(DoxygenEntity& tag,
|
|||
translatedComment += "}";
|
||||
}
|
||||
|
||||
void JavaDocConverter::handleTagSee(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string&)
|
||||
{
|
||||
void JavaDocConverter::handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &) {
|
||||
std::string dummy;
|
||||
if (!tag.entityList.size())
|
||||
return;
|
||||
|
|
@ -762,7 +638,6 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag,
|
|||
// handleNewLine(*it, translatedComment, dummy);
|
||||
continue;
|
||||
}
|
||||
|
||||
// restore entities which may be used in C++ type declaration
|
||||
if (it->typeOfEntity == "&") {
|
||||
methodRef += '&';
|
||||
|
|
@ -779,8 +654,7 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag,
|
|||
size_t lbrace = methodRef.find('(');
|
||||
size_t dblColon = methodRef.find("::");
|
||||
if (dblColon < lbrace) {
|
||||
methodRef = methodRef.substr(0, dblColon) + '#'
|
||||
+ methodRef.substr(dblColon + 2);
|
||||
methodRef = methodRef.substr(0, dblColon) + '#' + methodRef.substr(dblColon + 2);
|
||||
}
|
||||
|
||||
translatedComment += "@see ";
|
||||
|
|
@ -808,8 +682,7 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag,
|
|||
|-endline
|
||||
*
|
||||
*/
|
||||
int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level)
|
||||
{
|
||||
int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level) {
|
||||
DoxygenEntityListIt it = root.entityList.begin();
|
||||
while (it != root.entityList.end()) {
|
||||
// remove line endings
|
||||
|
|
@ -828,7 +701,7 @@ int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level)
|
|||
|
||||
int removedCount = 0;
|
||||
while (!root.entityList.empty()
|
||||
&& root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
|
||||
&& root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
|
||||
root.entityList.pop_back();
|
||||
removedCount++;
|
||||
}
|
||||
|
|
@ -841,8 +714,7 @@ int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level)
|
|||
* to indentation of the first line. Indentation of non-empty lines is not
|
||||
* changed - garbage in garbage out.
|
||||
*/
|
||||
std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc)
|
||||
{
|
||||
std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) {
|
||||
|
||||
size_t idx = doc.find('\n');
|
||||
size_t indent = 0;
|
||||
|
|
@ -857,10 +729,10 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc)
|
|||
}
|
||||
}
|
||||
|
||||
if (indent == 0) { // we can't indent the first line less than 0
|
||||
if (indent == 0) {
|
||||
// we can't indent the first line less than 0
|
||||
indent = 1;
|
||||
}
|
||||
|
||||
// Create the first line of Javadoc comment.
|
||||
string indentStr(indent - 1, ' ');
|
||||
string translatedStr = indentStr + "/**";
|
||||
|
|
@ -881,13 +753,11 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc)
|
|||
// line without '*' found - is it empty?
|
||||
if (translatedStr[nonspaceIdx] != '\n') {
|
||||
// add '* ' to each line without it
|
||||
translatedStr = translatedStr.substr(0, nonspaceIdx) + "* "
|
||||
+ translatedStr.substr(nonspaceIdx);
|
||||
translatedStr = translatedStr.substr(0, nonspaceIdx) + "* " + translatedStr.substr(nonspaceIdx);
|
||||
//printf(translatedStr.c_str());
|
||||
} else {
|
||||
// we found empty line, replace it with indented '*'
|
||||
translatedStr = translatedStr.substr(0, idx + 1) + indentStr + "* "
|
||||
+ translatedStr.substr(nonspaceIdx);
|
||||
translatedStr = translatedStr.substr(0, idx + 1) + indentStr + "* " + translatedStr.substr(nonspaceIdx);
|
||||
}
|
||||
}
|
||||
idx = translatedStr.find('\n', nonspaceIdx);
|
||||
|
|
@ -908,8 +778,7 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc)
|
|||
return translatedStr;
|
||||
}
|
||||
|
||||
String *JavaDocConverter::makeDocumentation(Node *node)
|
||||
{
|
||||
String *JavaDocConverter::makeDocumentation(Node *node) {
|
||||
|
||||
String *documentation = getDoxygenComment(node);
|
||||
|
||||
|
|
@ -919,7 +788,7 @@ String *JavaDocConverter::makeDocumentation(Node *node)
|
|||
|
||||
if (GetFlag(node, "feature:doxygen:notranslate")) {
|
||||
|
||||
string doc = Char (documentation);
|
||||
string doc = Char(documentation);
|
||||
|
||||
string translatedStr = indentAndInsertAsterisks(doc);
|
||||
|
||||
|
|
@ -936,7 +805,6 @@ String *JavaDocConverter::makeDocumentation(Node *node)
|
|||
std::cout << "---RESORTED LIST---" << std::endl;
|
||||
printTree(entityList);
|
||||
}
|
||||
|
||||
// store the current node
|
||||
// (currently just to handle params)
|
||||
currentNode = node;
|
||||
|
|
@ -949,13 +817,13 @@ String *JavaDocConverter::makeDocumentation(Node *node)
|
|||
|
||||
// strip line endings at the beginning
|
||||
while (!root.entityList.empty()
|
||||
&& root.entityList.begin()->typeOfEntity == "plainstd::endl") {
|
||||
&& root.entityList.begin()->typeOfEntity == "plainstd::endl") {
|
||||
root.entityList.pop_front();
|
||||
}
|
||||
|
||||
// and at the end
|
||||
while (!root.entityList.empty()
|
||||
&& root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
|
||||
&& root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
|
||||
root.entityList.pop_back();
|
||||
}
|
||||
|
||||
|
|
@ -971,8 +839,6 @@ String *JavaDocConverter::makeDocumentation(Node *node)
|
|||
return NewString(javaDocString.c_str());
|
||||
}
|
||||
|
||||
void JavaDocConverter::addError(int warningType, const std::string &message)
|
||||
{
|
||||
Swig_warning(warningType, "", 0, "Doxygen parser warning: %s. \n",
|
||||
message.c_str());
|
||||
void JavaDocConverter::addError(int warningType, const std::string &message) {
|
||||
Swig_warning(warningType, "", 0, "Doxygen parser warning: %s. \n", message.c_str());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,20 +30,23 @@ protected:
|
|||
* Used to properly format JavaDoc-style command
|
||||
*/
|
||||
std::string formatCommand(std::string unformattedLine, int indent);
|
||||
|
||||
/*
|
||||
* Translate every entity in a tree.
|
||||
*/
|
||||
std::string translateSubtree(DoxygenEntity & doxygenEntity);
|
||||
std::string translateSubtree(DoxygenEntity &doxygenEntity);
|
||||
|
||||
/*
|
||||
* Translate one entity with the appropriate handler, according
|
||||
* to the tagHandlers
|
||||
*/
|
||||
void translateEntity(DoxygenEntity &tag, std::string &translatedComment);
|
||||
|
||||
/*
|
||||
* Fix all endlines location, etc
|
||||
*/
|
||||
int shiftEndlinesUpTree(DoxygenEntity &root, int level = 0);
|
||||
|
||||
|
||||
/*
|
||||
* Convert params in link-objects and references
|
||||
*/
|
||||
|
|
@ -53,18 +56,15 @@ protected:
|
|||
* Typedef for the function that handles one tag
|
||||
* arg - some string argument to easily pass it through lookup table
|
||||
*/
|
||||
typedef void (JavaDocConverter::*tagHandler)(DoxygenEntity &tag,
|
||||
std::string &translatedComment, std::string &arg);
|
||||
typedef void (JavaDocConverter::*tagHandler) (DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/**
|
||||
* Copies verbatim args of the tag to output, used for commands like \f$, ...
|
||||
*/
|
||||
void handleTagVerbatim(DoxygenEntity& tag, std::string& translatedComment, std::string &arg);
|
||||
void handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/** Creates anchor link. */
|
||||
void handleTagAnchor(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg);
|
||||
void handleTagAnchor(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Wrap the command data with the html tag
|
||||
|
|
@ -73,80 +73,87 @@ protected:
|
|||
void handleTagHtml(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/* Handles HTML tags recognized by Doxygen, like <A ...>, <ul>, <table>, ... */
|
||||
void handleDoxyHtmlTag(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg);
|
||||
void handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/* Handles HTML entities recognized by Doxygen, like <, ©, ... */
|
||||
void handleHtmlEntity(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
std::string &arg);
|
||||
void handleHtmlEntity(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Just prints new line
|
||||
*/
|
||||
void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Print the name of tag to the output, used for escape-commands
|
||||
* arg - html-escaped variant, if not provided the command data is used
|
||||
*/
|
||||
void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Do not translate and print as-is
|
||||
* arg - the new tag name, if it needs to be renamed
|
||||
*/
|
||||
void handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Print only the content and strip original tag
|
||||
*/
|
||||
void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Print only data part of code
|
||||
*/
|
||||
void handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Print extended Javadoc command, like {@code ...} or {@literal ...}
|
||||
* arg - command name
|
||||
*/
|
||||
void handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Print the if-elseif-else-endif section
|
||||
*/
|
||||
void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Prints the specified message, than the contents of the tag
|
||||
* arg - message
|
||||
*/
|
||||
void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Insert <img src=... /> tag if the 'format' field is specified as 'html'
|
||||
*/
|
||||
void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Insert <p alt='title'>...</p>
|
||||
*/
|
||||
void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Insert \@param command, if it is really a function param
|
||||
*/
|
||||
void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Writes link for \ref tag.
|
||||
*/
|
||||
void handleTagRef(DoxygenEntity& tag, std::string& translatedComment,
|
||||
std::string&);
|
||||
void handleTagRef(DoxygenEntity &tag, std::string &translatedComment, std::string &);
|
||||
|
||||
/*
|
||||
* Insert {@link...} command, and handle all the <link-object>s correctly
|
||||
* (like converting types of params, etc)
|
||||
*/
|
||||
void handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
/*
|
||||
* Insert @see command, and handle all the <link-object>s correctly
|
||||
* (like converting types of params, etc)
|
||||
*/
|
||||
void handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &arg);
|
||||
|
||||
|
||||
private:
|
||||
Node *currentNode;
|
||||
// this contains the handler pointer and one string argument
|
||||
|
|
|
|||
|
|
@ -28,18 +28,14 @@ using std::string;
|
|||
|
||||
// Helper class increasing the provided indent string in its ctor and decreasing
|
||||
// it in its dtor.
|
||||
class IndentGuard
|
||||
{
|
||||
class IndentGuard {
|
||||
public:
|
||||
// One indent level.
|
||||
static const char* Level() { return " "; }
|
||||
|
||||
// Default ctor doesn't do anything and prevents the dtor from doing anything
|
||||
// too and should only be used when the guard needs to be initialized
|
||||
// conditionally as Init() can then be called after checking some condition.
|
||||
// Otherwise, prefer to use the non default ctor below.
|
||||
IndentGuard()
|
||||
{
|
||||
static const char *Level() {
|
||||
return " ";
|
||||
}
|
||||
// Default ctor doesn't do anything and prevents the dtor from doing anything// too and should only be used when the guard needs to be initialized// conditionally as Init() can then be called after checking some condition.// Otherwise, prefer to use the non default ctor below.
|
||||
IndentGuard() {
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
|
|
@ -47,14 +43,12 @@ public:
|
|||
// extra indent added to it in the dtor and the variable containing the indent
|
||||
// to use, which must be used after every new line by the code actually
|
||||
// updating the output.
|
||||
IndentGuard(string& output, string& indent)
|
||||
{
|
||||
IndentGuard(string &output, string &indent) {
|
||||
Init(output, indent);
|
||||
}
|
||||
|
||||
// Really initializes the object created using the default ctor.
|
||||
void Init(string& output, string& indent)
|
||||
{
|
||||
void Init(string &output, string &indent) {
|
||||
m_output = &output;
|
||||
m_indent = &indent;
|
||||
|
||||
|
|
@ -77,10 +71,11 @@ public:
|
|||
|
||||
// Get the indent for the first line of the paragraph, which is smaller than
|
||||
// the indent for the subsequent lines.
|
||||
string getFirstLineIndent() const { return string(m_firstLineIndent, ' '); }
|
||||
|
||||
~IndentGuard()
|
||||
{
|
||||
string getFirstLineIndent() const {
|
||||
return string(m_firstLineIndent, ' ');
|
||||
}
|
||||
|
||||
~IndentGuard() {
|
||||
if (!m_initialized)
|
||||
return;
|
||||
|
||||
|
|
@ -93,24 +88,23 @@ public:
|
|||
if (m_output->length() > lenIndentLevel) {
|
||||
const size_t start = m_output->length() - lenIndentLevel;
|
||||
if (m_output->compare(start, string::npos, Level()) == 0)
|
||||
m_output->erase(start);
|
||||
m_output->erase(start);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
string* m_output;
|
||||
string* m_indent;
|
||||
string *m_output;
|
||||
string *m_indent;
|
||||
unsigned m_firstLineIndent;
|
||||
bool m_initialized;
|
||||
|
||||
IndentGuard(const IndentGuard&);
|
||||
IndentGuard& operator=(const IndentGuard&);
|
||||
IndentGuard(const IndentGuard &);
|
||||
IndentGuard &operator=(const IndentGuard &);
|
||||
};
|
||||
|
||||
// Return the indent of the given multiline string, i.e. the maximal number of
|
||||
// spaces present in the beginning of all its non-empty lines.
|
||||
static size_t determineIndent(const string& s)
|
||||
{
|
||||
static size_t determineIndent(const string &s) {
|
||||
size_t minIndent = static_cast<size_t>(-1);
|
||||
|
||||
for (size_t lineStart = 0; lineStart < s.length();) {
|
||||
|
|
@ -136,8 +130,7 @@ static size_t determineIndent(const string& s)
|
|||
return minIndent;
|
||||
}
|
||||
|
||||
static void trimWhitespace(string& s)
|
||||
{
|
||||
static void trimWhitespace(string &s) {
|
||||
const size_t lastNonSpace = s.find_last_not_of(' ');
|
||||
if (lastNonSpace == string::npos)
|
||||
s.clear();
|
||||
|
|
@ -146,21 +139,16 @@ static void trimWhitespace(string& s)
|
|||
}
|
||||
|
||||
/* static */
|
||||
PyDocConverter::TagHandlersMap::mapped_type
|
||||
PyDocConverter::make_handler(tagHandler handler)
|
||||
{
|
||||
PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) {
|
||||
return make_pair(handler, std::string());
|
||||
}
|
||||
|
||||
/* static */
|
||||
PyDocConverter::TagHandlersMap::mapped_type
|
||||
PyDocConverter::make_handler(tagHandler handler, const char* arg)
|
||||
{
|
||||
PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler, const char *arg) {
|
||||
return make_pair(handler, arg);
|
||||
}
|
||||
|
||||
void PyDocConverter::fillStaticTables()
|
||||
{
|
||||
void PyDocConverter::fillStaticTables() {
|
||||
if (tagHandlers.size()) // fill only once
|
||||
return;
|
||||
|
||||
|
|
@ -213,9 +201,7 @@ void PyDocConverter::fillStaticTables()
|
|||
tagHandlers["details"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["em"] = make_handler(&PyDocConverter::handleParagraph, " ");
|
||||
tagHandlers["example"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["exception"] =
|
||||
tagHandlers["throw"] =
|
||||
tagHandlers["throws"] = make_handler(&PyDocConverter::handleTagException);
|
||||
tagHandlers["exception"] = tagHandlers["throw"] = tagHandlers["throws"] = make_handler(&PyDocConverter::handleTagException);
|
||||
tagHandlers["htmlonly"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["invariant"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["latexonly"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
|
|
@ -228,8 +214,7 @@ void PyDocConverter::fillStaticTables()
|
|||
tagHandlers["remark"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["remarks"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["sa"] = make_handler(&PyDocConverter::handleTagMessage, "See also: ");
|
||||
tagHandlers["see"] = make_handler(&PyDocConverter::handleTagMessage,
|
||||
"See also: ");
|
||||
tagHandlers["see"] = make_handler(&PyDocConverter::handleTagMessage, "See also: ");
|
||||
tagHandlers["since"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["short"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
tagHandlers["todo"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
|
|
@ -239,27 +224,21 @@ void PyDocConverter::fillStaticTables()
|
|||
tagHandlers["xmlonly"] = make_handler(&PyDocConverter::handleParagraph);
|
||||
// these commands have special handlers
|
||||
tagHandlers["arg"] = make_handler(&PyDocConverter::handleTagMessage, "* ");
|
||||
tagHandlers["cond"] = make_handler(&PyDocConverter::handleTagMessage,
|
||||
"Conditional comment: ");
|
||||
tagHandlers["cond"] = make_handler(&PyDocConverter::handleTagMessage, "Conditional comment: ");
|
||||
tagHandlers["else"] = make_handler(&PyDocConverter::handleTagIf, "Else: ");
|
||||
tagHandlers["elseif"] = make_handler(&PyDocConverter::handleTagIf, "Else if: ");
|
||||
tagHandlers["endcond"] = make_handler(&PyDocConverter::handleTagMessage,
|
||||
"End of conditional comment.");
|
||||
tagHandlers["endcond"] = make_handler(&PyDocConverter::handleTagMessage, "End of conditional comment.");
|
||||
tagHandlers["if"] = make_handler(&PyDocConverter::handleTagIf, "If: ");
|
||||
tagHandlers["ifnot"] = make_handler(&PyDocConverter::handleTagIf, "If not: ");
|
||||
tagHandlers["image"] = make_handler(&PyDocConverter::handleTagImage);
|
||||
tagHandlers["li"] = make_handler(&PyDocConverter::handleTagMessage, "* ");
|
||||
tagHandlers["overload"] = make_handler(&PyDocConverter::handleTagMessage,
|
||||
"This is an overloaded member function, provided for"
|
||||
" convenience.\nIt differs from the above function only in what"
|
||||
" argument(s) it accepts.");
|
||||
"This is an overloaded member function, provided for"
|
||||
" convenience.\nIt differs from the above function only in what" " argument(s) it accepts.");
|
||||
tagHandlers["par"] = make_handler(&PyDocConverter::handleTagPar);
|
||||
tagHandlers["param"] =
|
||||
tagHandlers["tparam"] = make_handler(&PyDocConverter::handleTagParam);
|
||||
tagHandlers["param"] = tagHandlers["tparam"] = make_handler(&PyDocConverter::handleTagParam);
|
||||
tagHandlers["ref"] = make_handler(&PyDocConverter::handleTagRef);
|
||||
tagHandlers["result"] =
|
||||
tagHandlers["return"] =
|
||||
tagHandlers["returns"] = make_handler(&PyDocConverter::handleTagReturn);
|
||||
tagHandlers["result"] = tagHandlers["return"] = tagHandlers["returns"] = make_handler(&PyDocConverter::handleTagReturn);
|
||||
|
||||
// this command just prints it's contents
|
||||
// (it is internal command of swig's parser, contains plain text)
|
||||
|
|
@ -268,15 +247,12 @@ void PyDocConverter::fillStaticTables()
|
|||
tagHandlers["n"] = make_handler(&PyDocConverter::handleNewLine);
|
||||
|
||||
// \f commands output literal Latex formula, which is still better than nothing.
|
||||
tagHandlers["f$"] =
|
||||
tagHandlers["f["] =
|
||||
tagHandlers["f{"] = make_handler(&PyDocConverter::handleMath);
|
||||
tagHandlers["f$"] = tagHandlers["f["] = tagHandlers["f{"] = make_handler(&PyDocConverter::handleMath);
|
||||
|
||||
// HTML tags
|
||||
tagHandlers["<a"] = make_handler(&PyDocConverter::handleDoxyHtmlTag_A);
|
||||
tagHandlers["<b"] = make_handler(&PyDocConverter::handleDoxyHtmlTag2, "**");
|
||||
tagHandlers["<blockquote"] = make_handler(&PyDocConverter::handleDoxyHtmlTag_A,
|
||||
"Quote: ");
|
||||
tagHandlers["<blockquote"] = make_handler(&PyDocConverter::handleDoxyHtmlTag_A, "Quote: ");
|
||||
tagHandlers["<body"] = make_handler(&PyDocConverter::handleDoxyHtmlTag);
|
||||
tagHandlers["<br"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "\n");
|
||||
|
||||
|
|
@ -294,8 +270,7 @@ void PyDocConverter::fillStaticTables()
|
|||
tagHandlers["<div"] = make_handler(&PyDocConverter::handleDoxyHtmlTag);
|
||||
tagHandlers["<em"] = make_handler(&PyDocConverter::handleDoxyHtmlTag2, "**");
|
||||
tagHandlers["<form"] = make_handler(&PyDocConverter::handleDoxyHtmlTag);
|
||||
tagHandlers["<hr"] = make_handler(&PyDocConverter::handleDoxyHtmlTag,
|
||||
"--------------------------------------------------------------------\n");
|
||||
tagHandlers["<hr"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "--------------------------------------------------------------------\n");
|
||||
tagHandlers["<h1"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "# ");
|
||||
tagHandlers["<h2"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "## ");
|
||||
tagHandlers["<h3"] = make_handler(&PyDocConverter::handleDoxyHtmlTag, "### ");
|
||||
|
|
@ -351,17 +326,13 @@ void PyDocConverter::fillStaticTables()
|
|||
tagHandlers["&rarr"] = make_handler(&PyDocConverter::handleHtmlEntity, "-->");
|
||||
}
|
||||
|
||||
PyDocConverter::PyDocConverter(int flags) :
|
||||
DoxygenTranslator(flags), m_tableLineLen(0), m_prevRowIsTH(
|
||||
false)
|
||||
{
|
||||
PyDocConverter::PyDocConverter(int flags):
|
||||
DoxygenTranslator(flags), m_tableLineLen(0), m_prevRowIsTH(false) {
|
||||
fillStaticTables();
|
||||
}
|
||||
|
||||
// Return the type as it should appear in the output documentation.
|
||||
static
|
||||
std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "")
|
||||
{
|
||||
static std::string getPyDocType(Node *n, const_String_or_char_ptr lname = "") {
|
||||
std::string type;
|
||||
|
||||
String *s = Swig_typemap_lookup("doctype", n, lname, 0);
|
||||
|
|
@ -371,13 +342,13 @@ std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "")
|
|||
if (Language::classLookup(s)) {
|
||||
// In Python C++ namespaces are flattened, so remove all but last component
|
||||
// of the name.
|
||||
String * const last = Swig_scopename_last(s);
|
||||
String *const last = Swig_scopename_last(s);
|
||||
|
||||
// We are not actually sure whether it's a documented class or not, but
|
||||
// there doesn't seem to be any harm in making it a reference if it isn't,
|
||||
// while there is a lot of benefit in having a hyperlink if it is.
|
||||
type = ":py:class:`";
|
||||
type += Char (last);
|
||||
type += Char(last);
|
||||
type += "`";
|
||||
|
||||
Delete(last);
|
||||
|
|
@ -390,14 +361,13 @@ std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "")
|
|||
return type;
|
||||
}
|
||||
|
||||
std::string PyDocConverter::getParamType(std::string param)
|
||||
{
|
||||
std::string PyDocConverter::getParamType(std::string param) {
|
||||
std::string type;
|
||||
|
||||
ParmList *plist = CopyParmList(Getattr(currentNode, "parms"));
|
||||
for (Parm *p = plist; p;p = nextSibling(p)) {
|
||||
String* pname = Getattr(p, "name");
|
||||
if (Char (pname) != param)
|
||||
for (Parm *p = plist; p; p = nextSibling(p)) {
|
||||
String *pname = Getattr(p, "name");
|
||||
if (Char(pname) != param)
|
||||
continue;
|
||||
|
||||
type = getPyDocType(p, pname);
|
||||
|
|
@ -407,8 +377,7 @@ std::string PyDocConverter::getParamType(std::string param)
|
|||
return type;
|
||||
}
|
||||
|
||||
std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity)
|
||||
{
|
||||
std::string PyDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) {
|
||||
std::string translatedComment;
|
||||
|
||||
if (doxygenEntity.isLeaf)
|
||||
|
|
@ -433,28 +402,19 @@ std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity)
|
|||
return translatedComment;
|
||||
}
|
||||
|
||||
void PyDocConverter::translateEntity(DoxygenEntity & doxyEntity,
|
||||
std::string &translatedComment)
|
||||
{
|
||||
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);
|
||||
if (it != tagHandlers.end())
|
||||
(this->*(it->second.first))(doxyEntity, translatedComment,
|
||||
it->second.second);
|
||||
(this->*(it->second.first)) (doxyEntity, translatedComment, it->second.second);
|
||||
}
|
||||
|
||||
void PyDocConverter::handleParagraph(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
translatedComment += translateSubtree(tag);
|
||||
}
|
||||
|
||||
void PyDocConverter::handleMath(DoxygenEntity &tag,
|
||||
std::string &translatedComment,
|
||||
const std::string& arg)
|
||||
{
|
||||
void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
IndentGuard indent;
|
||||
|
||||
// Only \f$ is translated to inline formulae, \f[ and \f{ are for the block ones.
|
||||
|
|
@ -507,10 +467,7 @@ void PyDocConverter::handleMath(DoxygenEntity &tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleCode(DoxygenEntity &tag,
|
||||
std::string &translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
IndentGuard indent(translatedComment, m_indent);
|
||||
|
||||
trimWhitespace(translatedComment);
|
||||
|
|
@ -552,43 +509,27 @@ void PyDocConverter::handleCode(DoxygenEntity &tag,
|
|||
translatedComment += '\n';
|
||||
}
|
||||
|
||||
void PyDocConverter::handlePlainString(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
translatedComment += tag.data;
|
||||
}
|
||||
|
||||
void PyDocConverter::handleTagVerbatim(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
translatedComment += arg + " ";
|
||||
for (DoxygenEntityListCIt it = tag.entityList.begin();
|
||||
it != tag.entityList.end(); it++) {
|
||||
for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) {
|
||||
translatedComment += it->data;
|
||||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleTagMessage(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
translatedComment += arg;
|
||||
handleParagraph(tag, translatedComment);
|
||||
}
|
||||
|
||||
void PyDocConverter::handleTagChar(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handleTagChar(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
translatedComment += tag.typeOfEntity;
|
||||
}
|
||||
|
||||
void PyDocConverter::handleTagIf(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleTagIf(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
translatedComment += arg;
|
||||
if (tag.entityList.size()) {
|
||||
translatedComment += tag.entityList.begin()->data;
|
||||
|
|
@ -597,10 +538,7 @@ void PyDocConverter::handleTagIf(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleTagPar(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handleTagPar(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
translatedComment += "Title: ";
|
||||
if (tag.entityList.size())
|
||||
translatedComment += tag.entityList.begin()->data;
|
||||
|
|
@ -608,10 +546,7 @@ void PyDocConverter::handleTagPar(DoxygenEntity& tag,
|
|||
handleParagraph(tag, translatedComment);
|
||||
}
|
||||
|
||||
void PyDocConverter::handleTagImage(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handleTagImage(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
if (tag.entityList.size() < 2)
|
||||
return;
|
||||
tag.entityList.pop_front();
|
||||
|
|
@ -622,10 +557,7 @@ void PyDocConverter::handleTagImage(DoxygenEntity& tag,
|
|||
translatedComment += "(" + tag.entityList.begin()->data + ")";
|
||||
}
|
||||
|
||||
void PyDocConverter::handleTagParam(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
if (tag.entityList.size() < 2)
|
||||
return;
|
||||
|
||||
|
|
@ -634,7 +566,7 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag,
|
|||
DoxygenEntity paramNameEntity = *tag.entityList.begin();
|
||||
tag.entityList.pop_front();
|
||||
|
||||
const std::string& paramName = paramNameEntity.data;
|
||||
const std::string ¶mName = paramNameEntity.data;
|
||||
|
||||
const std::string paramType = getParamType(paramName);
|
||||
if (!paramType.empty()) {
|
||||
|
|
@ -648,10 +580,7 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag,
|
|||
}
|
||||
|
||||
|
||||
void PyDocConverter::handleTagReturn(DoxygenEntity &tag,
|
||||
std::string &translatedComment,
|
||||
const std::string &)
|
||||
{
|
||||
void PyDocConverter::handleTagReturn(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
IndentGuard indent(translatedComment, m_indent);
|
||||
|
||||
const std::string pytype = getPyDocType(currentNode);
|
||||
|
|
@ -667,10 +596,7 @@ void PyDocConverter::handleTagReturn(DoxygenEntity &tag,
|
|||
}
|
||||
|
||||
|
||||
void PyDocConverter::handleTagException(DoxygenEntity &tag,
|
||||
std::string &translatedComment,
|
||||
const std::string &)
|
||||
{
|
||||
void PyDocConverter::handleTagException(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
IndentGuard indent(translatedComment, m_indent);
|
||||
|
||||
translatedComment += ":raises: ";
|
||||
|
|
@ -678,10 +604,7 @@ void PyDocConverter::handleTagException(DoxygenEntity &tag,
|
|||
}
|
||||
|
||||
|
||||
void PyDocConverter::handleTagRef(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handleTagRef(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
if (!tag.entityList.size())
|
||||
return;
|
||||
|
||||
|
|
@ -695,26 +618,19 @@ void PyDocConverter::handleTagRef(DoxygenEntity& tag,
|
|||
}
|
||||
|
||||
|
||||
void PyDocConverter::handleTagWrap(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
if (tag.entityList.size()) { // do not include empty tags
|
||||
std::string tagData = translateSubtree(tag);
|
||||
// wrap the thing, ignoring whitespace
|
||||
size_t wsPos = tagData.find_last_not_of("\n\t ");
|
||||
if (wsPos != std::string::npos && wsPos != tagData.size() - 1)
|
||||
translatedComment += arg + tagData.substr(0, wsPos + 1) + arg
|
||||
+ tagData.substr(wsPos + 1);
|
||||
translatedComment += arg + tagData.substr(0, wsPos + 1) + arg + tagData.substr(wsPos + 1);
|
||||
else
|
||||
translatedComment += arg + tagData + arg;
|
||||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
if (htmlTagArgs == "/") {
|
||||
// end html tag, for example "</ul>
|
||||
|
|
@ -724,10 +640,7 @@ void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
if (htmlTagArgs == "/") {
|
||||
// end html tag, for example "</ul>
|
||||
|
|
@ -736,10 +649,7 @@ void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
if (htmlTagArgs == "/") {
|
||||
// end html tag, "</a>
|
||||
|
|
@ -755,10 +665,7 @@ void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
if (htmlTagArgs == "/") {
|
||||
// end html tag, for example "</em>
|
||||
|
|
@ -768,18 +675,14 @@ void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &)
|
||||
{
|
||||
void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
size_t nlPos = translatedComment.rfind('\n');
|
||||
if (htmlTagArgs == "/") {
|
||||
// end tag, </tr> appends vertical table line '|'
|
||||
translatedComment += '|';
|
||||
if (nlPos != string::npos) {
|
||||
size_t startOfTableLinePos = translatedComment.find_first_not_of(" \t",
|
||||
nlPos + 1);
|
||||
size_t startOfTableLinePos = translatedComment.find_first_not_of(" \t", nlPos + 1);
|
||||
if (startOfTableLinePos != string::npos) {
|
||||
m_tableLineLen = translatedComment.size() - startOfTableLinePos;
|
||||
}
|
||||
|
|
@ -800,10 +703,7 @@ void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &)
|
||||
{
|
||||
void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
if (htmlTagArgs == "/") {
|
||||
// end tag, </th> is ignored
|
||||
|
|
@ -813,10 +713,7 @@ void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &)
|
||||
{
|
||||
void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity &tag, std::string &translatedComment, const std::string &) {
|
||||
std::string htmlTagArgs = tag.data;
|
||||
if (htmlTagArgs == "/") {
|
||||
// end tag, </td> is ignored
|
||||
|
|
@ -825,18 +722,12 @@ void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity& tag,
|
|||
}
|
||||
}
|
||||
|
||||
void PyDocConverter::handleHtmlEntity(DoxygenEntity&,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg)
|
||||
{
|
||||
void PyDocConverter::handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, const std::string &arg) {
|
||||
// html entities
|
||||
translatedComment += arg;
|
||||
}
|
||||
|
||||
void PyDocConverter::handleNewLine(DoxygenEntity&,
|
||||
std::string& translatedComment,
|
||||
const std::string&)
|
||||
{
|
||||
void PyDocConverter::handleNewLine(DoxygenEntity &, std::string &translatedComment, const std::string &) {
|
||||
trimWhitespace(translatedComment);
|
||||
|
||||
translatedComment += "\n";
|
||||
|
|
@ -844,8 +735,7 @@ void PyDocConverter::handleNewLine(DoxygenEntity&,
|
|||
translatedComment += m_indent;
|
||||
}
|
||||
|
||||
String *PyDocConverter::makeDocumentation(Node *n)
|
||||
{
|
||||
String *PyDocConverter::makeDocumentation(Node *n) {
|
||||
String *documentation;
|
||||
std::string pyDocString;
|
||||
|
||||
|
|
@ -873,7 +763,7 @@ String *PyDocConverter::makeDocumentation(Node *n)
|
|||
String *comment = NewString("");
|
||||
Append(comment, documentation);
|
||||
Replaceall(comment, "\n *", "\n");
|
||||
oneDoc = Char (comment);
|
||||
oneDoc = Char(comment);
|
||||
Delete(comment);
|
||||
} else {
|
||||
std::list<DoxygenEntity> entityList = parser.createTree(n, documentation);
|
||||
|
|
@ -898,12 +788,10 @@ String *PyDocConverter::makeDocumentation(Node *n)
|
|||
if (allDocumentation.size() > 1) {
|
||||
string indentStr;
|
||||
if (minIndent != static_cast<size_t>(-1))
|
||||
indentStr.assign(minIndent, ' ');
|
||||
indentStr.assign(minIndent, ' ');
|
||||
|
||||
std::ostringstream concatDocString;
|
||||
for (size_t realOverloadCount = 0;
|
||||
realOverloadCount < allDocumentation.size();
|
||||
realOverloadCount++) {
|
||||
for (size_t realOverloadCount = 0; realOverloadCount < allDocumentation.size(); realOverloadCount++) {
|
||||
if (realOverloadCount != 0) {
|
||||
// separate it from the preceding one.
|
||||
concatDocString << "\n" << indentStr << "|\n\n";
|
||||
|
|
@ -911,8 +799,7 @@ String *PyDocConverter::makeDocumentation(Node *n)
|
|||
|
||||
oneDoc = allDocumentation[realOverloadCount];
|
||||
trimWhitespace(oneDoc);
|
||||
concatDocString << indentStr << "*Overload " << (realOverloadCount + 1) << ":*\n"
|
||||
<< oneDoc;
|
||||
concatDocString << indentStr << "*Overload " << (realOverloadCount + 1) << ":*\n" << oneDoc;
|
||||
}
|
||||
pyDocString = concatDocString.str();
|
||||
} else if (allDocumentation.size() == 1) {
|
||||
|
|
@ -927,7 +814,7 @@ String *PyDocConverter::makeDocumentation(Node *n)
|
|||
String *comment = NewString("");
|
||||
Append(comment, documentation);
|
||||
Replaceall(comment, "\n *", "\n");
|
||||
pyDocString = Char (comment);
|
||||
pyDocString = Char(comment);
|
||||
Delete(comment);
|
||||
} else {
|
||||
std::list<DoxygenEntity> entityList = parser.createTree(n, documentation);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
#include "DoxygenEntity.h"
|
||||
#include "DoxygenTranslator.h"
|
||||
|
||||
#define DOC_STRING_LENGTH 64 // characters per line allowed
|
||||
#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type
|
||||
#define DOC_STRING_LENGTH 64 // characters per line allowed
|
||||
#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type
|
||||
|
||||
class PyDocConverter : public DoxygenTranslator {
|
||||
public:
|
||||
|
|
@ -39,42 +39,45 @@ protected:
|
|||
* display. Prints title for every group of tags that have
|
||||
* a section title associated with them
|
||||
*/
|
||||
std::string translateSubtree(DoxygenEntity & doxygenEntity);
|
||||
std::string translateSubtree(DoxygenEntity &doxygenEntity);
|
||||
|
||||
/*
|
||||
* Translate one entity with the appropriate handler, according
|
||||
* to the tagHandlers
|
||||
*/
|
||||
void translateEntity(DoxygenEntity & doxyEntity, std::string &translatedComment);
|
||||
void translateEntity(DoxygenEntity &doxyEntity, std::string &translatedComment);
|
||||
|
||||
/*
|
||||
* Typedef for the function that handles one tag
|
||||
* arg - some string argument to easily pass it through lookup table
|
||||
*/
|
||||
typedef void (PyDocConverter::*tagHandler)(DoxygenEntity &tag,
|
||||
std::string &translatedComment, const std::string &arg);
|
||||
typedef void (PyDocConverter::*tagHandler) (DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Wrap the command data with the some string
|
||||
* arg - string to wrap with, like '_' or '*'
|
||||
*/
|
||||
void handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Just prints new line
|
||||
*/
|
||||
void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Print the name of tag to the output, used for escape-commands
|
||||
*/
|
||||
void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Format the contents of the \exception tag or its synonyms.
|
||||
*/
|
||||
void handleTagException(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Print only the content and strip original tag
|
||||
*/
|
||||
void handleParagraph(DoxygenEntity &tag, std::string &translatedComment,
|
||||
const std::string &arg = std::string());
|
||||
void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg = std::string());
|
||||
|
||||
/*
|
||||
* Handle one of the Doxygen formula-related tags.
|
||||
|
|
@ -94,78 +97,73 @@ protected:
|
|||
/**
|
||||
* Copies verbatim args of the tag to output, used for commands like \f$, ...
|
||||
*/
|
||||
void handleTagVerbatim(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg);
|
||||
void handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Print the if-elseif-else-endif section
|
||||
*/
|
||||
void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Prints the specified message, than the contents of the tag
|
||||
* arg - message
|
||||
*/
|
||||
void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Insert 'Title: ...'
|
||||
*/
|
||||
void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Insert 'Image: ...'
|
||||
*/
|
||||
void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Format nice param description with type information
|
||||
*/
|
||||
void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Format the contents of the \return tag or its synonyms.
|
||||
*/
|
||||
void handleTagReturn(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Writes text for \ref tag.
|
||||
*/
|
||||
void handleTagRef(DoxygenEntity& tag, std::string& translatedComment, const std::string &arg);
|
||||
void handleTagRef(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/* Handles HTML tags recognized by Doxygen, like <A ...>, <ul>, <table>, ... */
|
||||
|
||||
void handleDoxyHtmlTag(DoxygenEntity& tag, std::string& translatedComment, const std::string &arg);
|
||||
void handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/** Does not output params of HTML tag, for example in <table border='1'>
|
||||
* 'border=1' is not written to output.
|
||||
*/
|
||||
void handleDoxyHtmlTagNoParam(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg);
|
||||
void handleDoxyHtmlTagNoParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/** Translates tag <a href = "url">text</a> to: text ("url"). */
|
||||
void handleDoxyHtmlTag_A(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg);
|
||||
void handleDoxyHtmlTag_A(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/*
|
||||
* Handles HTML tags, which are translated to markdown-like syntax, for example
|
||||
* <i>text</i> --> _text_. Appends arg for start HTML tag and end HTML tag.
|
||||
*/
|
||||
void handleDoxyHtmlTag2(DoxygenEntity& tag,
|
||||
std::string& translatedComment,
|
||||
const std::string &arg);
|
||||
void handleDoxyHtmlTag2(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/* Handles HTML table, tag <tr> */
|
||||
void handleDoxyHtmlTag_tr(DoxygenEntity& tag, std::string& translatedComment,
|
||||
const std::string &arg);
|
||||
void handleDoxyHtmlTag_tr(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/* Handles HTML table, tag <th> */
|
||||
void handleDoxyHtmlTag_th(DoxygenEntity& tag, std::string& translatedComment,
|
||||
const std::string &arg);
|
||||
void handleDoxyHtmlTag_th(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/* Handles HTML table, tag <td> */
|
||||
void handleDoxyHtmlTag_td(DoxygenEntity& tag, std::string& translatedComment,
|
||||
const std::string &arg);
|
||||
void handleDoxyHtmlTag_td(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
/* Handles HTML entities recognized by Doxygen, like <, ©, ... */
|
||||
void handleHtmlEntity(DoxygenEntity&, std::string& translatedComment, const std::string &arg);
|
||||
void handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, const std::string &arg);
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -184,7 +182,7 @@ private:
|
|||
|
||||
|
||||
// this contains the handler pointer and one string argument
|
||||
typedef std::map<std::string, std::pair<tagHandler, std::string> > TagHandlersMap;
|
||||
typedef std::map<std::string, std::pair<tagHandler, std::string> >TagHandlersMap;
|
||||
static TagHandlersMap tagHandlers;
|
||||
|
||||
// this contains the sections tittles, like 'Arguments:' or 'Notes:', that are printed only once
|
||||
|
|
@ -192,7 +190,7 @@ private:
|
|||
|
||||
// Helper functions for fillStaticTables(): make a new tag handler object.
|
||||
TagHandlersMap::mapped_type make_handler(tagHandler handler);
|
||||
TagHandlersMap::mapped_type make_handler(tagHandler handler, const char* arg);
|
||||
TagHandlersMap::mapped_type make_handler(tagHandler handler, const char *arg);
|
||||
|
||||
void fillStaticTables();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue