Also check documentation on the low-level API

This commit is contained in:
Alec Woods 2019-01-19 08:54:50 -05:00
commit fb58727135

View file

@ -1,10 +1,14 @@
from autodoc import *
import _autodoc
import comment_verifier
import inspect
import sys
def check(got, expected, expected_builtin=None, skip=False):
if not skip:
if is_python_builtin() and skip:
# Only skip for builtins
pass
else:
expect = expected
if is_python_builtin() and expected_builtin != None:
expect = expected_builtin
@ -15,10 +19,15 @@ 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"
@ -26,6 +35,13 @@ 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"
@ -33,11 +49,22 @@ 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"
@ -47,6 +74,15 @@ 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"
@ -56,11 +92,28 @@ 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")
check(inspect.getdoc(_autodoc.A_func0static),
"A_func0static(e, arg2, hello, f=2) -> int")
check(inspect.getdoc(A_func0static),
"A_func0static(e, arg2, hello, f=2) -> int")
check(inspect.getdoc(A.func1static),
"func1static(A e, short arg2, Tuple hello, double f=2) -> int")
check(inspect.getdoc(_autodoc.A_func1static),
"A_func1static(A e, short arg2, Tuple hello, double f=2) -> int")
check(inspect.getdoc(A_func1static),
"A_func1static(A e, short arg2, Tuple hello, double f=2) -> int")
check(inspect.getdoc(A.func2static),
"func2static(e, arg2, hello, f=2) -> int\n"
"\n"
@ -70,6 +123,24 @@ check(inspect.getdoc(A.func2static),
"arg2: short\n"
"hello: int tuple[2]\n"
"f: double")
check(inspect.getdoc(_autodoc.A_func2static),
"A_func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"f: double")
check(inspect.getdoc(A_func2static),
"A_func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"f: double")
check(inspect.getdoc(A.func3static),
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
@ -79,30 +150,91 @@ check(inspect.getdoc(A.func3static),
"arg2: short\n"
"hello: int tuple[2]\n"
"f: double")
check(inspect.getdoc(_autodoc.A_func3static),
"A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"f: double")
check(inspect.getdoc(A_func3static),
"A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"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"
)
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"
)
check(inspect.getdoc(A.variable_c),
"A.variable_c"
)
)
check(inspect.getdoc(_autodoc.A_variable_c_set),
"A_variable_c_set(self, variable_c) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"self: A *\n"
"variable_c: int"
)
check(inspect.getdoc(_autodoc.A_variable_c_get),
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"self: A *"
)
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) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"self: A *\n"
"variable_d: int"
)
check(inspect.getdoc(_autodoc.A_variable_d_get),
"A_variable_d_get(self) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"self: A *"
)
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"
"__init__(self, a, b, h) -> E\n"
"\n"
"Parameters\n"
@ -111,9 +243,16 @@ 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"
"__init__(F self, int a, int b, Hola h) -> F\n"
"\n"
"Parameters\n"
@ -122,9 +261,20 @@ 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")
@ -138,6 +288,7 @@ 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")