Fix display of documented template types when using the autodoc feature for Python.
This commit is contained in:
parent
251d25346d
commit
7be6c10d4a
4 changed files with 35 additions and 5 deletions
|
|
@ -7,6 +7,23 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.0.0 (in progress)
|
Version 4.0.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2017-07-07: wsfulton
|
||||||
|
[Python] Fix display of documented template types when using the autodoc
|
||||||
|
feature. For example when wrapping:
|
||||||
|
|
||||||
|
%feature("autodoc");
|
||||||
|
template<typename X> struct T {};
|
||||||
|
%template(TInteger) T<int>;
|
||||||
|
|
||||||
|
the generated documentation contains:
|
||||||
|
"""Proxy of C++ T< int > class."""
|
||||||
|
instead of:
|
||||||
|
"""Proxy of C++ T<(int)> class."""
|
||||||
|
and
|
||||||
|
"""__init__(TInteger self) -> TInteger"""
|
||||||
|
instead of
|
||||||
|
"""__init__(T<(int)> self) -> TInteger"""
|
||||||
|
|
||||||
2017-06-27: nihaln
|
2017-06-27: nihaln
|
||||||
[PHP] Update the OUTPUT Typemap to add return statement to the
|
[PHP] Update the OUTPUT Typemap to add return statement to the
|
||||||
PHP Wrapper.
|
PHP Wrapper.
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,14 @@ typedef int Integer;
|
||||||
void banana(S *a, const struct tagS *b, int c, Integer d) {}
|
void banana(S *a, const struct tagS *b, int c, Integer d) {}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
// Check docs for a template type
|
||||||
|
%inline %{
|
||||||
|
template<typename X> struct T {
|
||||||
|
T inout(T t) { return t; }
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
%template(TInteger) T<int>;
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
#ifdef SWIGPYTHON_BUILTIN
|
#ifdef SWIGPYTHON_BUILTIN
|
||||||
bool is_python_builtin() { return true; }
|
bool is_python_builtin() { return true; }
|
||||||
|
|
@ -140,4 +148,3 @@ bool is_python_builtin() { return true; }
|
||||||
bool is_python_builtin() { return false; }
|
bool is_python_builtin() { return false; }
|
||||||
#endif
|
#endif
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -365,3 +365,9 @@ check(func_output.__doc__, "func_output() -> int")
|
||||||
check(func_inout.__doc__, "func_inout(int * INOUT) -> int")
|
check(func_inout.__doc__, "func_inout(int * INOUT) -> int")
|
||||||
check(func_cb.__doc__, "func_cb(int c, int d) -> int")
|
check(func_cb.__doc__, "func_cb(int c, int d) -> int")
|
||||||
check(banana.__doc__, "banana(S a, S b, int c, Integer d)")
|
check(banana.__doc__, "banana(S a, S b, int c, Integer d)")
|
||||||
|
|
||||||
|
check(TInteger.__doc__, "Proxy of C++ T< int > class.", "::T< int >")
|
||||||
|
check(TInteger.__init__.__doc__, "__init__(TInteger self) -> TInteger", None, skip)
|
||||||
|
check(TInteger.inout.__doc__,
|
||||||
|
"inout(TInteger self, TInteger t) -> TInteger",
|
||||||
|
"inout(TInteger t) -> TInteger")
|
||||||
|
|
|
||||||
|
|
@ -1960,9 +1960,9 @@ public:
|
||||||
Delete(rname);
|
Delete(rname);
|
||||||
} else {
|
} else {
|
||||||
if (CPlusPlus) {
|
if (CPlusPlus) {
|
||||||
Printf(doc, "Proxy of C++ %s class.", real_classname);
|
Printf(doc, "Proxy of C++ %s class.", SwigType_namestr(real_classname));
|
||||||
} else {
|
} else {
|
||||||
Printf(doc, "Proxy of C %s struct.", real_classname);
|
Printf(doc, "Proxy of C %s struct.", SwigType_namestr(real_classname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1973,7 +1973,7 @@ public:
|
||||||
String *paramList = make_autodocParmList(n, showTypes);
|
String *paramList = make_autodocParmList(n, showTypes);
|
||||||
Printf(doc, "__init__(");
|
Printf(doc, "__init__(");
|
||||||
if (showTypes)
|
if (showTypes)
|
||||||
Printf(doc, "%s ", getClassName());
|
Printf(doc, "%s ", class_name);
|
||||||
if (Len(paramList))
|
if (Len(paramList))
|
||||||
Printf(doc, "self, %s) -> %s", paramList, class_name);
|
Printf(doc, "self, %s) -> %s", paramList, class_name);
|
||||||
else
|
else
|
||||||
|
|
@ -1984,7 +1984,7 @@ public:
|
||||||
|
|
||||||
case AUTODOC_DTOR:
|
case AUTODOC_DTOR:
|
||||||
if (showTypes)
|
if (showTypes)
|
||||||
Printf(doc, "__del__(%s self)", getClassName());
|
Printf(doc, "__del__(%s self)", class_name);
|
||||||
else
|
else
|
||||||
Printf(doc, "__del__(self)");
|
Printf(doc, "__del__(self)");
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue