formatting fixes after running make beautify plus a few manual formatting fixes

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11699 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-10-13 23:26:01 +00:00
commit 19d90026ef
17 changed files with 1805 additions and 1729 deletions

View file

@ -10,10 +10,10 @@
#include "DoxygenEntity.h"
#include <iostream>
DoxygenEntity::DoxygenEntity(std::string typeEnt){
typeOfEntity = typeEnt;
data = "";
isLeaf = true;
DoxygenEntity::DoxygenEntity(std::string typeEnt) {
typeOfEntity = typeEnt;
data = "";
isLeaf = true;
}
/* Basic node for commands that have
@ -21,173 +21,171 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){
* example: \b word
* OR holding a std::string
*/
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){
typeOfEntity = typeEnt;
data = param1;
isLeaf = true;
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1) {
typeOfEntity = typeEnt;
data = param1;
isLeaf = true;
}
/* Nonterminal node
* contains
*/
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList ){
typeOfEntity = typeEnt;
data = "";
isLeaf = false;
entityList = entList;
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList) {
typeOfEntity = typeEnt;
data = "";
isLeaf = false;
entityList = entList;
}
void DoxygenEntity::printEntity(int level){
int thisLevel = level;
if (isLeaf) {
for (int i = 0; i < thisLevel; i++) {
std::cout << "\t";
}
std::cout << "Node Command: " << typeOfEntity << " ";
if (data.compare("") != 0) {
std::cout << "Node Data: " << data;
}
std::cout << std::endl;
void DoxygenEntity::printEntity(int level) {
int thisLevel = level;
if (isLeaf) {
for (int i = 0; i < thisLevel; i++) {
std::cout << "\t";
}
} else {
std::cout << "Node Command: " << typeOfEntity << " ";
for (int i = 0; i < thisLevel; i++) {
std::cout << "\t";
}
if (data.compare("") != 0) {
std::cout << "Node Data: " << data;
}
std::cout << std::endl;
std::cout << "Node Command : " << typeOfEntity << std::endl;
} else {
std::list<DoxygenEntity>::iterator p = entityList.begin();
thisLevel++;
for (int i = 0; i < thisLevel; i++) {
std::cout << "\t";
}
while (p != entityList.end()){
(*p).printEntity(thisLevel);
p++;
}
}
std::cout << "Node Command : " << typeOfEntity << std::endl;
std::list < DoxygenEntity >::iterator p = entityList.begin();
thisLevel++;
while (p != entityList.end()) {
(*p).printEntity(thisLevel);
p++;
}
}
}
// not used, completely wrong - currently std lib reports 'invalid operator <'
bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){
bool CompareDoxygenEntities::operator() (DoxygenEntity & first, DoxygenEntity & second) {
// return first.typeOfEntity < second.typeOfEntity;
if(first.typeOfEntity.compare("brief") == 0)
// return first.typeOfEntity < second.typeOfEntity;
if (first.typeOfEntity.compare("brief") == 0)
return true;
if(second.typeOfEntity.compare("brief") == 0)
if (second.typeOfEntity.compare("brief") == 0)
return false;
if(first.typeOfEntity.compare("details") == 0)
if (first.typeOfEntity.compare("details") == 0)
return true;
if(second.typeOfEntity.compare("details") == 0)
if (second.typeOfEntity.compare("details") == 0)
return false;
if(first.typeOfEntity.compare("partofdescription") == 0)
if (first.typeOfEntity.compare("partofdescription") == 0)
return true;
if(second.typeOfEntity.compare("partofdescription") == 0)
if (second.typeOfEntity.compare("partofdescription") == 0)
return false;
if(first.typeOfEntity.compare("plainstd::string") == 0)
if (first.typeOfEntity.compare("plainstd::string") == 0)
return true;
if(second.typeOfEntity.compare("plainstd::string") == 0)
if (second.typeOfEntity.compare("plainstd::string") == 0)
return false;
if(first.typeOfEntity.compare("param") == 0){
if(second.typeOfEntity.compare("param")== 0)
if (first.typeOfEntity.compare("param") == 0) {
if (second.typeOfEntity.compare("param") == 0)
return true;
if(second.typeOfEntity.compare("return")== 0)
if (second.typeOfEntity.compare("return") == 0)
return true;
if(second.typeOfEntity.compare("exception")== 0)
if (second.typeOfEntity.compare("exception") == 0)
return true;
if(second.typeOfEntity.compare("author")== 0)
if (second.typeOfEntity.compare("author") == 0)
return true;
if(second.typeOfEntity.compare("version")== 0)
if (second.typeOfEntity.compare("version") == 0)
return true;
if(second.typeOfEntity.compare("see")== 0)
if (second.typeOfEntity.compare("see") == 0)
return true;
if(second.typeOfEntity.compare("since")== 0)
if (second.typeOfEntity.compare("since") == 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0)
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if(first.typeOfEntity.compare("return")== 0){
if(second.typeOfEntity.compare("return")== 0)
if (first.typeOfEntity.compare("return") == 0) {
if (second.typeOfEntity.compare("return") == 0)
return true;
if(second.typeOfEntity.compare("exception")== 0)
if (second.typeOfEntity.compare("exception") == 0)
return true;
if(second.typeOfEntity.compare("author")== 0)
if (second.typeOfEntity.compare("author") == 0)
return true;
if(second.typeOfEntity.compare("version")== 0)
if (second.typeOfEntity.compare("version") == 0)
return true;
if(second.typeOfEntity.compare("see")== 0)
if (second.typeOfEntity.compare("see") == 0)
return true;
if(second.typeOfEntity.compare("since")== 0)
if (second.typeOfEntity.compare("since") == 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0
)return true;
return false;
}
if(first.typeOfEntity.compare("exception")== 0){
if(second.typeOfEntity.compare("exception")== 0)
return true;
if(second.typeOfEntity.compare("author")== 0)
return true;
if(second.typeOfEntity.compare("version")== 0)
return true;
if(second.typeOfEntity.compare("see")== 0)
return true;
if(second.typeOfEntity.compare("since")== 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0)
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if(first.typeOfEntity.compare("author")== 0){
if(second.typeOfEntity.compare("author")== 0)
if (first.typeOfEntity.compare("exception") == 0) {
if (second.typeOfEntity.compare("exception") == 0)
return true;
if(second.typeOfEntity.compare("version")== 0)
if (second.typeOfEntity.compare("author") == 0)
return true;
if(second.typeOfEntity.compare("see")== 0)
if (second.typeOfEntity.compare("version") == 0)
return true;
if(second.typeOfEntity.compare("since")== 0)
if (second.typeOfEntity.compare("see") == 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0)
if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if(first.typeOfEntity.compare("version")== 0){
if(second.typeOfEntity.compare("version")== 0)
if (first.typeOfEntity.compare("author") == 0) {
if (second.typeOfEntity.compare("author") == 0)
return true;
if(second.typeOfEntity.compare("see")== 0)
if (second.typeOfEntity.compare("version") == 0)
return true;
if(second.typeOfEntity.compare("since")== 0)
if (second.typeOfEntity.compare("see") == 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0)
if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){
if(second.typeOfEntity.compare("see")== 0)
if (first.typeOfEntity.compare("version") == 0) {
if (second.typeOfEntity.compare("version") == 0)
return true;
if(second.typeOfEntity.compare("sa")== 0)
if (second.typeOfEntity.compare("see") == 0)
return true;
if(second.typeOfEntity.compare("since")== 0)
if (second.typeOfEntity.compare("since") == 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0)
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if(first.typeOfEntity.compare("since")== 0){
if(second.typeOfEntity.compare("since")== 0)
if (first.typeOfEntity.compare("see") == 0 || first.typeOfEntity.compare("sa") == 0) {
if (second.typeOfEntity.compare("see") == 0)
return true;
if(second.typeOfEntity.compare("deprecated")== 0)
if (second.typeOfEntity.compare("sa") == 0)
return true;
if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if(first.typeOfEntity.compare("deprecated")== 0){
if(second.typeOfEntity.compare("deprecated")== 0)
if (first.typeOfEntity.compare("since") == 0) {
if (second.typeOfEntity.compare("since") == 0)
return true;
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
if (first.typeOfEntity.compare("deprecated") == 0) {
if (second.typeOfEntity.compare("deprecated") == 0)
return true;
return false;
}
return true;
}

View file

@ -15,7 +15,7 @@
typedef enum {
SIMPLECOMMAND,
SIMPLECOMMAND,
IGNOREDSIMPLECOMMAND,
COMMANDWORD,
IGNOREDCOMMANDWORD,
@ -39,15 +39,15 @@ typedef enum {
/*
* Structure to represent a doxygen comment entry
*/
struct DoxygenEntity{
struct DoxygenEntity {
std::string typeOfEntity;
std::list <DoxygenEntity> entityList;
std::list < DoxygenEntity > entityList;
std::string data;
bool isLeaf;
DoxygenEntity(std::string typeEnt);
DoxygenEntity(std::string typeEnt, std::string param1);
DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList );
DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList);
void printEntity(int level);
};
@ -58,7 +58,7 @@ struct DoxygenEntity{
* such as brief descriptions are TAGGED as such
*/
struct CompareDoxygenEntities {
bool operator()(DoxygenEntity& first, DoxygenEntity& second);
bool operator() (DoxygenEntity & first, DoxygenEntity & second);
};
#endif /*TOKENLIST_H_*/
#endif

File diff suppressed because it is too large Load diff

View file

@ -3,12 +3,11 @@
#include <string>
#include <list>
#include "DoxygenEntity.h"
class DoxygenParser
{
class DoxygenParser {
public:
DoxygenParser();
virtual ~DoxygenParser();
std::list <DoxygenEntity> createTree(std::string doxygen);
std::list < DoxygenEntity > createTree(std::string doxygen);
};
#endif /*DOXYGENPARSER_H_*/
#endif

View file

@ -12,21 +12,21 @@
#include "JavaDocConverter.h"
#include "PyDocConverter.h"
bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation){
switch(format){
case JavaDoc:
return JavaDocConverter().getDocumentation(node, documentation);
case PyDoc:
return PyDocConverter().getDocumentation(node, documentation);
default:
return false;
bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation) {
switch (format) {
case JavaDoc:
return JavaDocConverter().getDocumentation(node, documentation);
case PyDoc:
return PyDocConverter().getDocumentation(node, documentation);
default:
return false;
}
}
void DoxygenTranslator::printTree(std::list<DoxygenEntity> &entityList){
std::list<DoxygenEntity>::iterator p = entityList.begin();
while (p != entityList.end()){
void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) {
std::list < DoxygenEntity >::iterator p = entityList.begin();
while (p != entityList.end()) {
(*p).printEntity(0);
p++;
}
}
}

View file

@ -28,14 +28,13 @@ enum DocumentationFormat {
* A class to translate doxygen comments attacted to parser nodes
* into alternative formats for use in code generated for target languages.
*/
class DoxygenTranslator
{
class DoxygenTranslator {
public:
/*
* Virtual destructor.
*/
virtual ~DoxygenTranslator(){}
virtual ~ DoxygenTranslator() {
}
/*
* Return the documentation for a given node formated for the correct
* documentation system.
@ -45,7 +44,7 @@ public:
* @return A bool to indicate if there was documentation to return for the node.
*/
static bool getDocumentation(Node *node, DocumentationFormat format, String *&documentation);
protected:
/*
* Overridden in subclasses to return the documentation formatted for a given
@ -55,11 +54,11 @@ protected:
* @return A bool to indicate if there was documentation to return for the node.
*/
virtual bool getDocumentation(Node *node, String *&documentation) = 0;
/*
* Prints the details of a parsed entity list to stdout (for debugging).
*/
void printTree(std::list<DoxygenEntity> &entityList);
void printTree(std::list < DoxygenEntity > &entityList);
};
#endif /*DOXYGENTRANSLATOR_H_*/
#endif

View file

@ -1,11 +1,10 @@
#ifndef DOXYGENTRANSWTOKENIZER_H_
#define DOXYGENTRANSWTOKENIZER_H_
class DoxygenTransWTokenizer
{
class DoxygenTransWTokenizer {
public:
DoxygenTransWTokenizer();
virtual ~DoxygenTransWTokenizer();
DoxygenTransWTokenizer();
virtual ~DoxygenTransWTokenizer();
};
#endif /*DOXYGENTRANSWTOKENIZER_H_*/
#endif

View file

@ -1,144 +1,144 @@
#ifndef TRANSLATOR_H_
#define TRANSLATOR_H_
#define BRIEFDESCRIPTION 99
#define LONGDESCRIPTION 100
#define A_COMMAND 101 /* \a */
#define ADDINDEX 102 /* \addindex */
#define ADDTOGROUP 103 /* \addtogroup */
#define ANCHOR 104 /* \anchor */
#define ARG_COMMAND 105 /* \arg */
#define ATTENTION 106 /* \attention */
#define AUTHOR 107 /* \author */
#define B_COMMAND 108 /* \b */
#define BRIEF 109 /* \brief */
#define BUG 110 /* \bug */
#define C_COMMAND 111 /* \c */
#define CALLGRAPH 112 /* \callgraph */
#define CALLERGRAPH 113 /* \callergraph */
#define CATEGORY 114 /* \category */
#define CLASS_COMMAND 115 /* \class */
#define CODE 116 /* \code */
#define COND 117 /* \cond */
#define COPYBRIEF 118 /* \copybrief */
#define COPYDETAILS 119 /* \copydetails */
#define COPYDOC 120 /* \copydoc */
#define DATE 121 /* \date */
#define DEF 122 /* \def */
#define DEFGROUP 123 /* \defgroup */
#define DEPRECATED 124 /* \deprecated */
#define DETAILS 125 /* \details */
#define DIR_COMMAND 126 /* \dir */
#define DONTINCLUDE 127 /* \dontinclude */
#define DOT 128 /* \dot */
#define DOTFILE 129 /* \dotfile */
#define E_COMMAND 130 /* \e */
#define ELSE_COMMAND 131 /* \else */
#define ELSEIF_COMMAND 132 /* \elseif */
#define EM 133 /* \em */
#define ENDCODE 134 /* \endcode */
#define ENDCOND 135 /* \endcond */
#define ENDDOT 136 /* \enddot */
#define ENDHTMLONLY 137 /* \endhtmlonly */
#define ENDIF 138 /* \endif */
#define ENDLATEXONLY 139 /* \endlatexonly */
#define ENDLINK 140 /* \endlink */
#define ENDMANONLY 141 /* \endmanonly */
#define ENDMSC 142 /* \endmsc */
#define ENDVERBATIM 143 /* \endverbatim */
#define ENDXMLONLY 144 /* \endxmlonly */
#define ENUM 145 /* \enum */
#define EXAMPLE 146 /* \example */
#define EXCEPTION 147 /* \exception */
#define FDOLLAR 148 /* \f$ */
#define FLEFTSQUAREBRACKET 149 /* \f[ */
#define FRIGHTSQUAREBRACKET 150 /* \f] */
#define FLEFTBRACKET 151 /* \f{ */
#define BRIEFDESCRIPTION 99
#define LONGDESCRIPTION 100
#define A_COMMAND 101 /* \a */
#define ADDINDEX 102 /* \addindex */
#define ADDTOGROUP 103 /* \addtogroup */
#define ANCHOR 104 /* \anchor */
#define ARG_COMMAND 105 /* \arg */
#define ATTENTION 106 /* \attention */
#define AUTHOR 107 /* \author */
#define B_COMMAND 108 /* \b */
#define BRIEF 109 /* \brief */
#define BUG 110 /* \bug */
#define C_COMMAND 111 /* \c */
#define CALLGRAPH 112 /* \callgraph */
#define CALLERGRAPH 113 /* \callergraph */
#define CATEGORY 114 /* \category */
#define CLASS_COMMAND 115 /* \class */
#define CODE 116 /* \code */
#define COND 117 /* \cond */
#define COPYBRIEF 118 /* \copybrief */
#define COPYDETAILS 119 /* \copydetails */
#define COPYDOC 120 /* \copydoc */
#define DATE 121 /* \date */
#define DEF 122 /* \def */
#define DEFGROUP 123 /* \defgroup */
#define DEPRECATED 124 /* \deprecated */
#define DETAILS 125 /* \details */
#define DIR_COMMAND 126 /* \dir */
#define DONTINCLUDE 127 /* \dontinclude */
#define DOT 128 /* \dot */
#define DOTFILE 129 /* \dotfile */
#define E_COMMAND 130 /* \e */
#define ELSE_COMMAND 131 /* \else */
#define ELSEIF_COMMAND 132 /* \elseif */
#define EM 133 /* \em */
#define ENDCODE 134 /* \endcode */
#define ENDCOND 135 /* \endcond */
#define ENDDOT 136 /* \enddot */
#define ENDHTMLONLY 137 /* \endhtmlonly */
#define ENDIF 138 /* \endif */
#define ENDLATEXONLY 139 /* \endlatexonly */
#define ENDLINK 140 /* \endlink */
#define ENDMANONLY 141 /* \endmanonly */
#define ENDMSC 142 /* \endmsc */
#define ENDVERBATIM 143 /* \endverbatim */
#define ENDXMLONLY 144 /* \endxmlonly */
#define ENUM 145 /* \enum */
#define EXAMPLE 146 /* \example */
#define EXCEPTION 147 /* \exception */
#define FDOLLAR 148 /* \f$ */
#define FLEFTSQUAREBRACKET 149 /* \f[ */
#define FRIGHTSQUAREBRACKET 150 /* \f] */
#define FLEFTBRACKET 151 /* \f{ */
#define FRIGHTBRACKET 152 /* \f} */
#define FILE_COMMAND 153 /* \file */
#define FN_COMMAND 154 /* \fn */
#define HEADERFILE 155/* \headerfile */
#define HIDEINITIALIZER 156 /* \hideinitializer */
#define FILE_COMMAND 153 /* \file */
#define FN_COMMAND 154 /* \fn */
#define HEADERFILE 155 /* \headerfile */
#define HIDEINITIALIZER 156 /* \hideinitializer */
#define HTMLINCLUDE 157 /* \htmlinclude */
#define HTMLONLY 158 /* \htmlonly */
#define IF_COMMAND 159 /* \if */
#define IFNOT_COMMAND 160 /* \ifnot */
#define IF_COMMAND 159 /* \if */
#define IFNOT_COMMAND 160 /* \ifnot */
#define IMAGE 161 /* \image */
#define INCLUDE_COMMAND 162 /* \include */
#define INCLUDELINENO 163 /* \includelineno */
#define INGROUP 164 /* \ingroup */
#define INTERNAL 165 /* \internal */
#define INVARIANT 166 /* \invariant */
#define INTERFACE_COMMAND 167 /* \interface */
#define LATEXONLY 168 /* \latexonly */
#define LI 169 /* \li */
#define LINE 170 /* \line */
#define LINK 171 /* \link */
#define MAINPAGE 172 /* \mainpage */
#define MANONLY 173 /* \manonly */
#define INCLUDE_COMMAND 162 /* \include */
#define INCLUDELINENO 163 /* \includelineno */
#define INGROUP 164 /* \ingroup */
#define INTERNAL 165 /* \internal */
#define INVARIANT 166 /* \invariant */
#define INTERFACE_COMMAND 167 /* \interface */
#define LATEXONLY 168 /* \latexonly */
#define LI 169 /* \li */
#define LINE 170 /* \line */
#define LINK 171 /* \link */
#define MAINPAGE 172 /* \mainpage */
#define MANONLY 173 /* \manonly */
#define MSC 174 /* \msc */
#define N 175 /* \n */
#define NAME 176 /* \name */
#define NAMESPACE 177 /* \namespace */
#define NOSUBGROUPING 178 /* \nosubgrouping */
#define NOTE 179 /* \note */
#define NAMESPACE 177 /* \namespace */
#define NOSUBGROUPING 178 /* \nosubgrouping */
#define NOTE 179 /* \note */
#define OVERLOAD 180 /* \overload */
#define P 181 /* \p */
#define PACKAGE 182 /* \package */
#define PACKAGE 182 /* \package */
#define PAGE 183 /* \page */
#define PAR 184 /* \par */
#define PARAGRAPH 185 /* \paragraph */
#define PAR 184 /* \par */
#define PARAGRAPH 185 /* \paragraph */
#define PARAM 186 /* \param */
#define POST 187 /* \post */
#define PRE 188 /* \pre */
#define PRIVATE 189 /* \private (PHP only) */
#define PRIVATESECTION 190 /* \privatesection (PHP only) */
#define PRE 188 /* \pre */
#define PRIVATE 189 /* \private (PHP only) */
#define PRIVATESECTION 190 /* \privatesection (PHP only) */
#define PROPERTY 191 /* \property */
#define PROTECTED 192 /* \protected (PHP only) */
#define PROTECTED 192 /* \protected (PHP only) */
#define PROTECTEDSECTION 193 /* \protectedsection (PHP only) */
#define PROTOCOL 194 /* \protocol */
#define PUBLIC 195 /* \public (PHP only) */
#define PUBLICSECTION 196 /* \publicsection (PHP only) */
#define REF 197 /* \ref */
#define RELATES 198 /* \relates */
#define RELATESALSO 199 /* \relatesalso */
#define REMARKS 200 /* \remarks */
#define RETURN_COMMAND 201 /* \return */
#define RETVAL 202 /* \retval */
#define SA 203 /* \sa */
#define SECTION 204 /* \section */
#define SEE 205 /* \see */
#define SHOWINITIALIZER 206 /* \showinitializer */
#define SINCE 207 /* \since */
#define SKIP 208 /* \skip */
#define SKIPLINE 209 /* \skipline */
#define STRUCT 210 /* \struct */
#define SUBPAGE 211 /* \subpage */
#define SUBSECTION 212 /* \subsection */
#define SUBSUBSECTION 213 /* \subsubsection */
#define TEST 214 /* \test */
#define THROW_COMMAND 215 /* \throw */
#define TODO_COMMAND 216 /* \todo */
#define TPARAM_COMMAND 217 /* \tparam */
#define TYPEDEF_COMMAND 218 /* \typedef */
#define UNION_COMMAND 219 /* \union */
#define UNTIL_COMMAND 220 /* \until */
#define VAR_COMMAND 221 /* \var */
#define VERBATIM 222 /* \verbatim */
#define VERBININCLUDE 223 /* \verbinclude */
#define VERSION 224 /* \version */
#define WARNING 225 /* \warning */
#define WEAKGROUP 226 /* \weakgroup */
#define XMLONLY 227/* \xmlonly */
#define XREFITEM 228 /* \xrefitem */
#define DOLLAR_COMMAND 229 /* \$ */
#define AT_COMMAND 230 /* \@ */
#define SLASH_COMMAND 231 /* \\ */
#define AND_COMMAND 232 /* \& */
#define TILDE_COMMAND 233 /* \~ */
#define LEFTANGLEBRACKET 234 /* \< */
#define RIGHTANGLEBRACKET 235 /* \> */
#define POUND_COMMAND 236 /* \# */
#define PERCENT_COMMAND 237 /* \% */
#define PROTOCOL 194 /* \protocol */
#define PUBLIC 195 /* \public (PHP only) */
#define PUBLICSECTION 196 /* \publicsection (PHP only) */
#define REF 197 /* \ref */
#define RELATES 198 /* \relates */
#define RELATESALSO 199 /* \relatesalso */
#define REMARKS 200 /* \remarks */
#define RETURN_COMMAND 201 /* \return */
#define RETVAL 202 /* \retval */
#define SA 203 /* \sa */
#define SECTION 204 /* \section */
#define SEE 205 /* \see */
#define SHOWINITIALIZER 206 /* \showinitializer */
#define SINCE 207 /* \since */
#define SKIP 208 /* \skip */
#define SKIPLINE 209 /* \skipline */
#define STRUCT 210 /* \struct */
#define SUBPAGE 211 /* \subpage */
#define SUBSECTION 212 /* \subsection */
#define SUBSUBSECTION 213 /* \subsubsection */
#define TEST 214 /* \test */
#define THROW_COMMAND 215 /* \throw */
#define TODO_COMMAND 216 /* \todo */
#define TPARAM_COMMAND 217 /* \tparam */
#define TYPEDEF_COMMAND 218 /* \typedef */
#define UNION_COMMAND 219 /* \union */
#define UNTIL_COMMAND 220 /* \until */
#define VAR_COMMAND 221 /* \var */
#define VERBATIM 222 /* \verbatim */
#define VERBININCLUDE 223 /* \verbinclude */
#define VERSION 224 /* \version */
#define WARNING 225 /* \warning */
#define WEAKGROUP 226 /* \weakgroup */
#define XMLONLY 227 /* \xmlonly */
#define XREFITEM 228 /* \xrefitem */
#define DOLLAR_COMMAND 229 /* \$ */
#define AT_COMMAND 230 /* \@ */
#define SLASH_COMMAND 231 /* \\ */
#define AND_COMMAND 232 /* \& */
#define TILDE_COMMAND 233 /* \~ */
#define LEFTANGLEBRACKET 234 /* \< */
#define RIGHTANGLEBRACKET 235 /* \> */
#define POUND_COMMAND 236 /* \# */
#define PERCENT_COMMAND 237 /* \% */
#endif /*TRANSLATOR_H_*/
#endif

View file

@ -1,42 +1,43 @@
#include "JavaDocConverter.h"
#include "DoxygenParser.h"
#include <iostream>
#define APPROX_LINE_LENGTH 64//characters per line allowed
#define TAB_SIZE 8//characters per line allowed
#define APPROX_LINE_LENGTH 64 //characters per line allowed
#define TAB_SIZE 8 //characters per line allowed
int printSortedTree2 = 0;
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag
std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent){
std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) {
std::string formattedLines = "\n * ";
int lastPosition = 0;
int i = 0;
int isFirstLine = 1;
while (i != -1 && i < (int)unformattedLine.length()){
int isFirstLine = 1;
while (i != -1 && i < (int) unformattedLine.length()) {
lastPosition = i;
if (isFirstLine){
i+=APPROX_LINE_LENGTH;
if (isFirstLine) {
i += APPROX_LINE_LENGTH;
} else {
i+=APPROX_LINE_LENGTH - indent*TAB_SIZE;
i += APPROX_LINE_LENGTH - indent * TAB_SIZE;
}
i = unformattedLine.find(" ", i);
if (i > 0 && i + 1 < (int)unformattedLine.length()){
if (!isFirstLine) for (int j = 0; j < indent; j++) {
formattedLines.append("\t");
if (i > 0 && i + 1 < (int) unformattedLine.length()) {
if (!isFirstLine)
for (int j = 0; j < indent; j++) {
formattedLines.append("\t");
} else {
isFirstLine = 0;
isFirstLine = 0;
}
formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1));
formattedLines.append("\n *");
}
}
if (lastPosition < (int)unformattedLine.length()){
if (lastPosition < (int) unformattedLine.length()) {
if (!isFirstLine) {
for (int j = 0; j < indent; j++) {
formattedLines.append("\t");
}
for (int j = 0; j < indent; j++) {
formattedLines.append("\t");
}
}
formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition));
}
@ -47,57 +48,47 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind
/* Contains the conversions for tags
* could probably be much more efficient...
*/
std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){
if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){
return doxygenEntity.data;
}
if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){
return doxygenEntity.data;
std::string JavaDocConverter::javaDocFormat(DoxygenEntity & doxygenEntity) {
if (doxygenEntity.typeOfEntity.compare("partofdescription") == 0) {
return doxygenEntity.data;
}
else if (doxygenEntity.typeOfEntity.compare("b") == 0){
if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0) {
return doxygenEntity.data;
} else if (doxygenEntity.typeOfEntity.compare("b") == 0) {
return "<b>" + doxygenEntity.data + "</b>";
}
else if (doxygenEntity.typeOfEntity.compare("c") == 0){
} else if (doxygenEntity.typeOfEntity.compare("c") == 0) {
return "<tt>" + doxygenEntity.data + "</tt>";
}
else if (doxygenEntity.typeOfEntity.compare("@") == 0){
} else if (doxygenEntity.typeOfEntity.compare("@") == 0) {
return "@";
}
else if (doxygenEntity.typeOfEntity.compare("\\") == 0){
} else if (doxygenEntity.typeOfEntity.compare("\\") == 0) {
return "\\";
}
else if (doxygenEntity.typeOfEntity.compare("<") == 0){
} else if (doxygenEntity.typeOfEntity.compare("<") == 0) {
return "&lt;";
}
else if (doxygenEntity.typeOfEntity.compare(">") == 0){
} else if (doxygenEntity.typeOfEntity.compare(">") == 0) {
return "&gt;";
}
else if (doxygenEntity.typeOfEntity.compare("&") == 0){
} else if (doxygenEntity.typeOfEntity.compare("&") == 0) {
return "&amp;";
}
else if (doxygenEntity.typeOfEntity.compare("#") == 0){
} else if (doxygenEntity.typeOfEntity.compare("#") == 0) {
return "#";
}
else if (doxygenEntity.typeOfEntity.compare("%") == 0){
} else if (doxygenEntity.typeOfEntity.compare("%") == 0) {
return "%";
}
else if (doxygenEntity.typeOfEntity.compare("~") == 0){
} else if (doxygenEntity.typeOfEntity.compare("~") == 0) {
return "~";
}
return "";
}
std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) {
std::string returnedString;
if (doxygenEntity.isLeaf) {
if (doxygenEntity.isLeaf) {
return javaDocFormat(doxygenEntity) + " ";
} else {
returnedString += javaDocFormat(doxygenEntity);
std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin();
std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()){
returnedString+= translateSubtree(*p);
while (p != doxygenEntity.entityList.end()) {
returnedString += translateSubtree(*p);
p++;
}
}
@ -105,45 +96,43 @@ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
}
std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){
std::string JavaDocConverter::translateEntity(DoxygenEntity & doxyEntity) {
if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) {
return formatCommand(std::string(translateSubtree(doxyEntity)), 0);
}
if ((doxyEntity.typeOfEntity.compare("brief") == 0) ||
(doxyEntity.typeOfEntity.compare("details") == 0)) {
if ((doxyEntity.typeOfEntity.compare("brief") == 0) || (doxyEntity.typeOfEntity.compare("details") == 0)) {
return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";
} else if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 ||
doxyEntity.typeOfEntity.compare("deprecated")== 0 ||
doxyEntity.typeOfEntity.compare("brief")== 0) {
} else if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 ||
doxyEntity.typeOfEntity.compare("deprecated") == 0 ||
doxyEntity.typeOfEntity.compare("brief") == 0) {
return formatCommand(doxyEntity.data, 0) + "\n * ";
} else if(doxyEntity.typeOfEntity.compare("see") == 0) {
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" +
translateSubtree(doxyEntity)), 2);
} else if (doxyEntity.typeOfEntity.compare("see") == 0) {
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2);
} else if(doxyEntity.typeOfEntity.compare("return")== 0
|| doxyEntity.typeOfEntity.compare("author")== 0
|| doxyEntity.typeOfEntity.compare("param")== 0
|| doxyEntity.typeOfEntity.compare("throw")== 0
|| doxyEntity.typeOfEntity.compare("throws")== 0
|| doxyEntity.typeOfEntity.compare("since")== 0
|| doxyEntity.typeOfEntity.compare("version")== 0
|| doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0){
} else if (doxyEntity.typeOfEntity.compare("return") == 0
|| doxyEntity.typeOfEntity.compare("author") == 0
|| doxyEntity.typeOfEntity.compare("param") == 0
|| doxyEntity.typeOfEntity.compare("throw") == 0
|| doxyEntity.typeOfEntity.compare("throws") == 0
|| doxyEntity.typeOfEntity.compare("since") == 0
|| doxyEntity.typeOfEntity.compare("version") == 0
|| doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0) {
// this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing
if (doxyEntity.typeOfEntity.compare("throw")== 0) {
if (doxyEntity.typeOfEntity.compare("throw") == 0) {
doxyEntity.typeOfEntity = "throws";
}
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2);
} else if(doxyEntity.typeOfEntity.compare("sa")== 0) {
} else if (doxyEntity.typeOfEntity.compare("sa") == 0) {
return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2);
} else {
return formatCommand(javaDocFormat(doxyEntity), 0 );
return formatCommand(javaDocFormat(doxyEntity), 0);
}
return "";
@ -157,31 +146,31 @@ bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) {
if (documentation == NULL) {
return false;
}
std::list <DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation));
// entityList.sort(CompareDoxygenEntities()); sorting currently not used,
// see CompareDoxygenEntities::operator() in DoxygenEntity.cpp
if(debug){
std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
// entityList.sort(CompareDoxygenEntities()); sorting currently not used,
// see CompareDoxygenEntities::operator() in DoxygenEntity.cpp
if (debug) {
std::cout << "---RESORTED LIST---" << std::endl;
printTree(entityList);
}
std::string javaDocString = "/**";
for(std::list<DoxygenEntity>::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){
for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) {
javaDocString += translateEntity(*entityIterator);
entityIterator++;
}
javaDocString += "\n */\n";
if(debug){
if (debug) {
std::cout << "\n---RESULT IN JAVADOC---" << std::endl;
std::cout << javaDocString;
std::cout << javaDocString;
}
documentation = NewString(javaDocString.c_str());
return true;
}

View file

@ -15,20 +15,20 @@
/*
* A class to translate doxygen comments into JavaDoc style comments.
*/
class JavaDocConverter : public DoxygenTranslator
{
class JavaDocConverter : public DoxygenTranslator {
public:
JavaDocConverter() : debug( false ){}
JavaDocConverter() : debug(false) {
}
virtual bool getDocumentation(Node *node, String *&documentation);
protected:
std::string formatCommand(std::string unformattedLine, int indent);
std::string translateEntity(DoxygenEntity &doxyEntity);
std::string javaDocFormat(DoxygenEntity &doxygenEntity);
std::string translateSubtree( DoxygenEntity &doxygenEntity);
std::string translateEntity(DoxygenEntity & doxyEntity);
std::string javaDocFormat(DoxygenEntity & doxygenEntity);
std::string translateSubtree(DoxygenEntity & doxygenEntity);
private:
bool debug;
};
#endif /*JAVADOCCONVERTER_H_*/
#endif

View file

@ -14,25 +14,25 @@
#include <iostream>
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag
PyDocConverter::PyDocConverter(){
debug = 1;
PyDocConverter::PyDocConverter() {
debug = 1;
}
std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) {
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p = NULL;
DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin();
DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin());
DoxygenEntity & paramNameEntity = *doxygenEntity.entityList.begin();
DoxygenEntity & paramDescriptionEntity = *(++doxygenEntity.entityList.begin());
std::string result;
std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH);
for (p = plist; p;) {
if(Char(Getattr(p, "name")) == paramNameEntity.data) {
if (Char(Getattr(p, "name")) == paramNameEntity.data) {
std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0));
std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0));
result = name + " (" + type + ") ";
result.resize(DOC_PARAM_STRING_LENGTH - 3, ' ');
result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH);
@ -45,162 +45,158 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
return result;
}
std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity){
std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity) {
#pragma unused(node)
return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity));
}
std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth){
std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth) {
std::ostringstream formattedString;
std::string currentLine;
for(std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition)
{
if(currentLine.length() == 0)
for (std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) {
if (currentLine.length() == 0)
currentLine.resize(indent, ' ');
currentLine += *stringPosition;
if(*stringPosition == ' ' && (int)currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end())
{
if (*stringPosition == ' ' && (int) currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) {
formattedString << currentLine << std::endl;
currentLine = "";
}
}
return formattedString.str();
}
std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) {
std::string returnedString;
if (doxygenEntity.isLeaf)
return doxygenEntity.data + " ";
else {
returnedString += doxygenEntity.data;
std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()){
returnedString+= translateSubtree(*p);
std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()) {
returnedString += translateSubtree(*p);
p++;
}
}
return returnedString;
}
std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){
if(doxyEntity.typeOfEntity.compare("partofdescription") == 0)
std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity & doxyEntity) {
if (doxyEntity.typeOfEntity.compare("partofdescription") == 0)
return justifyString(std::string(translateSubtree(doxyEntity)), 0);
if ((doxyEntity.typeOfEntity.compare("brief") == 0)
||(doxyEntity.typeOfEntity.compare("details") == 0))
|| (doxyEntity.typeOfEntity.compare("details") == 0))
return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n";
if(doxyEntity.typeOfEntity.compare("plainstd::string") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|| doxyEntity.typeOfEntity.compare("brief") == 0)
if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|| doxyEntity.typeOfEntity.compare("brief") == 0)
return justifyString(doxyEntity.data, 0) + "\n";
if(doxyEntity.typeOfEntity.compare("param") == 0)
if (doxyEntity.typeOfEntity.compare("param") == 0)
return formatParam(n, doxyEntity);
if(doxyEntity.typeOfEntity.compare("return") == 0)
if (doxyEntity.typeOfEntity.compare("return") == 0)
return formatReturnDescription(n, doxyEntity);
if(doxyEntity.typeOfEntity.compare("author") == 0
|| doxyEntity.typeOfEntity.compare("param") == 0
|| doxyEntity.typeOfEntity.compare("since") == 0
|| doxyEntity.typeOfEntity.compare("version") == 0
|| doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|| doxyEntity.typeOfEntity.compare("sa") == 0)
if (doxyEntity.typeOfEntity.compare("author") == 0
|| doxyEntity.typeOfEntity.compare("param") == 0
|| doxyEntity.typeOfEntity.compare("since") == 0
|| doxyEntity.typeOfEntity.compare("version") == 0
|| doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|| doxyEntity.typeOfEntity.compare("sa") == 0)
return "";
return justifyString(doxyEntity.data);
}
std::string PyDocConverter::processEntityList(Node *n, std::list<DoxygenEntity>& entityList){
std::string PyDocConverter::processEntityList(Node *n, std::list < DoxygenEntity > &entityList) {
std::string result;
bool inParamsSection = false;
for(std::list<DoxygenEntity>::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){
if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection){
for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) {
if (entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) {
inParamsSection = true;
result += "\nArguments:\n";
}
else if(entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection)
} else if (entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection)
inParamsSection = false;
result += translateEntity(n, *entityIterator);
entityIterator++;
}
}
return result;
}
bool PyDocConverter::getDocumentation(Node *n, String *&documentation){
bool PyDocConverter::getDocumentation(Node *n, String *&documentation) {
std::string pyDocString, result;
// for overloaded functions we must concat documentation for underlying overloads
if(Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")){
if (Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")) {
// rewind to the first overload
while (Getattr(n, "sym:previousSibling"))
n = Getattr(n, "sym:previousSibling");
std::vector<std::string> allDocumentation;
std::vector < std::string > allDocumentation;
// for each real method (not a generated overload) append the documentation
while(n){
documentation = Getattr(n,"DoxygenComment");
if(!Swig_is_generated_overload(n) && documentation){
std::list<DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation));
while (n) {
documentation = Getattr(n, "DoxygenComment");
if (!Swig_is_generated_overload(n) && documentation) {
std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
allDocumentation.push_back(processEntityList(n, entityList));
}
n = Getattr(n, "sym:nextSibling");
}
// construct final documentation string
if(allDocumentation.size() > 1){
if (allDocumentation.size() > 1) {
std::ostringstream concatDocString;
for(int realOverloadCount = 0; realOverloadCount < (int)allDocumentation.size(); realOverloadCount++){
for (int realOverloadCount = 0; realOverloadCount < (int) allDocumentation.size(); realOverloadCount++) {
concatDocString << generateDivider();
concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl;
concatDocString << generateDivider();
concatDocString << allDocumentation[realOverloadCount] << std::endl;
}
pyDocString = concatDocString.str();
}
else if (allDocumentation.size() == 1) {
} else if (allDocumentation.size() == 1) {
pyDocString = *(allDocumentation.begin());
}
}
}
// for other nodes just process as normal
else {
documentation = Getattr(n,"DoxygenComment");
if(documentation != NULL){
std::list<DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation));
documentation = Getattr(n, "DoxygenComment");
if (documentation != NULL) {
std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
pyDocString = processEntityList(n, entityList);
}
}
// if we got something log the result and construct DOH string to return
if(pyDocString.length()) {
if (pyDocString.length()) {
result = "\"\"\"\n" + pyDocString + "\"\"\"\n";
if(debug){
if (debug) {
std::cout << "\n---RESULT IN PYDOC---" << std::endl;
std::cout << result;
std::cout << std::endl;
}
documentation = NewString(result.c_str());
return true;
}
return false;
}
std::string PyDocConverter::generateDivider(){
std::string PyDocConverter::generateDivider() {
std::ostringstream dividerString;
for(int i = 0; i < DOC_STRING_LENGTH; i++)
for (int i = 0; i < DOC_STRING_LENGTH; i++)
dividerString << '-';
dividerString << std::endl;
return dividerString.str();

View file

@ -16,38 +16,37 @@
#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
{
class PyDocConverter : public DoxygenTranslator {
public:
PyDocConverter();
bool getDocumentation(Node *node, String *&documentation);
protected:
/*
* Process the contents of the entity list producing a documentation string.
* @param node The parse tree node that the entity list relates to.
* @param entityList The entity list to process
*/
std::string processEntityList(Node *node, std::list<DoxygenEntity>& entityList);
std::string processEntityList(Node *node, std::list < DoxygenEntity > &entityList);
/*
* Format the doxygen comment relating to a function or method parameter
* @param node The parse tree node that the parameter relates to.
* @param doxygenEntity The doxygen entity relating to the parameter docstring.
*/
std::string formatParam(Node *node, DoxygenEntity &doxygenEntity);
std::string formatParam(Node *node, DoxygenEntity & doxygenEntity);
/*
* Format the doxygen comment relating to the return value for a method or function.
* @param node The parse tree node that the parameter relates to.
* @param doxygenEntity The doxygen entity relating to the parameter docstring.
*/
std::string formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity);
std::string formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity);
/*
* Format a string so it is justified and split over several lines
* not exeeding a given length.
@ -56,17 +55,17 @@ protected:
* @param maxWidth The approximate maximum line width.
*/
std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH);
std::string translateSubtree( DoxygenEntity &doxygenEntity);
std::string translateEntity(Node *n, DoxygenEntity &doxyEntity);
std::string translateSubtree(DoxygenEntity & doxygenEntity);
std::string translateEntity(Node *n, DoxygenEntity & doxyEntity);
/*
* Utility method to generate a diving line for a documentation string.
*/
std::string generateDivider();
private:
bool debug;
};
#endif /*PYDOCCONVERTER_H_*/
#endif

View file

@ -3,27 +3,26 @@
using namespace std;
Token::Token(int tType, string tString)
{
tokenType = tType;
tokenString = tString;
Token::Token(int tType, string tString) {
tokenType = tType;
tokenString = tString;
}
string Token::toString()
{
if (tokenType == END_LINE){
return "{END OF LINE}";
}
if (tokenType == PARAGRAPH_END){
return "{END OF PARAGRAPH}";
}
if (tokenType == PLAINSTRING){
return "{PLAINSTRING :" + tokenString + "}";
}
if (tokenType == COMMAND){
return "{COMMAND : " + tokenString+ "}";
}
return "";
string Token::toString() {
if (tokenType == END_LINE) {
return "{END OF LINE}";
}
if (tokenType == PARAGRAPH_END) {
return "{END OF PARAGRAPH}";
}
if (tokenType == PLAINSTRING) {
return "{PLAINSTRING :" + tokenString + "}";
}
if (tokenType == COMMAND) {
return "{COMMAND : " + tokenString + "}";
}
return "";
}
Token:: ~Token(){}
Token::~Token() {
}

View file

@ -4,15 +4,14 @@
using namespace std;
class Token
{
class Token {
public:
Token(int tType, string tString);
~Token();
Token(int tType, string tString);
~Token();
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
string tokenString; /* the data , such as param for @param*/
string toString();
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
string tokenString; /* the data , such as param for @param */
string toString();
};
#endif /*TOKEN_H_*/
#endif

View file

@ -5,165 +5,161 @@
#include <list>
#include "Token.h"
#include "DoxygenEntity.h"
#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list
#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list
using namespace std;
int noisy2 = 0;
/* The tokenizer*/
TokenList::TokenList(const std::string &doxygenStringConst){
size_t commentPos;
string doxygenString = doxygenStringConst;
TokenList::TokenList(const std::string & doxygenStringConst) {
size_t commentPos;
string doxygenString = doxygenStringConst;
/* Comment start tokens are replaced in parser.y, see doxygen_comment and
doxygen_post_comment_item
do {
commentPos = doxygenString.find("///<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("/**<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("/*!<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("//!<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
break;
} while (true); */
/* Comment start tokens are replaced in parser.y, see doxygen_comment and
doxygen_post_comment_item
do {
commentPos = doxygenString.find("///<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("/**<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("/*!<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
commentPos = doxygenString.find("//!<");
if (commentPos != string::npos) {
doxygenString.replace(commentPos, 4, " ");
continue;
}
break;
} while (true);
*/
size_t currentIndex = 0;
size_t nextIndex = 0;
size_t currentIndex = 0;
size_t nextIndex = 0;
string currentWord;
string currentWord;
while (currentIndex < doxygenString.length()){
while (currentIndex < doxygenString.length()) {
if(doxygenString[currentIndex] == '\n'){
m_tokenList.push_back(Token(END_LINE, currentWord));
currentIndex++;
}
if (doxygenString[currentIndex] == '\n') {
m_tokenList.push_back(Token(END_LINE, currentWord));
currentIndex++;
}
// skip WS, except \n
while (currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' || doxygenString[currentIndex] == '\t'))
currentIndex++;
// skip WS, except \n
while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' '
|| doxygenString[currentIndex]== '\t')) currentIndex ++;
if (currentIndex < doxygenString.length()) {
if (currentIndex < doxygenString.length()) {
nextIndex = currentIndex;
nextIndex = currentIndex;
// skip non WS
while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex] != '\n'))
nextIndex++;
// skip non WS
while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' '
&& doxygenString[nextIndex] != '\t' && doxygenString[nextIndex]!= '\n'))
nextIndex++;
// now we have a token
currentWord = doxygenString.substr(currentIndex, nextIndex - currentIndex);
// now we have a token
currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex);
if (noisy2)
cout << "Current Word: " << currentWord << endl;
if(noisy2)
cout << "Current Word: " << currentWord << endl;
if (currentWord[0] == '@' || currentWord[0] == '\\') {
// it is doxygen command
currentWord = currentWord.substr(1, currentWord.length() - 1);
m_tokenList.push_back(Token(COMMAND, currentWord));
if (currentWord[0] == '@' || currentWord[0] == '\\'){
// it is doxygen command
currentWord = currentWord.substr(1, currentWord.length()-1);
m_tokenList.push_back(Token(COMMAND, currentWord));
} else if (currentWord[0] == '\n') {
} else if (currentWord[0] == '\n'){
m_tokenList.push_back(Token(END_LINE, currentWord));
m_tokenList.push_back(Token(END_LINE, currentWord));
}
else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){
bool isPlainString = false;
} else if (currentWord[0] == '*' || currentWord[0] == '/' || currentWord[0] == '!') {
if (currentWord.length() > 1) {
bool isPlainString = false;
for(size_t i = 1; i < currentWord.length(); i++){
if (currentWord[i] != '*' && currentWord[i] != '/' &&
currentWord[i] != '!') {
isPlainString = true;
break;
}
}
}
if(isPlainString)
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
if (currentWord.length() > 1) {
} else if (!currentWord.empty()) {
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
}
currentIndex = nextIndex;
}
for (size_t i = 1; i < currentWord.length(); i++) {
if (currentWord[i] != '*' && currentWord[i] != '/' && currentWord[i] != '!') {
isPlainString = true;
break;
}
}
}
m_tokenListIter = m_tokenList.begin();
if (isPlainString)
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
} else if (!currentWord.empty()) {
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
}
currentIndex = nextIndex;
}
}
m_tokenListIter = m_tokenList.begin();
}
TokenList:: ~TokenList(){
TokenList::~TokenList() {
}
Token TokenList::peek(){
if(m_tokenListIter!= m_tokenList.end()){
Token returnedToken = (*m_tokenListIter);
return returnedToken;
}
else
return Token(0, "");
}
Token TokenList::next(){
if(m_tokenListIter != m_tokenList.end()){
Token returnedToken = (*m_tokenListIter);
m_tokenListIter++;
return (returnedToken);
}
else
return Token(0, "");
}
list<Token>::iterator TokenList::end(){
return m_tokenList.end();
Token TokenList::peek() {
if (m_tokenListIter != m_tokenList.end()) {
Token returnedToken = (*m_tokenListIter);
return returnedToken;
} else
return Token(0, "");
}
list<Token>::iterator TokenList::current(){
Token TokenList::next() {
if (m_tokenListIter != m_tokenList.end()) {
Token returnedToken = (*m_tokenListIter);
m_tokenListIter++;
return (returnedToken);
} else
return Token(0, "");
}
list < Token >::iterator TokenList::end() {
return m_tokenList.end();
}
list < Token >::iterator TokenList::current() {
return m_tokenListIter;
}
list<Token>::iterator TokenList::iteratorCopy(){
list < Token >::iterator TokenList::iteratorCopy() {
return m_tokenListIter;
}
void TokenList::setIterator(list<Token>::iterator newPosition){
void TokenList::setIterator(list < Token >::iterator newPosition) {
m_tokenListIter = newPosition;
}
void TokenList::printList(){
list<Token>::iterator p = m_tokenList.begin();
int i = 1;
int b = 0;
while (p != m_tokenList.end()){
cout << (*p).toString() << " ";
b = i%TOKENSPERLINE;
if (b == 0) cout << endl;
p++; i++;
}
void TokenList::printList() {
list < Token >::iterator p = m_tokenList.begin();
int i = 1;
int b = 0;
while (p != m_tokenList.end()) {
cout << (*p).toString() << " ";
b = i % TOKENSPERLINE;
if (b == 0)
cout << endl;
p++;
i++;
}
}

View file

@ -10,25 +10,25 @@
* that can be derived from a formatted doxygen string
*/
class TokenList{
class TokenList {
private:
std::list<Token> m_tokenList;
std::list<Token>::iterator m_tokenListIter;
std::list < Token > m_tokenList;
std::list < Token >::iterator m_tokenListIter;
public:
TokenList(const std::string &doxygenString); /* constructor takes a blob of Doxygen comment */
~TokenList();
TokenList(const std::string & doxygenString); /* constructor takes a blob of Doxygen comment */
~TokenList();
Token peek(); /* returns next token without advancing */
Token next(); /* returns next token and advances */
Token peek(); /* returns next token without advancing */
Token next(); /* returns next token and advances */
std::list<Token>::iterator end(); /* returns an end iterator */
std::list<Token>::iterator current(); /* returns the current iterator */
std::list < Token >::iterator end(); /* returns an end iterator */
std::list < Token >::iterator current(); /* returns the current iterator */
std::list<Token>::iterator iteratorCopy(); /* returns a copy of the current iterator */
void setIterator(list<Token>::iterator newPosition); /*moves up the iterator*/
std::list < Token >::iterator iteratorCopy(); /* returns a copy of the current iterator */
void setIterator(list < Token >::iterator newPosition); /*moves up the iterator */
void printList(); /* prints out the sequence of tokens */
void printList(); /* prints out the sequence of tokens */
};
#endif /*TOKENLIST_H_*/
#endif