Major refactoring: translation now takes a node and returns a translated comment if there is one.
This is to allow for situations where you need to use several nodes to create a comment, for example where there are multiple overloads for the same function but the target language doesnt support overloading: in this case we want to combine comments to explain the possible overloads. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10843 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0f41d25c09
commit
01695a3128
10 changed files with 324 additions and 201 deletions
|
|
@ -91,10 +91,6 @@ class JAVA:public Language {
|
|||
Setline(p, Getline(n));
|
||||
return p;
|
||||
}
|
||||
/* DOXYGEN TO JAVADOC globals */
|
||||
//TODO make this bool a command line option
|
||||
DoxygenTranslator doxyTranslator;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -124,7 +120,7 @@ public:
|
|||
global_variable_flag(false),
|
||||
old_variable_names(false),
|
||||
member_func_flag(false),
|
||||
doxygen_javadoc_flag(true),
|
||||
doxygen_javadoc_flag(true),
|
||||
comment_creation_chatter(false),
|
||||
imclass_name(NULL),
|
||||
module_class_name(NULL),
|
||||
|
|
@ -160,7 +156,6 @@ public:
|
|||
should be easy to implement though */
|
||||
director_multiple_inheritance = 0;
|
||||
director_language = 1;
|
||||
doxyTranslator = DoxygenTranslator();
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -508,12 +503,13 @@ public:
|
|||
Printf(f_module, "%s\n", module_imports);
|
||||
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(f_module, "/* This was generated from top() */");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(f_module, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(f_module, "/* This was generated from top() */");
|
||||
Printf(f_module, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
if (Len(module_class_modifiers) > 0)
|
||||
Printf(f_module, "%s ", module_class_modifiers);
|
||||
|
|
@ -1234,15 +1230,17 @@ public:
|
|||
// Add extra indentation
|
||||
Replaceall(enum_code, "\n", "\n ");
|
||||
Replaceall(enum_code, " \n", "\n");
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printv(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration */", NIL );
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printv(proxy_class_constants_code, convertedString, NIL);
|
||||
free(convertedString);
|
||||
}
|
||||
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration() */");
|
||||
Printf(proxy_class_constants_code, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
|
||||
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
|
||||
} else {
|
||||
|
|
@ -1308,12 +1306,13 @@ public:
|
|||
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" );
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(enum_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(enum_code, "/* This was generated from enumvalueDeclaration() */");
|
||||
Printf(enum_code, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
{
|
||||
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
|
||||
|
|
@ -1379,15 +1378,16 @@ public:
|
|||
* file
|
||||
* ------------------------------------------------------------------------ */
|
||||
virtual int doxygenComment(Node *n){
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printv(structuralComments, "/* This was generated from doxygenComment() */\n", NIL);
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printv(structuralComments, convertedString, NIL);
|
||||
free(convertedString);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
if (doxygen_javadoc_flag){
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(structuralComments, "/* This was generated from doxygenComment() */");
|
||||
Printf(structuralComments, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------
|
||||
|
|
@ -1408,14 +1408,16 @@ public:
|
|||
String *tm;
|
||||
String *return_type = NewString("");
|
||||
String *constants_code = NewString("");
|
||||
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(constants_code, "/* This was generated from enumvalueDeclaration */\n");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(constants_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(constants_code, "/* This was generated from constantWrapper() */");
|
||||
Printf(constants_code, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
|
||||
if (!addSymbol(symname, n))
|
||||
|
|
@ -1681,12 +1683,13 @@ public:
|
|||
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printv(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n", NIL );
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printv(proxy_class_def, convertedString, NIL);
|
||||
free(convertedString);
|
||||
}
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */");
|
||||
Printf(proxy_class_def, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
|
||||
// Start writing the proxy class
|
||||
|
|
@ -2021,15 +2024,15 @@ public:
|
|||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0);
|
||||
}
|
||||
|
||||
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(function_code, "/* This was generated from proxyclassfunctionhandler */");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(function_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */");
|
||||
Printf(function_code, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
|
||||
/* Start generating the proxy function */
|
||||
|
|
@ -2254,15 +2257,16 @@ public:
|
|||
tm = Getattr(n, "tmap:jtype"); // typemaps were attached earlier to the node
|
||||
Printf(im_return_type, "%s", tm);
|
||||
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(function_code, "/* This was generated from constructionhandler */\n" );
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(function_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
}
|
||||
//translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(function_code, "/* This was generated from constructionhandler() */");
|
||||
Printf(function_code, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
|
||||
Printf(function_code, " %s %s(", methodmods, proxy_class_name);
|
||||
Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name);
|
||||
|
|
@ -2525,14 +2529,15 @@ public:
|
|||
String *pre_code = NewString("");
|
||||
String *post_code = NewString("");
|
||||
|
||||
//translate and write javadoc comment if flagged
|
||||
// translate and write javadoc comment if flagged
|
||||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n" );
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(function_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){
|
||||
if(comment_creation_chatter)
|
||||
Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */");
|
||||
Printf(function_code, Char(doxygen_comments));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
|
||||
if (l) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ char cvsroot_python_cxx[] = "$Id: python.cxx 10453 2008-05-15 21:18:44Z wsfulton
|
|||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
||||
#include <ctype.h>
|
||||
#include <sstream>
|
||||
#include "../DoxygenTranslator/src/DoxygenTranslator.h"
|
||||
|
||||
#define PYSHADOW_MEMBER 0x2
|
||||
|
|
@ -85,8 +86,6 @@ static int extranative = 0;
|
|||
static int outputtuple = 0;
|
||||
static int nortti = 0;
|
||||
|
||||
static DoxygenTranslator doxyTranslator;
|
||||
|
||||
/* flags for the make_autodoc function */
|
||||
enum autodoc_t {
|
||||
AUTODOC_CLASS,
|
||||
|
|
@ -2906,19 +2905,18 @@ public:
|
|||
}
|
||||
}
|
||||
Printf(f_shadow, ":\n");
|
||||
|
||||
//translate and write pydoc comment if flagged
|
||||
if (doxygen){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
//if(comment_creation_chatter) Printf(function_code, "/* This was generated from classHandler */");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")), "PYDOC");
|
||||
Printf(f_shadow, Char(pythoncode(convertedString, shadow_indent)));
|
||||
free(convertedString);
|
||||
}
|
||||
|
||||
// translate and write pydoc comment if flagged
|
||||
if (doxygen){
|
||||
String *doxygen_comments;
|
||||
if(DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)){
|
||||
Printf(f_shadow, Char(pythoncode(doxygen_comments, shadow_indent)));
|
||||
Delete(doxygen_comments);
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise use default docstrings if requested
|
||||
else if (have_docstring(n)) {
|
||||
// otherwise use default docstrings if requested
|
||||
else if (have_docstring(n)) {
|
||||
String *str = docstring(n, AUTODOC_CLASS, tab4);
|
||||
if (str != NULL && Len(str))
|
||||
Printv(f_shadow, tab4, str, "\n", NIL);
|
||||
|
|
@ -3130,15 +3128,33 @@ public:
|
|||
} else {
|
||||
Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL);
|
||||
Printv(f_shadow, "\n", NIL);
|
||||
if (doxygen) {
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
//if(comment_creation_chatter) Printf(function_code, "/* This was generated from classHandler */");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")), "PYDOC");
|
||||
Printf(f_shadow, Char(pythoncode(convertedString, tab8)));
|
||||
free(convertedString);
|
||||
}
|
||||
if (doxygen) {
|
||||
/*Node *documented_node = n;
|
||||
if(Getattr(n, "sym:overloaded")){
|
||||
// If the function is overloaded then this funciton is called
|
||||
// for the last one. Rewind to the first so the docstrings are
|
||||
// in order.
|
||||
while (Getattr(documented_node, "sym:previousSibling"))
|
||||
documented_node = Getattr(documented_node, "sym:previousSibling");
|
||||
|
||||
int real_overload_count = 0;
|
||||
std::ostringstream all_documentation;
|
||||
|
||||
// for each real method (not a generated overload) append the documentation
|
||||
while(documented_node){
|
||||
if(!is_generated_overload(documented_node) && Getattr(documented_node,"DoxygenComment")){
|
||||
all_documentation << "Overload " << ++real_overload_count << ":" << std::endl;
|
||||
all_documentation << Char(Getattr(documented_node,"DoxygenComment")) << std::endl;
|
||||
}
|
||||
documented_node = Getattr(documented_node, "sym:nextSibling");
|
||||
}
|
||||
if (have_docstring(n))
|
||||
|
||||
char *convertedString = doxyTranslator.convert(n,const_cast< char *>(all_documentation.str().c_str()), "PYDOC");
|
||||
Printf(f_shadow, Char(pythoncode(convertedString, tab8)));
|
||||
free(convertedString);
|
||||
}*/
|
||||
}
|
||||
else if (have_docstring(n))
|
||||
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
|
||||
if (have_pythonprepend(n)) {
|
||||
fproxy = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue