@alloy-js/python 0.5.0-dev.0 → 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/builtins/python.js +46 -0
- package/dist/dev/src/builtins/python.js.map +1 -1
- package/dist/dev/src/components/ClassDeclaration.js +19 -10
- package/dist/dev/src/components/ClassDeclaration.js.map +1 -1
- package/dist/dev/src/components/ClassMethodDeclaration.js +20 -5
- package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/DataclassDeclaration.js +14 -12
- package/dist/dev/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/dev/src/components/DecoratorList.js +55 -0
- package/dist/dev/src/components/DecoratorList.js.map +1 -0
- package/dist/dev/src/components/EnumDeclaration.js +21 -12
- package/dist/dev/src/components/EnumDeclaration.js.map +1 -1
- package/dist/dev/src/components/FunctionBase.js +21 -10
- package/dist/dev/src/components/FunctionBase.js.map +1 -1
- package/dist/dev/src/components/FutureStatement.js +1 -1
- package/dist/dev/src/components/MethodBase.js +16 -4
- package/dist/dev/src/components/MethodBase.js.map +1 -1
- package/dist/dev/src/components/PropertyDeclaration.js +68 -17
- package/dist/dev/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/dev/src/components/PydanticClassDeclaration.js +136 -0
- package/dist/dev/src/components/PydanticClassDeclaration.js.map +1 -0
- package/dist/dev/src/components/SourceFile.js +44 -32
- package/dist/dev/src/components/SourceFile.js.map +1 -1
- package/dist/dev/src/components/StaticMethodDeclaration.js +19 -5
- package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/index.js +1 -0
- package/dist/dev/src/components/index.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 +480 -381
- 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 +345 -358
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/decoratorlist.test.js +131 -0
- package/dist/dev/test/decoratorlist.test.js.map +1 -0
- 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 +231 -166
- 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 +452 -265
- 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 +200 -45
- 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 +177 -46
- package/dist/dev/test/propertydeclaration.test.js.map +1 -1
- package/dist/dev/test/pydanticclassdeclarations.test.js +1089 -0
- package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -0
- 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/builtins/python.d.ts +30 -0
- package/dist/src/builtins/python.d.ts.map +1 -1
- package/dist/src/builtins/python.js +46 -0
- package/dist/src/builtins/python.js.map +1 -1
- package/dist/src/components/ClassDeclaration.d.ts +21 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +6 -1
- package/dist/src/components/ClassDeclaration.js.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts +5 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.js +14 -3
- package/dist/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/src/components/DataclassDeclaration.d.ts.map +1 -1
- package/dist/src/components/DataclassDeclaration.js +10 -4
- package/dist/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/src/components/DecoratorList.d.ts +43 -0
- package/dist/src/components/DecoratorList.d.ts.map +1 -0
- package/dist/src/components/DecoratorList.js +47 -0
- package/dist/src/components/DecoratorList.js.map +1 -0
- package/dist/src/components/EnumDeclaration.d.ts +9 -0
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +6 -1
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/FunctionBase.d.ts +31 -1
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +9 -2
- package/dist/src/components/FunctionBase.js.map +1 -1
- package/dist/src/components/FutureStatement.d.ts +1 -1
- package/dist/src/components/FutureStatement.js +1 -1
- package/dist/src/components/MethodBase.d.ts.map +1 -1
- package/dist/src/components/MethodBase.js +10 -2
- package/dist/src/components/MethodBase.js.map +1 -1
- package/dist/src/components/PropertyDeclaration.d.ts +29 -0
- package/dist/src/components/PropertyDeclaration.d.ts.map +1 -1
- package/dist/src/components/PropertyDeclaration.js +48 -1
- package/dist/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/src/components/PydanticClassDeclaration.d.ts +120 -0
- package/dist/src/components/PydanticClassDeclaration.d.ts.map +1 -0
- package/dist/src/components/PydanticClassDeclaration.js +116 -0
- package/dist/src/components/PydanticClassDeclaration.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/src/components/StaticMethodDeclaration.d.ts +3 -0
- package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.js +13 -3
- package/dist/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.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 +316 -277
- 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 +153 -178
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/decoratorlist.test.d.ts +2 -0
- package/dist/test/decoratorlist.test.d.ts.map +1 -0
- package/dist/test/decoratorlist.test.js +83 -0
- package/dist/test/decoratorlist.test.js.map +1 -0
- package/dist/test/dundermethoddeclaration.test.js +7 -4
- package/dist/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/test/enums.test.js +172 -143
- 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 +256 -173
- 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 +106 -19
- 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 +90 -15
- package/dist/test/propertydeclaration.test.js.map +1 -1
- package/dist/test/pydanticclassdeclarations.test.d.ts +2 -0
- package/dist/test/pydanticclassdeclarations.test.d.ts.map +1 -0
- package/dist/test/pydanticclassdeclarations.test.js +773 -0
- package/dist/test/pydanticclassdeclarations.test.js.map +1 -0
- 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/ClassDeclaration.md +10 -7
- package/docs/api/components/ClassEnumDeclaration.md +9 -6
- package/docs/api/components/ClassMethodDeclaration.md +7 -5
- package/docs/api/components/DataclassDeclaration.md +9 -5
- package/docs/api/components/DunderMethodDeclaration.md +7 -5
- package/docs/api/components/FunctionDeclaration.md +9 -5
- package/docs/api/components/FutureStatement.md +1 -1
- package/docs/api/components/MethodDeclaration.md +11 -6
- package/docs/api/components/PropertyDeclaration.md +11 -8
- package/docs/api/components/PydanticClassDeclaration.md +146 -0
- package/docs/api/components/SourceFile.md +20 -8
- package/docs/api/components/StaticMethodDeclaration.md +7 -5
- package/docs/api/components/index.md +1 -0
- package/docs/api/index.md +3 -3
- package/docs/api/types/CommonFunctionProps.md +4 -3
- package/docs/api/types/PydanticModelConfigDictProps.md +32 -0
- package/docs/api/types/index.md +1 -0
- package/docs/api/variables/index.md +3 -0
- package/docs/api/variables/pydanticModule.md +27 -0
- package/docs/api/variables/pydanticSettingsModule.md +7 -0
- package/docs/api/variables/typingModule.md +9 -0
- package/package.json +4 -4
- package/src/builtins/python.ts +539 -1
- package/src/components/ClassDeclaration.tsx +23 -0
- package/src/components/ClassMethodDeclaration.tsx +9 -1
- package/src/components/DataclassDeclaration.tsx +18 -11
- package/src/components/DecoratorList.tsx +50 -0
- package/src/components/EnumDeclaration.tsx +11 -0
- package/src/components/FunctionBase.tsx +34 -3
- package/src/components/FutureStatement.tsx +1 -1
- package/src/components/MethodBase.tsx +6 -2
- package/src/components/PropertyDeclaration.tsx +48 -1
- package/src/components/PydanticClassDeclaration.tsx +222 -0
- package/src/components/SourceFile.tsx +6 -1
- package/src/components/StaticMethodDeclaration.tsx +7 -1
- package/src/components/index.ts +1 -0
- package/temp/api.json +1158 -86
- package/test/callsignatures.test.tsx +309 -283
- package/test/class-method-declaration.test.tsx +3 -4
- package/test/classdeclarations.test.tsx +277 -235
- package/test/classinstantiations.test.tsx +115 -109
- package/test/constructordeclaration.test.tsx +9 -6
- package/test/dataclassdeclarations.test.tsx +256 -349
- package/test/decoratorlist.test.tsx +114 -0
- package/test/dundermethoddeclaration.test.tsx +3 -4
- package/test/enums.test.tsx +84 -71
- 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 +218 -140
- package/test/imports.test.tsx +119 -91
- package/test/memberexpressions.test.tsx +265 -207
- package/test/methoddeclaration.test.tsx +115 -24
- package/test/namepolicies.test.tsx +69 -69
- package/test/propertydeclaration.test.tsx +71 -7
- package/test/pydanticclassdeclarations.test.tsx +704 -0
- 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
|
@@ -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 {
|
|
6
|
+
import { TestOutput, TestOutputDirectory } from "./utils.js";
|
|
8
7
|
describe("PyDoc", () => {
|
|
9
8
|
it("formats properly", () => {
|
|
10
|
-
|
|
9
|
+
expect(_$createComponent(TestOutput, {
|
|
11
10
|
get children() {
|
|
12
|
-
return
|
|
13
|
-
children
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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:
|
|
23
|
-
columnNumber:
|
|
24
|
-
})
|
|
29
|
+
lineNumber: 11,
|
|
30
|
+
columnNumber: 9
|
|
31
|
+
});
|
|
25
32
|
}
|
|
26
33
|
}, {
|
|
27
34
|
fileName: import.meta.url,
|
|
28
|
-
lineNumber:
|
|
29
|
-
columnNumber:
|
|
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
|
-
|
|
56
|
+
expect(_$createComponent(TestOutput, {
|
|
53
57
|
get children() {
|
|
54
|
-
return
|
|
55
|
-
children
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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:
|
|
65
|
-
columnNumber:
|
|
66
|
-
})
|
|
76
|
+
lineNumber: 43,
|
|
77
|
+
columnNumber: 9
|
|
78
|
+
});
|
|
67
79
|
}
|
|
68
80
|
}, {
|
|
69
81
|
fileName: import.meta.url,
|
|
70
|
-
lineNumber:
|
|
71
|
-
columnNumber:
|
|
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
|
-
|
|
98
|
+
expect(_$createComponent(TestOutput, {
|
|
90
99
|
get children() {
|
|
91
|
-
return
|
|
92
|
-
children
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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:
|
|
108
|
-
columnNumber:
|
|
109
|
-
})
|
|
124
|
+
lineNumber: 65,
|
|
125
|
+
columnNumber: 9
|
|
126
|
+
});
|
|
110
127
|
}
|
|
111
128
|
}, {
|
|
112
129
|
fileName: import.meta.url,
|
|
113
|
-
lineNumber:
|
|
114
|
-
columnNumber:
|
|
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
|
-
|
|
148
|
+
expect(_$createComponent(TestOutput, {
|
|
135
149
|
get children() {
|
|
136
|
-
return
|
|
137
|
-
children
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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:
|
|
147
|
-
columnNumber:
|
|
148
|
-
})
|
|
168
|
+
lineNumber: 90,
|
|
169
|
+
columnNumber: 9
|
|
170
|
+
});
|
|
149
171
|
}
|
|
150
172
|
}, {
|
|
151
173
|
fileName: import.meta.url,
|
|
152
|
-
lineNumber:
|
|
153
|
-
columnNumber:
|
|
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
|
-
|
|
176
|
-
children
|
|
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:
|
|
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
|
-
|
|
190
|
-
children
|
|
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:
|
|
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
|
-
|
|
206
|
-
children
|
|
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:
|
|
210
|
-
columnNumber:
|
|
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
|
-
|
|
218
|
-
children
|
|
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:
|
|
222
|
-
columnNumber:
|
|
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
|
-
|
|
232
|
-
get
|
|
233
|
-
return
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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:
|
|
252
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
295
|
-
get
|
|
296
|
-
return
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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:
|
|
311
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
351
|
-
get
|
|
352
|
-
return
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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:
|
|
372
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
415
|
-
get
|
|
416
|
-
return
|
|
417
|
-
|
|
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:
|
|
421
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
480
|
-
get
|
|
481
|
-
return
|
|
482
|
-
|
|
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:
|
|
486
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
524
|
-
get
|
|
525
|
-
return
|
|
526
|
-
|
|
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:
|
|
530
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
563
|
-
get
|
|
564
|
-
return
|
|
565
|
-
|
|
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:
|
|
569
|
-
columnNumber:
|
|
570
|
-
})
|
|
653
|
+
lineNumber: 487,
|
|
654
|
+
columnNumber: 9
|
|
655
|
+
});
|
|
571
656
|
}
|
|
572
657
|
}, {
|
|
573
658
|
fileName: import.meta.url,
|
|
574
|
-
lineNumber:
|
|
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
|
-
|
|
587
|
-
get
|
|
588
|
-
return
|
|
589
|
-
|
|
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:
|
|
593
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
617
|
-
get
|
|
618
|
-
return
|
|
619
|
-
|
|
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:
|
|
623
|
-
columnNumber:
|
|
624
|
-
})
|
|
719
|
+
lineNumber: 531,
|
|
720
|
+
columnNumber: 9
|
|
721
|
+
});
|
|
625
722
|
}
|
|
626
723
|
}, {
|
|
627
724
|
fileName: import.meta.url,
|
|
628
|
-
lineNumber:
|
|
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
|
-
|
|
641
|
-
get
|
|
642
|
-
return
|
|
643
|
-
|
|
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:
|
|
647
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
674
|
-
get
|
|
675
|
-
return
|
|
676
|
-
|
|
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:
|
|
680
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
731
|
-
get
|
|
732
|
-
return
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
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:
|
|
743
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
812
|
-
get
|
|
813
|
-
return
|
|
814
|
-
|
|
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:
|
|
818
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
851
|
-
get
|
|
852
|
-
return
|
|
853
|
-
|
|
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:
|
|
857
|
-
columnNumber:
|
|
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:
|
|
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
|
-
|
|
1007
|
+
expect(_$createComponent(TestOutput, {
|
|
883
1008
|
get children() {
|
|
884
|
-
return _$createComponent(py.
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
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:
|
|
1023
|
+
lineNumber: 790,
|
|
891
1024
|
columnNumber: 9
|
|
892
1025
|
});
|
|
893
1026
|
}
|
|
894
1027
|
}, {
|
|
895
1028
|
fileName: import.meta.url,
|
|
896
|
-
lineNumber:
|
|
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
|
-
|
|
910
|
-
get
|
|
911
|
-
return
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
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:
|
|
922
|
-
columnNumber:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
1148
|
+
lineNumber: 856,
|
|
1012
1149
|
columnNumber: 7
|
|
1013
1150
|
});
|
|
1014
|
-
|
|
1015
|
-
name: "A",
|
|
1016
|
-
doc: doc,
|
|
1151
|
+
expect(_$createComponent(TestOutput, {
|
|
1017
1152
|
get children() {
|
|
1018
|
-
return _$createComponent(py.
|
|
1153
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
1154
|
+
name: "A",
|
|
1155
|
+
doc: doc,
|
|
1019
1156
|
get children() {
|
|
1020
|
-
return
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
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:
|
|
1040
|
-
columnNumber:
|
|
1041
|
-
})
|
|
1184
|
+
lineNumber: 903,
|
|
1185
|
+
columnNumber: 11
|
|
1186
|
+
});
|
|
1042
1187
|
}
|
|
1043
1188
|
}, {
|
|
1044
1189
|
fileName: import.meta.url,
|
|
1045
|
-
lineNumber:
|
|
1046
|
-
columnNumber:
|
|
1190
|
+
lineNumber: 902,
|
|
1191
|
+
columnNumber: 9
|
|
1047
1192
|
});
|
|
1048
1193
|
}
|
|
1049
1194
|
}, {
|
|
1050
1195
|
fileName: import.meta.url,
|
|
1051
|
-
lineNumber:
|
|
1052
|
-
columnNumber:
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
1284
|
+
lineNumber: 971,
|
|
1147
1285
|
columnNumber: 7
|
|
1148
1286
|
});
|
|
1149
|
-
|
|
1150
|
-
name: "some_function",
|
|
1151
|
-
doc: doc,
|
|
1287
|
+
expect(_$createComponent(TestOutput, {
|
|
1152
1288
|
get children() {
|
|
1153
|
-
return _$createComponent(py.
|
|
1289
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1290
|
+
name: "some_function",
|
|
1291
|
+
doc: doc,
|
|
1154
1292
|
get children() {
|
|
1155
|
-
return
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
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:
|
|
1175
|
-
columnNumber:
|
|
1176
|
-
})
|
|
1320
|
+
lineNumber: 1005,
|
|
1321
|
+
columnNumber: 11
|
|
1322
|
+
});
|
|
1177
1323
|
}
|
|
1178
1324
|
}, {
|
|
1179
1325
|
fileName: import.meta.url,
|
|
1180
|
-
lineNumber:
|
|
1181
|
-
columnNumber:
|
|
1326
|
+
lineNumber: 1004,
|
|
1327
|
+
columnNumber: 9
|
|
1182
1328
|
});
|
|
1183
1329
|
}
|
|
1184
1330
|
}, {
|
|
1185
1331
|
fileName: import.meta.url,
|
|
1186
|
-
lineNumber:
|
|
1187
|
-
columnNumber:
|
|
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
|
|
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
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
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:
|
|
1245
|
-
columnNumber:
|
|
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:
|
|
1406
|
+
lineNumber: 1082,
|
|
1266
1407
|
columnNumber: 23
|
|
1267
1408
|
})];
|
|
1268
1409
|
}
|
|
1269
1410
|
}, {
|
|
1270
1411
|
fileName: import.meta.url,
|
|
1271
|
-
lineNumber:
|
|
1412
|
+
lineNumber: 1081,
|
|
1272
1413
|
columnNumber: 7
|
|
1273
1414
|
});
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
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:
|
|
1294
|
-
columnNumber:
|
|
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:
|
|
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:
|
|
1493
|
+
lineNumber: 1127,
|
|
1349
1494
|
columnNumber: 7
|
|
1350
1495
|
});
|
|
1351
|
-
|
|
1352
|
-
path: "utils.py",
|
|
1353
|
-
doc: moduleDoc,
|
|
1496
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1354
1497
|
get children() {
|
|
1355
|
-
return
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
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:
|
|
1527
|
+
lineNumber: 1153,
|
|
1375
1528
|
columnNumber: 9
|
|
1376
|
-
})
|
|
1529
|
+
});
|
|
1377
1530
|
}
|
|
1378
1531
|
}, {
|
|
1379
1532
|
fileName: import.meta.url,
|
|
1380
|
-
lineNumber:
|
|
1533
|
+
lineNumber: 1152,
|
|
1381
1534
|
columnNumber: 7
|
|
1382
|
-
})
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
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
|
-
|
|
1541
|
+
Attributes:
|
|
1542
|
+
DEFAULT_TIMEOUT (int): Default timeout value in seconds.
|
|
1396
1543
|
|
|
1397
|
-
|
|
1398
|
-
* Add caching functionality
|
|
1399
|
-
* Improve error messages
|
|
1400
|
-
"""
|
|
1544
|
+
MAX_RETRIES (int): Maximum number of retry attempts.
|
|
1401
1545
|
|
|
1402
|
-
|
|
1546
|
+
Todo:
|
|
1547
|
+
* Add caching functionality
|
|
1548
|
+
* Improve error messages
|
|
1549
|
+
"""
|
|
1403
1550
|
|
|
1404
|
-
|
|
1551
|
+
default_timeout = 30
|
|
1405
1552
|
|
|
1406
|
-
|
|
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:
|
|
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:
|
|
1581
|
+
lineNumber: 1190,
|
|
1434
1582
|
columnNumber: 7
|
|
1435
1583
|
});
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
1639
|
+
lineNumber: 1236,
|
|
1486
1640
|
columnNumber: 7
|
|
1487
1641
|
});
|
|
1488
|
-
|
|
1489
|
-
name: "ValidationError",
|
|
1490
|
-
bases: ["Exception"],
|
|
1491
|
-
doc: exceptionDoc,
|
|
1642
|
+
expect(_$createComponent(TestOutput, {
|
|
1492
1643
|
get children() {
|
|
1493
|
-
return _$createComponent(py.
|
|
1644
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
1645
|
+
name: "ValidationError",
|
|
1646
|
+
bases: ["Exception"],
|
|
1647
|
+
doc: exceptionDoc,
|
|
1494
1648
|
get children() {
|
|
1495
|
-
return
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
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:
|
|
1669
|
+
lineNumber: 1266,
|
|
1508
1670
|
columnNumber: 11
|
|
1509
|
-
})
|
|
1671
|
+
});
|
|
1510
1672
|
}
|
|
1511
1673
|
}, {
|
|
1512
1674
|
fileName: import.meta.url,
|
|
1513
|
-
lineNumber:
|
|
1675
|
+
lineNumber: 1261,
|
|
1514
1676
|
columnNumber: 9
|
|
1515
1677
|
});
|
|
1516
1678
|
}
|
|
1517
1679
|
}, {
|
|
1518
1680
|
fileName: import.meta.url,
|
|
1519
|
-
lineNumber:
|
|
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:
|
|
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:
|
|
1714
|
+
lineNumber: 1294,
|
|
1555
1715
|
columnNumber: 7
|
|
1556
1716
|
});
|
|
1557
|
-
|
|
1558
|
-
name: "Person",
|
|
1717
|
+
expect(_$createComponent(TestOutput, {
|
|
1559
1718
|
get children() {
|
|
1560
|
-
return _$createComponent(py.
|
|
1561
|
-
name: "
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
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:
|
|
1735
|
+
lineNumber: 1307,
|
|
1568
1736
|
columnNumber: 9
|
|
1569
1737
|
});
|
|
1570
1738
|
}
|
|
1571
1739
|
}, {
|
|
1572
1740
|
fileName: import.meta.url,
|
|
1573
|
-
lineNumber:
|
|
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:
|
|
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:
|
|
1783
|
+
lineNumber: 1331,
|
|
1617
1784
|
columnNumber: 7
|
|
1618
1785
|
});
|
|
1619
|
-
|
|
1620
|
-
name: "DataValidator",
|
|
1786
|
+
expect(_$createComponent(TestOutput, {
|
|
1621
1787
|
get children() {
|
|
1622
|
-
return _$createComponent(py.
|
|
1623
|
-
name: "
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
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:
|
|
1812
|
+
lineNumber: 1360,
|
|
1638
1813
|
columnNumber: 9
|
|
1639
1814
|
});
|
|
1640
1815
|
}
|
|
1641
1816
|
}, {
|
|
1642
1817
|
fileName: import.meta.url,
|
|
1643
|
-
lineNumber:
|
|
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
|
});
|