@alloy-js/python 0.5.0-dev.1 → 0.5.0-dev.2
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.
- package/dist/dev/src/components/SourceFile.js +44 -32
- package/dist/dev/src/components/SourceFile.js.map +1 -1
- package/dist/dev/test/callsignatures.test.js +471 -297
- package/dist/dev/test/callsignatures.test.js.map +1 -1
- package/dist/dev/test/class-method-declaration.test.js +21 -10
- package/dist/dev/test/class-method-declaration.test.js.map +1 -1
- package/dist/dev/test/classdeclarations.test.js +459 -393
- package/dist/dev/test/classdeclarations.test.js.map +1 -1
- package/dist/dev/test/classinstantiations.test.js +201 -168
- package/dist/dev/test/classinstantiations.test.js.map +1 -1
- package/dist/dev/test/constructordeclaration.test.js +22 -11
- package/dist/dev/test/constructordeclaration.test.js.map +1 -1
- package/dist/dev/test/dataclassdeclarations.test.js +322 -368
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/decoratorlist.test.js +96 -49
- package/dist/dev/test/decoratorlist.test.js.map +1 -1
- package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
- package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/enums.test.js +218 -184
- package/dist/dev/test/enums.test.js.map +1 -1
- package/dist/dev/test/externals.test.js +57 -45
- package/dist/dev/test/externals.test.js.map +1 -1
- package/dist/dev/test/factories.test.js +124 -50
- package/dist/dev/test/factories.test.js.map +1 -1
- package/dist/dev/test/functioncallexpressions.test.js +199 -164
- package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
- package/dist/dev/test/functiondeclaration.test.js +439 -272
- package/dist/dev/test/functiondeclaration.test.js.map +1 -1
- package/dist/dev/test/imports.test.js +273 -221
- package/dist/dev/test/imports.test.js.map +1 -1
- package/dist/dev/test/memberexpressions.test.js +1237 -972
- package/dist/dev/test/memberexpressions.test.js.map +1 -1
- package/dist/dev/test/methoddeclaration.test.js +142 -78
- package/dist/dev/test/methoddeclaration.test.js.map +1 -1
- package/dist/dev/test/namepolicies.test.js +130 -94
- package/dist/dev/test/namepolicies.test.js.map +1 -1
- package/dist/dev/test/propertydeclaration.test.js +88 -59
- package/dist/dev/test/propertydeclaration.test.js.map +1 -1
- package/dist/dev/test/pydanticclassdeclarations.test.js +299 -347
- package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/pydocs.test.js +888 -715
- package/dist/dev/test/pydocs.test.js.map +1 -1
- package/dist/dev/test/references.test.js +42 -35
- package/dist/dev/test/references.test.js.map +1 -1
- package/dist/dev/test/sourcefiles.test.js +1109 -841
- package/dist/dev/test/sourcefiles.test.js.map +1 -1
- package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
- package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/type-checking-imports.test.js +408 -359
- package/dist/dev/test/type-checking-imports.test.js.map +1 -1
- package/dist/dev/test/typereference.test.js +55 -40
- package/dist/dev/test/typereference.test.js.map +1 -1
- package/dist/dev/test/uniontypeexpression.test.js +222 -146
- package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
- package/dist/dev/test/utils.js +39 -77
- package/dist/dev/test/utils.js.map +1 -1
- package/dist/dev/test/values.test.js +237 -101
- package/dist/dev/test/values.test.js.map +1 -1
- package/dist/dev/test/variables.test.js +321 -203
- package/dist/dev/test/variables.test.js.map +1 -1
- package/dist/dev/test/vitest.setup.js +2 -0
- package/dist/dev/test/vitest.setup.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +2 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +12 -0
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/test/callsignatures.test.js +346 -272
- package/dist/test/callsignatures.test.js.map +1 -1
- package/dist/test/class-method-declaration.test.js +7 -4
- package/dist/test/class-method-declaration.test.js.map +1 -1
- package/dist/test/classdeclarations.test.js +302 -288
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/classinstantiations.test.js +112 -103
- package/dist/test/classinstantiations.test.js.map +1 -1
- package/dist/test/constructordeclaration.test.js +7 -4
- package/dist/test/constructordeclaration.test.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +134 -184
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/decoratorlist.test.js +59 -36
- package/dist/test/decoratorlist.test.js.map +1 -1
- package/dist/test/dundermethoddeclaration.test.js +7 -4
- package/dist/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/test/enums.test.js +161 -159
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/externals.test.js +24 -24
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/factories.test.js +75 -33
- package/dist/test/factories.test.js.map +1 -1
- package/dist/test/functioncallexpressions.test.js +117 -106
- package/dist/test/functioncallexpressions.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +247 -180
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/imports.test.js +171 -143
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/memberexpressions.test.js +582 -453
- package/dist/test/memberexpressions.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.js +66 -46
- package/dist/test/methoddeclaration.test.js.map +1 -1
- package/dist/test/namepolicies.test.js +90 -78
- package/dist/test/namepolicies.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.js +25 -20
- package/dist/test/propertydeclaration.test.js.map +1 -1
- package/dist/test/pydanticclassdeclarations.test.js +134 -190
- package/dist/test/pydanticclassdeclarations.test.js.map +1 -1
- package/dist/test/pydocs.test.js +573 -532
- package/dist/test/pydocs.test.js.map +1 -1
- package/dist/test/references.test.js +31 -28
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +700 -580
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/staticmethoddeclaration.test.js +7 -4
- package/dist/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/test/type-checking-imports.test.js +297 -284
- package/dist/test/type-checking-imports.test.js.map +1 -1
- package/dist/test/typereference.test.js +29 -22
- package/dist/test/typereference.test.js.map +1 -1
- package/dist/test/uniontypeexpression.test.js +124 -88
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/utils.d.ts +10 -17
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +32 -74
- package/dist/test/utils.js.map +1 -1
- package/dist/test/values.test.js +135 -67
- package/dist/test/values.test.js.map +1 -1
- package/dist/test/variables.test.js +201 -151
- package/dist/test/variables.test.js.map +1 -1
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/SourceFile.md +20 -8
- package/package.json +2 -2
- package/src/components/SourceFile.tsx +6 -1
- package/temp/api.json +16 -2
- package/test/callsignatures.test.tsx +309 -283
- package/test/class-method-declaration.test.tsx +3 -4
- package/test/classdeclarations.test.tsx +263 -248
- package/test/classinstantiations.test.tsx +115 -109
- package/test/constructordeclaration.test.tsx +9 -6
- package/test/dataclassdeclarations.test.tsx +243 -361
- package/test/decoratorlist.test.tsx +78 -59
- package/test/dundermethoddeclaration.test.tsx +3 -4
- package/test/enums.test.tsx +65 -81
- package/test/externals.test.tsx +25 -25
- package/test/factories.test.tsx +64 -22
- package/test/functioncallexpressions.test.tsx +123 -109
- package/test/functiondeclaration.test.tsx +209 -148
- package/test/imports.test.tsx +119 -91
- package/test/memberexpressions.test.tsx +265 -207
- package/test/methoddeclaration.test.tsx +84 -63
- package/test/namepolicies.test.tsx +69 -69
- package/test/propertydeclaration.test.tsx +7 -8
- package/test/pydanticclassdeclarations.test.tsx +355 -487
- package/test/pydocs.test.tsx +531 -579
- package/test/references.test.tsx +24 -23
- package/test/sourcefiles.test.tsx +527 -492
- package/test/staticmethoddeclaration.test.tsx +3 -4
- package/test/type-checking-imports.test.tsx +206 -218
- package/test/typereference.test.tsx +15 -12
- package/test/uniontypeexpression.test.tsx +74 -61
- package/test/utils.tsx +26 -110
- package/test/values.test.tsx +82 -32
- package/test/variables.test.tsx +162 -142
- package/test/vitest.setup.ts +1 -0
- package/vitest.config.ts +3 -0
package/test/pydocs.test.tsx
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { Prose } from "@alloy-js/core";
|
|
2
|
-
import { d } from "@alloy-js/core/testing";
|
|
3
2
|
import { describe, expect, it } from "vitest";
|
|
4
3
|
import { enumModule } from "../src/builtins/python.js";
|
|
5
4
|
import * as py from "../src/index.js";
|
|
6
|
-
import {
|
|
7
|
-
assertFileContents,
|
|
8
|
-
toSourceText,
|
|
9
|
-
toSourceTextMultiple,
|
|
10
|
-
} from "./utils.jsx";
|
|
5
|
+
import { TestOutput, TestOutputDirectory } from "./utils.jsx";
|
|
11
6
|
|
|
12
7
|
describe("PyDoc", () => {
|
|
13
8
|
it("formats properly", () => {
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
expect(
|
|
10
|
+
<TestOutput>
|
|
16
11
|
<py.PyDoc>
|
|
17
12
|
<Prose>
|
|
18
13
|
This is an example of a long docstring that will be broken in lines.
|
|
@@ -21,13 +16,10 @@ describe("PyDoc", () => {
|
|
|
21
16
|
<Prose>
|
|
22
17
|
This is another paragraph, and there's a line break before it.
|
|
23
18
|
</Prose>
|
|
24
|
-
</py.PyDoc
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
expect(res).toRenderTo(
|
|
30
|
-
d`
|
|
19
|
+
</py.PyDoc>
|
|
20
|
+
</TestOutput>,
|
|
21
|
+
).toRenderTo(
|
|
22
|
+
`
|
|
31
23
|
"""
|
|
32
24
|
This is an example of a long docstring
|
|
33
25
|
that will be broken in lines. We will
|
|
@@ -38,26 +30,23 @@ describe("PyDoc", () => {
|
|
|
38
30
|
line break before it.
|
|
39
31
|
"""
|
|
40
32
|
|
|
41
|
-
|
|
42
33
|
`,
|
|
34
|
+
{ tabWidth: 4, printWidth: 40 },
|
|
43
35
|
);
|
|
44
36
|
});
|
|
45
37
|
});
|
|
46
38
|
|
|
47
39
|
describe("PyDocExample", () => {
|
|
48
40
|
it("creates docstring with a code sample", () => {
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
expect(
|
|
42
|
+
<TestOutput>
|
|
51
43
|
<py.PyDoc>
|
|
52
44
|
<Prose>This is an example of a docstring with a code sample.</Prose>
|
|
53
45
|
<py.PyDocExample>print("Hello world!")</py.PyDocExample>
|
|
54
|
-
</py.PyDoc
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
expect(res).toRenderTo(
|
|
60
|
-
d`
|
|
46
|
+
</py.PyDoc>
|
|
47
|
+
</TestOutput>,
|
|
48
|
+
).toRenderTo(
|
|
49
|
+
`
|
|
61
50
|
"""
|
|
62
51
|
This is an example of a docstring with a
|
|
63
52
|
code sample.
|
|
@@ -65,25 +54,22 @@ describe("PyDocExample", () => {
|
|
|
65
54
|
>> print("Hello world!")
|
|
66
55
|
"""
|
|
67
56
|
|
|
68
|
-
|
|
69
57
|
`,
|
|
58
|
+
{ tabWidth: 4, printWidth: 40 },
|
|
70
59
|
);
|
|
71
60
|
});
|
|
72
61
|
|
|
73
62
|
it("creates docstring with more than one code sample", () => {
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
expect(
|
|
64
|
+
<TestOutput>
|
|
76
65
|
<py.PyDoc>
|
|
77
66
|
<Prose>This is an example of a docstring with a code sample.</Prose>
|
|
78
67
|
<py.PyDocExample>print("Hello world!")</py.PyDocExample>
|
|
79
68
|
<py.PyDocExample>print("Hello world again!")</py.PyDocExample>
|
|
80
|
-
</py.PyDoc
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
expect(res).toRenderTo(
|
|
86
|
-
d`
|
|
69
|
+
</py.PyDoc>
|
|
70
|
+
</TestOutput>,
|
|
71
|
+
).toRenderTo(
|
|
72
|
+
`
|
|
87
73
|
"""
|
|
88
74
|
This is an example of a docstring with a
|
|
89
75
|
code sample.
|
|
@@ -93,26 +79,23 @@ describe("PyDocExample", () => {
|
|
|
93
79
|
>> print("Hello world again!")
|
|
94
80
|
"""
|
|
95
81
|
|
|
96
|
-
|
|
97
82
|
`,
|
|
83
|
+
{ tabWidth: 4, printWidth: 40 },
|
|
98
84
|
);
|
|
99
85
|
});
|
|
100
86
|
|
|
101
87
|
it("creates docstring with a multiline code sample", () => {
|
|
102
|
-
|
|
103
|
-
|
|
88
|
+
expect(
|
|
89
|
+
<TestOutput>
|
|
104
90
|
<py.PyDoc>
|
|
105
91
|
<Prose>This is an example of a docstring with a code sample.</Prose>
|
|
106
92
|
<py.PyDocExample>
|
|
107
93
|
{`print("Hello world!")\nx = "Hello"\nprint(x)`}
|
|
108
94
|
</py.PyDocExample>
|
|
109
|
-
</py.PyDoc
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
expect(res).toRenderTo(
|
|
115
|
-
d`
|
|
95
|
+
</py.PyDoc>
|
|
96
|
+
</TestOutput>,
|
|
97
|
+
).toRenderTo(
|
|
98
|
+
`
|
|
116
99
|
"""
|
|
117
100
|
This is an example of a docstring with a
|
|
118
101
|
code sample.
|
|
@@ -122,40 +105,40 @@ describe("PyDocExample", () => {
|
|
|
122
105
|
>> print(x)
|
|
123
106
|
"""
|
|
124
107
|
|
|
125
|
-
|
|
126
108
|
`,
|
|
109
|
+
{ tabWidth: 4, printWidth: 40 },
|
|
127
110
|
);
|
|
128
111
|
});
|
|
129
112
|
});
|
|
130
113
|
|
|
131
114
|
describe("SimpleCommentBlock", () => {
|
|
132
115
|
it("renders simple comment block", () => {
|
|
133
|
-
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
116
|
+
expect(
|
|
117
|
+
<TestOutput>
|
|
118
|
+
<py.SimpleCommentBlock>
|
|
119
|
+
This is a simple comment block that spans multiple lines and should be
|
|
120
|
+
split automatically.
|
|
121
|
+
</py.SimpleCommentBlock>
|
|
122
|
+
</TestOutput>,
|
|
123
|
+
).toRenderTo(
|
|
124
|
+
`
|
|
141
125
|
# This is a simple comment block that spans multiple lines and should be split
|
|
142
126
|
# automatically.
|
|
143
|
-
|
|
144
127
|
`,
|
|
145
128
|
);
|
|
146
129
|
});
|
|
147
130
|
|
|
148
131
|
it("renders comment block with line breaks", () => {
|
|
149
|
-
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
132
|
+
expect(
|
|
133
|
+
<TestOutput>
|
|
134
|
+
<py.SimpleCommentBlock>
|
|
135
|
+
First line of comment.\nSecond line of comment.
|
|
136
|
+
</py.SimpleCommentBlock>
|
|
137
|
+
</TestOutput>,
|
|
138
|
+
).toRenderTo(
|
|
139
|
+
`
|
|
156
140
|
# First line of comment.
|
|
157
141
|
# Second line of comment.
|
|
158
|
-
|
|
159
142
|
`,
|
|
160
143
|
);
|
|
161
144
|
});
|
|
@@ -163,68 +146,66 @@ describe("SimpleCommentBlock", () => {
|
|
|
163
146
|
|
|
164
147
|
describe("SimpleInlineComment", () => {
|
|
165
148
|
it("renders inline comment", () => {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
);
|
|
149
|
+
expect(
|
|
150
|
+
<TestOutput>
|
|
151
|
+
{[
|
|
152
|
+
<>
|
|
153
|
+
x = 42
|
|
154
|
+
<py.SimpleInlineComment>
|
|
155
|
+
This is an inline comment
|
|
156
|
+
</py.SimpleInlineComment>
|
|
157
|
+
</>,
|
|
158
|
+
]}
|
|
159
|
+
</TestOutput>,
|
|
160
|
+
).toRenderTo(`x = 42 # This is an inline comment`);
|
|
179
161
|
});
|
|
180
162
|
|
|
181
163
|
it("renders inline comment with complex text", () => {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
);
|
|
164
|
+
expect(
|
|
165
|
+
<TestOutput>
|
|
166
|
+
{[
|
|
167
|
+
<>
|
|
168
|
+
result = calculate()
|
|
169
|
+
<py.SimpleInlineComment>
|
|
170
|
+
TODO: Add error handling here
|
|
171
|
+
</py.SimpleInlineComment>
|
|
172
|
+
</>,
|
|
173
|
+
]}
|
|
174
|
+
</TestOutput>,
|
|
175
|
+
).toRenderTo(`result = calculate() # TODO: Add error handling here`);
|
|
195
176
|
});
|
|
196
177
|
});
|
|
197
178
|
|
|
198
179
|
describe("New Documentation Components", () => {
|
|
199
180
|
it("ModuleDoc renders correctly", () => {
|
|
200
|
-
|
|
201
|
-
<
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
181
|
+
expect(
|
|
182
|
+
<TestOutput>
|
|
183
|
+
<py.ModuleDoc
|
|
184
|
+
description={[
|
|
185
|
+
<Prose>
|
|
186
|
+
This module demonstrates documentation as specified by the Google
|
|
187
|
+
Python Style Guide.
|
|
188
|
+
</Prose>,
|
|
189
|
+
]}
|
|
190
|
+
attributes={[
|
|
191
|
+
{
|
|
192
|
+
name: "module_level_variable1",
|
|
193
|
+
type: "int",
|
|
194
|
+
children: "Module level variables may be documented.",
|
|
195
|
+
},
|
|
196
|
+
]}
|
|
197
|
+
examples={[<py.PyDocExample>print("mod")</py.PyDocExample>]}
|
|
198
|
+
seeAlso={["another_module.func", "RelatedClass"]}
|
|
199
|
+
warning="Internal API."
|
|
200
|
+
deprecated="Use new_module instead."
|
|
201
|
+
todo={[
|
|
202
|
+
"For module TODOs",
|
|
203
|
+
"You have to also use sphinx.ext.todo extension",
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
</TestOutput>,
|
|
207
|
+
).toRenderTo(
|
|
208
|
+
`
|
|
228
209
|
"""
|
|
229
210
|
This module demonstrates documentation as specified by the Google Python Style
|
|
230
211
|
Guide.
|
|
@@ -250,30 +231,29 @@ describe("New Documentation Components", () => {
|
|
|
250
231
|
* You have to also use sphinx.ext.todo extension
|
|
251
232
|
"""
|
|
252
233
|
|
|
253
|
-
|
|
254
234
|
`,
|
|
255
235
|
);
|
|
256
236
|
});
|
|
257
237
|
|
|
258
238
|
it("PropertyDoc renders correctly", () => {
|
|
259
|
-
|
|
260
|
-
<
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
239
|
+
expect(
|
|
240
|
+
<TestOutput>
|
|
241
|
+
<py.PropertyDoc
|
|
242
|
+
description={[
|
|
243
|
+
<Prose>
|
|
244
|
+
Properties should be documented in their getter method.
|
|
245
|
+
</Prose>,
|
|
246
|
+
]}
|
|
247
|
+
returns="str: The readonly property value."
|
|
248
|
+
examples={[<py.PyDocExample>print(obj.name)</py.PyDocExample>]}
|
|
249
|
+
seeAlso={["other_property"]}
|
|
250
|
+
warning="Access may be slow."
|
|
251
|
+
deprecated="Use full_name instead."
|
|
252
|
+
note="If the setter method contains notable behavior, it should be mentioned here."
|
|
253
|
+
/>
|
|
254
|
+
</TestOutput>,
|
|
255
|
+
).toRenderTo(
|
|
256
|
+
`
|
|
277
257
|
"""
|
|
278
258
|
Properties should be documented in their getter method.
|
|
279
259
|
|
|
@@ -296,37 +276,36 @@ describe("New Documentation Components", () => {
|
|
|
296
276
|
If the setter method contains notable behavior, it should be mentioned here.
|
|
297
277
|
"""
|
|
298
278
|
|
|
299
|
-
|
|
300
279
|
`,
|
|
301
280
|
);
|
|
302
281
|
});
|
|
303
282
|
|
|
304
283
|
it("GeneratorDoc renders correctly", () => {
|
|
305
|
-
|
|
306
|
-
<
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
{
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
284
|
+
expect(
|
|
285
|
+
<TestOutput>
|
|
286
|
+
<py.GeneratorDoc
|
|
287
|
+
description={[
|
|
288
|
+
<Prose>
|
|
289
|
+
Generators have a Yields section instead of a Returns section.
|
|
290
|
+
</Prose>,
|
|
291
|
+
]}
|
|
292
|
+
parameters={[
|
|
293
|
+
{
|
|
294
|
+
name: "n",
|
|
295
|
+
type: "int",
|
|
296
|
+
doc: "The upper limit of the range to generate, from 0 to n - 1.",
|
|
297
|
+
},
|
|
298
|
+
]}
|
|
299
|
+
yields="int: The next number in the range of 0 to n - 1."
|
|
300
|
+
examples={[<py.PyDocExample>print(next(gen))</py.PyDocExample>]}
|
|
301
|
+
seeAlso={["make_generator"]}
|
|
302
|
+
warning="Do not consume in tight loops without sleep."
|
|
303
|
+
deprecated="Use new_generator instead."
|
|
304
|
+
note="Examples should be written in doctest format."
|
|
305
|
+
/>
|
|
306
|
+
</TestOutput>,
|
|
307
|
+
).toRenderTo(
|
|
308
|
+
`
|
|
330
309
|
"""
|
|
331
310
|
Generators have a Yields section instead of a Returns section.
|
|
332
311
|
|
|
@@ -352,50 +331,51 @@ describe("New Documentation Components", () => {
|
|
|
352
331
|
Examples should be written in doctest format.
|
|
353
332
|
"""
|
|
354
333
|
|
|
355
|
-
|
|
356
334
|
`,
|
|
357
335
|
);
|
|
358
336
|
});
|
|
359
337
|
|
|
360
338
|
it("ExceptionDoc renders correctly", () => {
|
|
361
|
-
|
|
362
|
-
<
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
339
|
+
expect(
|
|
340
|
+
<TestOutput>
|
|
341
|
+
<py.ExceptionDoc
|
|
342
|
+
description={[
|
|
343
|
+
<Prose>
|
|
344
|
+
Exceptions are documented in the same way as classes.
|
|
345
|
+
</Prose>,
|
|
346
|
+
]}
|
|
347
|
+
parameters={[
|
|
348
|
+
{
|
|
349
|
+
name: "msg",
|
|
350
|
+
type: "str",
|
|
351
|
+
doc: "Human readable string describing the exception.",
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: "code",
|
|
355
|
+
type: "int",
|
|
356
|
+
default: undefined,
|
|
357
|
+
doc: "Error code.",
|
|
358
|
+
},
|
|
359
|
+
]}
|
|
360
|
+
attributes={[
|
|
361
|
+
{
|
|
362
|
+
name: "msg",
|
|
363
|
+
type: "str",
|
|
364
|
+
children: "Human readable string describing the exception.",
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "code",
|
|
368
|
+
type: "int",
|
|
369
|
+
children: "Exception error code.",
|
|
370
|
+
},
|
|
371
|
+
]}
|
|
372
|
+
seeAlso={["BaseException"]}
|
|
373
|
+
deprecated="Use NewException instead."
|
|
374
|
+
note="Do not include the 'self' parameter in the Args section."
|
|
375
|
+
/>
|
|
376
|
+
</TestOutput>,
|
|
377
|
+
).toRenderTo(
|
|
378
|
+
`
|
|
399
379
|
"""
|
|
400
380
|
Exceptions are documented in the same way as classes.
|
|
401
381
|
|
|
@@ -419,34 +399,33 @@ describe("New Documentation Components", () => {
|
|
|
419
399
|
Do not include the 'self' parameter in the Args section.
|
|
420
400
|
"""
|
|
421
401
|
|
|
422
|
-
|
|
423
402
|
`,
|
|
424
403
|
);
|
|
425
404
|
});
|
|
426
405
|
|
|
427
406
|
it("MethodDoc renders correctly without default note", () => {
|
|
428
|
-
|
|
429
|
-
<
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
{
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
407
|
+
expect(
|
|
408
|
+
<TestOutput>
|
|
409
|
+
<py.MethodDoc
|
|
410
|
+
description={[
|
|
411
|
+
<Prose>Class methods are similar to regular functions.</Prose>,
|
|
412
|
+
]}
|
|
413
|
+
parameters={[
|
|
414
|
+
{
|
|
415
|
+
name: "param1",
|
|
416
|
+
doc: "The first parameter.",
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: "param2",
|
|
420
|
+
doc: "The second parameter.",
|
|
421
|
+
},
|
|
422
|
+
]}
|
|
423
|
+
returns="True if successful, False otherwise."
|
|
424
|
+
overrides="Base.method"
|
|
425
|
+
/>
|
|
426
|
+
</TestOutput>,
|
|
427
|
+
).toRenderTo(
|
|
428
|
+
`
|
|
450
429
|
"""
|
|
451
430
|
Class methods are similar to regular functions.
|
|
452
431
|
|
|
@@ -462,30 +441,29 @@ describe("New Documentation Components", () => {
|
|
|
462
441
|
Base.method
|
|
463
442
|
"""
|
|
464
443
|
|
|
465
|
-
|
|
466
444
|
`,
|
|
467
445
|
);
|
|
468
446
|
});
|
|
469
447
|
|
|
470
448
|
it("MethodDoc renders correctly with custom note", () => {
|
|
471
|
-
|
|
472
|
-
<
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
{
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
449
|
+
expect(
|
|
450
|
+
<TestOutput>
|
|
451
|
+
<py.MethodDoc
|
|
452
|
+
description={[
|
|
453
|
+
<Prose>Class methods are similar to regular functions.</Prose>,
|
|
454
|
+
]}
|
|
455
|
+
parameters={[
|
|
456
|
+
{
|
|
457
|
+
name: "param1",
|
|
458
|
+
doc: "The first parameter.",
|
|
459
|
+
},
|
|
460
|
+
]}
|
|
461
|
+
returns="True if successful, False otherwise."
|
|
462
|
+
note="This method has special behavior when called multiple times."
|
|
463
|
+
/>
|
|
464
|
+
</TestOutput>,
|
|
465
|
+
).toRenderTo(
|
|
466
|
+
`
|
|
489
467
|
"""
|
|
490
468
|
Class methods are similar to regular functions.
|
|
491
469
|
|
|
@@ -499,39 +477,41 @@ describe("New Documentation Components", () => {
|
|
|
499
477
|
This method has special behavior when called multiple times.
|
|
500
478
|
"""
|
|
501
479
|
|
|
502
|
-
|
|
503
480
|
`,
|
|
504
481
|
);
|
|
505
482
|
});
|
|
506
483
|
|
|
507
484
|
it("ModuleDoc with minimal content", () => {
|
|
508
|
-
|
|
509
|
-
<
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
485
|
+
expect(
|
|
486
|
+
<TestOutput>
|
|
487
|
+
<py.ModuleDoc
|
|
488
|
+
description={[<Prose>Simple module description.</Prose>]}
|
|
489
|
+
/>
|
|
490
|
+
</TestOutput>,
|
|
491
|
+
).toRenderTo(
|
|
492
|
+
`
|
|
516
493
|
"""
|
|
517
494
|
Simple module description.
|
|
518
495
|
"""
|
|
519
496
|
|
|
520
|
-
|
|
521
497
|
`,
|
|
522
498
|
);
|
|
523
499
|
});
|
|
524
500
|
|
|
525
501
|
it("ModuleDoc with only todo items", () => {
|
|
526
|
-
|
|
527
|
-
<
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
502
|
+
expect(
|
|
503
|
+
<TestOutput>
|
|
504
|
+
<py.ModuleDoc
|
|
505
|
+
description={[<Prose>Module with pending tasks.</Prose>]}
|
|
506
|
+
todo={[
|
|
507
|
+
"Implement feature X",
|
|
508
|
+
"Add more tests",
|
|
509
|
+
"Update documentation",
|
|
510
|
+
]}
|
|
511
|
+
/>
|
|
512
|
+
</TestOutput>,
|
|
513
|
+
).toRenderTo(
|
|
514
|
+
`
|
|
535
515
|
"""
|
|
536
516
|
Module with pending tasks.
|
|
537
517
|
|
|
@@ -541,45 +521,43 @@ describe("New Documentation Components", () => {
|
|
|
541
521
|
* Update documentation
|
|
542
522
|
"""
|
|
543
523
|
|
|
544
|
-
|
|
545
524
|
`,
|
|
546
525
|
);
|
|
547
526
|
});
|
|
548
527
|
|
|
549
528
|
it("PropertyDoc minimal (description only)", () => {
|
|
550
|
-
|
|
551
|
-
<
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
529
|
+
expect(
|
|
530
|
+
<TestOutput>
|
|
531
|
+
<py.PropertyDoc
|
|
532
|
+
description={[<Prose>A simple readonly property.</Prose>]}
|
|
533
|
+
/>
|
|
534
|
+
</TestOutput>,
|
|
535
|
+
).toRenderTo(
|
|
536
|
+
`
|
|
558
537
|
"""
|
|
559
538
|
A simple readonly property.
|
|
560
539
|
"""
|
|
561
540
|
|
|
562
|
-
|
|
563
541
|
`,
|
|
564
542
|
);
|
|
565
543
|
});
|
|
566
544
|
|
|
567
545
|
it("PropertyDoc with getter and setter info", () => {
|
|
568
|
-
|
|
569
|
-
<
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
546
|
+
expect(
|
|
547
|
+
<TestOutput>
|
|
548
|
+
<py.PropertyDoc
|
|
549
|
+
description={[
|
|
550
|
+
<Prose>
|
|
551
|
+
Properties with both a getter and setter should only be documented
|
|
552
|
+
in their getter method.
|
|
553
|
+
</Prose>,
|
|
554
|
+
]}
|
|
555
|
+
returns=":obj:`list` of :obj:`str`: The property value."
|
|
556
|
+
note="If the setter method contains notable behavior, it should be mentioned here."
|
|
557
|
+
/>
|
|
558
|
+
</TestOutput>,
|
|
559
|
+
).toRenderTo(
|
|
560
|
+
`
|
|
583
561
|
"""
|
|
584
562
|
Properties with both a getter and setter should only be documented in their
|
|
585
563
|
getter method.
|
|
@@ -591,48 +569,47 @@ describe("New Documentation Components", () => {
|
|
|
591
569
|
If the setter method contains notable behavior, it should be mentioned here.
|
|
592
570
|
"""
|
|
593
571
|
|
|
594
|
-
|
|
595
572
|
`,
|
|
596
573
|
);
|
|
597
574
|
});
|
|
598
575
|
|
|
599
576
|
it("GeneratorDoc with complex parameters", () => {
|
|
600
|
-
|
|
601
|
-
<
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
{
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
577
|
+
expect(
|
|
578
|
+
<TestOutput>
|
|
579
|
+
<py.GeneratorDoc
|
|
580
|
+
description={[
|
|
581
|
+
<Prose>
|
|
582
|
+
A more complex generator example with multiple parameters.
|
|
583
|
+
</Prose>,
|
|
584
|
+
]}
|
|
585
|
+
parameters={[
|
|
586
|
+
{
|
|
587
|
+
name: "start",
|
|
588
|
+
type: "int",
|
|
589
|
+
default: "0",
|
|
590
|
+
doc: "Starting value for the sequence.",
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
name: "stop",
|
|
594
|
+
type: "int",
|
|
595
|
+
doc: "Ending value for the sequence (exclusive).",
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
name: "step",
|
|
599
|
+
type: "int",
|
|
600
|
+
default: "1",
|
|
601
|
+
doc: "Step size between values.",
|
|
602
|
+
},
|
|
603
|
+
]}
|
|
604
|
+
yields="int: The next number in the sequence."
|
|
605
|
+
raises={[
|
|
606
|
+
"ValueError: If step is zero.",
|
|
607
|
+
"TypeError: If parameters are not integers.",
|
|
608
|
+
]}
|
|
609
|
+
/>
|
|
610
|
+
</TestOutput>,
|
|
611
|
+
).toRenderTo(
|
|
612
|
+
`
|
|
636
613
|
"""
|
|
637
614
|
A more complex generator example with multiple parameters.
|
|
638
615
|
|
|
@@ -653,63 +630,62 @@ describe("New Documentation Components", () => {
|
|
|
653
630
|
TypeError: If parameters are not integers.
|
|
654
631
|
"""
|
|
655
632
|
|
|
656
|
-
|
|
657
633
|
`,
|
|
658
634
|
);
|
|
659
635
|
});
|
|
660
636
|
|
|
661
637
|
it("ExceptionDoc with comprehensive documentation", () => {
|
|
662
|
-
|
|
663
|
-
<
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
{
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
{
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
638
|
+
expect(
|
|
639
|
+
<TestOutput>
|
|
640
|
+
<py.ExceptionDoc
|
|
641
|
+
description={[
|
|
642
|
+
<Prose>A custom exception for authentication failures.</Prose>,
|
|
643
|
+
<Prose>
|
|
644
|
+
This exception is raised when authentication credentials are
|
|
645
|
+
invalid or when authentication tokens have expired.
|
|
646
|
+
</Prose>,
|
|
647
|
+
]}
|
|
648
|
+
parameters={[
|
|
649
|
+
{
|
|
650
|
+
name: "message",
|
|
651
|
+
type: "str",
|
|
652
|
+
doc: "Human readable error message describing the authentication failure.",
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
name: "error_code",
|
|
656
|
+
type: "int",
|
|
657
|
+
default: "401",
|
|
658
|
+
doc: "HTTP error code associated with the authentication failure.",
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: "retry_after",
|
|
662
|
+
type: "int",
|
|
663
|
+
default: undefined,
|
|
664
|
+
doc: "Number of seconds to wait before retrying authentication.",
|
|
665
|
+
},
|
|
666
|
+
]}
|
|
667
|
+
attributes={[
|
|
668
|
+
{
|
|
669
|
+
name: "message",
|
|
670
|
+
type: "str",
|
|
671
|
+
children: "The error message.",
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
name: "error_code",
|
|
675
|
+
type: "int",
|
|
676
|
+
children: "HTTP status code.",
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
name: "retry_after",
|
|
680
|
+
type: "int",
|
|
681
|
+
children: "Retry delay in seconds, if applicable.",
|
|
682
|
+
},
|
|
683
|
+
]}
|
|
684
|
+
note="This exception should be caught and handled gracefully in production code."
|
|
685
|
+
/>
|
|
686
|
+
</TestOutput>,
|
|
687
|
+
).toRenderTo(
|
|
688
|
+
`
|
|
713
689
|
"""
|
|
714
690
|
A custom exception for authentication failures.
|
|
715
691
|
|
|
@@ -736,35 +712,34 @@ describe("New Documentation Components", () => {
|
|
|
736
712
|
This exception should be caught and handled gracefully in production code.
|
|
737
713
|
"""
|
|
738
714
|
|
|
739
|
-
|
|
740
715
|
`,
|
|
741
716
|
);
|
|
742
717
|
});
|
|
743
718
|
|
|
744
719
|
it("MethodDoc with raises but no returns", () => {
|
|
745
|
-
|
|
746
|
-
<
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
{
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
720
|
+
expect(
|
|
721
|
+
<TestOutput>
|
|
722
|
+
<py.MethodDoc
|
|
723
|
+
description={[
|
|
724
|
+
<Prose>
|
|
725
|
+
A method that performs an action but doesn't return a value.
|
|
726
|
+
</Prose>,
|
|
727
|
+
]}
|
|
728
|
+
parameters={[
|
|
729
|
+
{
|
|
730
|
+
name: "data",
|
|
731
|
+
type: "bytes",
|
|
732
|
+
doc: "Raw data to process.",
|
|
733
|
+
},
|
|
734
|
+
]}
|
|
735
|
+
raises={[
|
|
736
|
+
"ValueError: If data is empty or invalid.",
|
|
737
|
+
"IOError: If processing fails due to I/O issues.",
|
|
738
|
+
]}
|
|
739
|
+
/>
|
|
740
|
+
</TestOutput>,
|
|
741
|
+
).toRenderTo(
|
|
742
|
+
`
|
|
768
743
|
"""
|
|
769
744
|
A method that performs an action but doesn't return a value.
|
|
770
745
|
|
|
@@ -778,24 +753,23 @@ describe("New Documentation Components", () => {
|
|
|
778
753
|
IOError: If processing fails due to I/O issues.
|
|
779
754
|
"""
|
|
780
755
|
|
|
781
|
-
|
|
782
756
|
`,
|
|
783
757
|
);
|
|
784
758
|
});
|
|
785
759
|
|
|
786
760
|
it("MethodDoc with no parameters", () => {
|
|
787
|
-
|
|
788
|
-
<
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
761
|
+
expect(
|
|
762
|
+
<TestOutput>
|
|
763
|
+
<py.MethodDoc
|
|
764
|
+
description={[
|
|
765
|
+
<Prose>A simple method with no parameters (except self).</Prose>,
|
|
766
|
+
]}
|
|
767
|
+
returns="bool: True if the operation was successful."
|
|
768
|
+
note="This is a parameterless method that only operates on instance state."
|
|
769
|
+
/>
|
|
770
|
+
</TestOutput>,
|
|
771
|
+
).toRenderTo(
|
|
772
|
+
`
|
|
799
773
|
"""
|
|
800
774
|
A simple method with no parameters (except self).
|
|
801
775
|
|
|
@@ -806,57 +780,55 @@ describe("New Documentation Components", () => {
|
|
|
806
780
|
This is a parameterless method that only operates on instance state.
|
|
807
781
|
"""
|
|
808
782
|
|
|
809
|
-
|
|
810
783
|
`,
|
|
811
784
|
);
|
|
812
785
|
});
|
|
813
786
|
|
|
814
787
|
it("AttributeDoc standalone usage", () => {
|
|
815
|
-
|
|
816
|
-
<
|
|
817
|
-
<py.
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
788
|
+
expect(
|
|
789
|
+
<TestOutput>
|
|
790
|
+
<py.PyDoc>
|
|
791
|
+
<py.AttributeDoc name="connection_timeout" type="float">
|
|
792
|
+
Maximum time in seconds to wait for a connection to be established.
|
|
793
|
+
</py.AttributeDoc>
|
|
794
|
+
</py.PyDoc>
|
|
795
|
+
</TestOutput>,
|
|
796
|
+
).toRenderTo(
|
|
797
|
+
`
|
|
825
798
|
"""
|
|
826
799
|
connection_timeout (float): Maximum time in seconds to wait for a connection to
|
|
827
800
|
be established.
|
|
828
801
|
"""
|
|
829
802
|
|
|
830
|
-
|
|
831
803
|
`,
|
|
832
804
|
);
|
|
833
805
|
});
|
|
834
806
|
|
|
835
807
|
it("GeneratorDoc with examples in description", () => {
|
|
836
|
-
|
|
837
|
-
<
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
{
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
808
|
+
expect(
|
|
809
|
+
<TestOutput>
|
|
810
|
+
<py.GeneratorDoc
|
|
811
|
+
description={[
|
|
812
|
+
<Prose>
|
|
813
|
+
Generators have a Yields section instead of a Returns section.
|
|
814
|
+
</Prose>,
|
|
815
|
+
<py.PyDocExample>
|
|
816
|
+
{`print([i for i in example_generator(4)])\n[0, 1, 2, 3]`}
|
|
817
|
+
</py.PyDocExample>,
|
|
818
|
+
]}
|
|
819
|
+
parameters={[
|
|
820
|
+
{
|
|
821
|
+
name: "n",
|
|
822
|
+
type: "int",
|
|
823
|
+
doc: "The upper limit of the range to generate, from 0 to n - 1.",
|
|
824
|
+
},
|
|
825
|
+
]}
|
|
826
|
+
yields="int: The next number in the range of 0 to n - 1."
|
|
827
|
+
note="Examples should be written in doctest format, and should illustrate how to use the function."
|
|
828
|
+
/>
|
|
829
|
+
</TestOutput>,
|
|
830
|
+
).toRenderTo(
|
|
831
|
+
`
|
|
860
832
|
"""
|
|
861
833
|
Generators have a Yields section instead of a Returns section.
|
|
862
834
|
|
|
@@ -873,7 +845,6 @@ describe("New Documentation Components", () => {
|
|
|
873
845
|
Examples should be written in doctest format, and should illustrate how to use the function.
|
|
874
846
|
"""
|
|
875
847
|
|
|
876
|
-
|
|
877
848
|
`,
|
|
878
849
|
);
|
|
879
850
|
});
|
|
@@ -925,8 +896,9 @@ describe("Full example", () => {
|
|
|
925
896
|
style="google"
|
|
926
897
|
/>
|
|
927
898
|
);
|
|
928
|
-
|
|
929
|
-
|
|
899
|
+
|
|
900
|
+
expect(
|
|
901
|
+
<TestOutput>
|
|
930
902
|
<py.ClassDeclaration name="A" doc={doc}>
|
|
931
903
|
<py.StatementList>
|
|
932
904
|
<py.VariableDeclaration name="just_name" />
|
|
@@ -937,13 +909,10 @@ describe("Full example", () => {
|
|
|
937
909
|
initializer={12}
|
|
938
910
|
/>
|
|
939
911
|
</py.StatementList>
|
|
940
|
-
</py.ClassDeclaration
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
expect(res).toRenderTo(
|
|
946
|
-
d`
|
|
912
|
+
</py.ClassDeclaration>
|
|
913
|
+
</TestOutput>,
|
|
914
|
+
).toRenderTo(
|
|
915
|
+
`
|
|
947
916
|
class A:
|
|
948
917
|
"""
|
|
949
918
|
This is an example of a long docstring that will be broken in lines. We will
|
|
@@ -964,7 +933,7 @@ describe("Full example", () => {
|
|
|
964
933
|
nickname, or even a codename (e.g., 'Agent X'). It's used primarily
|
|
965
934
|
for display purposes, logging, or greeting messages and is not
|
|
966
935
|
required to be unique or validated unless specified by the caller.
|
|
967
|
-
Defaults to
|
|
936
|
+
Defaults to "John Doe".
|
|
968
937
|
|
|
969
938
|
somebody2 (str): Somebody's name. This can be any string representing a
|
|
970
939
|
person, whether it's a first name, full name, nickname, or even a
|
|
@@ -993,7 +962,6 @@ describe("Full example", () => {
|
|
|
993
962
|
name_and_type: int = None
|
|
994
963
|
name_type_and_value: int = 12
|
|
995
964
|
|
|
996
|
-
|
|
997
965
|
`,
|
|
998
966
|
);
|
|
999
967
|
});
|
|
@@ -1030,8 +998,9 @@ describe("Full example", () => {
|
|
|
1030
998
|
style="google"
|
|
1031
999
|
/>
|
|
1032
1000
|
);
|
|
1033
|
-
|
|
1034
|
-
|
|
1001
|
+
|
|
1002
|
+
expect(
|
|
1003
|
+
<TestOutput>
|
|
1035
1004
|
<py.FunctionDeclaration name="some_function" doc={doc}>
|
|
1036
1005
|
<py.StatementList>
|
|
1037
1006
|
<py.VariableDeclaration name="just_name" />
|
|
@@ -1042,13 +1011,10 @@ describe("Full example", () => {
|
|
|
1042
1011
|
initializer={12}
|
|
1043
1012
|
/>
|
|
1044
1013
|
</py.StatementList>
|
|
1045
|
-
</py.FunctionDeclaration
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
expect(res).toRenderTo(
|
|
1051
|
-
d`
|
|
1014
|
+
</py.FunctionDeclaration>
|
|
1015
|
+
</TestOutput>,
|
|
1016
|
+
).toRenderTo(
|
|
1017
|
+
`
|
|
1052
1018
|
def some_function():
|
|
1053
1019
|
"""
|
|
1054
1020
|
This is an example of a long docstring that will be broken in lines. We will
|
|
@@ -1064,7 +1030,7 @@ describe("Full example", () => {
|
|
|
1064
1030
|
nickname, or even a codename (e.g., 'Agent X'). It's used primarily
|
|
1065
1031
|
for display purposes, logging, or greeting messages and is not
|
|
1066
1032
|
required to be unique or validated unless specified by the caller.
|
|
1067
|
-
Defaults to
|
|
1033
|
+
Defaults to "John Doe".
|
|
1068
1034
|
|
|
1069
1035
|
somebody2 (str): Somebody's name. This can be any string representing a
|
|
1070
1036
|
person, whether it's a first name, full name, nickname, or even a
|
|
@@ -1088,25 +1054,21 @@ describe("Full example", () => {
|
|
|
1088
1054
|
name_and_type: number = None
|
|
1089
1055
|
name_type_and_value: number = 12
|
|
1090
1056
|
|
|
1091
|
-
|
|
1092
1057
|
`,
|
|
1093
1058
|
);
|
|
1094
1059
|
});
|
|
1095
1060
|
|
|
1096
1061
|
it("renders correctly in a Variable", () => {
|
|
1097
|
-
|
|
1098
|
-
|
|
1062
|
+
expect(
|
|
1063
|
+
<TestOutput>
|
|
1099
1064
|
<py.VariableDeclaration
|
|
1100
1065
|
name="myVar"
|
|
1101
1066
|
initializer={42}
|
|
1102
1067
|
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."
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
expect(res).toRenderTo(
|
|
1109
|
-
d`
|
|
1068
|
+
/>
|
|
1069
|
+
</TestOutput>,
|
|
1070
|
+
).toRenderTo(
|
|
1071
|
+
`
|
|
1110
1072
|
# This is a very long docstring that will be broken in two lines when rendered.
|
|
1111
1073
|
# This part of the docstring will be in the second line.
|
|
1112
1074
|
my_var = 42
|
|
@@ -1120,8 +1082,8 @@ describe("Full example", () => {
|
|
|
1120
1082
|
description={[<Prose>An enum representing colors.</Prose>]}
|
|
1121
1083
|
/>
|
|
1122
1084
|
);
|
|
1123
|
-
|
|
1124
|
-
[
|
|
1085
|
+
expect(
|
|
1086
|
+
<TestOutput externals={[enumModule]}>
|
|
1125
1087
|
<py.ClassEnumDeclaration
|
|
1126
1088
|
name="Color"
|
|
1127
1089
|
baseType="IntEnum"
|
|
@@ -1131,11 +1093,10 @@ describe("Full example", () => {
|
|
|
1131
1093
|
{ name: "BLUE", value: "3", doc: "The color blue." },
|
|
1132
1094
|
]}
|
|
1133
1095
|
doc={doc}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
const expected = d`
|
|
1096
|
+
/>
|
|
1097
|
+
</TestOutput>,
|
|
1098
|
+
).toRenderTo(
|
|
1099
|
+
`
|
|
1139
1100
|
from enum import IntEnum
|
|
1140
1101
|
|
|
1141
1102
|
|
|
@@ -1157,9 +1118,8 @@ describe("Full example", () => {
|
|
|
1157
1118
|
The color blue.
|
|
1158
1119
|
"""
|
|
1159
1120
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
expect(result).toRenderTo(expected);
|
|
1121
|
+
`,
|
|
1122
|
+
);
|
|
1163
1123
|
});
|
|
1164
1124
|
|
|
1165
1125
|
it("ModuleDoc with SourceFile integration", () => {
|
|
@@ -1188,47 +1148,40 @@ describe("Full example", () => {
|
|
|
1188
1148
|
/>
|
|
1189
1149
|
);
|
|
1190
1150
|
|
|
1191
|
-
|
|
1192
|
-
<
|
|
1193
|
-
<py.
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
assertFileContents(res, {
|
|
1208
|
-
"utils.py": d`
|
|
1209
|
-
"""
|
|
1210
|
-
This module provides utility functions for data processing. It includes
|
|
1211
|
-
functions for validation, transformation, and analysis.
|
|
1212
|
-
|
|
1213
|
-
Attributes:
|
|
1214
|
-
DEFAULT_TIMEOUT (int): Default timeout value in seconds.
|
|
1151
|
+
expect(
|
|
1152
|
+
<TestOutputDirectory>
|
|
1153
|
+
<py.SourceFile path="utils.py" doc={moduleDoc}>
|
|
1154
|
+
<py.VariableDeclaration name="DEFAULT_TIMEOUT" initializer={30} />
|
|
1155
|
+
<py.VariableDeclaration name="MAX_RETRIES" initializer={3} />
|
|
1156
|
+
<py.FunctionDeclaration name="process_data">
|
|
1157
|
+
pass
|
|
1158
|
+
</py.FunctionDeclaration>
|
|
1159
|
+
</py.SourceFile>
|
|
1160
|
+
</TestOutputDirectory>,
|
|
1161
|
+
).toRenderTo({
|
|
1162
|
+
"utils.py": `
|
|
1163
|
+
"""
|
|
1164
|
+
This module provides utility functions for data processing. It includes
|
|
1165
|
+
functions for validation, transformation, and analysis.
|
|
1215
1166
|
|
|
1216
|
-
|
|
1167
|
+
Attributes:
|
|
1168
|
+
DEFAULT_TIMEOUT (int): Default timeout value in seconds.
|
|
1217
1169
|
|
|
1218
|
-
|
|
1219
|
-
* Add caching functionality
|
|
1220
|
-
* Improve error messages
|
|
1221
|
-
"""
|
|
1170
|
+
MAX_RETRIES (int): Maximum number of retry attempts.
|
|
1222
1171
|
|
|
1223
|
-
|
|
1172
|
+
Todo:
|
|
1173
|
+
* Add caching functionality
|
|
1174
|
+
* Improve error messages
|
|
1175
|
+
"""
|
|
1224
1176
|
|
|
1225
|
-
|
|
1177
|
+
default_timeout = 30
|
|
1226
1178
|
|
|
1227
|
-
|
|
1228
|
-
pass
|
|
1179
|
+
max_retries = 3
|
|
1229
1180
|
|
|
1181
|
+
def process_data():
|
|
1182
|
+
pass
|
|
1230
1183
|
|
|
1231
|
-
|
|
1184
|
+
`,
|
|
1232
1185
|
});
|
|
1233
1186
|
});
|
|
1234
1187
|
|
|
@@ -1253,14 +1206,14 @@ describe("Full example", () => {
|
|
|
1253
1206
|
/>
|
|
1254
1207
|
);
|
|
1255
1208
|
|
|
1256
|
-
|
|
1257
|
-
<
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1209
|
+
expect(
|
|
1210
|
+
<TestOutput>
|
|
1211
|
+
<py.FunctionDeclaration name="fibonacci_generator" doc={generatorDoc}>
|
|
1212
|
+
yield 0
|
|
1213
|
+
</py.FunctionDeclaration>
|
|
1214
|
+
</TestOutput>,
|
|
1215
|
+
).toRenderTo(
|
|
1216
|
+
`
|
|
1264
1217
|
def fibonacci_generator():
|
|
1265
1218
|
"""
|
|
1266
1219
|
A generator function that yields fibonacci numbers. This is an efficient way
|
|
@@ -1274,7 +1227,6 @@ describe("Full example", () => {
|
|
|
1274
1227
|
"""
|
|
1275
1228
|
yield 0
|
|
1276
1229
|
|
|
1277
|
-
|
|
1278
1230
|
`,
|
|
1279
1231
|
);
|
|
1280
1232
|
});
|
|
@@ -1304,21 +1256,21 @@ describe("Full example", () => {
|
|
|
1304
1256
|
/>
|
|
1305
1257
|
);
|
|
1306
1258
|
|
|
1307
|
-
|
|
1308
|
-
<
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
<py.
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1259
|
+
expect(
|
|
1260
|
+
<TestOutput>
|
|
1261
|
+
<py.ClassDeclaration
|
|
1262
|
+
name="ValidationError"
|
|
1263
|
+
bases={["Exception"]}
|
|
1264
|
+
doc={exceptionDoc}
|
|
1265
|
+
>
|
|
1266
|
+
<py.StatementList>
|
|
1267
|
+
<py.VariableDeclaration name="field_name" type="str" />
|
|
1268
|
+
<py.VariableDeclaration name="error_code" type="int" />
|
|
1269
|
+
</py.StatementList>
|
|
1270
|
+
</py.ClassDeclaration>
|
|
1271
|
+
</TestOutput>,
|
|
1272
|
+
).toRenderTo(
|
|
1273
|
+
`
|
|
1322
1274
|
class ValidationError(Exception):
|
|
1323
1275
|
"""
|
|
1324
1276
|
Custom exception raised when data validation fails. This exception includes
|
|
@@ -1333,7 +1285,6 @@ describe("Full example", () => {
|
|
|
1333
1285
|
field_name: str = None
|
|
1334
1286
|
error_code: int = None
|
|
1335
1287
|
|
|
1336
|
-
|
|
1337
1288
|
`,
|
|
1338
1289
|
);
|
|
1339
1290
|
});
|
|
@@ -1351,15 +1302,16 @@ describe("Full example", () => {
|
|
|
1351
1302
|
/>
|
|
1352
1303
|
);
|
|
1353
1304
|
|
|
1354
|
-
|
|
1355
|
-
<
|
|
1356
|
-
<py.
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1305
|
+
expect(
|
|
1306
|
+
<TestOutput>
|
|
1307
|
+
<py.ClassDeclaration name="Person">
|
|
1308
|
+
<py.PropertyDeclaration name="full_name" doc={propertyDoc} type="str">
|
|
1309
|
+
return "John Doe"
|
|
1310
|
+
</py.PropertyDeclaration>
|
|
1311
|
+
</py.ClassDeclaration>
|
|
1312
|
+
</TestOutput>,
|
|
1313
|
+
).toRenderTo(
|
|
1314
|
+
`
|
|
1363
1315
|
class Person:
|
|
1364
1316
|
@property
|
|
1365
1317
|
def full_name(self) -> str:
|
|
@@ -1370,7 +1322,8 @@ describe("Full example", () => {
|
|
|
1370
1322
|
return "John Doe"
|
|
1371
1323
|
|
|
1372
1324
|
|
|
1373
|
-
|
|
1325
|
+
`,
|
|
1326
|
+
);
|
|
1374
1327
|
});
|
|
1375
1328
|
|
|
1376
1329
|
it("MethodDoc with FunctionDeclaration (inside class) integration", () => {
|
|
@@ -1402,24 +1355,24 @@ describe("Full example", () => {
|
|
|
1402
1355
|
/>
|
|
1403
1356
|
);
|
|
1404
1357
|
|
|
1405
|
-
|
|
1406
|
-
<
|
|
1407
|
-
<py.
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
{
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1358
|
+
expect(
|
|
1359
|
+
<TestOutput>
|
|
1360
|
+
<py.ClassDeclaration name="DataValidator">
|
|
1361
|
+
<py.MethodDeclaration
|
|
1362
|
+
name="validate"
|
|
1363
|
+
doc={methodDoc}
|
|
1364
|
+
parameters={[
|
|
1365
|
+
{ name: "data", type: "dict" },
|
|
1366
|
+
{ name: "strict", type: "bool", default: true },
|
|
1367
|
+
]}
|
|
1368
|
+
returnType="bool"
|
|
1369
|
+
>
|
|
1370
|
+
return self.validate(data, strict)
|
|
1371
|
+
</py.MethodDeclaration>
|
|
1372
|
+
</py.ClassDeclaration>
|
|
1373
|
+
</TestOutput>,
|
|
1374
|
+
).toRenderTo(
|
|
1375
|
+
`
|
|
1423
1376
|
class DataValidator:
|
|
1424
1377
|
def validate(self, data: dict, strict: bool = True) -> bool:
|
|
1425
1378
|
"""
|
|
@@ -1444,7 +1397,6 @@ describe("Full example", () => {
|
|
|
1444
1397
|
return self.validate(data, strict)
|
|
1445
1398
|
|
|
1446
1399
|
|
|
1447
|
-
|
|
1448
1400
|
`,
|
|
1449
1401
|
);
|
|
1450
1402
|
});
|