Merge branch 'm7thon-issue-445-python-class-docstrings'
* m7thon-issue-445-python-class-docstrings: Add changes note for Python tp_doc slot and docstring Set class docstring in tp_doc slot for python -builtin Conflicts: CHANGES.current
This commit is contained in:
commit
a00ab42f80
2 changed files with 24 additions and 6 deletions
|
|
@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.7 (in progress)
|
Version 3.0.7 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2015-07-18: m7thon
|
||||||
|
[Python] Docstrings provided via %feature("docstring") are now quoted and added to
|
||||||
|
the tp_doc slot when using python builtin classes (-builtin). When no docstring is
|
||||||
|
provided, the tp_doc slot is set to the fully qualified C/C++ class name.
|
||||||
|
Github issues #445 and #461.
|
||||||
|
|
||||||
2015-07-17: kwwette
|
2015-07-17: kwwette
|
||||||
[octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski).
|
[octave] Support Octave version 4.0.0 (thanks to patches from Orion Poplawski).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1808,6 +1808,12 @@ public:
|
||||||
// Only do the autodoc if there isn't a docstring for the class
|
// Only do the autodoc if there isn't a docstring for the class
|
||||||
String *str = Getattr(n, "feature:docstring");
|
String *str = Getattr(n, "feature:docstring");
|
||||||
if (!str || Len(str) == 0) {
|
if (!str || Len(str) == 0) {
|
||||||
|
if (builtin) {
|
||||||
|
String *name = Getattr(n, "name");
|
||||||
|
String *rname = add_explicit_scope(SwigType_namestr(name));
|
||||||
|
Printf(doc, "%s", rname);
|
||||||
|
Delete(rname);
|
||||||
|
} else {
|
||||||
if (CPlusPlus) {
|
if (CPlusPlus) {
|
||||||
Printf(doc, "Proxy of C++ %s class", real_classname);
|
Printf(doc, "Proxy of C++ %s class", real_classname);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1815,6 +1821,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case AUTODOC_CTOR:
|
case AUTODOC_CTOR:
|
||||||
if (Strcmp(class_name, symname) == 0) {
|
if (Strcmp(class_name, symname) == 0) {
|
||||||
|
|
@ -3882,7 +3889,7 @@ public:
|
||||||
else
|
else
|
||||||
quoted_symname = NewStringf("\"%s\"", symname);
|
quoted_symname = NewStringf("\"%s\"", symname);
|
||||||
}
|
}
|
||||||
String *quoted_rname = NewStringf("\"%s\"", rname);
|
String *quoted_tp_doc_str = NewStringf("\"%s\"", getSlot(n, "feature:python:tp_doc"));
|
||||||
char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit";
|
char const *tp_init = builtin_tp_init ? Char(builtin_tp_init) : Swig_directorclass(n) ? "0" : "SwigPyBuiltin_BadInit";
|
||||||
String *tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES");
|
String *tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES");
|
||||||
String *py3_tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE");
|
String *py3_tp_flags = NewString("Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE");
|
||||||
|
|
@ -3925,7 +3932,7 @@ public:
|
||||||
Printv(f, "#else\n", NIL);
|
Printv(f, "#else\n", NIL);
|
||||||
printSlot(f, tp_flags, "tp_flags");
|
printSlot(f, tp_flags, "tp_flags");
|
||||||
Printv(f, "#endif\n", NIL);
|
Printv(f, "#endif\n", NIL);
|
||||||
printSlot(f, quoted_rname, "tp_doc");
|
printSlot(f, quoted_tp_doc_str, "tp_doc");
|
||||||
printSlot(f, getSlot(n, "feature:python:tp_traverse"), "tp_traverse", "traverseproc");
|
printSlot(f, getSlot(n, "feature:python:tp_traverse"), "tp_traverse", "traverseproc");
|
||||||
printSlot(f, getSlot(n, "feature:python:tp_clear"), "tp_clear", "inquiry");
|
printSlot(f, getSlot(n, "feature:python:tp_clear"), "tp_clear", "inquiry");
|
||||||
printSlot(f, richcompare_func, "feature:python:tp_richcompare", "richcmpfunc");
|
printSlot(f, richcompare_func, "feature:python:tp_richcompare", "richcmpfunc");
|
||||||
|
|
@ -4108,7 +4115,7 @@ public:
|
||||||
Delete(tp_flags);
|
Delete(tp_flags);
|
||||||
Delete(py3_tp_flags);
|
Delete(py3_tp_flags);
|
||||||
Delete(quoted_symname);
|
Delete(quoted_symname);
|
||||||
Delete(quoted_rname);
|
Delete(quoted_tp_doc_str);
|
||||||
Delete(clientdata_klass);
|
Delete(clientdata_klass);
|
||||||
Delete(richcompare_func);
|
Delete(richcompare_func);
|
||||||
Delete(getset_name);
|
Delete(getset_name);
|
||||||
|
|
@ -4208,6 +4215,11 @@ public:
|
||||||
String *str = cdocstring(n, AUTODOC_CLASS);
|
String *str = cdocstring(n, AUTODOC_CLASS);
|
||||||
Setattr(n, "feature:python:tp_doc", str);
|
Setattr(n, "feature:python:tp_doc", str);
|
||||||
Delete(str);
|
Delete(str);
|
||||||
|
} else {
|
||||||
|
String *name = Getattr(n, "name");
|
||||||
|
String *rname = add_explicit_scope(SwigType_namestr(name));
|
||||||
|
Setattr(n, "feature:python:tp_doc", rname);
|
||||||
|
Delete(rname);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Printv(f_shadow, "class ", class_name, NIL);
|
Printv(f_shadow, "class ", class_name, NIL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue