Progress towards a working pydoc implementation.
- Nodes are now passed to the documentation translator so that type information can be looked up and used in parameter comments. - Class comments are now inserted as well as some method information, git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10838 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
825e67b2b0
commit
0db7edfa63
11 changed files with 314 additions and 23 deletions
|
|
@ -510,7 +510,7 @@ public:
|
|||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(f_module, "/* This was generated from top() */");
|
||||
char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(f_module, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -1238,7 +1238,7 @@ public:
|
|||
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(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printv(proxy_class_constants_code, convertedString, NIL);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -1310,7 +1310,7 @@ public:
|
|||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" );
|
||||
char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(enum_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -1382,7 +1382,7 @@ public:
|
|||
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(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printv(structuralComments, convertedString, NIL);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -1412,7 +1412,7 @@ public:
|
|||
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(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(constants_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -1683,7 +1683,7 @@ public:
|
|||
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(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printv(proxy_class_def, convertedString, NIL);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -2026,7 +2026,7 @@ public:
|
|||
if (doxygen_javadoc_flag){
|
||||
if (Getattr(n,"DoxygenComment")){
|
||||
if(comment_creation_chatter) Printf(function_code, "/* This was generated from proxyclassfunctionhandler */");
|
||||
char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(function_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -2258,7 +2258,7 @@ public:
|
|||
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(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(function_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
@ -2529,7 +2529,7 @@ public:
|
|||
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(Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC");
|
||||
Printf(function_code, convertedString);
|
||||
free(convertedString);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* Python language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_python_cxx[] = "$Id$";
|
||||
char cvsroot_python_cxx[] = "$Id: python.cxx 10453 2008-05-15 21:18:44Z wsfulton $";
|
||||
|
||||
#include "swigmod.h"
|
||||
#define ctab2 " "
|
||||
|
|
@ -18,6 +18,7 @@ char cvsroot_python_cxx[] = "$Id$";
|
|||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
||||
#include <ctype.h>
|
||||
#include "../DoxygenTranslator/src/DoxygenTranslator.h"
|
||||
|
||||
#define PYSHADOW_MEMBER 0x2
|
||||
|
||||
|
|
@ -70,6 +71,7 @@ static int buildnone = 0;
|
|||
static int nobuildnone = 0;
|
||||
static int safecstrings = 0;
|
||||
static int dirvtable = 0;
|
||||
static int doxygen = 1;
|
||||
static int proxydel = 1;
|
||||
static int fastunpack = 0;
|
||||
static int fastproxy = 0;
|
||||
|
|
@ -83,6 +85,8 @@ 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,
|
||||
|
|
@ -103,6 +107,7 @@ Python Options (available with -python)\n\
|
|||
-classptr - Generate shadow 'ClassPtr' as in older swig versions\n\
|
||||
-cppcast - Enable C++ casting operators (default) \n\
|
||||
-dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\
|
||||
-doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\
|
||||
-extranative - Return extra native C++ wraps for std containers when possible \n\
|
||||
-fastinit - Use fast init mechanism for classes (default)\n\
|
||||
-fastunpack - Use fast unpack mechanism to parse the argument functions \n\
|
||||
|
|
@ -324,6 +329,9 @@ public:
|
|||
} else if (strcmp(argv[i], "-dirvtable") == 0) {
|
||||
dirvtable = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-doxygen") == 0) {
|
||||
doxygen = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-nodirvtable") == 0) {
|
||||
dirvtable = 0;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -2898,11 +2906,24 @@ public:
|
|||
}
|
||||
}
|
||||
Printf(f_shadow, ":\n");
|
||||
if (have_docstring(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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (!modern) {
|
||||
Printv(f_shadow, tab4, "__swig_setmethods__ = {}\n", NIL);
|
||||
if (Len(base_class)) {
|
||||
|
|
@ -3109,6 +3130,14 @@ 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 (have_docstring(n))
|
||||
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
|
||||
if (have_pythonprepend(n)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue