parsing fixes, helped behaviour of normal text descriptions in comments
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10788 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d621d21617
commit
719abc61cc
6 changed files with 100 additions and 45 deletions
|
|
@ -1,8 +1,10 @@
|
|||
/** \file example.h
|
||||
/*! \file example.h
|
||||
comments on example.h */
|
||||
|
||||
/*! This is describing class Shape
|
||||
\author Bob
|
||||
\exception some sort of exception
|
||||
\see OtherShapes()
|
||||
*/
|
||||
|
||||
class Shape {
|
||||
|
|
@ -13,11 +15,12 @@ public:
|
|||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
};
|
||||
double x, y; /*!< Important things */
|
||||
double x, y; /*!< Important variables */
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0; /*!< \return the area */
|
||||
virtual double perimeter(void) = 0; /*!< \return the perimeter */
|
||||
static int nshapes;
|
||||
virtual double area(void) = 0; /*!< \return the area \exception exception description */
|
||||
virtual double perimeter(void) = 0; /*!< \exception exception description
|
||||
\return the perimeter */
|
||||
static int nshapes; /*!< Details about nshapes. */
|
||||
};
|
||||
/*! This is describing class Circle */
|
||||
class Circle : public Shape {
|
||||
|
|
@ -25,8 +28,9 @@ private:
|
|||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { };
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
virtual double area(void); /*!< \return the area \exception exception description */
|
||||
virtual double perimeter(void); /*!< \exception exception description
|
||||
\return the perimeter */
|
||||
};
|
||||
|
||||
/*! This is describing class square */
|
||||
|
|
@ -34,7 +38,9 @@ class Square : public Shape {
|
|||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w) : width(w) { };
|
||||
Square(double w) : width(w) { }; /*!< Create square
|
||||
/param w the width
|
||||
/exception some description */
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ DoxygenParser::~DoxygenParser()
|
|||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
int noisy = 1; // set this to 1 for extra chatter from the parsing stage.
|
||||
int noisy = 0; // set this to 1 for extra chatter from the parsing stage.
|
||||
int addCommand(string currCommand, TokenList &tokList, list <DoxygenEntity> &aNewList);
|
||||
list <DoxygenEntity> parse(list<Token>::iterator endParsingIndex, TokenList &tokList);
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example"
|
|||
string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"};
|
||||
string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"};
|
||||
string ignoreCommandLines[] = {"nothing at the moment"};
|
||||
string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
|
||||
string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
|
||||
"deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"};
|
||||
string ignoreCommandParagraphs[] = {"nothing at the moment"};
|
||||
string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly",
|
||||
|
|
@ -208,27 +208,28 @@ list<Token>::iterator getOneLine(TokenList &tokList){
|
|||
list<Token>::iterator endOfLine = tokList.iteratorCopy();
|
||||
while(endOfLine!= tokList.end()){
|
||||
if ((* endOfLine).tokenType == END_LINE){
|
||||
endOfLine++;
|
||||
//cout << "REACHED END" << endl;
|
||||
//endOfLine++;
|
||||
return endOfLine;
|
||||
}
|
||||
//cout << (* endOfLine).toString();
|
||||
endOfLine++;
|
||||
}
|
||||
cout << "REACHED END" << endl;
|
||||
|
||||
return tokList.end();
|
||||
}
|
||||
|
||||
/* Returns a properly formatted string
|
||||
* up til ANY command or end of paragraph is encountered.
|
||||
* up til ANY command or end of line is encountered.
|
||||
*/
|
||||
string getStringTilCommand(TokenList &tokList){
|
||||
string description;
|
||||
if (tokList.peek().tokenType == 0) return "";
|
||||
while(tokList.peek().tokenType == PLAINSTRING || tokList.peek().tokenType == END_LINE ){
|
||||
while(tokList.peek().tokenType == PLAINSTRING){
|
||||
Token currentToken = tokList.next();
|
||||
if(currentToken.tokenType == PLAINSTRING) {
|
||||
description = description + currentToken.tokenString + " ";
|
||||
}
|
||||
else if (tokList.peek().tokenType == END_LINE) break;
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
|
@ -259,7 +260,7 @@ list<Token>::iterator getEndOfParagraph(TokenList &tokList){
|
|||
endOfParagraph++;
|
||||
if ((* endOfParagraph).tokenType == END_LINE){
|
||||
endOfParagraph++;
|
||||
cout << "ENCOUNTERED END OF PARA" << endl;
|
||||
//cout << "ENCOUNTERED END OF PARA" << endl;
|
||||
return endOfParagraph;
|
||||
}
|
||||
}
|
||||
|
|
@ -762,14 +763,14 @@ list<DoxygenEntity> parseRoot(list<Token>::iterator endParsingIndex, TokenList &
|
|||
if (currCommand < 0 ){
|
||||
if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl;
|
||||
tokList.next();
|
||||
addCommand(string("details"), tokList, aNewList);}
|
||||
addCommand(string("partofdescription"), tokList, aNewList);}
|
||||
//cout << "Command: " << currWord << " " << currCommand << endl;
|
||||
else { tokList.next();
|
||||
addCommand(currToken.tokenString, tokList, aNewList);
|
||||
}
|
||||
}
|
||||
else if (currToken.tokenType == PLAINSTRING){
|
||||
addCommand(string("details"), tokList, aNewList);
|
||||
addCommand(string("partofdescription"), tokList, aNewList);
|
||||
}
|
||||
}
|
||||
return aNewList;
|
||||
|
|
|
|||
|
|
@ -36,27 +36,27 @@ char *DoxygenTranslator::convert(char* doxygenBlob, char* option){
|
|||
|
||||
int testCommands(){
|
||||
string exampleArray[] = {
|
||||
"/**\n * \n * Random Line \n * \\@ \n * Random Line After */",
|
||||
"/**\n * \n * Random Line Before \n * \\b bold \n * Random Line After */",
|
||||
"/**\n * \n * Random Line \n * \\copydoc bold \n * Random Line After */",
|
||||
"/**\n * \n * Random Line \n * \n * \\addindex An Entire Line\n * \\addindex An Entire Line\n * Random Line After */",
|
||||
"/**\n * \n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \n * Random Line After */",
|
||||
"/**\n * \n * Random Line \n * \\return An Entire Paragraph \n * Including This Line \n * \\author Shouldn't be part of return */",
|
||||
"/**\n * \n * Random Line \n * \\code this should continue \n * until here \\endcode \n * Random Line After */",
|
||||
"/**\n * \n * Random Line \n * \\param singleword then the rest of \n * the description \n * \n * Random Line After */",
|
||||
"/**\n * \n * Random Line \n * \\page singleword this should go til here \n * but not this */",
|
||||
"/**\n * \n * Random Line \n * \\page singleword this should go til here \n * but not this */",
|
||||
"/**\n * \n * Random Line \n * \\category singleword \n * but not this */",
|
||||
"/**\n * \n * Random Line \n * \\category singleword oneword \n * but not this */",
|
||||
"/**\n * \n * Random Line \n * \\category singleword oneword twoword \n * but not this */",
|
||||
"/**\n * \n * Random Line \n * \\dir singleword \n * but not this */",
|
||||
"/**\n * \n * Random Line \n * \\dir \n * but not this */",
|
||||
"/**\n * \n * Random Line \n * \\fakecommand details \n * but not this */"
|
||||
"/**\n * Random Line \n * \\@ \n * Random Line After */",
|
||||
"/**\n * Random Line Before \n * \n * \\b bold \n * Random Line After */",
|
||||
"/**\n * Random Line \n * \n *\\copydoc bold \n * Random Line After */",
|
||||
"/**\n * Random Line \n * \n * \\addindex An Entire Line\n * \\addindex An Entire Line\n * Random Line After */",
|
||||
"/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \n * Random Line After */",
|
||||
"/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \\author Shouldn't be part of return */",
|
||||
"/**\n * Random Line \n * \n * \\code this should continue \n * until here \\endcode \n * Random Line After */",
|
||||
"/**\n * Random Line \n * \n * \\param singleword then the rest of \n * the description \n * \n * Random Line After */",
|
||||
"/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */",
|
||||
"/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */",
|
||||
"/**\n * Random Line \n * \n * \\category singleword \n * but not this */",
|
||||
"/**\n * Random Line \n * \n * \\category singleword oneword \n * but not this */",
|
||||
"/**\n * Random Line \n * \n * \\category singleword oneword twoword \n * but not this */",
|
||||
"/**\n * Random Line \n * \n * \\dir singleword \n * but not this */",
|
||||
"/**\n * Random Line \n * \n * \\dir \n * but not this */",
|
||||
"/**\n * Random Line \n * \n * \\fakecommand details \n * but not this */"
|
||||
};
|
||||
//string exampleArrayUniques = {};
|
||||
DoxygenTranslator dT = DoxygenTranslator();
|
||||
for (int i = 0; i < 16; i ++ ){
|
||||
cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl;
|
||||
//cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl;
|
||||
char *nonConstString = (char *)malloc(exampleArray[i].length()+1);
|
||||
strcpy(nonConstString, exampleArray[i].c_str());
|
||||
char * result = dT.convert(nonConstString, "JAVADOC");
|
||||
|
|
@ -66,3 +66,21 @@ int testCommands(){
|
|||
return 1;
|
||||
}
|
||||
|
||||
//int main(int argc, char *argv[]){
|
||||
//string doxygenString1 = "//! \\brief a brief description \n\n A normal member taking two arguments and returning an \\b integer value. This is a very long description for the simple purpose of showing off formatting. Let's make it a bit longer just to be sure. \n/*!\n \\param a an \\b integer argument.\n \\return The test results\n \\param s a constant character pointer. Let's also make this a very long description! \n \\bug this command should, for now, be totally ignored\n \\author cheryl foil\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */";
|
||||
//cout << "---ORIGINAL DOXYGEN--- " << endl << doxygenString1 << endl;
|
||||
//char *nonConstString = (char *)malloc(doxygenString1.length()+1);
|
||||
//strcpy(nonConstString, doxygenString1.c_str());
|
||||
//DoxygenTranslator dT = DoxygenTranslator();
|
||||
//char *result = dT.convert("/**\n * \n * Random Line \n * \n * \\name An Entire Line \n * NOT This Line \n * \n * Random Line After */", "JAVADOC");
|
||||
//result = dT.convert(nonConstString, "JAVADOC");
|
||||
//cout << "End";
|
||||
//list <DoxygenEntity> rootList = doxyParse.createTree(doxygenString1);
|
||||
//JavaDocConverter jDC = JavaDocConverter();
|
||||
//jDC.convertToJavaDoc(rootList);
|
||||
//testCommands();
|
||||
//return 1;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){
|
|||
if(second.typeOfEntity.compare("brief") == 0) return false;
|
||||
if(first.typeOfEntity.compare("details") == 0) return true;
|
||||
if(second.typeOfEntity.compare("details") == 0) return false;
|
||||
if(first.typeOfEntity.compare("partofdescription") == 0) return true;
|
||||
if(first.typeOfEntity.compare("partofdescription") == 0) return false;
|
||||
if(first.typeOfEntity.compare("plainstring") == 0) return true;
|
||||
if(second.typeOfEntity.compare("plainstring") == 0) return false;
|
||||
if(first.typeOfEntity.compare("param") == 0){
|
||||
|
|
@ -132,14 +134,41 @@ string formatCommand(string unformattedLine, int indent){
|
|||
* could probably be much more efficient...
|
||||
*/
|
||||
string javaDocFormat(DoxygenEntity &doxygenEntity){
|
||||
if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){
|
||||
return doxygenEntity.data;
|
||||
}
|
||||
if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){
|
||||
return doxygenEntity.data;
|
||||
return doxygenEntity.data;
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("b") == 0){
|
||||
return "\b<b>" + doxygenEntity.data + "</b>";
|
||||
return "<b>" + doxygenEntity.data + "</b>";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("c") == 0){
|
||||
return "\b<tt>" + doxygenEntity.data + "</tt>";
|
||||
return "<tt>" + doxygenEntity.data + "</tt>";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("@") == 0){
|
||||
return "@";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("\\") == 0){
|
||||
return "\\";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("<") == 0){
|
||||
return "<";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare(">") == 0){
|
||||
return ">";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("&") == 0){
|
||||
return "&";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("#") == 0){
|
||||
return "#";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("%") == 0){
|
||||
return "%";
|
||||
}
|
||||
else if (doxygenEntity.typeOfEntity.compare("~") == 0){
|
||||
return "~";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
@ -160,6 +189,7 @@ string translateSubtree( DoxygenEntity &doxygenEntity){
|
|||
}
|
||||
|
||||
string translateEntity(DoxygenEntity &doxyEntity){
|
||||
if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(string(translateSubtree(doxyEntity)), 0);
|
||||
if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){
|
||||
return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";}
|
||||
else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0)
|
||||
|
|
@ -179,7 +209,7 @@ string translateEntity(DoxygenEntity &doxyEntity){
|
|||
else if(doxyEntity.typeOfEntity.compare("sa")== 0){
|
||||
return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2);
|
||||
}
|
||||
|
||||
else return formatCommand(javaDocFormat(doxyEntity), 0 );
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +231,8 @@ string JavaDocConverter:: convertToJavaDoc(list <DoxygenEntity> entityList){
|
|||
}
|
||||
|
||||
javaDocString += "\n */\n";
|
||||
if(printSortedTree2){
|
||||
cout << "\n---RESULT IN JAVADOC---" << endl;
|
||||
cout << javaDocString;
|
||||
cout << javaDocString; }
|
||||
return javaDocString;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#include <list>
|
||||
#include <string>
|
||||
#include "DoxygenEntity.h"
|
||||
|
||||
#ifndef JAVADOCCONVERTER_H_
|
||||
#define JAVADOCCONVERTER_H_
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ class JAVA:public Language {
|
|||
bool global_variable_flag; // Flag for when wrapping a global variable
|
||||
bool old_variable_names; // Flag for old style variable names in the intermediary class
|
||||
bool member_func_flag; // flag set when wrapping a member function
|
||||
bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc
|
||||
bool comment_creation_chatter; //flag for getting information about where comments were created in java.cxx
|
||||
|
||||
String *imclass_name; // intermediary class name
|
||||
String *module_class_name; // module class name
|
||||
|
|
@ -90,8 +92,6 @@ class JAVA:public Language {
|
|||
return p;
|
||||
}
|
||||
/* DOXYGEN TO JAVADOC globals */
|
||||
bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc
|
||||
bool comment_creation_chatter; //flag for getting information about where comments were created in java.cxx
|
||||
//TODO make this bool a command line option
|
||||
DoxygenTranslator doxyTranslator;
|
||||
|
||||
|
|
@ -124,6 +124,7 @@ public:
|
|||
global_variable_flag(false),
|
||||
old_variable_names(false),
|
||||
member_func_flag(false),
|
||||
doxygen_javadoc_flag(true),
|
||||
comment_creation_chatter(false),
|
||||
imclass_name(NULL),
|
||||
module_class_name(NULL),
|
||||
|
|
@ -213,7 +214,6 @@ public:
|
|||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
|
||||
doxygen_javadoc_flag = true;
|
||||
SWIG_library_directory("java");
|
||||
|
||||
// Look for certain command line options
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue