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:
parent
ad9eb0e0bb
commit
19d90026ef
17 changed files with 1805 additions and 1729 deletions
|
|
@ -10,10 +10,10 @@
|
||||||
#include "DoxygenEntity.h"
|
#include "DoxygenEntity.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
DoxygenEntity::DoxygenEntity(std::string typeEnt){
|
DoxygenEntity::DoxygenEntity(std::string typeEnt) {
|
||||||
typeOfEntity = typeEnt;
|
typeOfEntity = typeEnt;
|
||||||
data = "";
|
data = "";
|
||||||
isLeaf = true;
|
isLeaf = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Basic node for commands that have
|
/* Basic node for commands that have
|
||||||
|
|
@ -21,173 +21,171 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){
|
||||||
* example: \b word
|
* example: \b word
|
||||||
* OR holding a std::string
|
* OR holding a std::string
|
||||||
*/
|
*/
|
||||||
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){
|
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1) {
|
||||||
typeOfEntity = typeEnt;
|
typeOfEntity = typeEnt;
|
||||||
data = param1;
|
data = param1;
|
||||||
isLeaf = true;
|
isLeaf = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nonterminal node
|
/* Nonterminal node
|
||||||
* contains
|
* contains
|
||||||
*/
|
*/
|
||||||
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList ){
|
DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList) {
|
||||||
typeOfEntity = typeEnt;
|
typeOfEntity = typeEnt;
|
||||||
data = "";
|
data = "";
|
||||||
isLeaf = false;
|
isLeaf = false;
|
||||||
entityList = entList;
|
entityList = entList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoxygenEntity::printEntity(int level){
|
void DoxygenEntity::printEntity(int level) {
|
||||||
int thisLevel = level;
|
int thisLevel = level;
|
||||||
if (isLeaf) {
|
if (isLeaf) {
|
||||||
for (int i = 0; i < thisLevel; i++) {
|
for (int i = 0; i < thisLevel; i++) {
|
||||||
std::cout << "\t";
|
std::cout << "\t";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Node Command: " << typeOfEntity << " ";
|
|
||||||
|
|
||||||
if (data.compare("") != 0) {
|
|
||||||
std::cout << "Node Data: " << data;
|
|
||||||
}
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
} else {
|
std::cout << "Node Command: " << typeOfEntity << " ";
|
||||||
|
|
||||||
for (int i = 0; i < thisLevel; i++) {
|
if (data.compare("") != 0) {
|
||||||
std::cout << "\t";
|
std::cout << "Node Data: " << data;
|
||||||
}
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::cout << "Node Command : " << typeOfEntity << std::endl;
|
} else {
|
||||||
|
|
||||||
std::list<DoxygenEntity>::iterator p = entityList.begin();
|
for (int i = 0; i < thisLevel; i++) {
|
||||||
thisLevel++;
|
std::cout << "\t";
|
||||||
|
}
|
||||||
|
|
||||||
while (p != entityList.end()){
|
std::cout << "Node Command : " << typeOfEntity << std::endl;
|
||||||
(*p).printEntity(thisLevel);
|
|
||||||
p++;
|
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 <'
|
// 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;
|
// return first.typeOfEntity < second.typeOfEntity;
|
||||||
if(first.typeOfEntity.compare("brief") == 0)
|
if (first.typeOfEntity.compare("brief") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("brief") == 0)
|
if (second.typeOfEntity.compare("brief") == 0)
|
||||||
return false;
|
return false;
|
||||||
if(first.typeOfEntity.compare("details") == 0)
|
if (first.typeOfEntity.compare("details") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("details") == 0)
|
if (second.typeOfEntity.compare("details") == 0)
|
||||||
return false;
|
return false;
|
||||||
if(first.typeOfEntity.compare("partofdescription") == 0)
|
if (first.typeOfEntity.compare("partofdescription") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("partofdescription") == 0)
|
if (second.typeOfEntity.compare("partofdescription") == 0)
|
||||||
return false;
|
return false;
|
||||||
if(first.typeOfEntity.compare("plainstd::string") == 0)
|
if (first.typeOfEntity.compare("plainstd::string") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("plainstd::string") == 0)
|
if (second.typeOfEntity.compare("plainstd::string") == 0)
|
||||||
return false;
|
return false;
|
||||||
if(first.typeOfEntity.compare("param") == 0){
|
if (first.typeOfEntity.compare("param") == 0) {
|
||||||
if(second.typeOfEntity.compare("param")== 0)
|
if (second.typeOfEntity.compare("param") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("return")== 0)
|
if (second.typeOfEntity.compare("return") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("exception")== 0)
|
if (second.typeOfEntity.compare("exception") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("author")== 0)
|
if (second.typeOfEntity.compare("author") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("version")== 0)
|
if (second.typeOfEntity.compare("version") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("see")== 0)
|
if (second.typeOfEntity.compare("see") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("since")== 0)
|
if (second.typeOfEntity.compare("since") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("deprecated")== 0)
|
if (second.typeOfEntity.compare("deprecated") == 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(first.typeOfEntity.compare("return")== 0){
|
if (first.typeOfEntity.compare("return") == 0) {
|
||||||
if(second.typeOfEntity.compare("return")== 0)
|
if (second.typeOfEntity.compare("return") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("exception")== 0)
|
if (second.typeOfEntity.compare("exception") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("author")== 0)
|
if (second.typeOfEntity.compare("author") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("version")== 0)
|
if (second.typeOfEntity.compare("version") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("see")== 0)
|
if (second.typeOfEntity.compare("see") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("since")== 0)
|
if (second.typeOfEntity.compare("since") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("deprecated")== 0
|
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)
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(first.typeOfEntity.compare("author")== 0){
|
if (first.typeOfEntity.compare("exception") == 0) {
|
||||||
if(second.typeOfEntity.compare("author")== 0)
|
if (second.typeOfEntity.compare("exception") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("version")== 0)
|
if (second.typeOfEntity.compare("author") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("see")== 0)
|
if (second.typeOfEntity.compare("version") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("since")== 0)
|
if (second.typeOfEntity.compare("see") == 0)
|
||||||
return true;
|
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 true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(first.typeOfEntity.compare("version")== 0){
|
if (first.typeOfEntity.compare("author") == 0) {
|
||||||
if(second.typeOfEntity.compare("version")== 0)
|
if (second.typeOfEntity.compare("author") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("see")== 0)
|
if (second.typeOfEntity.compare("version") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("since")== 0)
|
if (second.typeOfEntity.compare("see") == 0)
|
||||||
return true;
|
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 true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){
|
if (first.typeOfEntity.compare("version") == 0) {
|
||||||
if(second.typeOfEntity.compare("see")== 0)
|
if (second.typeOfEntity.compare("version") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("sa")== 0)
|
if (second.typeOfEntity.compare("see") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("since")== 0)
|
if (second.typeOfEntity.compare("since") == 0)
|
||||||
return true;
|
return true;
|
||||||
if(second.typeOfEntity.compare("deprecated")== 0)
|
if (second.typeOfEntity.compare("deprecated") == 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(first.typeOfEntity.compare("since")== 0){
|
if (first.typeOfEntity.compare("see") == 0 || first.typeOfEntity.compare("sa") == 0) {
|
||||||
if(second.typeOfEntity.compare("since")== 0)
|
if (second.typeOfEntity.compare("see") == 0)
|
||||||
return true;
|
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 true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(first.typeOfEntity.compare("deprecated")== 0){
|
if (first.typeOfEntity.compare("since") == 0) {
|
||||||
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("deprecated") == 0) {
|
||||||
|
if (second.typeOfEntity.compare("deprecated") == 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SIMPLECOMMAND,
|
SIMPLECOMMAND,
|
||||||
IGNOREDSIMPLECOMMAND,
|
IGNOREDSIMPLECOMMAND,
|
||||||
COMMANDWORD,
|
COMMANDWORD,
|
||||||
IGNOREDCOMMANDWORD,
|
IGNOREDCOMMANDWORD,
|
||||||
|
|
@ -39,15 +39,15 @@ typedef enum {
|
||||||
/*
|
/*
|
||||||
* Structure to represent a doxygen comment entry
|
* Structure to represent a doxygen comment entry
|
||||||
*/
|
*/
|
||||||
struct DoxygenEntity{
|
struct DoxygenEntity {
|
||||||
std::string typeOfEntity;
|
std::string typeOfEntity;
|
||||||
std::list <DoxygenEntity> entityList;
|
std::list < DoxygenEntity > entityList;
|
||||||
std::string data;
|
std::string data;
|
||||||
bool isLeaf;
|
bool isLeaf;
|
||||||
|
|
||||||
DoxygenEntity(std::string typeEnt);
|
DoxygenEntity(std::string typeEnt);
|
||||||
DoxygenEntity(std::string typeEnt, std::string param1);
|
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);
|
void printEntity(int level);
|
||||||
};
|
};
|
||||||
|
|
@ -58,7 +58,7 @@ struct DoxygenEntity{
|
||||||
* such as brief descriptions are TAGGED as such
|
* such as brief descriptions are TAGGED as such
|
||||||
*/
|
*/
|
||||||
struct CompareDoxygenEntities {
|
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
|
|
@ -3,12 +3,11 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "DoxygenEntity.h"
|
#include "DoxygenEntity.h"
|
||||||
class DoxygenParser
|
class DoxygenParser {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DoxygenParser();
|
DoxygenParser();
|
||||||
virtual ~DoxygenParser();
|
virtual ~DoxygenParser();
|
||||||
std::list <DoxygenEntity> createTree(std::string doxygen);
|
std::list < DoxygenEntity > createTree(std::string doxygen);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*DOXYGENPARSER_H_*/
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,21 @@
|
||||||
#include "JavaDocConverter.h"
|
#include "JavaDocConverter.h"
|
||||||
#include "PyDocConverter.h"
|
#include "PyDocConverter.h"
|
||||||
|
|
||||||
bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation){
|
bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation) {
|
||||||
switch(format){
|
switch (format) {
|
||||||
case JavaDoc:
|
case JavaDoc:
|
||||||
return JavaDocConverter().getDocumentation(node, documentation);
|
return JavaDocConverter().getDocumentation(node, documentation);
|
||||||
case PyDoc:
|
case PyDoc:
|
||||||
return PyDocConverter().getDocumentation(node, documentation);
|
return PyDocConverter().getDocumentation(node, documentation);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoxygenTranslator::printTree(std::list<DoxygenEntity> &entityList){
|
void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) {
|
||||||
std::list<DoxygenEntity>::iterator p = entityList.begin();
|
std::list < DoxygenEntity >::iterator p = entityList.begin();
|
||||||
while (p != entityList.end()){
|
while (p != entityList.end()) {
|
||||||
(*p).printEntity(0);
|
(*p).printEntity(0);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,13 @@ enum DocumentationFormat {
|
||||||
* A class to translate doxygen comments attacted to parser nodes
|
* A class to translate doxygen comments attacted to parser nodes
|
||||||
* into alternative formats for use in code generated for target languages.
|
* into alternative formats for use in code generated for target languages.
|
||||||
*/
|
*/
|
||||||
class DoxygenTranslator
|
class DoxygenTranslator {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
* Virtual destructor.
|
* Virtual destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~DoxygenTranslator(){}
|
virtual ~ DoxygenTranslator() {
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Return the documentation for a given node formated for the correct
|
* Return the documentation for a given node formated for the correct
|
||||||
* documentation system.
|
* documentation system.
|
||||||
|
|
@ -45,7 +44,7 @@ public:
|
||||||
* @return A bool to indicate if there was documentation to return for the node.
|
* @return A bool to indicate if there was documentation to return for the node.
|
||||||
*/
|
*/
|
||||||
static bool getDocumentation(Node *node, DocumentationFormat format, String *&documentation);
|
static bool getDocumentation(Node *node, DocumentationFormat format, String *&documentation);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*
|
/*
|
||||||
* Overridden in subclasses to return the documentation formatted for a given
|
* 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.
|
* @return A bool to indicate if there was documentation to return for the node.
|
||||||
*/
|
*/
|
||||||
virtual bool getDocumentation(Node *node, String *&documentation) = 0;
|
virtual bool getDocumentation(Node *node, String *&documentation) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints the details of a parsed entity list to stdout (for debugging).
|
* 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
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,11 +1,10 @@
|
||||||
#ifndef DOXYGENTRANSWTOKENIZER_H_
|
#ifndef DOXYGENTRANSWTOKENIZER_H_
|
||||||
#define DOXYGENTRANSWTOKENIZER_H_
|
#define DOXYGENTRANSWTOKENIZER_H_
|
||||||
|
|
||||||
class DoxygenTransWTokenizer
|
class DoxygenTransWTokenizer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DoxygenTransWTokenizer();
|
DoxygenTransWTokenizer();
|
||||||
virtual ~DoxygenTransWTokenizer();
|
virtual ~DoxygenTransWTokenizer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*DOXYGENTRANSWTOKENIZER_H_*/
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,144 +1,144 @@
|
||||||
#ifndef TRANSLATOR_H_
|
#ifndef TRANSLATOR_H_
|
||||||
#define TRANSLATOR_H_
|
#define TRANSLATOR_H_
|
||||||
|
|
||||||
#define BRIEFDESCRIPTION 99
|
#define BRIEFDESCRIPTION 99
|
||||||
#define LONGDESCRIPTION 100
|
#define LONGDESCRIPTION 100
|
||||||
#define A_COMMAND 101 /* \a */
|
#define A_COMMAND 101 /* \a */
|
||||||
#define ADDINDEX 102 /* \addindex */
|
#define ADDINDEX 102 /* \addindex */
|
||||||
#define ADDTOGROUP 103 /* \addtogroup */
|
#define ADDTOGROUP 103 /* \addtogroup */
|
||||||
#define ANCHOR 104 /* \anchor */
|
#define ANCHOR 104 /* \anchor */
|
||||||
#define ARG_COMMAND 105 /* \arg */
|
#define ARG_COMMAND 105 /* \arg */
|
||||||
#define ATTENTION 106 /* \attention */
|
#define ATTENTION 106 /* \attention */
|
||||||
#define AUTHOR 107 /* \author */
|
#define AUTHOR 107 /* \author */
|
||||||
#define B_COMMAND 108 /* \b */
|
#define B_COMMAND 108 /* \b */
|
||||||
#define BRIEF 109 /* \brief */
|
#define BRIEF 109 /* \brief */
|
||||||
#define BUG 110 /* \bug */
|
#define BUG 110 /* \bug */
|
||||||
#define C_COMMAND 111 /* \c */
|
#define C_COMMAND 111 /* \c */
|
||||||
#define CALLGRAPH 112 /* \callgraph */
|
#define CALLGRAPH 112 /* \callgraph */
|
||||||
#define CALLERGRAPH 113 /* \callergraph */
|
#define CALLERGRAPH 113 /* \callergraph */
|
||||||
#define CATEGORY 114 /* \category */
|
#define CATEGORY 114 /* \category */
|
||||||
#define CLASS_COMMAND 115 /* \class */
|
#define CLASS_COMMAND 115 /* \class */
|
||||||
#define CODE 116 /* \code */
|
#define CODE 116 /* \code */
|
||||||
#define COND 117 /* \cond */
|
#define COND 117 /* \cond */
|
||||||
#define COPYBRIEF 118 /* \copybrief */
|
#define COPYBRIEF 118 /* \copybrief */
|
||||||
#define COPYDETAILS 119 /* \copydetails */
|
#define COPYDETAILS 119 /* \copydetails */
|
||||||
#define COPYDOC 120 /* \copydoc */
|
#define COPYDOC 120 /* \copydoc */
|
||||||
#define DATE 121 /* \date */
|
#define DATE 121 /* \date */
|
||||||
#define DEF 122 /* \def */
|
#define DEF 122 /* \def */
|
||||||
#define DEFGROUP 123 /* \defgroup */
|
#define DEFGROUP 123 /* \defgroup */
|
||||||
#define DEPRECATED 124 /* \deprecated */
|
#define DEPRECATED 124 /* \deprecated */
|
||||||
#define DETAILS 125 /* \details */
|
#define DETAILS 125 /* \details */
|
||||||
#define DIR_COMMAND 126 /* \dir */
|
#define DIR_COMMAND 126 /* \dir */
|
||||||
#define DONTINCLUDE 127 /* \dontinclude */
|
#define DONTINCLUDE 127 /* \dontinclude */
|
||||||
#define DOT 128 /* \dot */
|
#define DOT 128 /* \dot */
|
||||||
#define DOTFILE 129 /* \dotfile */
|
#define DOTFILE 129 /* \dotfile */
|
||||||
#define E_COMMAND 130 /* \e */
|
#define E_COMMAND 130 /* \e */
|
||||||
#define ELSE_COMMAND 131 /* \else */
|
#define ELSE_COMMAND 131 /* \else */
|
||||||
#define ELSEIF_COMMAND 132 /* \elseif */
|
#define ELSEIF_COMMAND 132 /* \elseif */
|
||||||
#define EM 133 /* \em */
|
#define EM 133 /* \em */
|
||||||
#define ENDCODE 134 /* \endcode */
|
#define ENDCODE 134 /* \endcode */
|
||||||
#define ENDCOND 135 /* \endcond */
|
#define ENDCOND 135 /* \endcond */
|
||||||
#define ENDDOT 136 /* \enddot */
|
#define ENDDOT 136 /* \enddot */
|
||||||
#define ENDHTMLONLY 137 /* \endhtmlonly */
|
#define ENDHTMLONLY 137 /* \endhtmlonly */
|
||||||
#define ENDIF 138 /* \endif */
|
#define ENDIF 138 /* \endif */
|
||||||
#define ENDLATEXONLY 139 /* \endlatexonly */
|
#define ENDLATEXONLY 139 /* \endlatexonly */
|
||||||
#define ENDLINK 140 /* \endlink */
|
#define ENDLINK 140 /* \endlink */
|
||||||
#define ENDMANONLY 141 /* \endmanonly */
|
#define ENDMANONLY 141 /* \endmanonly */
|
||||||
#define ENDMSC 142 /* \endmsc */
|
#define ENDMSC 142 /* \endmsc */
|
||||||
#define ENDVERBATIM 143 /* \endverbatim */
|
#define ENDVERBATIM 143 /* \endverbatim */
|
||||||
#define ENDXMLONLY 144 /* \endxmlonly */
|
#define ENDXMLONLY 144 /* \endxmlonly */
|
||||||
#define ENUM 145 /* \enum */
|
#define ENUM 145 /* \enum */
|
||||||
#define EXAMPLE 146 /* \example */
|
#define EXAMPLE 146 /* \example */
|
||||||
#define EXCEPTION 147 /* \exception */
|
#define EXCEPTION 147 /* \exception */
|
||||||
#define FDOLLAR 148 /* \f$ */
|
#define FDOLLAR 148 /* \f$ */
|
||||||
#define FLEFTSQUAREBRACKET 149 /* \f[ */
|
#define FLEFTSQUAREBRACKET 149 /* \f[ */
|
||||||
#define FRIGHTSQUAREBRACKET 150 /* \f] */
|
#define FRIGHTSQUAREBRACKET 150 /* \f] */
|
||||||
#define FLEFTBRACKET 151 /* \f{ */
|
#define FLEFTBRACKET 151 /* \f{ */
|
||||||
#define FRIGHTBRACKET 152 /* \f} */
|
#define FRIGHTBRACKET 152 /* \f} */
|
||||||
#define FILE_COMMAND 153 /* \file */
|
#define FILE_COMMAND 153 /* \file */
|
||||||
#define FN_COMMAND 154 /* \fn */
|
#define FN_COMMAND 154 /* \fn */
|
||||||
#define HEADERFILE 155/* \headerfile */
|
#define HEADERFILE 155 /* \headerfile */
|
||||||
#define HIDEINITIALIZER 156 /* \hideinitializer */
|
#define HIDEINITIALIZER 156 /* \hideinitializer */
|
||||||
#define HTMLINCLUDE 157 /* \htmlinclude */
|
#define HTMLINCLUDE 157 /* \htmlinclude */
|
||||||
#define HTMLONLY 158 /* \htmlonly */
|
#define HTMLONLY 158 /* \htmlonly */
|
||||||
#define IF_COMMAND 159 /* \if */
|
#define IF_COMMAND 159 /* \if */
|
||||||
#define IFNOT_COMMAND 160 /* \ifnot */
|
#define IFNOT_COMMAND 160 /* \ifnot */
|
||||||
#define IMAGE 161 /* \image */
|
#define IMAGE 161 /* \image */
|
||||||
#define INCLUDE_COMMAND 162 /* \include */
|
#define INCLUDE_COMMAND 162 /* \include */
|
||||||
#define INCLUDELINENO 163 /* \includelineno */
|
#define INCLUDELINENO 163 /* \includelineno */
|
||||||
#define INGROUP 164 /* \ingroup */
|
#define INGROUP 164 /* \ingroup */
|
||||||
#define INTERNAL 165 /* \internal */
|
#define INTERNAL 165 /* \internal */
|
||||||
#define INVARIANT 166 /* \invariant */
|
#define INVARIANT 166 /* \invariant */
|
||||||
#define INTERFACE_COMMAND 167 /* \interface */
|
#define INTERFACE_COMMAND 167 /* \interface */
|
||||||
#define LATEXONLY 168 /* \latexonly */
|
#define LATEXONLY 168 /* \latexonly */
|
||||||
#define LI 169 /* \li */
|
#define LI 169 /* \li */
|
||||||
#define LINE 170 /* \line */
|
#define LINE 170 /* \line */
|
||||||
#define LINK 171 /* \link */
|
#define LINK 171 /* \link */
|
||||||
#define MAINPAGE 172 /* \mainpage */
|
#define MAINPAGE 172 /* \mainpage */
|
||||||
#define MANONLY 173 /* \manonly */
|
#define MANONLY 173 /* \manonly */
|
||||||
#define MSC 174 /* \msc */
|
#define MSC 174 /* \msc */
|
||||||
#define N 175 /* \n */
|
#define N 175 /* \n */
|
||||||
#define NAME 176 /* \name */
|
#define NAME 176 /* \name */
|
||||||
#define NAMESPACE 177 /* \namespace */
|
#define NAMESPACE 177 /* \namespace */
|
||||||
#define NOSUBGROUPING 178 /* \nosubgrouping */
|
#define NOSUBGROUPING 178 /* \nosubgrouping */
|
||||||
#define NOTE 179 /* \note */
|
#define NOTE 179 /* \note */
|
||||||
#define OVERLOAD 180 /* \overload */
|
#define OVERLOAD 180 /* \overload */
|
||||||
#define P 181 /* \p */
|
#define P 181 /* \p */
|
||||||
#define PACKAGE 182 /* \package */
|
#define PACKAGE 182 /* \package */
|
||||||
#define PAGE 183 /* \page */
|
#define PAGE 183 /* \page */
|
||||||
#define PAR 184 /* \par */
|
#define PAR 184 /* \par */
|
||||||
#define PARAGRAPH 185 /* \paragraph */
|
#define PARAGRAPH 185 /* \paragraph */
|
||||||
#define PARAM 186 /* \param */
|
#define PARAM 186 /* \param */
|
||||||
#define POST 187 /* \post */
|
#define POST 187 /* \post */
|
||||||
#define PRE 188 /* \pre */
|
#define PRE 188 /* \pre */
|
||||||
#define PRIVATE 189 /* \private (PHP only) */
|
#define PRIVATE 189 /* \private (PHP only) */
|
||||||
#define PRIVATESECTION 190 /* \privatesection (PHP only) */
|
#define PRIVATESECTION 190 /* \privatesection (PHP only) */
|
||||||
#define PROPERTY 191 /* \property */
|
#define PROPERTY 191 /* \property */
|
||||||
#define PROTECTED 192 /* \protected (PHP only) */
|
#define PROTECTED 192 /* \protected (PHP only) */
|
||||||
#define PROTECTEDSECTION 193 /* \protectedsection (PHP only) */
|
#define PROTECTEDSECTION 193 /* \protectedsection (PHP only) */
|
||||||
#define PROTOCOL 194 /* \protocol */
|
#define PROTOCOL 194 /* \protocol */
|
||||||
#define PUBLIC 195 /* \public (PHP only) */
|
#define PUBLIC 195 /* \public (PHP only) */
|
||||||
#define PUBLICSECTION 196 /* \publicsection (PHP only) */
|
#define PUBLICSECTION 196 /* \publicsection (PHP only) */
|
||||||
#define REF 197 /* \ref */
|
#define REF 197 /* \ref */
|
||||||
#define RELATES 198 /* \relates */
|
#define RELATES 198 /* \relates */
|
||||||
#define RELATESALSO 199 /* \relatesalso */
|
#define RELATESALSO 199 /* \relatesalso */
|
||||||
#define REMARKS 200 /* \remarks */
|
#define REMARKS 200 /* \remarks */
|
||||||
#define RETURN_COMMAND 201 /* \return */
|
#define RETURN_COMMAND 201 /* \return */
|
||||||
#define RETVAL 202 /* \retval */
|
#define RETVAL 202 /* \retval */
|
||||||
#define SA 203 /* \sa */
|
#define SA 203 /* \sa */
|
||||||
#define SECTION 204 /* \section */
|
#define SECTION 204 /* \section */
|
||||||
#define SEE 205 /* \see */
|
#define SEE 205 /* \see */
|
||||||
#define SHOWINITIALIZER 206 /* \showinitializer */
|
#define SHOWINITIALIZER 206 /* \showinitializer */
|
||||||
#define SINCE 207 /* \since */
|
#define SINCE 207 /* \since */
|
||||||
#define SKIP 208 /* \skip */
|
#define SKIP 208 /* \skip */
|
||||||
#define SKIPLINE 209 /* \skipline */
|
#define SKIPLINE 209 /* \skipline */
|
||||||
#define STRUCT 210 /* \struct */
|
#define STRUCT 210 /* \struct */
|
||||||
#define SUBPAGE 211 /* \subpage */
|
#define SUBPAGE 211 /* \subpage */
|
||||||
#define SUBSECTION 212 /* \subsection */
|
#define SUBSECTION 212 /* \subsection */
|
||||||
#define SUBSUBSECTION 213 /* \subsubsection */
|
#define SUBSUBSECTION 213 /* \subsubsection */
|
||||||
#define TEST 214 /* \test */
|
#define TEST 214 /* \test */
|
||||||
#define THROW_COMMAND 215 /* \throw */
|
#define THROW_COMMAND 215 /* \throw */
|
||||||
#define TODO_COMMAND 216 /* \todo */
|
#define TODO_COMMAND 216 /* \todo */
|
||||||
#define TPARAM_COMMAND 217 /* \tparam */
|
#define TPARAM_COMMAND 217 /* \tparam */
|
||||||
#define TYPEDEF_COMMAND 218 /* \typedef */
|
#define TYPEDEF_COMMAND 218 /* \typedef */
|
||||||
#define UNION_COMMAND 219 /* \union */
|
#define UNION_COMMAND 219 /* \union */
|
||||||
#define UNTIL_COMMAND 220 /* \until */
|
#define UNTIL_COMMAND 220 /* \until */
|
||||||
#define VAR_COMMAND 221 /* \var */
|
#define VAR_COMMAND 221 /* \var */
|
||||||
#define VERBATIM 222 /* \verbatim */
|
#define VERBATIM 222 /* \verbatim */
|
||||||
#define VERBININCLUDE 223 /* \verbinclude */
|
#define VERBININCLUDE 223 /* \verbinclude */
|
||||||
#define VERSION 224 /* \version */
|
#define VERSION 224 /* \version */
|
||||||
#define WARNING 225 /* \warning */
|
#define WARNING 225 /* \warning */
|
||||||
#define WEAKGROUP 226 /* \weakgroup */
|
#define WEAKGROUP 226 /* \weakgroup */
|
||||||
#define XMLONLY 227/* \xmlonly */
|
#define XMLONLY 227 /* \xmlonly */
|
||||||
#define XREFITEM 228 /* \xrefitem */
|
#define XREFITEM 228 /* \xrefitem */
|
||||||
#define DOLLAR_COMMAND 229 /* \$ */
|
#define DOLLAR_COMMAND 229 /* \$ */
|
||||||
#define AT_COMMAND 230 /* \@ */
|
#define AT_COMMAND 230 /* \@ */
|
||||||
#define SLASH_COMMAND 231 /* \\ */
|
#define SLASH_COMMAND 231 /* \\ */
|
||||||
#define AND_COMMAND 232 /* \& */
|
#define AND_COMMAND 232 /* \& */
|
||||||
#define TILDE_COMMAND 233 /* \~ */
|
#define TILDE_COMMAND 233 /* \~ */
|
||||||
#define LEFTANGLEBRACKET 234 /* \< */
|
#define LEFTANGLEBRACKET 234 /* \< */
|
||||||
#define RIGHTANGLEBRACKET 235 /* \> */
|
#define RIGHTANGLEBRACKET 235 /* \> */
|
||||||
#define POUND_COMMAND 236 /* \# */
|
#define POUND_COMMAND 236 /* \# */
|
||||||
#define PERCENT_COMMAND 237 /* \% */
|
#define PERCENT_COMMAND 237 /* \% */
|
||||||
|
|
||||||
#endif /*TRANSLATOR_H_*/
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,43 @@
|
||||||
#include "JavaDocConverter.h"
|
#include "JavaDocConverter.h"
|
||||||
#include "DoxygenParser.h"
|
#include "DoxygenParser.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define APPROX_LINE_LENGTH 64//characters per line allowed
|
#define APPROX_LINE_LENGTH 64 //characters per line allowed
|
||||||
#define TAB_SIZE 8//characters per line allowed
|
#define TAB_SIZE 8 //characters per line allowed
|
||||||
int printSortedTree2 = 0;
|
int printSortedTree2 = 0;
|
||||||
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag
|
//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 * ";
|
std::string formattedLines = "\n * ";
|
||||||
int lastPosition = 0;
|
int lastPosition = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int isFirstLine = 1;
|
int isFirstLine = 1;
|
||||||
while (i != -1 && i < (int)unformattedLine.length()){
|
while (i != -1 && i < (int) unformattedLine.length()) {
|
||||||
lastPosition = i;
|
lastPosition = i;
|
||||||
if (isFirstLine){
|
if (isFirstLine) {
|
||||||
i+=APPROX_LINE_LENGTH;
|
i += APPROX_LINE_LENGTH;
|
||||||
} else {
|
} else {
|
||||||
i+=APPROX_LINE_LENGTH - indent*TAB_SIZE;
|
i += APPROX_LINE_LENGTH - indent * TAB_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = unformattedLine.find(" ", i);
|
i = unformattedLine.find(" ", i);
|
||||||
|
|
||||||
if (i > 0 && i + 1 < (int)unformattedLine.length()){
|
if (i > 0 && i + 1 < (int) unformattedLine.length()) {
|
||||||
if (!isFirstLine) for (int j = 0; j < indent; j++) {
|
if (!isFirstLine)
|
||||||
formattedLines.append("\t");
|
for (int j = 0; j < indent; j++) {
|
||||||
|
formattedLines.append("\t");
|
||||||
} else {
|
} else {
|
||||||
isFirstLine = 0;
|
isFirstLine = 0;
|
||||||
}
|
}
|
||||||
formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1));
|
formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1));
|
||||||
formattedLines.append("\n *");
|
formattedLines.append("\n *");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lastPosition < (int)unformattedLine.length()){
|
if (lastPosition < (int) unformattedLine.length()) {
|
||||||
if (!isFirstLine) {
|
if (!isFirstLine) {
|
||||||
for (int j = 0; j < indent; j++) {
|
for (int j = 0; j < indent; j++) {
|
||||||
formattedLines.append("\t");
|
formattedLines.append("\t");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition));
|
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
|
/* Contains the conversions for tags
|
||||||
* could probably be much more efficient...
|
* could probably be much more efficient...
|
||||||
*/
|
*/
|
||||||
std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){
|
std::string JavaDocConverter::javaDocFormat(DoxygenEntity & doxygenEntity) {
|
||||||
if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){
|
if (doxygenEntity.typeOfEntity.compare("partofdescription") == 0) {
|
||||||
return doxygenEntity.data;
|
return doxygenEntity.data;
|
||||||
}
|
|
||||||
if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 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>";
|
return "<b>" + doxygenEntity.data + "</b>";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("c") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("c") == 0){
|
|
||||||
return "<tt>" + doxygenEntity.data + "</tt>";
|
return "<tt>" + doxygenEntity.data + "</tt>";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("@") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("@") == 0){
|
|
||||||
return "@";
|
return "@";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("\\") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("\\") == 0){
|
|
||||||
return "\\";
|
return "\\";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("<") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("<") == 0){
|
|
||||||
return "<";
|
return "<";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare(">") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare(">") == 0){
|
|
||||||
return ">";
|
return ">";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("&") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("&") == 0){
|
|
||||||
return "&";
|
return "&";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("#") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("#") == 0){
|
|
||||||
return "#";
|
return "#";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("%") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("%") == 0){
|
|
||||||
return "%";
|
return "%";
|
||||||
}
|
} else if (doxygenEntity.typeOfEntity.compare("~") == 0) {
|
||||||
else if (doxygenEntity.typeOfEntity.compare("~") == 0){
|
|
||||||
return "~";
|
return "~";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
|
std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) {
|
||||||
std::string returnedString;
|
std::string returnedString;
|
||||||
if (doxygenEntity.isLeaf) {
|
if (doxygenEntity.isLeaf) {
|
||||||
return javaDocFormat(doxygenEntity) + " ";
|
return javaDocFormat(doxygenEntity) + " ";
|
||||||
} else {
|
} else {
|
||||||
returnedString += javaDocFormat(doxygenEntity);
|
returnedString += javaDocFormat(doxygenEntity);
|
||||||
std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin();
|
std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin();
|
||||||
|
|
||||||
while (p != doxygenEntity.entityList.end()){
|
while (p != doxygenEntity.entityList.end()) {
|
||||||
returnedString+= translateSubtree(*p);
|
returnedString += translateSubtree(*p);
|
||||||
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) {
|
if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) {
|
||||||
return formatCommand(std::string(translateSubtree(doxyEntity)), 0);
|
return formatCommand(std::string(translateSubtree(doxyEntity)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((doxyEntity.typeOfEntity.compare("brief") == 0) ||
|
if ((doxyEntity.typeOfEntity.compare("brief") == 0) || (doxyEntity.typeOfEntity.compare("details") == 0)) {
|
||||||
(doxyEntity.typeOfEntity.compare("details") == 0)) {
|
|
||||||
return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";
|
return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";
|
||||||
|
|
||||||
} else if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 ||
|
} else if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 ||
|
||||||
doxyEntity.typeOfEntity.compare("deprecated")== 0 ||
|
doxyEntity.typeOfEntity.compare("deprecated") == 0 ||
|
||||||
doxyEntity.typeOfEntity.compare("brief")== 0) {
|
doxyEntity.typeOfEntity.compare("brief") == 0) {
|
||||||
return formatCommand(doxyEntity.data, 0) + "\n * ";
|
return formatCommand(doxyEntity.data, 0) + "\n * ";
|
||||||
|
|
||||||
} else if(doxyEntity.typeOfEntity.compare("see") == 0) {
|
} else if (doxyEntity.typeOfEntity.compare("see") == 0) {
|
||||||
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" +
|
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2);
|
||||||
translateSubtree(doxyEntity)), 2);
|
|
||||||
|
|
||||||
} else if(doxyEntity.typeOfEntity.compare("return")== 0
|
} else if (doxyEntity.typeOfEntity.compare("return") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("author")== 0
|
|| doxyEntity.typeOfEntity.compare("author") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("param")== 0
|
|| doxyEntity.typeOfEntity.compare("param") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("throw")== 0
|
|| doxyEntity.typeOfEntity.compare("throw") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("throws")== 0
|
|| doxyEntity.typeOfEntity.compare("throws") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("since")== 0
|
|| doxyEntity.typeOfEntity.compare("since") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("version")== 0
|
|| doxyEntity.typeOfEntity.compare("version") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("exception") == 0
|
|| doxyEntity.typeOfEntity.compare("exception") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("deprecated") == 0){
|
|| doxyEntity.typeOfEntity.compare("deprecated") == 0) {
|
||||||
|
|
||||||
// this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing
|
// 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";
|
doxyEntity.typeOfEntity = "throws";
|
||||||
}
|
}
|
||||||
return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2);
|
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);
|
return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return formatCommand(javaDocFormat(doxyEntity), 0 );
|
return formatCommand(javaDocFormat(doxyEntity), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|
@ -157,31 +146,31 @@ bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) {
|
||||||
if (documentation == NULL) {
|
if (documentation == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list <DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation));
|
|
||||||
|
|
||||||
// entityList.sort(CompareDoxygenEntities()); sorting currently not used,
|
std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
|
||||||
// see CompareDoxygenEntities::operator() in DoxygenEntity.cpp
|
|
||||||
|
// entityList.sort(CompareDoxygenEntities()); sorting currently not used,
|
||||||
if(debug){
|
// see CompareDoxygenEntities::operator() in DoxygenEntity.cpp
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
std::cout << "---RESORTED LIST---" << std::endl;
|
std::cout << "---RESORTED LIST---" << std::endl;
|
||||||
printTree(entityList);
|
printTree(entityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string javaDocString = "/**";
|
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);
|
javaDocString += translateEntity(*entityIterator);
|
||||||
entityIterator++;
|
entityIterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
javaDocString += "\n */\n";
|
javaDocString += "\n */\n";
|
||||||
|
|
||||||
if(debug){
|
if (debug) {
|
||||||
std::cout << "\n---RESULT IN JAVADOC---" << std::endl;
|
std::cout << "\n---RESULT IN JAVADOC---" << std::endl;
|
||||||
std::cout << javaDocString;
|
std::cout << javaDocString;
|
||||||
}
|
}
|
||||||
|
|
||||||
documentation = NewString(javaDocString.c_str());
|
documentation = NewString(javaDocString.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,20 +15,20 @@
|
||||||
/*
|
/*
|
||||||
* A class to translate doxygen comments into JavaDoc style comments.
|
* A class to translate doxygen comments into JavaDoc style comments.
|
||||||
*/
|
*/
|
||||||
class JavaDocConverter : public DoxygenTranslator
|
class JavaDocConverter : public DoxygenTranslator {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
JavaDocConverter() : debug( false ){}
|
JavaDocConverter() : debug(false) {
|
||||||
|
}
|
||||||
virtual bool getDocumentation(Node *node, String *&documentation);
|
virtual bool getDocumentation(Node *node, String *&documentation);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string formatCommand(std::string unformattedLine, int indent);
|
std::string formatCommand(std::string unformattedLine, int indent);
|
||||||
std::string translateEntity(DoxygenEntity &doxyEntity);
|
std::string translateEntity(DoxygenEntity & doxyEntity);
|
||||||
std::string javaDocFormat(DoxygenEntity &doxygenEntity);
|
std::string javaDocFormat(DoxygenEntity & doxygenEntity);
|
||||||
std::string translateSubtree( DoxygenEntity &doxygenEntity);
|
std::string translateSubtree(DoxygenEntity & doxygenEntity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug;
|
bool debug;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*JAVADOCCONVERTER_H_*/
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -14,25 +14,25 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag
|
//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag
|
||||||
PyDocConverter::PyDocConverter(){
|
PyDocConverter::PyDocConverter() {
|
||||||
debug = 1;
|
debug = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
|
std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) {
|
||||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||||
Parm *p = NULL;
|
Parm *p = NULL;
|
||||||
|
|
||||||
DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin();
|
DoxygenEntity & paramNameEntity = *doxygenEntity.entityList.begin();
|
||||||
DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin());
|
DoxygenEntity & paramDescriptionEntity = *(++doxygenEntity.entityList.begin());
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH);
|
std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH);
|
||||||
|
|
||||||
for (p = plist; p;) {
|
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 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));
|
std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0));
|
||||||
|
|
||||||
result = name + " (" + type + ") ";
|
result = name + " (" + type + ") ";
|
||||||
result.resize(DOC_PARAM_STRING_LENGTH - 3, ' ');
|
result.resize(DOC_PARAM_STRING_LENGTH - 3, ' ');
|
||||||
result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH);
|
result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH);
|
||||||
|
|
@ -45,162 +45,158 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity){
|
std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity) {
|
||||||
#pragma unused(node)
|
#pragma unused(node)
|
||||||
return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity));
|
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::ostringstream formattedString;
|
||||||
std::string currentLine;
|
std::string currentLine;
|
||||||
|
|
||||||
for(std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition)
|
for (std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) {
|
||||||
{
|
if (currentLine.length() == 0)
|
||||||
if(currentLine.length() == 0)
|
|
||||||
currentLine.resize(indent, ' ');
|
currentLine.resize(indent, ' ');
|
||||||
|
|
||||||
currentLine += *stringPosition;
|
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;
|
formattedString << currentLine << std::endl;
|
||||||
currentLine = "";
|
currentLine = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return formattedString.str();
|
return formattedString.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
|
std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) {
|
||||||
std::string returnedString;
|
std::string returnedString;
|
||||||
if (doxygenEntity.isLeaf)
|
if (doxygenEntity.isLeaf)
|
||||||
return doxygenEntity.data + " ";
|
return doxygenEntity.data + " ";
|
||||||
else {
|
else {
|
||||||
returnedString += doxygenEntity.data;
|
returnedString += doxygenEntity.data;
|
||||||
std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin();
|
std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin();
|
||||||
while (p != doxygenEntity.entityList.end()){
|
while (p != doxygenEntity.entityList.end()) {
|
||||||
returnedString+= translateSubtree(*p);
|
returnedString += translateSubtree(*p);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnedString;
|
return returnedString;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){
|
std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity & doxyEntity) {
|
||||||
if(doxyEntity.typeOfEntity.compare("partofdescription") == 0)
|
if (doxyEntity.typeOfEntity.compare("partofdescription") == 0)
|
||||||
return justifyString(std::string(translateSubtree(doxyEntity)), 0);
|
return justifyString(std::string(translateSubtree(doxyEntity)), 0);
|
||||||
|
|
||||||
if ((doxyEntity.typeOfEntity.compare("brief") == 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";
|
return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n";
|
||||||
|
|
||||||
if(doxyEntity.typeOfEntity.compare("plainstd::string") == 0
|
if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("brief") == 0)
|
|| doxyEntity.typeOfEntity.compare("brief") == 0)
|
||||||
return justifyString(doxyEntity.data, 0) + "\n";
|
return justifyString(doxyEntity.data, 0) + "\n";
|
||||||
|
|
||||||
if(doxyEntity.typeOfEntity.compare("param") == 0)
|
if (doxyEntity.typeOfEntity.compare("param") == 0)
|
||||||
return formatParam(n, doxyEntity);
|
return formatParam(n, doxyEntity);
|
||||||
|
|
||||||
if(doxyEntity.typeOfEntity.compare("return") == 0)
|
if (doxyEntity.typeOfEntity.compare("return") == 0)
|
||||||
return formatReturnDescription(n, doxyEntity);
|
return formatReturnDescription(n, doxyEntity);
|
||||||
|
|
||||||
if(doxyEntity.typeOfEntity.compare("author") == 0
|
if (doxyEntity.typeOfEntity.compare("author") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("param") == 0
|
|| doxyEntity.typeOfEntity.compare("param") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("since") == 0
|
|| doxyEntity.typeOfEntity.compare("since") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("version") == 0
|
|| doxyEntity.typeOfEntity.compare("version") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("exception") == 0
|
|| doxyEntity.typeOfEntity.compare("exception") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|
|| doxyEntity.typeOfEntity.compare("deprecated") == 0
|
||||||
|| doxyEntity.typeOfEntity.compare("sa") == 0)
|
|| doxyEntity.typeOfEntity.compare("sa") == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return justifyString(doxyEntity.data);
|
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;
|
std::string result;
|
||||||
bool inParamsSection = false;
|
bool inParamsSection = false;
|
||||||
|
|
||||||
for(std::list<DoxygenEntity>::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){
|
for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) {
|
||||||
if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection){
|
if (entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) {
|
||||||
inParamsSection = true;
|
inParamsSection = true;
|
||||||
result += "\nArguments:\n";
|
result += "\nArguments:\n";
|
||||||
}
|
} else if (entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection)
|
||||||
else if(entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection)
|
|
||||||
inParamsSection = false;
|
inParamsSection = false;
|
||||||
|
|
||||||
result += translateEntity(n, *entityIterator);
|
result += translateEntity(n, *entityIterator);
|
||||||
entityIterator++;
|
entityIterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PyDocConverter::getDocumentation(Node *n, String *&documentation){
|
bool PyDocConverter::getDocumentation(Node *n, String *&documentation) {
|
||||||
std::string pyDocString, result;
|
std::string pyDocString, result;
|
||||||
|
|
||||||
// for overloaded functions we must concat documentation for underlying overloads
|
// 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
|
// rewind to the first overload
|
||||||
while (Getattr(n, "sym:previousSibling"))
|
while (Getattr(n, "sym:previousSibling"))
|
||||||
n = 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
|
// for each real method (not a generated overload) append the documentation
|
||||||
while(n){
|
while (n) {
|
||||||
documentation = Getattr(n,"DoxygenComment");
|
documentation = Getattr(n, "DoxygenComment");
|
||||||
if(!Swig_is_generated_overload(n) && documentation){
|
if (!Swig_is_generated_overload(n) && documentation) {
|
||||||
std::list<DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation));
|
std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
|
||||||
allDocumentation.push_back(processEntityList(n, entityList));
|
allDocumentation.push_back(processEntityList(n, entityList));
|
||||||
}
|
}
|
||||||
n = Getattr(n, "sym:nextSibling");
|
n = Getattr(n, "sym:nextSibling");
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct final documentation string
|
// construct final documentation string
|
||||||
if(allDocumentation.size() > 1){
|
if (allDocumentation.size() > 1) {
|
||||||
std::ostringstream concatDocString;
|
std::ostringstream concatDocString;
|
||||||
for(int realOverloadCount = 0; realOverloadCount < (int)allDocumentation.size(); realOverloadCount++){
|
for (int realOverloadCount = 0; realOverloadCount < (int) allDocumentation.size(); realOverloadCount++) {
|
||||||
concatDocString << generateDivider();
|
concatDocString << generateDivider();
|
||||||
concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl;
|
concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl;
|
||||||
concatDocString << generateDivider();
|
concatDocString << generateDivider();
|
||||||
concatDocString << allDocumentation[realOverloadCount] << std::endl;
|
concatDocString << allDocumentation[realOverloadCount] << std::endl;
|
||||||
}
|
}
|
||||||
pyDocString = concatDocString.str();
|
pyDocString = concatDocString.str();
|
||||||
}
|
} else if (allDocumentation.size() == 1) {
|
||||||
else if (allDocumentation.size() == 1) {
|
|
||||||
pyDocString = *(allDocumentation.begin());
|
pyDocString = *(allDocumentation.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for other nodes just process as normal
|
// for other nodes just process as normal
|
||||||
else {
|
else {
|
||||||
documentation = Getattr(n,"DoxygenComment");
|
documentation = Getattr(n, "DoxygenComment");
|
||||||
if(documentation != NULL){
|
if (documentation != NULL) {
|
||||||
std::list<DoxygenEntity> entityList = DoxygenParser().createTree(Char(documentation));
|
std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation));
|
||||||
pyDocString = processEntityList(n, entityList);
|
pyDocString = processEntityList(n, entityList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we got something log the result and construct DOH string to return
|
// if we got something log the result and construct DOH string to return
|
||||||
if(pyDocString.length()) {
|
if (pyDocString.length()) {
|
||||||
result = "\"\"\"\n" + pyDocString + "\"\"\"\n";
|
result = "\"\"\"\n" + pyDocString + "\"\"\"\n";
|
||||||
|
|
||||||
if(debug){
|
if (debug) {
|
||||||
std::cout << "\n---RESULT IN PYDOC---" << std::endl;
|
std::cout << "\n---RESULT IN PYDOC---" << std::endl;
|
||||||
std::cout << result;
|
std::cout << result;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
documentation = NewString(result.c_str());
|
documentation = NewString(result.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PyDocConverter::generateDivider(){
|
std::string PyDocConverter::generateDivider() {
|
||||||
std::ostringstream dividerString;
|
std::ostringstream dividerString;
|
||||||
for(int i = 0; i < DOC_STRING_LENGTH; i++)
|
for (int i = 0; i < DOC_STRING_LENGTH; i++)
|
||||||
dividerString << '-';
|
dividerString << '-';
|
||||||
dividerString << std::endl;
|
dividerString << std::endl;
|
||||||
return dividerString.str();
|
return dividerString.str();
|
||||||
|
|
|
||||||
|
|
@ -16,38 +16,37 @@
|
||||||
#include "DoxygenEntity.h"
|
#include "DoxygenEntity.h"
|
||||||
#include "DoxygenTranslator.h"
|
#include "DoxygenTranslator.h"
|
||||||
|
|
||||||
#define DOC_STRING_LENGTH 64 // characters per line allowed
|
#define DOC_STRING_LENGTH 64 // characters per line allowed
|
||||||
#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type
|
#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type
|
||||||
|
|
||||||
class PyDocConverter : public DoxygenTranslator
|
class PyDocConverter : public DoxygenTranslator {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
PyDocConverter();
|
PyDocConverter();
|
||||||
bool getDocumentation(Node *node, String *&documentation);
|
bool getDocumentation(Node *node, String *&documentation);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process the contents of the entity list producing a documentation string.
|
* Process the contents of the entity list producing a documentation string.
|
||||||
* @param node The parse tree node that the entity list relates to.
|
* @param node The parse tree node that the entity list relates to.
|
||||||
* @param entityList The entity list to process
|
* @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
|
* Format the doxygen comment relating to a function or method parameter
|
||||||
* @param node The parse tree node that the parameter relates to.
|
* @param node The parse tree node that the parameter relates to.
|
||||||
* @param doxygenEntity The doxygen entity relating to the parameter docstring.
|
* @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.
|
* 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 node The parse tree node that the parameter relates to.
|
||||||
* @param doxygenEntity The doxygen entity relating to the parameter docstring.
|
* @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
|
* Format a string so it is justified and split over several lines
|
||||||
* not exeeding a given length.
|
* not exeeding a given length.
|
||||||
|
|
@ -56,17 +55,17 @@ protected:
|
||||||
* @param maxWidth The approximate maximum line width.
|
* @param maxWidth The approximate maximum line width.
|
||||||
*/
|
*/
|
||||||
std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH);
|
std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH);
|
||||||
|
|
||||||
std::string translateSubtree( DoxygenEntity &doxygenEntity);
|
std::string translateSubtree(DoxygenEntity & doxygenEntity);
|
||||||
std::string translateEntity(Node *n, DoxygenEntity &doxyEntity);
|
std::string translateEntity(Node *n, DoxygenEntity & doxyEntity);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility method to generate a diving line for a documentation string.
|
* Utility method to generate a diving line for a documentation string.
|
||||||
*/
|
*/
|
||||||
std::string generateDivider();
|
std::string generateDivider();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug;
|
bool debug;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*PYDOCCONVERTER_H_*/
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,27 +3,26 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
Token::Token(int tType, string tString)
|
Token::Token(int tType, string tString) {
|
||||||
{
|
tokenType = tType;
|
||||||
tokenType = tType;
|
tokenString = tString;
|
||||||
tokenString = tString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Token::toString()
|
string Token::toString() {
|
||||||
{
|
if (tokenType == END_LINE) {
|
||||||
if (tokenType == END_LINE){
|
return "{END OF LINE}";
|
||||||
return "{END OF LINE}";
|
}
|
||||||
}
|
if (tokenType == PARAGRAPH_END) {
|
||||||
if (tokenType == PARAGRAPH_END){
|
return "{END OF PARAGRAPH}";
|
||||||
return "{END OF PARAGRAPH}";
|
}
|
||||||
}
|
if (tokenType == PLAINSTRING) {
|
||||||
if (tokenType == PLAINSTRING){
|
return "{PLAINSTRING :" + tokenString + "}";
|
||||||
return "{PLAINSTRING :" + tokenString + "}";
|
}
|
||||||
}
|
if (tokenType == COMMAND) {
|
||||||
if (tokenType == COMMAND){
|
return "{COMMAND : " + tokenString + "}";
|
||||||
return "{COMMAND : " + tokenString+ "}";
|
}
|
||||||
}
|
return "";
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Token:: ~Token(){}
|
Token::~Token() {
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,14 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class Token
|
class Token {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Token(int tType, string tString);
|
Token(int tType, string tString);
|
||||||
~Token();
|
~Token();
|
||||||
|
|
||||||
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
|
int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */
|
||||||
string tokenString; /* the data , such as param for @param*/
|
string tokenString; /* the data , such as param for @param */
|
||||||
string toString();
|
string toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*TOKEN_H_*/
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5,165 +5,161 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "Token.h"
|
#include "Token.h"
|
||||||
#include "DoxygenEntity.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;
|
using namespace std;
|
||||||
|
|
||||||
int noisy2 = 0;
|
int noisy2 = 0;
|
||||||
/* The tokenizer*/
|
/* The tokenizer*/
|
||||||
TokenList::TokenList(const std::string &doxygenStringConst){
|
TokenList::TokenList(const std::string & doxygenStringConst) {
|
||||||
size_t commentPos;
|
size_t commentPos;
|
||||||
string doxygenString = doxygenStringConst;
|
string doxygenString = doxygenStringConst;
|
||||||
|
|
||||||
/* Comment start tokens are replaced in parser.y, see doxygen_comment and
|
/* Comment start tokens are replaced in parser.y, see doxygen_comment and
|
||||||
doxygen_post_comment_item
|
doxygen_post_comment_item
|
||||||
do {
|
do {
|
||||||
commentPos = doxygenString.find("///<");
|
commentPos = doxygenString.find("///<");
|
||||||
if (commentPos != string::npos) {
|
if (commentPos != string::npos) {
|
||||||
doxygenString.replace(commentPos, 4, " ");
|
doxygenString.replace(commentPos, 4, " ");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
commentPos = doxygenString.find("/**<");
|
commentPos = doxygenString.find("/**<");
|
||||||
if (commentPos != string::npos) {
|
if (commentPos != string::npos) {
|
||||||
doxygenString.replace(commentPos, 4, " ");
|
doxygenString.replace(commentPos, 4, " ");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
commentPos = doxygenString.find("/*!<");
|
commentPos = doxygenString.find("/*!<");
|
||||||
if (commentPos != string::npos) {
|
if (commentPos != string::npos) {
|
||||||
doxygenString.replace(commentPos, 4, " ");
|
doxygenString.replace(commentPos, 4, " ");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
commentPos = doxygenString.find("//!<");
|
commentPos = doxygenString.find("//!<");
|
||||||
if (commentPos != string::npos) {
|
if (commentPos != string::npos) {
|
||||||
doxygenString.replace(commentPos, 4, " ");
|
doxygenString.replace(commentPos, 4, " ");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true); */
|
} while (true);
|
||||||
|
*/
|
||||||
|
|
||||||
size_t currentIndex = 0;
|
size_t currentIndex = 0;
|
||||||
size_t nextIndex = 0;
|
size_t nextIndex = 0;
|
||||||
|
|
||||||
string currentWord;
|
string currentWord;
|
||||||
|
|
||||||
while (currentIndex < doxygenString.length()){
|
while (currentIndex < doxygenString.length()) {
|
||||||
|
|
||||||
if(doxygenString[currentIndex] == '\n'){
|
if (doxygenString[currentIndex] == '\n') {
|
||||||
m_tokenList.push_back(Token(END_LINE, currentWord));
|
m_tokenList.push_back(Token(END_LINE, currentWord));
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
}
|
}
|
||||||
|
// skip WS, except \n
|
||||||
|
while (currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' || doxygenString[currentIndex] == '\t'))
|
||||||
|
currentIndex++;
|
||||||
|
|
||||||
// skip WS, except \n
|
if (currentIndex < doxygenString.length()) {
|
||||||
while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' '
|
|
||||||
|| doxygenString[currentIndex]== '\t')) currentIndex ++;
|
|
||||||
|
|
||||||
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
|
// now we have a token
|
||||||
while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' '
|
currentWord = doxygenString.substr(currentIndex, nextIndex - currentIndex);
|
||||||
&& doxygenString[nextIndex] != '\t' && doxygenString[nextIndex]!= '\n'))
|
|
||||||
nextIndex++;
|
|
||||||
|
|
||||||
// now we have a token
|
if (noisy2)
|
||||||
currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex);
|
cout << "Current Word: " << currentWord << endl;
|
||||||
|
|
||||||
if(noisy2)
|
if (currentWord[0] == '@' || currentWord[0] == '\\') {
|
||||||
cout << "Current Word: " << currentWord << endl;
|
// it is doxygen command
|
||||||
|
currentWord = currentWord.substr(1, currentWord.length() - 1);
|
||||||
|
m_tokenList.push_back(Token(COMMAND, currentWord));
|
||||||
|
|
||||||
if (currentWord[0] == '@' || currentWord[0] == '\\'){
|
} else if (currentWord[0] == '\n') {
|
||||||
// it is doxygen command
|
|
||||||
currentWord = currentWord.substr(1, currentWord.length()-1);
|
|
||||||
m_tokenList.push_back(Token(COMMAND, currentWord));
|
|
||||||
|
|
||||||
} 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] == '!') {
|
||||||
|
|
||||||
}
|
|
||||||
else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){
|
|
||||||
|
|
||||||
bool isPlainString = false;
|
|
||||||
|
|
||||||
if (currentWord.length() > 1) {
|
bool isPlainString = false;
|
||||||
|
|
||||||
for(size_t i = 1; i < currentWord.length(); i++){
|
if (currentWord.length() > 1) {
|
||||||
if (currentWord[i] != '*' && currentWord[i] != '/' &&
|
|
||||||
currentWord[i] != '!') {
|
|
||||||
isPlainString = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isPlainString)
|
|
||||||
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
|
|
||||||
|
|
||||||
} else if (!currentWord.empty()) {
|
for (size_t i = 1; i < currentWord.length(); i++) {
|
||||||
m_tokenList.push_back(Token(PLAINSTRING, currentWord));
|
if (currentWord[i] != '*' && currentWord[i] != '/' && currentWord[i] != '!') {
|
||||||
}
|
isPlainString = true;
|
||||||
currentIndex = nextIndex;
|
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(){
|
Token TokenList::peek() {
|
||||||
if(m_tokenListIter!= m_tokenList.end()){
|
if (m_tokenListIter != m_tokenList.end()) {
|
||||||
Token returnedToken = (*m_tokenListIter);
|
Token returnedToken = (*m_tokenListIter);
|
||||||
return returnedToken;
|
return returnedToken;
|
||||||
}
|
} else
|
||||||
else
|
return Token(0, "");
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
return m_tokenListIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
list<Token>::iterator TokenList::iteratorCopy(){
|
list < Token >::iterator TokenList::iteratorCopy() {
|
||||||
return m_tokenListIter;
|
return m_tokenListIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TokenList::setIterator(list<Token>::iterator newPosition){
|
void TokenList::setIterator(list < Token >::iterator newPosition) {
|
||||||
m_tokenListIter = newPosition;
|
m_tokenListIter = newPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TokenList::printList(){
|
void TokenList::printList() {
|
||||||
list<Token>::iterator p = m_tokenList.begin();
|
list < Token >::iterator p = m_tokenList.begin();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
int b = 0;
|
int b = 0;
|
||||||
while (p != m_tokenList.end()){
|
while (p != m_tokenList.end()) {
|
||||||
cout << (*p).toString() << " ";
|
cout << (*p).toString() << " ";
|
||||||
b = i%TOKENSPERLINE;
|
b = i % TOKENSPERLINE;
|
||||||
if (b == 0) cout << endl;
|
if (b == 0)
|
||||||
p++; i++;
|
cout << endl;
|
||||||
}
|
p++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,25 +10,25 @@
|
||||||
* that can be derived from a formatted doxygen string
|
* that can be derived from a formatted doxygen string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TokenList{
|
class TokenList {
|
||||||
private:
|
private:
|
||||||
std::list<Token> m_tokenList;
|
std::list < Token > m_tokenList;
|
||||||
std::list<Token>::iterator m_tokenListIter;
|
std::list < Token >::iterator m_tokenListIter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TokenList(const std::string &doxygenString); /* constructor takes a blob of Doxygen comment */
|
TokenList(const std::string & doxygenString); /* constructor takes a blob of Doxygen comment */
|
||||||
~TokenList();
|
~TokenList();
|
||||||
|
|
||||||
Token peek(); /* returns next token without advancing */
|
Token peek(); /* returns next token without advancing */
|
||||||
Token next(); /* returns next token and advances */
|
Token next(); /* returns next token and advances */
|
||||||
|
|
||||||
std::list<Token>::iterator end(); /* returns an end iterator */
|
std::list < Token >::iterator end(); /* returns an end iterator */
|
||||||
std::list<Token>::iterator current(); /* returns the current iterator */
|
std::list < Token >::iterator current(); /* returns the current iterator */
|
||||||
|
|
||||||
std::list<Token>::iterator iteratorCopy(); /* returns a copy of 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*/
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue