PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/python/autodoc_runme.py

#
Python | 176 lines | 168 code | 8 blank | 0 comment | 1 complexity | f75ee435ddb3869e8421e5941dfaf73b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. from autodoc import *
  2. def check(got, expected):
  3. if expected != got:
  4. raise RuntimeError("\n" + "Expected: [" + expected + "]\n" + "Got : [" + got + "]")
  5. check(A.__doc__, "Proxy of C++ A class")
  6. check(A.funk.__doc__, "just a string")
  7. check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
  8. check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
  9. check(A.func2.__doc__, "\n"
  10. " func2(self, arg2, hello) -> int\n"
  11. "\n"
  12. " Parameters:\n"
  13. " arg2: short\n"
  14. " hello: int tuple[2]\n"
  15. "\n"
  16. " "
  17. )
  18. check(A.func3.__doc__, "\n"
  19. " func3(A self, short arg2, Tuple hello) -> int\n"
  20. "\n"
  21. " Parameters:\n"
  22. " arg2: short\n"
  23. " hello: int tuple[2]\n"
  24. "\n"
  25. " "
  26. )
  27. check(A.func0default.__doc__, "\n"
  28. " func0default(self, e, arg3, hello, f=2) -> int\n"
  29. " func0default(self, e, arg3, hello) -> int\n"
  30. " "
  31. )
  32. check(A.func1default.__doc__, "\n"
  33. " func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
  34. " func1default(A self, A e, short arg3, Tuple hello) -> int\n"
  35. " "
  36. )
  37. check(A.func2default.__doc__, "\n"
  38. " func2default(self, e, arg3, hello, f=2) -> int\n"
  39. "\n"
  40. " Parameters:\n"
  41. " e: A *\n"
  42. " arg3: short\n"
  43. " hello: int tuple[2]\n"
  44. " f: double\n"
  45. "\n"
  46. " func2default(self, e, arg3, hello) -> int\n"
  47. "\n"
  48. " Parameters:\n"
  49. " e: A *\n"
  50. " arg3: short\n"
  51. " hello: int tuple[2]\n"
  52. "\n"
  53. " "
  54. )
  55. check(A.func3default.__doc__, "\n"
  56. " func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
  57. "\n"
  58. " Parameters:\n"
  59. " e: A *\n"
  60. " arg3: short\n"
  61. " hello: int tuple[2]\n"
  62. " f: double\n"
  63. "\n"
  64. " func3default(A self, A e, short arg3, Tuple hello) -> int\n"
  65. "\n"
  66. " Parameters:\n"
  67. " e: A *\n"
  68. " arg3: short\n"
  69. " hello: int tuple[2]\n"
  70. "\n"
  71. " "
  72. )
  73. check(A.func0static.__doc__, "\n"
  74. " func0static(e, arg2, hello, f=2) -> int\n"
  75. " func0static(e, arg2, hello) -> int\n"
  76. " "
  77. )
  78. check(A.func1static.__doc__, "\n"
  79. " func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
  80. " func1static(A e, short arg2, Tuple hello) -> int\n"
  81. " "
  82. )
  83. check(A.func2static.__doc__, "\n"
  84. " func2static(e, arg2, hello, f=2) -> int\n"
  85. "\n"
  86. " Parameters:\n"
  87. " e: A *\n"
  88. " arg2: short\n"
  89. " hello: int tuple[2]\n"
  90. " f: double\n"
  91. "\n"
  92. " func2static(e, arg2, hello) -> int\n"
  93. "\n"
  94. " Parameters:\n"
  95. " e: A *\n"
  96. " arg2: short\n"
  97. " hello: int tuple[2]\n"
  98. "\n"
  99. " "
  100. )
  101. check(A.func3static.__doc__, "\n"
  102. " func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
  103. "\n"
  104. " Parameters:\n"
  105. " e: A *\n"
  106. " arg2: short\n"
  107. " hello: int tuple[2]\n"
  108. " f: double\n"
  109. "\n"
  110. " func3static(A e, short arg2, Tuple hello) -> int\n"
  111. "\n"
  112. " Parameters:\n"
  113. " e: A *\n"
  114. " arg2: short\n"
  115. " hello: int tuple[2]\n"
  116. "\n"
  117. " "
  118. )
  119. check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
  120. check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
  121. check(A.variable_c.__doc__, "\n"
  122. "A_variable_c_get(self) -> int\n"
  123. "\n"
  124. "Parameters:\n"
  125. " self: A *\n"
  126. "\n"
  127. )
  128. check(A.variable_d.__doc__, "\n"
  129. "A_variable_d_get(A self) -> int\n"
  130. "\n"
  131. "Parameters:\n"
  132. " self: A *\n"
  133. "\n"
  134. )
  135. check(B.__doc__, "Proxy of C++ B class")
  136. check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
  137. check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
  138. check(E.__init__.__doc__, "\n"
  139. " __init__(self, a, b, h) -> E\n"
  140. "\n"
  141. " Parameters:\n"
  142. " a: special comment for parameter a\n"
  143. " b: another special comment for parameter b\n"
  144. " h: enum Hola\n"
  145. "\n"
  146. " "
  147. )
  148. check(F.__init__.__doc__, "\n"
  149. " __init__(F self, int a, int b, Hola h) -> F\n"
  150. "\n"
  151. " Parameters:\n"
  152. " a: special comment for parameter a\n"
  153. " b: another special comment for parameter b\n"
  154. " h: enum Hola\n"
  155. "\n"
  156. " "
  157. )
  158. check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
  159. check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
  160. check(funkdefaults.__doc__, "\n"
  161. " funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
  162. " funkdefaults(A e, short arg2, int c, int d) -> int\n"
  163. " "
  164. )
  165. check(func_input.__doc__, "func_input(int * INPUT) -> int")
  166. check(func_output.__doc__, "func_output() -> int")
  167. check(func_inout.__doc__, "func_inout(int * INOUT) -> int")
  168. check(banana.__doc__, "banana(S a, S b, int c, Integer d)")