@alloy-js/python 0.5.0-dev.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/dev/src/components/CallSignature.js +2 -2
  3. package/dist/dev/src/components/CallSignature.js.map +1 -1
  4. package/dist/dev/src/components/ConstructorDeclaration.js +1 -1
  5. package/dist/dev/src/components/ConstructorDeclaration.js.map +1 -1
  6. package/dist/dev/src/components/DataclassDeclaration.js +5 -5
  7. package/dist/dev/src/components/DataclassDeclaration.js.map +1 -1
  8. package/dist/dev/src/components/FunctionBase.js +9 -9
  9. package/dist/dev/src/components/FunctionBase.js.map +1 -1
  10. package/dist/dev/src/components/PropertyDeclaration.js +8 -8
  11. package/dist/dev/src/components/PropertyDeclaration.js.map +1 -1
  12. package/dist/dev/src/components/PyDoc.js +64 -64
  13. package/dist/dev/src/components/PyDoc.js.map +1 -1
  14. package/dist/dev/src/components/PydanticClassDeclaration.js +5 -5
  15. package/dist/dev/src/components/PydanticClassDeclaration.js.map +1 -1
  16. package/dist/dev/src/components/SourceFile.js +44 -32
  17. package/dist/dev/src/components/SourceFile.js.map +1 -1
  18. package/dist/dev/src/symbols/python-output-symbol.js.map +1 -1
  19. package/dist/dev/test/callsignatures.test.js +471 -297
  20. package/dist/dev/test/callsignatures.test.js.map +1 -1
  21. package/dist/dev/test/class-method-declaration.test.js +21 -10
  22. package/dist/dev/test/class-method-declaration.test.js.map +1 -1
  23. package/dist/dev/test/classdeclarations.test.js +459 -393
  24. package/dist/dev/test/classdeclarations.test.js.map +1 -1
  25. package/dist/dev/test/classinstantiations.test.js +201 -168
  26. package/dist/dev/test/classinstantiations.test.js.map +1 -1
  27. package/dist/dev/test/constructordeclaration.test.js +22 -11
  28. package/dist/dev/test/constructordeclaration.test.js.map +1 -1
  29. package/dist/dev/test/dataclassdeclarations.test.js +322 -368
  30. package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
  31. package/dist/dev/test/decoratorlist.test.js +96 -49
  32. package/dist/dev/test/decoratorlist.test.js.map +1 -1
  33. package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
  34. package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
  35. package/dist/dev/test/enums.test.js +218 -184
  36. package/dist/dev/test/enums.test.js.map +1 -1
  37. package/dist/dev/test/externals.test.js +57 -45
  38. package/dist/dev/test/externals.test.js.map +1 -1
  39. package/dist/dev/test/factories.test.js +124 -50
  40. package/dist/dev/test/factories.test.js.map +1 -1
  41. package/dist/dev/test/functioncallexpressions.test.js +199 -164
  42. package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
  43. package/dist/dev/test/functiondeclaration.test.js +439 -272
  44. package/dist/dev/test/functiondeclaration.test.js.map +1 -1
  45. package/dist/dev/test/imports.test.js +273 -221
  46. package/dist/dev/test/imports.test.js.map +1 -1
  47. package/dist/dev/test/memberexpressions.test.js +1237 -972
  48. package/dist/dev/test/memberexpressions.test.js.map +1 -1
  49. package/dist/dev/test/methoddeclaration.test.js +142 -78
  50. package/dist/dev/test/methoddeclaration.test.js.map +1 -1
  51. package/dist/dev/test/namepolicies.test.js +130 -94
  52. package/dist/dev/test/namepolicies.test.js.map +1 -1
  53. package/dist/dev/test/propertydeclaration.test.js +88 -59
  54. package/dist/dev/test/propertydeclaration.test.js.map +1 -1
  55. package/dist/dev/test/pydanticclassdeclarations.test.js +299 -347
  56. package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -1
  57. package/dist/dev/test/pydocs.test.js +888 -715
  58. package/dist/dev/test/pydocs.test.js.map +1 -1
  59. package/dist/dev/test/references.test.js +42 -35
  60. package/dist/dev/test/references.test.js.map +1 -1
  61. package/dist/dev/test/sourcefiles.test.js +1109 -841
  62. package/dist/dev/test/sourcefiles.test.js.map +1 -1
  63. package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
  64. package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
  65. package/dist/dev/test/type-checking-imports.test.js +408 -359
  66. package/dist/dev/test/type-checking-imports.test.js.map +1 -1
  67. package/dist/dev/test/typereference.test.js +55 -40
  68. package/dist/dev/test/typereference.test.js.map +1 -1
  69. package/dist/dev/test/uniontypeexpression.test.js +222 -146
  70. package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
  71. package/dist/dev/test/utils.js +39 -77
  72. package/dist/dev/test/utils.js.map +1 -1
  73. package/dist/dev/test/values.test.js +237 -101
  74. package/dist/dev/test/values.test.js.map +1 -1
  75. package/dist/dev/test/variables.test.js +321 -203
  76. package/dist/dev/test/variables.test.js.map +1 -1
  77. package/dist/dev/test/vitest.setup.js +2 -0
  78. package/dist/dev/test/vitest.setup.js.map +1 -0
  79. package/dist/src/components/CallSignature.d.ts.map +1 -1
  80. package/dist/src/components/CallSignature.js.map +1 -1
  81. package/dist/src/components/ConstructorDeclaration.d.ts.map +1 -1
  82. package/dist/src/components/ConstructorDeclaration.js.map +1 -1
  83. package/dist/src/components/DataclassDeclaration.d.ts.map +1 -1
  84. package/dist/src/components/DataclassDeclaration.js.map +1 -1
  85. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  86. package/dist/src/components/FunctionBase.js.map +1 -1
  87. package/dist/src/components/PropertyDeclaration.d.ts.map +1 -1
  88. package/dist/src/components/PropertyDeclaration.js.map +1 -1
  89. package/dist/src/components/PyDoc.d.ts.map +1 -1
  90. package/dist/src/components/PyDoc.js.map +1 -1
  91. package/dist/src/components/PydanticClassDeclaration.d.ts.map +1 -1
  92. package/dist/src/components/PydanticClassDeclaration.js.map +1 -1
  93. package/dist/src/components/SourceFile.d.ts +2 -2
  94. package/dist/src/components/SourceFile.d.ts.map +1 -1
  95. package/dist/src/components/SourceFile.js +12 -0
  96. package/dist/src/components/SourceFile.js.map +1 -1
  97. package/dist/src/symbols/python-output-symbol.d.ts.map +1 -1
  98. package/dist/src/symbols/python-output-symbol.js.map +1 -1
  99. package/dist/test/callsignatures.test.js +346 -272
  100. package/dist/test/callsignatures.test.js.map +1 -1
  101. package/dist/test/class-method-declaration.test.js +7 -4
  102. package/dist/test/class-method-declaration.test.js.map +1 -1
  103. package/dist/test/classdeclarations.test.js +302 -288
  104. package/dist/test/classdeclarations.test.js.map +1 -1
  105. package/dist/test/classinstantiations.test.js +112 -103
  106. package/dist/test/classinstantiations.test.js.map +1 -1
  107. package/dist/test/constructordeclaration.test.js +7 -4
  108. package/dist/test/constructordeclaration.test.js.map +1 -1
  109. package/dist/test/dataclassdeclarations.test.js +134 -184
  110. package/dist/test/dataclassdeclarations.test.js.map +1 -1
  111. package/dist/test/decoratorlist.test.js +59 -36
  112. package/dist/test/decoratorlist.test.js.map +1 -1
  113. package/dist/test/dundermethoddeclaration.test.js +7 -4
  114. package/dist/test/dundermethoddeclaration.test.js.map +1 -1
  115. package/dist/test/enums.test.js +161 -159
  116. package/dist/test/enums.test.js.map +1 -1
  117. package/dist/test/externals.test.js +24 -24
  118. package/dist/test/externals.test.js.map +1 -1
  119. package/dist/test/factories.test.js +75 -33
  120. package/dist/test/factories.test.js.map +1 -1
  121. package/dist/test/functioncallexpressions.test.js +117 -106
  122. package/dist/test/functioncallexpressions.test.js.map +1 -1
  123. package/dist/test/functiondeclaration.test.js +247 -180
  124. package/dist/test/functiondeclaration.test.js.map +1 -1
  125. package/dist/test/imports.test.js +171 -143
  126. package/dist/test/imports.test.js.map +1 -1
  127. package/dist/test/memberexpressions.test.js +582 -453
  128. package/dist/test/memberexpressions.test.js.map +1 -1
  129. package/dist/test/methoddeclaration.test.js +66 -46
  130. package/dist/test/methoddeclaration.test.js.map +1 -1
  131. package/dist/test/namepolicies.test.js +90 -78
  132. package/dist/test/namepolicies.test.js.map +1 -1
  133. package/dist/test/propertydeclaration.test.js +25 -20
  134. package/dist/test/propertydeclaration.test.js.map +1 -1
  135. package/dist/test/pydanticclassdeclarations.test.js +134 -190
  136. package/dist/test/pydanticclassdeclarations.test.js.map +1 -1
  137. package/dist/test/pydocs.test.js +573 -532
  138. package/dist/test/pydocs.test.js.map +1 -1
  139. package/dist/test/references.test.js +31 -28
  140. package/dist/test/references.test.js.map +1 -1
  141. package/dist/test/sourcefiles.test.js +700 -580
  142. package/dist/test/sourcefiles.test.js.map +1 -1
  143. package/dist/test/staticmethoddeclaration.test.js +7 -4
  144. package/dist/test/staticmethoddeclaration.test.js.map +1 -1
  145. package/dist/test/type-checking-imports.test.js +297 -284
  146. package/dist/test/type-checking-imports.test.js.map +1 -1
  147. package/dist/test/typereference.test.js +29 -22
  148. package/dist/test/typereference.test.js.map +1 -1
  149. package/dist/test/uniontypeexpression.test.js +124 -88
  150. package/dist/test/uniontypeexpression.test.js.map +1 -1
  151. package/dist/test/utils.d.ts +10 -17
  152. package/dist/test/utils.d.ts.map +1 -1
  153. package/dist/test/utils.js +32 -74
  154. package/dist/test/utils.js.map +1 -1
  155. package/dist/test/values.test.js +135 -67
  156. package/dist/test/values.test.js.map +1 -1
  157. package/dist/test/variables.test.js +201 -151
  158. package/dist/test/variables.test.js.map +1 -1
  159. package/dist/test/vitest.setup.d.ts +2 -0
  160. package/dist/test/vitest.setup.d.ts.map +1 -0
  161. package/dist/test/vitest.setup.js +2 -0
  162. package/dist/test/vitest.setup.js.map +1 -0
  163. package/dist/tsconfig.tsbuildinfo +1 -1
  164. package/docs/api/components/FunctionalEnumDeclaration.md +3 -6
  165. package/docs/api/components/MemberExpression.md +1 -5
  166. package/docs/api/components/SourceFile.md +20 -8
  167. package/docs/api/components/index.md +0 -2
  168. package/docs/api/functions/isTypeRefContext.md +1 -1
  169. package/docs/api/index.md +2 -2
  170. package/docs/api/types/ReferenceProps.md +7 -0
  171. package/docs/api/types/TypeRefContextProps.md +7 -0
  172. package/docs/api/types/index.md +2 -0
  173. package/package.json +11 -10
  174. package/src/components/CallSignature.tsx +4 -2
  175. package/src/components/ConstructorDeclaration.tsx +4 -2
  176. package/src/components/DataclassDeclaration.tsx +1 -2
  177. package/src/components/FunctionBase.tsx +1 -2
  178. package/src/components/PropertyDeclaration.tsx +8 -4
  179. package/src/components/PyDoc.tsx +12 -6
  180. package/src/components/PydanticClassDeclaration.tsx +1 -2
  181. package/src/components/SourceFile.tsx +6 -1
  182. package/src/symbols/python-output-symbol.ts +1 -2
  183. package/temp/api.json +107 -61
  184. package/test/callsignatures.test.tsx +309 -283
  185. package/test/class-method-declaration.test.tsx +3 -4
  186. package/test/classdeclarations.test.tsx +263 -248
  187. package/test/classinstantiations.test.tsx +115 -109
  188. package/test/constructordeclaration.test.tsx +9 -6
  189. package/test/dataclassdeclarations.test.tsx +243 -361
  190. package/test/decoratorlist.test.tsx +78 -59
  191. package/test/dundermethoddeclaration.test.tsx +3 -4
  192. package/test/enums.test.tsx +65 -81
  193. package/test/externals.test.tsx +25 -25
  194. package/test/factories.test.tsx +64 -22
  195. package/test/functioncallexpressions.test.tsx +123 -109
  196. package/test/functiondeclaration.test.tsx +209 -148
  197. package/test/imports.test.tsx +119 -91
  198. package/test/memberexpressions.test.tsx +265 -207
  199. package/test/methoddeclaration.test.tsx +84 -63
  200. package/test/namepolicies.test.tsx +69 -69
  201. package/test/propertydeclaration.test.tsx +7 -8
  202. package/test/pydanticclassdeclarations.test.tsx +355 -487
  203. package/test/pydocs.test.tsx +531 -579
  204. package/test/references.test.tsx +24 -23
  205. package/test/sourcefiles.test.tsx +527 -492
  206. package/test/staticmethoddeclaration.test.tsx +3 -4
  207. package/test/type-checking-imports.test.tsx +206 -218
  208. package/test/typereference.test.tsx +15 -12
  209. package/test/uniontypeexpression.test.tsx +74 -61
  210. package/test/utils.tsx +26 -110
  211. package/test/values.test.tsx +82 -32
  212. package/test/variables.test.tsx +162 -142
  213. package/test/vitest.setup.ts +1 -0
  214. package/tsdoc-metadata.json +1 -1
  215. package/vitest.config.ts +4 -0
  216. package/docs/api/components/Reference.md +0 -31
  217. package/docs/api/components/TypeRefContext.md +0 -41
@@ -1,38 +1,40 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
2
  import { Prose } from "@alloy-js/core";
3
- import { d } from "@alloy-js/core/testing";
4
3
  import { describe, expect, it } from "vitest";
5
4
  import { enumModule } from "../src/builtins/python.js";
6
5
  import * as py from "../src/index.js";
7
- import { assertFileContents, toSourceText, toSourceTextMultiple } from "./utils.js";
6
+ import { TestOutput, TestOutputDirectory } from "./utils.js";
8
7
  describe("PyDoc", () => {
9
8
  it("formats properly", () => {
10
- const res = toSourceText([_$createComponent(py.PyDoc, {
9
+ expect(_$createComponent(TestOutput, {
11
10
  get children() {
12
- return [_$createComponent(Prose, {
13
- children: "This is an example of a long docstring that will be broken in lines. We will also render another paragraph after this one."
14
- }, {
15
- fileName: import.meta.url,
16
- lineNumber: 17,
17
- columnNumber: 11
18
- }), _$createComponent(Prose, {
19
- children: "This is another paragraph, and there's a line break before it."
11
+ return _$createComponent(py.PyDoc, {
12
+ get children() {
13
+ return [_$createComponent(Prose, {
14
+ children: "This is an example of a long docstring that will be broken in lines. We will also render another paragraph after this one."
15
+ }, {
16
+ fileName: import.meta.url,
17
+ lineNumber: 12,
18
+ columnNumber: 11
19
+ }), _$createComponent(Prose, {
20
+ children: "This is another paragraph, and there's a line break before it."
21
+ }, {
22
+ fileName: import.meta.url,
23
+ lineNumber: 16,
24
+ columnNumber: 11
25
+ })];
26
+ }
20
27
  }, {
21
28
  fileName: import.meta.url,
22
- lineNumber: 21,
23
- columnNumber: 11
24
- })];
29
+ lineNumber: 11,
30
+ columnNumber: 9
31
+ });
25
32
  }
26
33
  }, {
27
34
  fileName: import.meta.url,
28
- lineNumber: 16,
29
- columnNumber: 9
30
- })], {
31
- printOptions: {
32
- printWidth: 40
33
- }
34
- });
35
- expect(res).toRenderTo(d`
35
+ lineNumber: 10,
36
+ columnNumber: 7
37
+ })).toRenderTo(`
36
38
  """
37
39
  This is an example of a long docstring
38
40
  that will be broken in lines. We will
@@ -43,38 +45,43 @@ describe("PyDoc", () => {
43
45
  line break before it.
44
46
  """
45
47
 
46
-
47
- `);
48
+ `, {
49
+ tabWidth: 4,
50
+ printWidth: 40
51
+ });
48
52
  });
49
53
  });
50
54
  describe("PyDocExample", () => {
51
55
  it("creates docstring with a code sample", () => {
52
- const res = toSourceText([_$createComponent(py.PyDoc, {
56
+ expect(_$createComponent(TestOutput, {
53
57
  get children() {
54
- return [_$createComponent(Prose, {
55
- children: "This is an example of a docstring with a code sample."
56
- }, {
57
- fileName: import.meta.url,
58
- lineNumber: 52,
59
- columnNumber: 11
60
- }), _$createComponent(py.PyDocExample, {
61
- children: "print(\"Hello world!\")"
58
+ return _$createComponent(py.PyDoc, {
59
+ get children() {
60
+ return [_$createComponent(Prose, {
61
+ children: "This is an example of a docstring with a code sample."
62
+ }, {
63
+ fileName: import.meta.url,
64
+ lineNumber: 44,
65
+ columnNumber: 11
66
+ }), _$createComponent(py.PyDocExample, {
67
+ children: "print(\"Hello world!\")"
68
+ }, {
69
+ fileName: import.meta.url,
70
+ lineNumber: 45,
71
+ columnNumber: 11
72
+ })];
73
+ }
62
74
  }, {
63
75
  fileName: import.meta.url,
64
- lineNumber: 53,
65
- columnNumber: 11
66
- })];
76
+ lineNumber: 43,
77
+ columnNumber: 9
78
+ });
67
79
  }
68
80
  }, {
69
81
  fileName: import.meta.url,
70
- lineNumber: 51,
71
- columnNumber: 9
72
- })], {
73
- printOptions: {
74
- printWidth: 40
75
- }
76
- });
77
- expect(res).toRenderTo(d`
82
+ lineNumber: 42,
83
+ columnNumber: 7
84
+ })).toRenderTo(`
78
85
  """
79
86
  This is an example of a docstring with a
80
87
  code sample.
@@ -82,42 +89,47 @@ describe("PyDocExample", () => {
82
89
  >> print("Hello world!")
83
90
  """
84
91
 
85
-
86
- `);
92
+ `, {
93
+ tabWidth: 4,
94
+ printWidth: 40
95
+ });
87
96
  });
88
97
  it("creates docstring with more than one code sample", () => {
89
- const res = toSourceText([_$createComponent(py.PyDoc, {
98
+ expect(_$createComponent(TestOutput, {
90
99
  get children() {
91
- return [_$createComponent(Prose, {
92
- children: "This is an example of a docstring with a code sample."
93
- }, {
94
- fileName: import.meta.url,
95
- lineNumber: 77,
96
- columnNumber: 11
97
- }), _$createComponent(py.PyDocExample, {
98
- children: "print(\"Hello world!\")"
99
- }, {
100
- fileName: import.meta.url,
101
- lineNumber: 78,
102
- columnNumber: 11
103
- }), _$createComponent(py.PyDocExample, {
104
- children: "print(\"Hello world again!\")"
100
+ return _$createComponent(py.PyDoc, {
101
+ get children() {
102
+ return [_$createComponent(Prose, {
103
+ children: "This is an example of a docstring with a code sample."
104
+ }, {
105
+ fileName: import.meta.url,
106
+ lineNumber: 66,
107
+ columnNumber: 11
108
+ }), _$createComponent(py.PyDocExample, {
109
+ children: "print(\"Hello world!\")"
110
+ }, {
111
+ fileName: import.meta.url,
112
+ lineNumber: 67,
113
+ columnNumber: 11
114
+ }), _$createComponent(py.PyDocExample, {
115
+ children: "print(\"Hello world again!\")"
116
+ }, {
117
+ fileName: import.meta.url,
118
+ lineNumber: 68,
119
+ columnNumber: 11
120
+ })];
121
+ }
105
122
  }, {
106
123
  fileName: import.meta.url,
107
- lineNumber: 79,
108
- columnNumber: 11
109
- })];
124
+ lineNumber: 65,
125
+ columnNumber: 9
126
+ });
110
127
  }
111
128
  }, {
112
129
  fileName: import.meta.url,
113
- lineNumber: 76,
114
- columnNumber: 9
115
- })], {
116
- printOptions: {
117
- printWidth: 40
118
- }
119
- });
120
- expect(res).toRenderTo(d`
130
+ lineNumber: 64,
131
+ columnNumber: 7
132
+ })).toRenderTo(`
121
133
  """
122
134
  This is an example of a docstring with a
123
135
  code sample.
@@ -127,36 +139,41 @@ describe("PyDocExample", () => {
127
139
  >> print("Hello world again!")
128
140
  """
129
141
 
130
-
131
- `);
142
+ `, {
143
+ tabWidth: 4,
144
+ printWidth: 40
145
+ });
132
146
  });
133
147
  it("creates docstring with a multiline code sample", () => {
134
- const res = toSourceText([_$createComponent(py.PyDoc, {
148
+ expect(_$createComponent(TestOutput, {
135
149
  get children() {
136
- return [_$createComponent(Prose, {
137
- children: "This is an example of a docstring with a code sample."
138
- }, {
139
- fileName: import.meta.url,
140
- lineNumber: 105,
141
- columnNumber: 11
142
- }), _$createComponent(py.PyDocExample, {
143
- children: `print("Hello world!")\nx = "Hello"\nprint(x)`
150
+ return _$createComponent(py.PyDoc, {
151
+ get children() {
152
+ return [_$createComponent(Prose, {
153
+ children: "This is an example of a docstring with a code sample."
154
+ }, {
155
+ fileName: import.meta.url,
156
+ lineNumber: 91,
157
+ columnNumber: 11
158
+ }), _$createComponent(py.PyDocExample, {
159
+ children: `print("Hello world!")\nx = "Hello"\nprint(x)`
160
+ }, {
161
+ fileName: import.meta.url,
162
+ lineNumber: 92,
163
+ columnNumber: 11
164
+ })];
165
+ }
144
166
  }, {
145
167
  fileName: import.meta.url,
146
- lineNumber: 106,
147
- columnNumber: 11
148
- })];
168
+ lineNumber: 90,
169
+ columnNumber: 9
170
+ });
149
171
  }
150
172
  }, {
151
173
  fileName: import.meta.url,
152
- lineNumber: 104,
153
- columnNumber: 9
154
- })], {
155
- printOptions: {
156
- printWidth: 40
157
- }
158
- });
159
- expect(res).toRenderTo(d`
174
+ lineNumber: 89,
175
+ columnNumber: 7
176
+ })).toRenderTo(`
160
177
  """
161
178
  This is an example of a docstring with a
162
179
  code sample.
@@ -166,102 +183,133 @@ describe("PyDocExample", () => {
166
183
  >> print(x)
167
184
  """
168
185
 
169
-
170
- `);
186
+ `, {
187
+ tabWidth: 4,
188
+ printWidth: 40
189
+ });
171
190
  });
172
191
  });
173
192
  describe("SimpleCommentBlock", () => {
174
193
  it("renders simple comment block", () => {
175
- const res = toSourceText([_$createComponent(py.SimpleCommentBlock, {
176
- children: "This is a simple comment block that spans multiple lines and should be split automatically."
194
+ expect(_$createComponent(TestOutput, {
195
+ get children() {
196
+ return _$createComponent(py.SimpleCommentBlock, {
197
+ children: "This is a simple comment block that spans multiple lines and should be split automatically."
198
+ }, {
199
+ fileName: import.meta.url,
200
+ lineNumber: 118,
201
+ columnNumber: 9
202
+ });
203
+ }
177
204
  }, {
178
205
  fileName: import.meta.url,
179
- lineNumber: 134,
206
+ lineNumber: 117,
180
207
  columnNumber: 7
181
- })]);
182
- expect(res).toRenderTo(d`
208
+ })).toRenderTo(`
183
209
  # This is a simple comment block that spans multiple lines and should be split
184
210
  # automatically.
185
-
186
211
  `);
187
212
  });
188
213
  it("renders comment block with line breaks", () => {
189
- const res = toSourceText([_$createComponent(py.SimpleCommentBlock, {
190
- children: "First line of comment.\\nSecond line of comment."
214
+ expect(_$createComponent(TestOutput, {
215
+ get children() {
216
+ return _$createComponent(py.SimpleCommentBlock, {
217
+ children: "First line of comment.\\nSecond line of comment."
218
+ }, {
219
+ fileName: import.meta.url,
220
+ lineNumber: 134,
221
+ columnNumber: 9
222
+ });
223
+ }
191
224
  }, {
192
225
  fileName: import.meta.url,
193
- lineNumber: 150,
226
+ lineNumber: 133,
194
227
  columnNumber: 7
195
- })]);
196
- expect(res).toRenderTo(d`
228
+ })).toRenderTo(`
197
229
  # First line of comment.
198
230
  # Second line of comment.
199
-
200
231
  `);
201
232
  });
202
233
  });
203
234
  describe("SimpleInlineComment", () => {
204
235
  it("renders inline comment", () => {
205
- const res = toSourceText([["x = 42", _$createComponent(py.SimpleInlineComment, {
206
- children: "This is an inline comment"
236
+ expect(_$createComponent(TestOutput, {
237
+ get children() {
238
+ return [["x = 42", _$createComponent(py.SimpleInlineComment, {
239
+ children: "This is an inline comment"
240
+ }, {
241
+ fileName: import.meta.url,
242
+ lineNumber: 154,
243
+ columnNumber: 13
244
+ })]];
245
+ }
207
246
  }, {
208
247
  fileName: import.meta.url,
209
- lineNumber: 169,
210
- columnNumber: 9
211
- })]]);
212
- expect(res).toRenderTo(d`
213
- x = 42 # This is an inline comment
214
- `);
248
+ lineNumber: 150,
249
+ columnNumber: 7
250
+ })).toRenderTo(`x = 42 # This is an inline comment`);
215
251
  });
216
252
  it("renders inline comment with complex text", () => {
217
- const res = toSourceText([["result = calculate()", _$createComponent(py.SimpleInlineComment, {
218
- children: "TODO: Add error handling here"
253
+ expect(_$createComponent(TestOutput, {
254
+ get children() {
255
+ return [["result = calculate()", _$createComponent(py.SimpleInlineComment, {
256
+ children: "TODO: Add error handling here"
257
+ }, {
258
+ fileName: import.meta.url,
259
+ lineNumber: 169,
260
+ columnNumber: 13
261
+ })]];
262
+ }
219
263
  }, {
220
264
  fileName: import.meta.url,
221
- lineNumber: 185,
222
- columnNumber: 9
223
- })]]);
224
- expect(res).toRenderTo(d`
225
- result = calculate() # TODO: Add error handling here
226
- `);
265
+ lineNumber: 165,
266
+ columnNumber: 7
267
+ })).toRenderTo(`result = calculate() # TODO: Add error handling here`);
227
268
  });
228
269
  });
229
270
  describe("New Documentation Components", () => {
230
271
  it("ModuleDoc renders correctly", () => {
231
- const res = toSourceText([_$createComponent(py.ModuleDoc, {
232
- get description() {
233
- return [_$createComponent(Prose, {
234
- children: "This module demonstrates documentation as specified by the Google Python Style Guide."
235
- }, {
236
- fileName: import.meta.url,
237
- lineNumber: 203,
238
- columnNumber: 11
239
- })];
240
- },
241
- attributes: [{
242
- name: "module_level_variable1",
243
- type: "int",
244
- children: "Module level variables may be documented."
245
- }],
246
- get examples() {
247
- return [_$createComponent(py.PyDocExample, {
248
- children: "print(\"mod\")"
272
+ expect(_$createComponent(TestOutput, {
273
+ get children() {
274
+ return _$createComponent(py.ModuleDoc, {
275
+ get description() {
276
+ return [_$createComponent(Prose, {
277
+ children: "This module demonstrates documentation as specified by the Google Python Style Guide."
278
+ }, {
279
+ fileName: import.meta.url,
280
+ lineNumber: 185,
281
+ columnNumber: 13
282
+ })];
283
+ },
284
+ attributes: [{
285
+ name: "module_level_variable1",
286
+ type: "int",
287
+ children: "Module level variables may be documented."
288
+ }],
289
+ get examples() {
290
+ return [_$createComponent(py.PyDocExample, {
291
+ children: "print(\"mod\")"
292
+ }, {
293
+ fileName: import.meta.url,
294
+ lineNumber: 197,
295
+ columnNumber: 22
296
+ })];
297
+ },
298
+ seeAlso: ["another_module.func", "RelatedClass"],
299
+ warning: "Internal API.",
300
+ deprecated: "Use new_module instead.",
301
+ todo: ["For module TODOs", "You have to also use sphinx.ext.todo extension"]
249
302
  }, {
250
303
  fileName: import.meta.url,
251
- lineNumber: 215,
252
- columnNumber: 20
253
- })];
254
- },
255
- seeAlso: ["another_module.func", "RelatedClass"],
256
- warning: "Internal API.",
257
- deprecated: "Use new_module instead.",
258
- todo: ["For module TODOs", "You have to also use sphinx.ext.todo extension"]
304
+ lineNumber: 183,
305
+ columnNumber: 9
306
+ });
307
+ }
259
308
  }, {
260
309
  fileName: import.meta.url,
261
- lineNumber: 201,
310
+ lineNumber: 182,
262
311
  columnNumber: 7
263
- })]);
264
- expect(res).toRenderTo(d`
312
+ })).toRenderTo(`
265
313
  """
266
314
  This module demonstrates documentation as specified by the Google Python Style
267
315
  Guide.
@@ -287,40 +335,46 @@ describe("New Documentation Components", () => {
287
335
  * You have to also use sphinx.ext.todo extension
288
336
  """
289
337
 
290
-
291
338
  `);
292
339
  });
293
340
  it("PropertyDoc renders correctly", () => {
294
- const res = toSourceText([_$createComponent(py.PropertyDoc, {
295
- get description() {
296
- return [_$createComponent(Prose, {
297
- children: "Properties should be documented in their getter method."
298
- }, {
299
- fileName: import.meta.url,
300
- lineNumber: 262,
301
- columnNumber: 11
302
- })];
303
- },
304
- returns: "str: The readonly property value.",
305
- get examples() {
306
- return [_$createComponent(py.PyDocExample, {
307
- children: "print(obj.name)"
341
+ expect(_$createComponent(TestOutput, {
342
+ get children() {
343
+ return _$createComponent(py.PropertyDoc, {
344
+ get description() {
345
+ return [_$createComponent(Prose, {
346
+ children: "Properties should be documented in their getter method."
347
+ }, {
348
+ fileName: import.meta.url,
349
+ lineNumber: 243,
350
+ columnNumber: 13
351
+ })];
352
+ },
353
+ returns: "str: The readonly property value.",
354
+ get examples() {
355
+ return [_$createComponent(py.PyDocExample, {
356
+ children: "print(obj.name)"
357
+ }, {
358
+ fileName: import.meta.url,
359
+ lineNumber: 248,
360
+ columnNumber: 22
361
+ })];
362
+ },
363
+ seeAlso: ["other_property"],
364
+ warning: "Access may be slow.",
365
+ deprecated: "Use full_name instead.",
366
+ note: "If the setter method contains notable behavior, it should be mentioned here."
308
367
  }, {
309
368
  fileName: import.meta.url,
310
- lineNumber: 267,
311
- columnNumber: 20
312
- })];
313
- },
314
- seeAlso: ["other_property"],
315
- warning: "Access may be slow.",
316
- deprecated: "Use full_name instead.",
317
- note: "If the setter method contains notable behavior, it should be mentioned here."
369
+ lineNumber: 241,
370
+ columnNumber: 9
371
+ });
372
+ }
318
373
  }, {
319
374
  fileName: import.meta.url,
320
- lineNumber: 260,
375
+ lineNumber: 240,
321
376
  columnNumber: 7
322
- })]);
323
- expect(res).toRenderTo(d`
377
+ })).toRenderTo(`
324
378
  """
325
379
  Properties should be documented in their getter method.
326
380
 
@@ -343,45 +397,51 @@ describe("New Documentation Components", () => {
343
397
  If the setter method contains notable behavior, it should be mentioned here.
344
398
  """
345
399
 
346
-
347
400
  `);
348
401
  });
349
402
  it("GeneratorDoc renders correctly", () => {
350
- const res = toSourceText([_$createComponent(py.GeneratorDoc, {
351
- get description() {
352
- return [_$createComponent(Prose, {
353
- children: "Generators have a Yields section instead of a Returns section."
354
- }, {
355
- fileName: import.meta.url,
356
- lineNumber: 308,
357
- columnNumber: 11
358
- })];
359
- },
360
- parameters: [{
361
- name: "n",
362
- type: "int",
363
- doc: "The upper limit of the range to generate, from 0 to n - 1."
364
- }],
365
- yields: "int: The next number in the range of 0 to n - 1.",
366
- get examples() {
367
- return [_$createComponent(py.PyDocExample, {
368
- children: "print(next(gen))"
403
+ expect(_$createComponent(TestOutput, {
404
+ get children() {
405
+ return _$createComponent(py.GeneratorDoc, {
406
+ get description() {
407
+ return [_$createComponent(Prose, {
408
+ children: "Generators have a Yields section instead of a Returns section."
409
+ }, {
410
+ fileName: import.meta.url,
411
+ lineNumber: 288,
412
+ columnNumber: 13
413
+ })];
414
+ },
415
+ parameters: [{
416
+ name: "n",
417
+ type: "int",
418
+ doc: "The upper limit of the range to generate, from 0 to n - 1."
419
+ }],
420
+ yields: "int: The next number in the range of 0 to n - 1.",
421
+ get examples() {
422
+ return [_$createComponent(py.PyDocExample, {
423
+ children: "print(next(gen))"
424
+ }, {
425
+ fileName: import.meta.url,
426
+ lineNumber: 300,
427
+ columnNumber: 22
428
+ })];
429
+ },
430
+ seeAlso: ["make_generator"],
431
+ warning: "Do not consume in tight loops without sleep.",
432
+ deprecated: "Use new_generator instead.",
433
+ note: "Examples should be written in doctest format."
369
434
  }, {
370
435
  fileName: import.meta.url,
371
- lineNumber: 320,
372
- columnNumber: 20
373
- })];
374
- },
375
- seeAlso: ["make_generator"],
376
- warning: "Do not consume in tight loops without sleep.",
377
- deprecated: "Use new_generator instead.",
378
- note: "Examples should be written in doctest format."
436
+ lineNumber: 286,
437
+ columnNumber: 9
438
+ });
439
+ }
379
440
  }, {
380
441
  fileName: import.meta.url,
381
- lineNumber: 306,
442
+ lineNumber: 285,
382
443
  columnNumber: 7
383
- })]);
384
- expect(res).toRenderTo(d`
444
+ })).toRenderTo(`
385
445
  """
386
446
  Generators have a Yields section instead of a Returns section.
387
447
 
@@ -407,48 +467,54 @@ describe("New Documentation Components", () => {
407
467
  Examples should be written in doctest format.
408
468
  """
409
469
 
410
-
411
470
  `);
412
471
  });
413
472
  it("ExceptionDoc renders correctly", () => {
414
- const res = toSourceText([_$createComponent(py.ExceptionDoc, {
415
- get description() {
416
- return [_$createComponent(Prose, {
417
- children: "Exceptions are documented in the same way as classes."
473
+ expect(_$createComponent(TestOutput, {
474
+ get children() {
475
+ return _$createComponent(py.ExceptionDoc, {
476
+ get description() {
477
+ return [_$createComponent(Prose, {
478
+ children: "Exceptions are documented in the same way as classes."
479
+ }, {
480
+ fileName: import.meta.url,
481
+ lineNumber: 343,
482
+ columnNumber: 13
483
+ })];
484
+ },
485
+ parameters: [{
486
+ name: "msg",
487
+ type: "str",
488
+ doc: "Human readable string describing the exception."
489
+ }, {
490
+ name: "code",
491
+ type: "int",
492
+ default: undefined,
493
+ doc: "Error code."
494
+ }],
495
+ attributes: [{
496
+ name: "msg",
497
+ type: "str",
498
+ children: "Human readable string describing the exception."
499
+ }, {
500
+ name: "code",
501
+ type: "int",
502
+ children: "Exception error code."
503
+ }],
504
+ seeAlso: ["BaseException"],
505
+ deprecated: "Use NewException instead.",
506
+ note: "Do not include the 'self' parameter in the Args section."
418
507
  }, {
419
508
  fileName: import.meta.url,
420
- lineNumber: 364,
421
- columnNumber: 11
422
- })];
423
- },
424
- parameters: [{
425
- name: "msg",
426
- type: "str",
427
- doc: "Human readable string describing the exception."
428
- }, {
429
- name: "code",
430
- type: "int",
431
- default: undefined,
432
- doc: "Error code."
433
- }],
434
- attributes: [{
435
- name: "msg",
436
- type: "str",
437
- children: "Human readable string describing the exception."
438
- }, {
439
- name: "code",
440
- type: "int",
441
- children: "Exception error code."
442
- }],
443
- seeAlso: ["BaseException"],
444
- deprecated: "Use NewException instead.",
445
- note: "Do not include the 'self' parameter in the Args section."
509
+ lineNumber: 341,
510
+ columnNumber: 9
511
+ });
512
+ }
446
513
  }, {
447
514
  fileName: import.meta.url,
448
- lineNumber: 362,
515
+ lineNumber: 340,
449
516
  columnNumber: 7
450
- })]);
451
- expect(res).toRenderTo(d`
517
+ })).toRenderTo(`
452
518
  """
453
519
  Exceptions are documented in the same way as classes.
454
520
 
@@ -472,35 +538,41 @@ describe("New Documentation Components", () => {
472
538
  Do not include the 'self' parameter in the Args section.
473
539
  """
474
540
 
475
-
476
541
  `);
477
542
  });
478
543
  it("MethodDoc renders correctly without default note", () => {
479
- const res = toSourceText([_$createComponent(py.MethodDoc, {
480
- get description() {
481
- return [_$createComponent(Prose, {
482
- children: "Class methods are similar to regular functions."
544
+ expect(_$createComponent(TestOutput, {
545
+ get children() {
546
+ return _$createComponent(py.MethodDoc, {
547
+ get description() {
548
+ return [_$createComponent(Prose, {
549
+ children: "Class methods are similar to regular functions."
550
+ }, {
551
+ fileName: import.meta.url,
552
+ lineNumber: 411,
553
+ columnNumber: 13
554
+ })];
555
+ },
556
+ parameters: [{
557
+ name: "param1",
558
+ doc: "The first parameter."
559
+ }, {
560
+ name: "param2",
561
+ doc: "The second parameter."
562
+ }],
563
+ returns: "True if successful, False otherwise.",
564
+ overrides: "Base.method"
483
565
  }, {
484
566
  fileName: import.meta.url,
485
- lineNumber: 431,
486
- columnNumber: 11
487
- })];
488
- },
489
- parameters: [{
490
- name: "param1",
491
- doc: "The first parameter."
492
- }, {
493
- name: "param2",
494
- doc: "The second parameter."
495
- }],
496
- returns: "True if successful, False otherwise.",
497
- overrides: "Base.method"
567
+ lineNumber: 409,
568
+ columnNumber: 9
569
+ });
570
+ }
498
571
  }, {
499
572
  fileName: import.meta.url,
500
- lineNumber: 429,
573
+ lineNumber: 408,
501
574
  columnNumber: 7
502
- })]);
503
- expect(res).toRenderTo(d`
575
+ })).toRenderTo(`
504
576
  """
505
577
  Class methods are similar to regular functions.
506
578
 
@@ -516,32 +588,38 @@ describe("New Documentation Components", () => {
516
588
  Base.method
517
589
  """
518
590
 
519
-
520
591
  `);
521
592
  });
522
593
  it("MethodDoc renders correctly with custom note", () => {
523
- const res = toSourceText([_$createComponent(py.MethodDoc, {
524
- get description() {
525
- return [_$createComponent(Prose, {
526
- children: "Class methods are similar to regular functions."
594
+ expect(_$createComponent(TestOutput, {
595
+ get children() {
596
+ return _$createComponent(py.MethodDoc, {
597
+ get description() {
598
+ return [_$createComponent(Prose, {
599
+ children: "Class methods are similar to regular functions."
600
+ }, {
601
+ fileName: import.meta.url,
602
+ lineNumber: 453,
603
+ columnNumber: 13
604
+ })];
605
+ },
606
+ parameters: [{
607
+ name: "param1",
608
+ doc: "The first parameter."
609
+ }],
610
+ returns: "True if successful, False otherwise.",
611
+ note: "This method has special behavior when called multiple times."
527
612
  }, {
528
613
  fileName: import.meta.url,
529
- lineNumber: 474,
530
- columnNumber: 11
531
- })];
532
- },
533
- parameters: [{
534
- name: "param1",
535
- doc: "The first parameter."
536
- }],
537
- returns: "True if successful, False otherwise.",
538
- note: "This method has special behavior when called multiple times."
614
+ lineNumber: 451,
615
+ columnNumber: 9
616
+ });
617
+ }
539
618
  }, {
540
619
  fileName: import.meta.url,
541
- lineNumber: 472,
620
+ lineNumber: 450,
542
621
  columnNumber: 7
543
- })]);
544
- expect(res).toRenderTo(d`
622
+ })).toRenderTo(`
545
623
  """
546
624
  Class methods are similar to regular functions.
547
625
 
@@ -555,51 +633,63 @@ describe("New Documentation Components", () => {
555
633
  This method has special behavior when called multiple times.
556
634
  """
557
635
 
558
-
559
636
  `);
560
637
  });
561
638
  it("ModuleDoc with minimal content", () => {
562
- const res = toSourceText([_$createComponent(py.ModuleDoc, {
563
- get description() {
564
- return [_$createComponent(Prose, {
565
- children: "Simple module description."
639
+ expect(_$createComponent(TestOutput, {
640
+ get children() {
641
+ return _$createComponent(py.ModuleDoc, {
642
+ get description() {
643
+ return [_$createComponent(Prose, {
644
+ children: "Simple module description."
645
+ }, {
646
+ fileName: import.meta.url,
647
+ lineNumber: 488,
648
+ columnNumber: 25
649
+ })];
650
+ }
566
651
  }, {
567
652
  fileName: import.meta.url,
568
- lineNumber: 510,
569
- columnNumber: 23
570
- })];
653
+ lineNumber: 487,
654
+ columnNumber: 9
655
+ });
571
656
  }
572
657
  }, {
573
658
  fileName: import.meta.url,
574
- lineNumber: 509,
659
+ lineNumber: 486,
575
660
  columnNumber: 7
576
- })]);
577
- expect(res).toRenderTo(d`
661
+ })).toRenderTo(`
578
662
  """
579
663
  Simple module description.
580
664
  """
581
665
 
582
-
583
666
  `);
584
667
  });
585
668
  it("ModuleDoc with only todo items", () => {
586
- const res = toSourceText([_$createComponent(py.ModuleDoc, {
587
- get description() {
588
- return [_$createComponent(Prose, {
589
- children: "Module with pending tasks."
669
+ expect(_$createComponent(TestOutput, {
670
+ get children() {
671
+ return _$createComponent(py.ModuleDoc, {
672
+ get description() {
673
+ return [_$createComponent(Prose, {
674
+ children: "Module with pending tasks."
675
+ }, {
676
+ fileName: import.meta.url,
677
+ lineNumber: 505,
678
+ columnNumber: 25
679
+ })];
680
+ },
681
+ todo: ["Implement feature X", "Add more tests", "Update documentation"]
590
682
  }, {
591
683
  fileName: import.meta.url,
592
- lineNumber: 528,
593
- columnNumber: 23
594
- })];
595
- },
596
- todo: ["Implement feature X", "Add more tests", "Update documentation"]
684
+ lineNumber: 504,
685
+ columnNumber: 9
686
+ });
687
+ }
597
688
  }, {
598
689
  fileName: import.meta.url,
599
- lineNumber: 527,
690
+ lineNumber: 503,
600
691
  columnNumber: 7
601
- })]);
602
- expect(res).toRenderTo(d`
692
+ })).toRenderTo(`
603
693
  """
604
694
  Module with pending tasks.
605
695
 
@@ -609,52 +699,64 @@ describe("New Documentation Components", () => {
609
699
  * Update documentation
610
700
  """
611
701
 
612
-
613
702
  `);
614
703
  });
615
704
  it("PropertyDoc minimal (description only)", () => {
616
- const res = toSourceText([_$createComponent(py.PropertyDoc, {
617
- get description() {
618
- return [_$createComponent(Prose, {
619
- children: "A simple readonly property."
705
+ expect(_$createComponent(TestOutput, {
706
+ get children() {
707
+ return _$createComponent(py.PropertyDoc, {
708
+ get description() {
709
+ return [_$createComponent(Prose, {
710
+ children: "A simple readonly property."
711
+ }, {
712
+ fileName: import.meta.url,
713
+ lineNumber: 532,
714
+ columnNumber: 25
715
+ })];
716
+ }
620
717
  }, {
621
718
  fileName: import.meta.url,
622
- lineNumber: 552,
623
- columnNumber: 23
624
- })];
719
+ lineNumber: 531,
720
+ columnNumber: 9
721
+ });
625
722
  }
626
723
  }, {
627
724
  fileName: import.meta.url,
628
- lineNumber: 551,
725
+ lineNumber: 530,
629
726
  columnNumber: 7
630
- })]);
631
- expect(res).toRenderTo(d`
727
+ })).toRenderTo(`
632
728
  """
633
729
  A simple readonly property.
634
730
  """
635
731
 
636
-
637
732
  `);
638
733
  });
639
734
  it("PropertyDoc with getter and setter info", () => {
640
- const res = toSourceText([_$createComponent(py.PropertyDoc, {
641
- get description() {
642
- return [_$createComponent(Prose, {
643
- children: "Properties with both a getter and setter should only be documented in their getter method."
735
+ expect(_$createComponent(TestOutput, {
736
+ get children() {
737
+ return _$createComponent(py.PropertyDoc, {
738
+ get description() {
739
+ return [_$createComponent(Prose, {
740
+ children: "Properties with both a getter and setter should only be documented in their getter method."
741
+ }, {
742
+ fileName: import.meta.url,
743
+ lineNumber: 550,
744
+ columnNumber: 13
745
+ })];
746
+ },
747
+ returns: ":obj:`list` of :obj:`str`: The property value.",
748
+ note: "If the setter method contains notable behavior, it should be mentioned here."
644
749
  }, {
645
750
  fileName: import.meta.url,
646
- lineNumber: 571,
647
- columnNumber: 11
648
- })];
649
- },
650
- returns: ":obj:`list` of :obj:`str`: The property value.",
651
- note: "If the setter method contains notable behavior, it should be mentioned here."
751
+ lineNumber: 548,
752
+ columnNumber: 9
753
+ });
754
+ }
652
755
  }, {
653
756
  fileName: import.meta.url,
654
- lineNumber: 569,
757
+ lineNumber: 547,
655
758
  columnNumber: 7
656
- })]);
657
- expect(res).toRenderTo(d`
759
+ })).toRenderTo(`
658
760
  """
659
761
  Properties with both a getter and setter should only be documented in their
660
762
  getter method.
@@ -666,43 +768,49 @@ describe("New Documentation Components", () => {
666
768
  If the setter method contains notable behavior, it should be mentioned here.
667
769
  """
668
770
 
669
-
670
771
  `);
671
772
  });
672
773
  it("GeneratorDoc with complex parameters", () => {
673
- const res = toSourceText([_$createComponent(py.GeneratorDoc, {
674
- get description() {
675
- return [_$createComponent(Prose, {
676
- children: "A more complex generator example with multiple parameters."
774
+ expect(_$createComponent(TestOutput, {
775
+ get children() {
776
+ return _$createComponent(py.GeneratorDoc, {
777
+ get description() {
778
+ return [_$createComponent(Prose, {
779
+ children: "A more complex generator example with multiple parameters."
780
+ }, {
781
+ fileName: import.meta.url,
782
+ lineNumber: 581,
783
+ columnNumber: 13
784
+ })];
785
+ },
786
+ parameters: [{
787
+ name: "start",
788
+ type: "int",
789
+ default: "0",
790
+ doc: "Starting value for the sequence."
791
+ }, {
792
+ name: "stop",
793
+ type: "int",
794
+ doc: "Ending value for the sequence (exclusive)."
795
+ }, {
796
+ name: "step",
797
+ type: "int",
798
+ default: "1",
799
+ doc: "Step size between values."
800
+ }],
801
+ yields: "int: The next number in the sequence.",
802
+ raises: ["ValueError: If step is zero.", "TypeError: If parameters are not integers."]
677
803
  }, {
678
804
  fileName: import.meta.url,
679
- lineNumber: 603,
680
- columnNumber: 11
681
- })];
682
- },
683
- parameters: [{
684
- name: "start",
685
- type: "int",
686
- default: "0",
687
- doc: "Starting value for the sequence."
688
- }, {
689
- name: "stop",
690
- type: "int",
691
- doc: "Ending value for the sequence (exclusive)."
692
- }, {
693
- name: "step",
694
- type: "int",
695
- default: "1",
696
- doc: "Step size between values."
697
- }],
698
- yields: "int: The next number in the sequence.",
699
- raises: ["ValueError: If step is zero.", "TypeError: If parameters are not integers."]
805
+ lineNumber: 579,
806
+ columnNumber: 9
807
+ });
808
+ }
700
809
  }, {
701
810
  fileName: import.meta.url,
702
- lineNumber: 601,
811
+ lineNumber: 578,
703
812
  columnNumber: 7
704
- })]);
705
- expect(res).toRenderTo(d`
813
+ })).toRenderTo(`
706
814
  """
707
815
  A more complex generator example with multiple parameters.
708
816
 
@@ -723,61 +831,67 @@ describe("New Documentation Components", () => {
723
831
  TypeError: If parameters are not integers.
724
832
  """
725
833
 
726
-
727
834
  `);
728
835
  });
729
836
  it("ExceptionDoc with comprehensive documentation", () => {
730
- const res = toSourceText([_$createComponent(py.ExceptionDoc, {
731
- get description() {
732
- return [_$createComponent(Prose, {
733
- children: "A custom exception for authentication failures."
734
- }, {
735
- fileName: import.meta.url,
736
- lineNumber: 665,
737
- columnNumber: 11
738
- }), _$createComponent(Prose, {
739
- children: "This exception is raised when authentication credentials are invalid or when authentication tokens have expired."
837
+ expect(_$createComponent(TestOutput, {
838
+ get children() {
839
+ return _$createComponent(py.ExceptionDoc, {
840
+ get description() {
841
+ return [_$createComponent(Prose, {
842
+ children: "A custom exception for authentication failures."
843
+ }, {
844
+ fileName: import.meta.url,
845
+ lineNumber: 642,
846
+ columnNumber: 13
847
+ }), _$createComponent(Prose, {
848
+ children: "This exception is raised when authentication credentials are invalid or when authentication tokens have expired."
849
+ }, {
850
+ fileName: import.meta.url,
851
+ lineNumber: 643,
852
+ columnNumber: 13
853
+ })];
854
+ },
855
+ parameters: [{
856
+ name: "message",
857
+ type: "str",
858
+ doc: "Human readable error message describing the authentication failure."
859
+ }, {
860
+ name: "error_code",
861
+ type: "int",
862
+ default: "401",
863
+ doc: "HTTP error code associated with the authentication failure."
864
+ }, {
865
+ name: "retry_after",
866
+ type: "int",
867
+ default: undefined,
868
+ doc: "Number of seconds to wait before retrying authentication."
869
+ }],
870
+ attributes: [{
871
+ name: "message",
872
+ type: "str",
873
+ children: "The error message."
874
+ }, {
875
+ name: "error_code",
876
+ type: "int",
877
+ children: "HTTP status code."
878
+ }, {
879
+ name: "retry_after",
880
+ type: "int",
881
+ children: "Retry delay in seconds, if applicable."
882
+ }],
883
+ note: "This exception should be caught and handled gracefully in production code."
740
884
  }, {
741
885
  fileName: import.meta.url,
742
- lineNumber: 666,
743
- columnNumber: 11
744
- })];
745
- },
746
- parameters: [{
747
- name: "message",
748
- type: "str",
749
- doc: "Human readable error message describing the authentication failure."
750
- }, {
751
- name: "error_code",
752
- type: "int",
753
- default: "401",
754
- doc: "HTTP error code associated with the authentication failure."
755
- }, {
756
- name: "retry_after",
757
- type: "int",
758
- default: undefined,
759
- doc: "Number of seconds to wait before retrying authentication."
760
- }],
761
- attributes: [{
762
- name: "message",
763
- type: "str",
764
- children: "The error message."
765
- }, {
766
- name: "error_code",
767
- type: "int",
768
- children: "HTTP status code."
769
- }, {
770
- name: "retry_after",
771
- type: "int",
772
- children: "Retry delay in seconds, if applicable."
773
- }],
774
- note: "This exception should be caught and handled gracefully in production code."
886
+ lineNumber: 640,
887
+ columnNumber: 9
888
+ });
889
+ }
775
890
  }, {
776
891
  fileName: import.meta.url,
777
- lineNumber: 663,
892
+ lineNumber: 639,
778
893
  columnNumber: 7
779
- })]);
780
- expect(res).toRenderTo(d`
894
+ })).toRenderTo(`
781
895
  """
782
896
  A custom exception for authentication failures.
783
897
 
@@ -804,32 +918,38 @@ describe("New Documentation Components", () => {
804
918
  This exception should be caught and handled gracefully in production code.
805
919
  """
806
920
 
807
-
808
921
  `);
809
922
  });
810
923
  it("MethodDoc with raises but no returns", () => {
811
- const res = toSourceText([_$createComponent(py.MethodDoc, {
812
- get description() {
813
- return [_$createComponent(Prose, {
814
- children: "A method that performs an action but doesn't return a value."
924
+ expect(_$createComponent(TestOutput, {
925
+ get children() {
926
+ return _$createComponent(py.MethodDoc, {
927
+ get description() {
928
+ return [_$createComponent(Prose, {
929
+ children: "A method that performs an action but doesn't return a value."
930
+ }, {
931
+ fileName: import.meta.url,
932
+ lineNumber: 724,
933
+ columnNumber: 13
934
+ })];
935
+ },
936
+ parameters: [{
937
+ name: "data",
938
+ type: "bytes",
939
+ doc: "Raw data to process."
940
+ }],
941
+ raises: ["ValueError: If data is empty or invalid.", "IOError: If processing fails due to I/O issues."]
815
942
  }, {
816
943
  fileName: import.meta.url,
817
- lineNumber: 748,
818
- columnNumber: 11
819
- })];
820
- },
821
- parameters: [{
822
- name: "data",
823
- type: "bytes",
824
- doc: "Raw data to process."
825
- }],
826
- raises: ["ValueError: If data is empty or invalid.", "IOError: If processing fails due to I/O issues."]
944
+ lineNumber: 722,
945
+ columnNumber: 9
946
+ });
947
+ }
827
948
  }, {
828
949
  fileName: import.meta.url,
829
- lineNumber: 746,
950
+ lineNumber: 721,
830
951
  columnNumber: 7
831
- })]);
832
- expect(res).toRenderTo(d`
952
+ })).toRenderTo(`
833
953
  """
834
954
  A method that performs an action but doesn't return a value.
835
955
 
@@ -843,28 +963,34 @@ describe("New Documentation Components", () => {
843
963
  IOError: If processing fails due to I/O issues.
844
964
  """
845
965
 
846
-
847
966
  `);
848
967
  });
849
968
  it("MethodDoc with no parameters", () => {
850
- const res = toSourceText([_$createComponent(py.MethodDoc, {
851
- get description() {
852
- return [_$createComponent(Prose, {
853
- children: "A simple method with no parameters (except self)."
969
+ expect(_$createComponent(TestOutput, {
970
+ get children() {
971
+ return _$createComponent(py.MethodDoc, {
972
+ get description() {
973
+ return [_$createComponent(Prose, {
974
+ children: "A simple method with no parameters (except self)."
975
+ }, {
976
+ fileName: import.meta.url,
977
+ lineNumber: 765,
978
+ columnNumber: 13
979
+ })];
980
+ },
981
+ returns: "bool: True if the operation was successful.",
982
+ note: "This is a parameterless method that only operates on instance state."
854
983
  }, {
855
984
  fileName: import.meta.url,
856
- lineNumber: 790,
857
- columnNumber: 11
858
- })];
859
- },
860
- returns: "bool: True if the operation was successful.",
861
- note: "This is a parameterless method that only operates on instance state."
985
+ lineNumber: 763,
986
+ columnNumber: 9
987
+ });
988
+ }
862
989
  }, {
863
990
  fileName: import.meta.url,
864
- lineNumber: 788,
991
+ lineNumber: 762,
865
992
  columnNumber: 7
866
- })]);
867
- expect(res).toRenderTo(d`
993
+ })).toRenderTo(`
868
994
  """
869
995
  A simple method with no parameters (except self).
870
996
 
@@ -875,66 +1001,78 @@ describe("New Documentation Components", () => {
875
1001
  This is a parameterless method that only operates on instance state.
876
1002
  """
877
1003
 
878
-
879
1004
  `);
880
1005
  });
881
1006
  it("AttributeDoc standalone usage", () => {
882
- const res = toSourceText([_$createComponent(py.PyDoc, {
1007
+ expect(_$createComponent(TestOutput, {
883
1008
  get children() {
884
- return _$createComponent(py.AttributeDoc, {
885
- name: "connection_timeout",
886
- type: "float",
887
- children: "Maximum time in seconds to wait for a connection to be established."
1009
+ return _$createComponent(py.PyDoc, {
1010
+ get children() {
1011
+ return _$createComponent(py.AttributeDoc, {
1012
+ name: "connection_timeout",
1013
+ type: "float",
1014
+ children: "Maximum time in seconds to wait for a connection to be established."
1015
+ }, {
1016
+ fileName: import.meta.url,
1017
+ lineNumber: 791,
1018
+ columnNumber: 11
1019
+ });
1020
+ }
888
1021
  }, {
889
1022
  fileName: import.meta.url,
890
- lineNumber: 817,
1023
+ lineNumber: 790,
891
1024
  columnNumber: 9
892
1025
  });
893
1026
  }
894
1027
  }, {
895
1028
  fileName: import.meta.url,
896
- lineNumber: 816,
1029
+ lineNumber: 789,
897
1030
  columnNumber: 7
898
- })]);
899
- expect(res).toRenderTo(d`
1031
+ })).toRenderTo(`
900
1032
  """
901
1033
  connection_timeout (float): Maximum time in seconds to wait for a connection to
902
1034
  be established.
903
1035
  """
904
1036
 
905
-
906
1037
  `);
907
1038
  });
908
1039
  it("GeneratorDoc with examples in description", () => {
909
- const res = toSourceText([_$createComponent(py.GeneratorDoc, {
910
- get description() {
911
- return [_$createComponent(Prose, {
912
- children: "Generators have a Yields section instead of a Returns section."
913
- }, {
914
- fileName: import.meta.url,
915
- lineNumber: 839,
916
- columnNumber: 11
917
- }), _$createComponent(py.PyDocExample, {
918
- children: `print([i for i in example_generator(4)])\n[0, 1, 2, 3]`
1040
+ expect(_$createComponent(TestOutput, {
1041
+ get children() {
1042
+ return _$createComponent(py.GeneratorDoc, {
1043
+ get description() {
1044
+ return [_$createComponent(Prose, {
1045
+ children: "Generators have a Yields section instead of a Returns section."
1046
+ }, {
1047
+ fileName: import.meta.url,
1048
+ lineNumber: 812,
1049
+ columnNumber: 13
1050
+ }), _$createComponent(py.PyDocExample, {
1051
+ children: `print([i for i in example_generator(4)])\n[0, 1, 2, 3]`
1052
+ }, {
1053
+ fileName: import.meta.url,
1054
+ lineNumber: 815,
1055
+ columnNumber: 13
1056
+ })];
1057
+ },
1058
+ parameters: [{
1059
+ name: "n",
1060
+ type: "int",
1061
+ doc: "The upper limit of the range to generate, from 0 to n - 1."
1062
+ }],
1063
+ yields: "int: The next number in the range of 0 to n - 1.",
1064
+ note: "Examples should be written in doctest format, and should illustrate how to use the function."
919
1065
  }, {
920
1066
  fileName: import.meta.url,
921
- lineNumber: 842,
922
- columnNumber: 11
923
- })];
924
- },
925
- parameters: [{
926
- name: "n",
927
- type: "int",
928
- doc: "The upper limit of the range to generate, from 0 to n - 1."
929
- }],
930
- yields: "int: The next number in the range of 0 to n - 1.",
931
- note: "Examples should be written in doctest format, and should illustrate how to use the function."
1067
+ lineNumber: 810,
1068
+ columnNumber: 9
1069
+ });
1070
+ }
932
1071
  }, {
933
1072
  fileName: import.meta.url,
934
- lineNumber: 837,
1073
+ lineNumber: 809,
935
1074
  columnNumber: 7
936
- })]);
937
- expect(res).toRenderTo(d`
1075
+ })).toRenderTo(`
938
1076
  """
939
1077
  Generators have a Yields section instead of a Returns section.
940
1078
 
@@ -951,7 +1089,6 @@ describe("New Documentation Components", () => {
951
1089
  Examples should be written in doctest format, and should illustrate how to use the function.
952
1090
  """
953
1091
 
954
-
955
1092
  `);
956
1093
  });
957
1094
  });
@@ -963,13 +1100,13 @@ describe("Full example", () => {
963
1100
  children: "This is an example of a long docstring that will be broken in lines. We will also render another paragraph after this one."
964
1101
  }, {
965
1102
  fileName: import.meta.url,
966
- lineNumber: 887,
1103
+ lineNumber: 858,
967
1104
  columnNumber: 11
968
1105
  }), _$createComponent(py.PyDocExample, {
969
1106
  children: `print("Hello world!")\nx = "Hello"\nprint(x)`
970
1107
  }, {
971
1108
  fileName: import.meta.url,
972
- lineNumber: 891,
1109
+ lineNumber: 862,
973
1110
  columnNumber: 11
974
1111
  })];
975
1112
  },
@@ -987,7 +1124,7 @@ describe("Full example", () => {
987
1124
  children: "print(\"class-doc\")"
988
1125
  }, {
989
1126
  fileName: import.meta.url,
990
- lineNumber: 907,
1127
+ lineNumber: 878,
991
1128
  columnNumber: 20
992
1129
  })];
993
1130
  },
@@ -1008,55 +1145,57 @@ describe("Full example", () => {
1008
1145
  style: "google"
1009
1146
  }, {
1010
1147
  fileName: import.meta.url,
1011
- lineNumber: 885,
1148
+ lineNumber: 856,
1012
1149
  columnNumber: 7
1013
1150
  });
1014
- const res = toSourceText([_$createComponent(py.ClassDeclaration, {
1015
- name: "A",
1016
- doc: doc,
1151
+ expect(_$createComponent(TestOutput, {
1017
1152
  get children() {
1018
- return _$createComponent(py.StatementList, {
1153
+ return _$createComponent(py.ClassDeclaration, {
1154
+ name: "A",
1155
+ doc: doc,
1019
1156
  get children() {
1020
- return [_$createComponent(py.VariableDeclaration, {
1021
- name: "just_name"
1022
- }, {
1023
- fileName: import.meta.url,
1024
- lineNumber: 932,
1025
- columnNumber: 13
1026
- }), _$createComponent(py.VariableDeclaration, {
1027
- name: "name_and_type",
1028
- type: "int"
1029
- }, {
1030
- fileName: import.meta.url,
1031
- lineNumber: 933,
1032
- columnNumber: 13
1033
- }), _$createComponent(py.VariableDeclaration, {
1034
- name: "name_type_and_value",
1035
- type: "int",
1036
- initializer: 12
1157
+ return _$createComponent(py.StatementList, {
1158
+ get children() {
1159
+ return [_$createComponent(py.VariableDeclaration, {
1160
+ name: "just_name"
1161
+ }, {
1162
+ fileName: import.meta.url,
1163
+ lineNumber: 904,
1164
+ columnNumber: 13
1165
+ }), _$createComponent(py.VariableDeclaration, {
1166
+ name: "name_and_type",
1167
+ type: "int"
1168
+ }, {
1169
+ fileName: import.meta.url,
1170
+ lineNumber: 905,
1171
+ columnNumber: 13
1172
+ }), _$createComponent(py.VariableDeclaration, {
1173
+ name: "name_type_and_value",
1174
+ type: "int",
1175
+ initializer: 12
1176
+ }, {
1177
+ fileName: import.meta.url,
1178
+ lineNumber: 906,
1179
+ columnNumber: 13
1180
+ })];
1181
+ }
1037
1182
  }, {
1038
1183
  fileName: import.meta.url,
1039
- lineNumber: 934,
1040
- columnNumber: 13
1041
- })];
1184
+ lineNumber: 903,
1185
+ columnNumber: 11
1186
+ });
1042
1187
  }
1043
1188
  }, {
1044
1189
  fileName: import.meta.url,
1045
- lineNumber: 931,
1046
- columnNumber: 11
1190
+ lineNumber: 902,
1191
+ columnNumber: 9
1047
1192
  });
1048
1193
  }
1049
1194
  }, {
1050
1195
  fileName: import.meta.url,
1051
- lineNumber: 930,
1052
- columnNumber: 9
1053
- })], {
1054
- printOptions: {
1055
- printWidth: 80,
1056
- tabWidth: 4
1057
- }
1058
- });
1059
- expect(res).toRenderTo(d`
1196
+ lineNumber: 901,
1197
+ columnNumber: 7
1198
+ })).toRenderTo(`
1060
1199
  class A:
1061
1200
  """
1062
1201
  This is an example of a long docstring that will be broken in lines. We will
@@ -1077,7 +1216,7 @@ describe("Full example", () => {
1077
1216
  nickname, or even a codename (e.g., 'Agent X'). It's used primarily
1078
1217
  for display purposes, logging, or greeting messages and is not
1079
1218
  required to be unique or validated unless specified by the caller.
1080
- Defaults to \"John Doe\".
1219
+ Defaults to "John Doe".
1081
1220
 
1082
1221
  somebody2 (str): Somebody's name. This can be any string representing a
1083
1222
  person, whether it's a first name, full name, nickname, or even a
@@ -1106,7 +1245,6 @@ describe("Full example", () => {
1106
1245
  name_and_type: int = None
1107
1246
  name_type_and_value: int = 12
1108
1247
 
1109
-
1110
1248
  `);
1111
1249
  });
1112
1250
  it("renders correctly in a Function", () => {
@@ -1116,13 +1254,13 @@ describe("Full example", () => {
1116
1254
  children: "This is an example of a long docstring that will be broken in lines. We will also render another paragraph after this one."
1117
1255
  }, {
1118
1256
  fileName: import.meta.url,
1119
- lineNumber: 1005,
1257
+ lineNumber: 973,
1120
1258
  columnNumber: 11
1121
1259
  }), _$createComponent(py.PyDocExample, {
1122
1260
  children: `print("Hello world!")\nx = "Hello"\nprint(x)`
1123
1261
  }, {
1124
1262
  fileName: import.meta.url,
1125
- lineNumber: 1009,
1263
+ lineNumber: 977,
1126
1264
  columnNumber: 11
1127
1265
  })];
1128
1266
  },
@@ -1143,55 +1281,57 @@ describe("Full example", () => {
1143
1281
  style: "google"
1144
1282
  }, {
1145
1283
  fileName: import.meta.url,
1146
- lineNumber: 1003,
1284
+ lineNumber: 971,
1147
1285
  columnNumber: 7
1148
1286
  });
1149
- const res = toSourceText([_$createComponent(py.FunctionDeclaration, {
1150
- name: "some_function",
1151
- doc: doc,
1287
+ expect(_$createComponent(TestOutput, {
1152
1288
  get children() {
1153
- return _$createComponent(py.StatementList, {
1289
+ return _$createComponent(py.FunctionDeclaration, {
1290
+ name: "some_function",
1291
+ doc: doc,
1154
1292
  get children() {
1155
- return [_$createComponent(py.VariableDeclaration, {
1156
- name: "just_name"
1157
- }, {
1158
- fileName: import.meta.url,
1159
- lineNumber: 1037,
1160
- columnNumber: 13
1161
- }), _$createComponent(py.VariableDeclaration, {
1162
- name: "name_and_type",
1163
- type: "number"
1164
- }, {
1165
- fileName: import.meta.url,
1166
- lineNumber: 1038,
1167
- columnNumber: 13
1168
- }), _$createComponent(py.VariableDeclaration, {
1169
- name: "name_type_and_value",
1170
- type: "number",
1171
- initializer: 12
1293
+ return _$createComponent(py.StatementList, {
1294
+ get children() {
1295
+ return [_$createComponent(py.VariableDeclaration, {
1296
+ name: "just_name"
1297
+ }, {
1298
+ fileName: import.meta.url,
1299
+ lineNumber: 1006,
1300
+ columnNumber: 13
1301
+ }), _$createComponent(py.VariableDeclaration, {
1302
+ name: "name_and_type",
1303
+ type: "number"
1304
+ }, {
1305
+ fileName: import.meta.url,
1306
+ lineNumber: 1007,
1307
+ columnNumber: 13
1308
+ }), _$createComponent(py.VariableDeclaration, {
1309
+ name: "name_type_and_value",
1310
+ type: "number",
1311
+ initializer: 12
1312
+ }, {
1313
+ fileName: import.meta.url,
1314
+ lineNumber: 1008,
1315
+ columnNumber: 13
1316
+ })];
1317
+ }
1172
1318
  }, {
1173
1319
  fileName: import.meta.url,
1174
- lineNumber: 1039,
1175
- columnNumber: 13
1176
- })];
1320
+ lineNumber: 1005,
1321
+ columnNumber: 11
1322
+ });
1177
1323
  }
1178
1324
  }, {
1179
1325
  fileName: import.meta.url,
1180
- lineNumber: 1036,
1181
- columnNumber: 11
1326
+ lineNumber: 1004,
1327
+ columnNumber: 9
1182
1328
  });
1183
1329
  }
1184
1330
  }, {
1185
1331
  fileName: import.meta.url,
1186
- lineNumber: 1035,
1187
- columnNumber: 9
1188
- })], {
1189
- printOptions: {
1190
- printWidth: 80,
1191
- tabWidth: 4
1192
- }
1193
- });
1194
- expect(res).toRenderTo(d`
1332
+ lineNumber: 1003,
1333
+ columnNumber: 7
1334
+ })).toRenderTo(`
1195
1335
  def some_function():
1196
1336
  """
1197
1337
  This is an example of a long docstring that will be broken in lines. We will
@@ -1207,7 +1347,7 @@ describe("Full example", () => {
1207
1347
  nickname, or even a codename (e.g., 'Agent X'). It's used primarily
1208
1348
  for display purposes, logging, or greeting messages and is not
1209
1349
  required to be unique or validated unless specified by the caller.
1210
- Defaults to \"John Doe\".
1350
+ Defaults to "John Doe".
1211
1351
 
1212
1352
  somebody2 (str): Somebody's name. This can be any string representing a
1213
1353
  person, whether it's a first name, full name, nickname, or even a
@@ -1231,25 +1371,26 @@ describe("Full example", () => {
1231
1371
  name_and_type: number = None
1232
1372
  name_type_and_value: number = 12
1233
1373
 
1234
-
1235
1374
  `);
1236
1375
  });
1237
1376
  it("renders correctly in a Variable", () => {
1238
- const res = toSourceText([_$createComponent(py.VariableDeclaration, {
1239
- name: "myVar",
1240
- initializer: 42,
1241
- doc: "This is a very long docstring that will be broken in two lines when rendered. This part of the docstring will be in the second line."
1377
+ expect(_$createComponent(TestOutput, {
1378
+ get children() {
1379
+ return _$createComponent(py.VariableDeclaration, {
1380
+ name: "myVar",
1381
+ initializer: 42,
1382
+ doc: "This is a very long docstring that will be broken in two lines when rendered. This part of the docstring will be in the second line."
1383
+ }, {
1384
+ fileName: import.meta.url,
1385
+ lineNumber: 1064,
1386
+ columnNumber: 9
1387
+ });
1388
+ }
1242
1389
  }, {
1243
1390
  fileName: import.meta.url,
1244
- lineNumber: 1099,
1245
- columnNumber: 9
1246
- })], {
1247
- printOptions: {
1248
- printWidth: 80,
1249
- tabWidth: 4
1250
- }
1251
- });
1252
- expect(res).toRenderTo(d`
1391
+ lineNumber: 1063,
1392
+ columnNumber: 7
1393
+ })).toRenderTo(`
1253
1394
  # This is a very long docstring that will be broken in two lines when rendered.
1254
1395
  # This part of the docstring will be in the second line.
1255
1396
  my_var = 42
@@ -1262,40 +1403,46 @@ describe("Full example", () => {
1262
1403
  children: "An enum representing colors."
1263
1404
  }, {
1264
1405
  fileName: import.meta.url,
1265
- lineNumber: 1120,
1406
+ lineNumber: 1082,
1266
1407
  columnNumber: 23
1267
1408
  })];
1268
1409
  }
1269
1410
  }, {
1270
1411
  fileName: import.meta.url,
1271
- lineNumber: 1119,
1412
+ lineNumber: 1081,
1272
1413
  columnNumber: 7
1273
1414
  });
1274
- const result = toSourceText([_$createComponent(py.ClassEnumDeclaration, {
1275
- name: "Color",
1276
- baseType: "IntEnum",
1277
- members: [{
1278
- name: "RED",
1279
- value: "1",
1280
- doc: "The color red."
1281
- }, {
1282
- name: "GREEN",
1283
- value: "2",
1284
- doc: "The color green."
1285
- }, {
1286
- name: "BLUE",
1287
- value: "3",
1288
- doc: "The color blue."
1289
- }],
1290
- doc: doc
1415
+ expect(_$createComponent(TestOutput, {
1416
+ externals: [enumModule],
1417
+ get children() {
1418
+ return _$createComponent(py.ClassEnumDeclaration, {
1419
+ name: "Color",
1420
+ baseType: "IntEnum",
1421
+ members: [{
1422
+ name: "RED",
1423
+ value: "1",
1424
+ doc: "The color red."
1425
+ }, {
1426
+ name: "GREEN",
1427
+ value: "2",
1428
+ doc: "The color green."
1429
+ }, {
1430
+ name: "BLUE",
1431
+ value: "3",
1432
+ doc: "The color blue."
1433
+ }],
1434
+ doc: doc
1435
+ }, {
1436
+ fileName: import.meta.url,
1437
+ lineNumber: 1087,
1438
+ columnNumber: 9
1439
+ });
1440
+ }
1291
1441
  }, {
1292
1442
  fileName: import.meta.url,
1293
- lineNumber: 1125,
1294
- columnNumber: 9
1295
- })], {
1296
- externals: [enumModule]
1297
- });
1298
- const expected = d`
1443
+ lineNumber: 1086,
1444
+ columnNumber: 7
1445
+ })).toRenderTo(`
1299
1446
  from enum import IntEnum
1300
1447
 
1301
1448
 
@@ -1317,9 +1464,7 @@ describe("Full example", () => {
1317
1464
  The color blue.
1318
1465
  """
1319
1466
 
1320
-
1321
- `;
1322
- expect(result).toRenderTo(expected);
1467
+ `);
1323
1468
  });
1324
1469
  it("ModuleDoc with SourceFile integration", () => {
1325
1470
  const moduleDoc = _$createComponent(py.ModuleDoc, {
@@ -1328,7 +1473,7 @@ describe("Full example", () => {
1328
1473
  children: "This module provides utility functions for data processing. It includes functions for validation, transformation, and analysis."
1329
1474
  }, {
1330
1475
  fileName: import.meta.url,
1331
- lineNumber: 1169,
1476
+ lineNumber: 1129,
1332
1477
  columnNumber: 11
1333
1478
  })];
1334
1479
  },
@@ -1345,69 +1490,72 @@ describe("Full example", () => {
1345
1490
  style: "google"
1346
1491
  }, {
1347
1492
  fileName: import.meta.url,
1348
- lineNumber: 1167,
1493
+ lineNumber: 1127,
1349
1494
  columnNumber: 7
1350
1495
  });
1351
- const content = _$createComponent(py.SourceFile, {
1352
- path: "utils.py",
1353
- doc: moduleDoc,
1496
+ expect(_$createComponent(TestOutputDirectory, {
1354
1497
  get children() {
1355
- return [_$createComponent(py.VariableDeclaration, {
1356
- name: "DEFAULT_TIMEOUT",
1357
- initializer: 30
1358
- }, {
1359
- fileName: import.meta.url,
1360
- lineNumber: 1193,
1361
- columnNumber: 9
1362
- }), _$createComponent(py.VariableDeclaration, {
1363
- name: "MAX_RETRIES",
1364
- initializer: 3
1365
- }, {
1366
- fileName: import.meta.url,
1367
- lineNumber: 1194,
1368
- columnNumber: 9
1369
- }), _$createComponent(py.FunctionDeclaration, {
1370
- name: "process_data",
1371
- children: "pass"
1498
+ return _$createComponent(py.SourceFile, {
1499
+ path: "utils.py",
1500
+ doc: moduleDoc,
1501
+ get children() {
1502
+ return [_$createComponent(py.VariableDeclaration, {
1503
+ name: "DEFAULT_TIMEOUT",
1504
+ initializer: 30
1505
+ }, {
1506
+ fileName: import.meta.url,
1507
+ lineNumber: 1154,
1508
+ columnNumber: 11
1509
+ }), _$createComponent(py.VariableDeclaration, {
1510
+ name: "MAX_RETRIES",
1511
+ initializer: 3
1512
+ }, {
1513
+ fileName: import.meta.url,
1514
+ lineNumber: 1155,
1515
+ columnNumber: 11
1516
+ }), _$createComponent(py.FunctionDeclaration, {
1517
+ name: "process_data",
1518
+ children: "pass"
1519
+ }, {
1520
+ fileName: import.meta.url,
1521
+ lineNumber: 1156,
1522
+ columnNumber: 11
1523
+ })];
1524
+ }
1372
1525
  }, {
1373
1526
  fileName: import.meta.url,
1374
- lineNumber: 1195,
1527
+ lineNumber: 1153,
1375
1528
  columnNumber: 9
1376
- })];
1529
+ });
1377
1530
  }
1378
1531
  }, {
1379
1532
  fileName: import.meta.url,
1380
- lineNumber: 1192,
1533
+ lineNumber: 1152,
1381
1534
  columnNumber: 7
1382
- });
1383
- const res = toSourceTextMultiple([content]);
1384
- const file = res.contents.find(f => f.kind === "file" && f.path === "utils.py");
1385
- expect(file).toBeDefined();
1386
- assertFileContents(res, {
1387
- "utils.py": d`
1388
- """
1389
- This module provides utility functions for data processing. It includes
1390
- functions for validation, transformation, and analysis.
1391
-
1392
- Attributes:
1393
- DEFAULT_TIMEOUT (int): Default timeout value in seconds.
1535
+ })).toRenderTo({
1536
+ "utils.py": `
1537
+ """
1538
+ This module provides utility functions for data processing. It includes
1539
+ functions for validation, transformation, and analysis.
1394
1540
 
1395
- MAX_RETRIES (int): Maximum number of retry attempts.
1541
+ Attributes:
1542
+ DEFAULT_TIMEOUT (int): Default timeout value in seconds.
1396
1543
 
1397
- Todo:
1398
- * Add caching functionality
1399
- * Improve error messages
1400
- """
1544
+ MAX_RETRIES (int): Maximum number of retry attempts.
1401
1545
 
1402
- default_timeout = 30
1546
+ Todo:
1547
+ * Add caching functionality
1548
+ * Improve error messages
1549
+ """
1403
1550
 
1404
- max_retries = 3
1551
+ default_timeout = 30
1405
1552
 
1406
- def process_data():
1407
- pass
1553
+ max_retries = 3
1408
1554
 
1555
+ def process_data():
1556
+ pass
1409
1557
 
1410
- `
1558
+ `
1411
1559
  });
1412
1560
  });
1413
1561
  it("GeneratorDoc with FunctionDeclaration integration", () => {
@@ -1417,7 +1565,7 @@ describe("Full example", () => {
1417
1565
  children: "A generator function that yields fibonacci numbers. This is an efficient way to generate the sequence on demand."
1418
1566
  }, {
1419
1567
  fileName: import.meta.url,
1420
- lineNumber: 1239,
1568
+ lineNumber: 1192,
1421
1569
  columnNumber: 11
1422
1570
  })];
1423
1571
  },
@@ -1430,19 +1578,26 @@ describe("Full example", () => {
1430
1578
  style: "google"
1431
1579
  }, {
1432
1580
  fileName: import.meta.url,
1433
- lineNumber: 1237,
1581
+ lineNumber: 1190,
1434
1582
  columnNumber: 7
1435
1583
  });
1436
- const result = toSourceText([_$createComponent(py.FunctionDeclaration, {
1437
- name: "fibonacci_generator",
1438
- doc: generatorDoc,
1439
- children: "yield 0"
1584
+ expect(_$createComponent(TestOutput, {
1585
+ get children() {
1586
+ return _$createComponent(py.FunctionDeclaration, {
1587
+ name: "fibonacci_generator",
1588
+ doc: generatorDoc,
1589
+ children: "yield 0"
1590
+ }, {
1591
+ fileName: import.meta.url,
1592
+ lineNumber: 1211,
1593
+ columnNumber: 9
1594
+ });
1595
+ }
1440
1596
  }, {
1441
1597
  fileName: import.meta.url,
1442
- lineNumber: 1257,
1598
+ lineNumber: 1210,
1443
1599
  columnNumber: 7
1444
- })]);
1445
- expect(result).toRenderTo(d`
1600
+ })).toRenderTo(`
1446
1601
  def fibonacci_generator():
1447
1602
  """
1448
1603
  A generator function that yields fibonacci numbers. This is an efficient way
@@ -1456,7 +1611,6 @@ describe("Full example", () => {
1456
1611
  """
1457
1612
  yield 0
1458
1613
 
1459
-
1460
1614
  `);
1461
1615
  });
1462
1616
  it("ExceptionDoc with ClassDeclaration integration", () => {
@@ -1466,7 +1620,7 @@ describe("Full example", () => {
1466
1620
  children: "Custom exception raised when data validation fails. This exception includes details about the validation error."
1467
1621
  }, {
1468
1622
  fileName: import.meta.url,
1469
- lineNumber: 1286,
1623
+ lineNumber: 1238,
1470
1624
  columnNumber: 11
1471
1625
  })];
1472
1626
  },
@@ -1482,44 +1636,51 @@ describe("Full example", () => {
1482
1636
  style: "google"
1483
1637
  }, {
1484
1638
  fileName: import.meta.url,
1485
- lineNumber: 1284,
1639
+ lineNumber: 1236,
1486
1640
  columnNumber: 7
1487
1641
  });
1488
- const result = toSourceText([_$createComponent(py.ClassDeclaration, {
1489
- name: "ValidationError",
1490
- bases: ["Exception"],
1491
- doc: exceptionDoc,
1642
+ expect(_$createComponent(TestOutput, {
1492
1643
  get children() {
1493
- return _$createComponent(py.StatementList, {
1644
+ return _$createComponent(py.ClassDeclaration, {
1645
+ name: "ValidationError",
1646
+ bases: ["Exception"],
1647
+ doc: exceptionDoc,
1494
1648
  get children() {
1495
- return [_$createComponent(py.VariableDeclaration, {
1496
- name: "field_name",
1497
- type: "str"
1498
- }, {
1499
- fileName: import.meta.url,
1500
- lineNumber: 1314,
1501
- columnNumber: 11
1502
- }), _$createComponent(py.VariableDeclaration, {
1503
- name: "error_code",
1504
- type: "int"
1649
+ return _$createComponent(py.StatementList, {
1650
+ get children() {
1651
+ return [_$createComponent(py.VariableDeclaration, {
1652
+ name: "field_name",
1653
+ type: "str"
1654
+ }, {
1655
+ fileName: import.meta.url,
1656
+ lineNumber: 1267,
1657
+ columnNumber: 13
1658
+ }), _$createComponent(py.VariableDeclaration, {
1659
+ name: "error_code",
1660
+ type: "int"
1661
+ }, {
1662
+ fileName: import.meta.url,
1663
+ lineNumber: 1268,
1664
+ columnNumber: 13
1665
+ })];
1666
+ }
1505
1667
  }, {
1506
1668
  fileName: import.meta.url,
1507
- lineNumber: 1315,
1669
+ lineNumber: 1266,
1508
1670
  columnNumber: 11
1509
- })];
1671
+ });
1510
1672
  }
1511
1673
  }, {
1512
1674
  fileName: import.meta.url,
1513
- lineNumber: 1313,
1675
+ lineNumber: 1261,
1514
1676
  columnNumber: 9
1515
1677
  });
1516
1678
  }
1517
1679
  }, {
1518
1680
  fileName: import.meta.url,
1519
- lineNumber: 1308,
1681
+ lineNumber: 1260,
1520
1682
  columnNumber: 7
1521
- })]);
1522
- expect(result).toRenderTo(d`
1683
+ })).toRenderTo(`
1523
1684
  class ValidationError(Exception):
1524
1685
  """
1525
1686
  Custom exception raised when data validation fails. This exception includes
@@ -1534,7 +1695,6 @@ describe("Full example", () => {
1534
1695
  field_name: str = None
1535
1696
  error_code: int = None
1536
1697
 
1537
-
1538
1698
  `);
1539
1699
  });
1540
1700
  it("PropertyDoc with FunctionDeclaration (as property method) integration", () => {
@@ -1544,36 +1704,43 @@ describe("Full example", () => {
1544
1704
  children: "The full name of the person, combining first and last name. This property automatically formats the name with proper capitalization."
1545
1705
  }, {
1546
1706
  fileName: import.meta.url,
1547
- lineNumber: 1345,
1707
+ lineNumber: 1296,
1548
1708
  columnNumber: 11
1549
1709
  })];
1550
1710
  },
1551
1711
  style: "google"
1552
1712
  }, {
1553
1713
  fileName: import.meta.url,
1554
- lineNumber: 1343,
1714
+ lineNumber: 1294,
1555
1715
  columnNumber: 7
1556
1716
  });
1557
- const result = toSourceText([_$createComponent(py.ClassDeclaration, {
1558
- name: "Person",
1717
+ expect(_$createComponent(TestOutput, {
1559
1718
  get children() {
1560
- return _$createComponent(py.PropertyDeclaration, {
1561
- name: "full_name",
1562
- doc: propertyDoc,
1563
- type: "str",
1564
- children: "return \"John Doe\""
1719
+ return _$createComponent(py.ClassDeclaration, {
1720
+ name: "Person",
1721
+ get children() {
1722
+ return _$createComponent(py.PropertyDeclaration, {
1723
+ name: "full_name",
1724
+ doc: propertyDoc,
1725
+ type: "str",
1726
+ children: "return \"John Doe\""
1727
+ }, {
1728
+ fileName: import.meta.url,
1729
+ lineNumber: 1308,
1730
+ columnNumber: 11
1731
+ });
1732
+ }
1565
1733
  }, {
1566
1734
  fileName: import.meta.url,
1567
- lineNumber: 1356,
1735
+ lineNumber: 1307,
1568
1736
  columnNumber: 9
1569
1737
  });
1570
1738
  }
1571
1739
  }, {
1572
1740
  fileName: import.meta.url,
1573
- lineNumber: 1355,
1741
+ lineNumber: 1306,
1574
1742
  columnNumber: 7
1575
- })]);
1576
- expect(result).toRenderTo(`
1743
+ })).toRenderTo(`
1577
1744
  class Person:
1578
1745
  @property
1579
1746
  def full_name(self) -> str:
@@ -1593,7 +1760,7 @@ describe("Full example", () => {
1593
1760
  children: "Validates the input data according to the defined schema. This method performs comprehensive validation including type checking."
1594
1761
  }, {
1595
1762
  fileName: import.meta.url,
1596
- lineNumber: 1380,
1763
+ lineNumber: 1333,
1597
1764
  columnNumber: 11
1598
1765
  })];
1599
1766
  },
@@ -1613,37 +1780,44 @@ describe("Full example", () => {
1613
1780
  style: "google"
1614
1781
  }, {
1615
1782
  fileName: import.meta.url,
1616
- lineNumber: 1378,
1783
+ lineNumber: 1331,
1617
1784
  columnNumber: 7
1618
1785
  });
1619
- const result = toSourceText([_$createComponent(py.ClassDeclaration, {
1620
- name: "DataValidator",
1786
+ expect(_$createComponent(TestOutput, {
1621
1787
  get children() {
1622
- return _$createComponent(py.MethodDeclaration, {
1623
- name: "validate",
1624
- doc: methodDoc,
1625
- parameters: [{
1626
- name: "data",
1627
- type: "dict"
1628
- }, {
1629
- name: "strict",
1630
- type: "bool",
1631
- default: true
1632
- }],
1633
- returnType: "bool",
1634
- children: "return self.validate(data, strict)"
1788
+ return _$createComponent(py.ClassDeclaration, {
1789
+ name: "DataValidator",
1790
+ get children() {
1791
+ return _$createComponent(py.MethodDeclaration, {
1792
+ name: "validate",
1793
+ doc: methodDoc,
1794
+ parameters: [{
1795
+ name: "data",
1796
+ type: "dict"
1797
+ }, {
1798
+ name: "strict",
1799
+ type: "bool",
1800
+ default: true
1801
+ }],
1802
+ returnType: "bool",
1803
+ children: "return self.validate(data, strict)"
1804
+ }, {
1805
+ fileName: import.meta.url,
1806
+ lineNumber: 1361,
1807
+ columnNumber: 11
1808
+ });
1809
+ }
1635
1810
  }, {
1636
1811
  fileName: import.meta.url,
1637
- lineNumber: 1407,
1812
+ lineNumber: 1360,
1638
1813
  columnNumber: 9
1639
1814
  });
1640
1815
  }
1641
1816
  }, {
1642
1817
  fileName: import.meta.url,
1643
- lineNumber: 1406,
1818
+ lineNumber: 1359,
1644
1819
  columnNumber: 7
1645
- })]);
1646
- expect(result).toRenderTo(d`
1820
+ })).toRenderTo(`
1647
1821
  class DataValidator:
1648
1822
  def validate(self, data: dict, strict: bool = True) -> bool:
1649
1823
  """
@@ -1668,7 +1842,6 @@ describe("Full example", () => {
1668
1842
  return self.validate(data, strict)
1669
1843
 
1670
1844
 
1671
-
1672
1845
  `);
1673
1846
  });
1674
1847
  });