diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index 0e9356901..9f4365ee1 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -76,6 +76,10 @@ %feature("autodoc","1") D::D(int a, int b, Hola h); // names + types %feature("autodoc","2") E::E(int a, int b, Hola h); // extended %feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types +%feature("autodoc","0") C::~C(); // names +%feature("autodoc","1") D::~D(); // names + types +%feature("autodoc","2") E::~E(); // extended +%feature("autodoc","3") F::~F(); // extended + types %inline { diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 011323c10..6002d49fe 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -205,7 +205,9 @@ if not is_python_builtin(): ) check(inspect.getdoc(_autodoc.A_variable_d_get), "A_variable_d_get(A self) -> int") check(inspect.getdoc(_autodoc.new_C), "new_C(a, b, h) -> C") + check(inspect.getdoc(_autodoc.delete_C), "delete_C(self)") check(inspect.getdoc(_autodoc.new_D), "new_D(int a, int b, Hola h) -> D") + check(inspect.getdoc(_autodoc.delete_D), "delete_D(D self)") check(inspect.getdoc(_autodoc.new_E), "new_E(a, b, h) -> E\n" "\n" @@ -215,6 +217,7 @@ if not is_python_builtin(): "b: another special comment for parameter b\n" "h: enum Hola" ) + check(inspect.getdoc(_autodoc.delete_E), "delete_E(self)") check(inspect.getdoc(_autodoc.new_F), "new_F(int a, int b, Hola h) -> F\n" "\n" @@ -224,6 +227,7 @@ if not is_python_builtin(): "b: another special comment for parameter b\n" "h: enum Hola" ) + check(inspect.getdoc(_autodoc.delete_F), "delete_F(F self)") check(inspect.getdoc(_autodoc.B_funk), "B_funk(B self, int c, int d) -> int") check(inspect.getdoc(_autodoc.TInteger_inout), "TInteger_inout(TInteger self, TInteger t) -> TInteger") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index b6a8e5d79..7610fca7e 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1810,6 +1810,7 @@ public: String *make_autodoc(Node *n, autodoc_t ad_type, bool low_level = false) { int extended = 0; + bool first_func = true; // If the function is overloaded then this function is called // for the last one. Rewind to the first so the docstrings are // in order. @@ -1861,6 +1862,9 @@ public: continue; } + if (! first_func) + Append(doc, "\n"); + if (type) { if (Strcmp(type, "void") == 0) { type_str = NULL; @@ -1877,6 +1881,13 @@ public: ad_type = AUTODOC_METHOD; } } + /* Treat destructors as methods for documentation purposes */ + String *nodeType = Getattr(n, "nodeType"); + if (nodeType && Strcmp(nodeType, "destructor") == 0) { + if (ad_type == AUTODOC_FUNC) { + ad_type = AUTODOC_METHOD; + } + } switch (ad_type) { case AUTODOC_CLASS: @@ -1980,7 +1991,7 @@ public: // if it's overloaded then get the next decl and loop around again n = Getattr(n, "sym:nextSibling"); if (n) - Append(doc, "\n"); + first_func = false; } return doc;