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
|
|
@ -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