Fixing docstrings for variables and static functions for consistency
This commit is contained in:
parent
86e08c8e34
commit
5106573b29
2 changed files with 104 additions and 114 deletions
|
|
@ -19,15 +19,10 @@ skip = True
|
|||
|
||||
check(inspect.getdoc(A), "Proxy of C++ A class.", "::A")
|
||||
check(inspect.getdoc(A.funk), "just a string.")
|
||||
check(inspect.getdoc(_autodoc.A_funk), "just a string.")
|
||||
check(inspect.getdoc(A.func0),
|
||||
"func0(self, arg2, hello) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func0),
|
||||
"A_func0(self, arg2, hello) -> int")
|
||||
check(inspect.getdoc(A.func1),
|
||||
"func1(A self, short arg2, Tuple hello) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func1),
|
||||
"A_func1(A self, short arg2, Tuple hello) -> int")
|
||||
check(inspect.getdoc(A.func2),
|
||||
"func2(self, arg2, hello) -> int\n"
|
||||
"\n"
|
||||
|
|
@ -35,13 +30,6 @@ check(inspect.getdoc(A.func2),
|
|||
"----------\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]")
|
||||
check(inspect.getdoc(_autodoc.A_func2),
|
||||
"A_func2(self, arg2, hello) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]")
|
||||
check(inspect.getdoc(A.func3),
|
||||
"func3(A self, short arg2, Tuple hello) -> int\n"
|
||||
"\n"
|
||||
|
|
@ -49,22 +37,11 @@ check(inspect.getdoc(A.func3),
|
|||
"----------\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]")
|
||||
check(inspect.getdoc(_autodoc.A_func3),
|
||||
"A_func3(A self, short arg2, Tuple hello) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]")
|
||||
|
||||
check(inspect.getdoc(A.func0default),
|
||||
"func0default(self, e, arg3, hello, f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func0default),
|
||||
"A_func0default(self, e, arg3, hello, f=2) -> int")
|
||||
check(inspect.getdoc(A.func1default),
|
||||
"func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func1default),
|
||||
"A_func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int")
|
||||
check(inspect.getdoc(A.func2default),
|
||||
"func2default(self, e, arg3, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
|
|
@ -74,15 +51,6 @@ check(inspect.getdoc(A.func2default),
|
|||
"arg3: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_func2default),
|
||||
"A_func2default(self, e, arg3, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg3: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(A.func3default),
|
||||
"func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
|
|
@ -92,15 +60,6 @@ check(inspect.getdoc(A.func3default),
|
|||
"arg3: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_func3default),
|
||||
"A_func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg3: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
|
||||
check(inspect.getdoc(A.func0static),
|
||||
"func0static(e, arg2, hello, f=2) -> int")
|
||||
|
|
@ -170,60 +129,111 @@ check(inspect.getdoc(A_func3static),
|
|||
"f: double")
|
||||
|
||||
check(inspect.getdoc(A.variable_a),
|
||||
"A.variable_a"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_a_set),
|
||||
"A_variable_a_set(self, variable_a)"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_a_get),
|
||||
"A_variable_a_get(self) -> int"
|
||||
"variable_a"
|
||||
)
|
||||
check(inspect.getdoc(A.variable_b),
|
||||
"A.variable_b : int"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_b_set),
|
||||
"A_variable_b_set(A self, int variable_b)"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_b_get),
|
||||
"A_variable_b_get(A self) -> int"
|
||||
"variable_b : int"
|
||||
)
|
||||
check(inspect.getdoc(A.variable_c),
|
||||
"A.variable_c"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_c_set),
|
||||
"A_variable_c_set(self, variable_c)\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"variable_c: int"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_c_get),
|
||||
"A_variable_c_get(self) -> int"
|
||||
"variable_c"
|
||||
)
|
||||
check(inspect.getdoc(A.variable_d),
|
||||
"A.variable_d : int"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_d_set),
|
||||
"A_variable_d_set(A self, int variable_d)\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"variable_d: int"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_d_get),
|
||||
"A_variable_d_get(A self) -> int"
|
||||
"variable_d : int"
|
||||
)
|
||||
|
||||
# Check the low-level functions (not present when using -builtin except for the static ones)
|
||||
if not is_python_builtin():
|
||||
check(inspect.getdoc(_autodoc.A_funk), "just a string.")
|
||||
check(inspect.getdoc(_autodoc.A_func0),
|
||||
"A_func0(self, arg2, hello) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func1),
|
||||
"A_func1(A self, short arg2, Tuple hello) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func2),
|
||||
"A_func2(self, arg2, hello) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]")
|
||||
check(inspect.getdoc(_autodoc.A_func3),
|
||||
"A_func3(A self, short arg2, Tuple hello) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]")
|
||||
check(inspect.getdoc(_autodoc.A_func0default),
|
||||
"A_func0default(self, e, arg3, hello, f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func1default),
|
||||
"A_func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func2default),
|
||||
"A_func2default(self, e, arg3, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg3: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_func3default),
|
||||
"A_func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg3: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_variable_a_set), "A_variable_a_set(self, variable_a)")
|
||||
check(inspect.getdoc(_autodoc.A_variable_a_get), "A_variable_a_get(self) -> int" )
|
||||
check(inspect.getdoc(_autodoc.A_variable_b_set), "A_variable_b_set(A self, int variable_b)")
|
||||
check(inspect.getdoc(_autodoc.A_variable_b_get), "A_variable_b_get(A self) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_variable_c_set),
|
||||
"A_variable_c_set(self, variable_c)\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"variable_c: int"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.A_variable_c_get), "A_variable_c_get(self) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_variable_d_set),
|
||||
"A_variable_d_set(A self, int variable_d)\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"variable_d: int"
|
||||
)
|
||||
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.new_D), "new_D(int a, int b, Hola h) -> D")
|
||||
check(inspect.getdoc(_autodoc.new_E),
|
||||
"new_E(a, b, h) -> E\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"a: special comment for parameter a\n"
|
||||
"b: another special comment for parameter b\n"
|
||||
"h: enum Hola"
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.new_F),
|
||||
"new_F(int a, int b, Hola h) -> F\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"a: special comment for parameter a\n"
|
||||
"b: another special comment for parameter b\n"
|
||||
"h: enum Hola"
|
||||
)
|
||||
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")
|
||||
|
||||
check(inspect.getdoc(B),
|
||||
"Proxy of C++ B class.",
|
||||
"::B"
|
||||
)
|
||||
check(inspect.getdoc(C.__init__), "__init__(self, a, b, h) -> C", None, skip)
|
||||
check(inspect.getdoc(_autodoc.new_C), "new_C(a, b, h) -> C")
|
||||
check(inspect.getdoc(D.__init__),
|
||||
"__init__(D self, int a, int b, Hola h) -> D", None, skip)
|
||||
check(inspect.getdoc(_autodoc.new_D),
|
||||
"new_D(int a, int b, Hola h) -> D")
|
||||
check(inspect.getdoc(E.__init__),
|
||||
"__init__(self, a, b, h) -> E\n"
|
||||
"\n"
|
||||
|
|
@ -233,15 +243,6 @@ check(inspect.getdoc(E.__init__),
|
|||
"b: another special comment for parameter b\n"
|
||||
"h: enum Hola", None, skip
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.new_E),
|
||||
"new_E(a, b, h) -> E\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"a: special comment for parameter a\n"
|
||||
"b: another special comment for parameter b\n"
|
||||
"h: enum Hola"
|
||||
)
|
||||
check(inspect.getdoc(F.__init__),
|
||||
"__init__(F self, int a, int b, Hola h) -> F\n"
|
||||
"\n"
|
||||
|
|
@ -251,20 +252,9 @@ check(inspect.getdoc(F.__init__),
|
|||
"b: another special comment for parameter b\n"
|
||||
"h: enum Hola", None, skip
|
||||
)
|
||||
check(inspect.getdoc(_autodoc.new_F),
|
||||
"new_F(int a, int b, Hola h) -> F\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"a: special comment for parameter a\n"
|
||||
"b: another special comment for parameter b\n"
|
||||
"h: enum Hola"
|
||||
)
|
||||
|
||||
check(inspect.getdoc(B.funk),
|
||||
"funk(B self, int c, int d) -> int")
|
||||
check(inspect.getdoc(_autodoc.B_funk),
|
||||
"B_funk(B self, int c, int d) -> int")
|
||||
check(inspect.getdoc(funk), "funk(A e, short arg2, int c, int d) -> int")
|
||||
check(inspect.getdoc(funkdefaults),
|
||||
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int")
|
||||
|
|
@ -278,7 +268,6 @@ check(inspect.getdoc(banana), "banana(S a, S b, int c, Integer d)")
|
|||
check(inspect.getdoc(TInteger), "Proxy of C++ T< int > class.", "::T< int >")
|
||||
check(inspect.getdoc(TInteger.__init__), "__init__(TInteger self) -> TInteger", None, skip)
|
||||
check(inspect.getdoc(TInteger.inout), "inout(TInteger self, TInteger t) -> TInteger")
|
||||
check(inspect.getdoc(_autodoc.TInteger_inout), "TInteger_inout(TInteger self, TInteger t) -> TInteger")
|
||||
|
||||
check(inspect.getdoc(process), "process(int _from, int _in, int var) -> int")
|
||||
check(inspect.getdoc(process2), "process2(int _from=0, int _in=1, int var=2) -> int")
|
||||
|
|
|
|||
|
|
@ -1606,8 +1606,8 @@ public:
|
|||
* set then it will build a combined docstring.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
String *docstring(Node *n, autodoc_t ad_type, const String *indent) {
|
||||
String *docstr = build_combined_docstring(n, ad_type, indent);
|
||||
String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool low_level = false) {
|
||||
String *docstr = build_combined_docstring(n, ad_type, indent, low_level);
|
||||
if (!Len(docstr))
|
||||
return docstr;
|
||||
|
||||
|
|
@ -1948,14 +1948,15 @@ public:
|
|||
return NULL;
|
||||
case AUTODOC_VAR:
|
||||
// Variables can also be documented (e.g. through the property() function in python)
|
||||
Printf(doc, "%s.%s", class_name, symname);
|
||||
String *type = Getattr(n, "tmap:doc:type");
|
||||
if (! type)
|
||||
type = Getattr(n, "membervariableHandler:type");
|
||||
if (! type)
|
||||
type = Getattr(n, "type");
|
||||
if (showTypes)
|
||||
Printf(doc, "%s", symname);
|
||||
if (showTypes) {
|
||||
String *type = Getattr(n, "tmap:doc:type");
|
||||
if (! type)
|
||||
type = Getattr(n, "membervariableHandler:type");
|
||||
if (! type)
|
||||
type = Getattr(n, "type");
|
||||
Printf(doc, " : %s", type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Delete(type_str);
|
||||
|
|
@ -2391,7 +2392,7 @@ public:
|
|||
/* Make a wrapper function to insert the code into */
|
||||
Printv(f_dest, "\n", "def ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
|
||||
if (have_docstring(n))
|
||||
Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
|
||||
Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4, true), "\n", NIL);
|
||||
if (have_pythonprepend(n))
|
||||
Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL);
|
||||
if (have_pythonappend(n)) {
|
||||
|
|
@ -3301,7 +3302,7 @@ public:
|
|||
}
|
||||
Setattr(h, "getter", "SwigPyObject_get___dict__");
|
||||
if (! Getattr(h, "doc")) {
|
||||
Setattr(n, "doc:name", Getattr(n, "name"));
|
||||
Setattr(n, "doc:high:name", Getattr(n, "name"));
|
||||
Setattr(h, "doc", cdocstring(n, AUTODOC_VAR));
|
||||
}
|
||||
}
|
||||
|
|
@ -3319,7 +3320,7 @@ public:
|
|||
Setattr(h, "getter", wrapper_name);
|
||||
Delattr(n, "memberget");
|
||||
if (! Getattr(h, "doc")) {
|
||||
Setattr(n, "doc:name", Getattr(n, "name"));
|
||||
Setattr(n, "doc:high:name", Getattr(n, "name"));
|
||||
Setattr(h, "doc", cdocstring(n, AUTODOC_VAR));
|
||||
}
|
||||
}
|
||||
|
|
@ -3336,7 +3337,7 @@ public:
|
|||
Setattr(h, "setter", wrapper_name);
|
||||
Delattr(n, "memberset");
|
||||
if (! Getattr(h, "doc")) {
|
||||
Setattr(n, "doc:name", Getattr(n, "name"));
|
||||
Setattr(n, "doc:high:name", Getattr(n, "name"));
|
||||
Setattr(h, "doc", cdocstring(n, AUTODOC_VAR));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue