@alloy-js/python 0.2.0-dev.3 → 0.2.0-dev.4
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/src/builtins/python.d.ts +3 -0
- package/dist/src/builtins/python.d.ts.map +1 -1
- package/dist/src/builtins/python.js +6 -0
- package/dist/src/builtins/python.js.map +1 -1
- package/dist/src/components/CallSignature.d.ts +4 -15
- package/dist/src/components/CallSignature.d.ts.map +1 -1
- package/dist/src/components/CallSignature.js +13 -67
- package/dist/src/components/CallSignature.js.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts +22 -0
- package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/ClassMethodDeclaration.js +32 -0
- package/dist/src/components/ClassMethodDeclaration.js.map +1 -0
- package/dist/src/components/ConstructorDeclaration.d.ts +21 -0
- package/dist/src/components/ConstructorDeclaration.d.ts.map +1 -0
- package/dist/src/components/ConstructorDeclaration.js +35 -0
- package/dist/src/components/ConstructorDeclaration.js.map +1 -0
- package/dist/src/components/DunderMethodDeclaration.d.ts +21 -0
- package/dist/src/components/DunderMethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/DunderMethodDeclaration.js +29 -0
- package/dist/src/components/DunderMethodDeclaration.js.map +1 -0
- package/dist/src/components/EnumDeclaration.d.ts +11 -32
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +10 -48
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/EnumMember.js +3 -3
- package/dist/src/components/EnumMember.js.map +1 -1
- package/dist/src/components/FunctionBase.d.ts +48 -0
- package/dist/src/components/FunctionBase.d.ts.map +1 -0
- package/dist/src/components/FunctionBase.js +91 -0
- package/dist/src/components/FunctionBase.js.map +1 -0
- package/dist/src/components/FunctionDeclaration.d.ts +11 -31
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +22 -79
- package/dist/src/components/FunctionDeclaration.js.map +1 -1
- package/dist/src/components/MethodBase.d.ts +29 -0
- package/dist/src/components/MethodBase.d.ts.map +1 -0
- package/dist/src/components/MethodBase.js +32 -0
- package/dist/src/components/MethodBase.js.map +1 -0
- package/dist/src/components/MethodDeclaration.d.ts +22 -0
- package/dist/src/components/MethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/MethodDeclaration.js +34 -0
- package/dist/src/components/MethodDeclaration.js.map +1 -0
- package/dist/src/components/PropertyDeclaration.d.ts +71 -0
- package/dist/src/components/PropertyDeclaration.d.ts.map +1 -0
- package/dist/src/components/PropertyDeclaration.js +227 -0
- package/dist/src/components/PropertyDeclaration.js.map +1 -0
- package/dist/src/components/PyDoc.d.ts +107 -42
- package/dist/src/components/PyDoc.d.ts.map +1 -1
- package/dist/src/components/PyDoc.js +845 -181
- package/dist/src/components/PyDoc.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts +24 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +28 -1
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.d.ts +22 -0
- package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -0
- package/dist/src/components/StaticMethodDeclaration.js +32 -0
- package/dist/src/components/StaticMethodDeclaration.js.map +1 -0
- package/dist/src/components/TypeArguments.d.ts +9 -0
- package/dist/src/components/TypeArguments.d.ts.map +1 -0
- package/dist/src/components/TypeArguments.js +18 -0
- package/dist/src/components/TypeArguments.js.map +1 -0
- package/dist/src/components/TypeReference.d.ts +14 -0
- package/dist/src/components/TypeReference.d.ts.map +1 -0
- package/dist/src/components/TypeReference.js +29 -0
- package/dist/src/components/TypeReference.js.map +1 -0
- package/dist/src/components/UnionTypeExpression.d.ts +1 -2
- package/dist/src/components/UnionTypeExpression.d.ts.map +1 -1
- package/dist/src/components/UnionTypeExpression.js +3 -11
- package/dist/src/components/UnionTypeExpression.js.map +1 -1
- package/dist/src/components/VariableDeclaration.d.ts.map +1 -1
- package/dist/src/components/VariableDeclaration.js +3 -3
- package/dist/src/components/VariableDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +10 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +9 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/parameter-descriptor.d.ts +1 -4
- package/dist/src/parameter-descriptor.d.ts.map +1 -1
- package/dist/src/parameter-descriptor.js +7 -1
- package/dist/src/parameter-descriptor.js.map +1 -1
- package/dist/src/symbol-creation.d.ts +4 -0
- package/dist/src/symbol-creation.d.ts.map +1 -1
- package/dist/src/symbol-creation.js +12 -0
- package/dist/src/symbol-creation.js.map +1 -1
- package/dist/src/symbols/factories.d.ts +15 -0
- package/dist/src/symbols/factories.d.ts.map +1 -0
- package/dist/src/symbols/factories.js +28 -0
- package/dist/src/symbols/factories.js.map +1 -0
- package/dist/src/symbols/index.d.ts +1 -0
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +1 -0
- package/dist/src/symbols/index.js.map +1 -1
- package/dist/src/symbols/reference.d.ts +1 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +1 -1
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/test/callsignatures.test.js +42 -64
- package/dist/test/callsignatures.test.js.map +1 -1
- package/dist/test/class-method-declaration.test.d.ts +2 -0
- package/dist/test/class-method-declaration.test.d.ts.map +1 -0
- package/dist/test/class-method-declaration.test.js +61 -0
- package/dist/test/class-method-declaration.test.js.map +1 -0
- package/dist/test/classdeclarations.test.js +6 -8
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/constructordeclaration.test.d.ts +2 -0
- package/dist/test/constructordeclaration.test.d.ts.map +1 -0
- package/dist/test/constructordeclaration.test.js +58 -0
- package/dist/test/constructordeclaration.test.js.map +1 -0
- package/dist/test/dundermethoddeclaration.test.d.ts +2 -0
- package/dist/test/dundermethoddeclaration.test.d.ts.map +1 -0
- package/dist/test/dundermethoddeclaration.test.js +65 -0
- package/dist/test/dundermethoddeclaration.test.js.map +1 -0
- package/dist/test/enums.test.js +14 -16
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/externals.test.js +2 -4
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/factories.test.d.ts +2 -0
- package/dist/test/factories.test.d.ts.map +1 -0
- package/dist/test/factories.test.js +78 -0
- package/dist/test/factories.test.js.map +1 -0
- package/dist/test/functiondeclaration.test.js +213 -59
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/memberexpressions.test.js +1 -1
- package/dist/test/memberexpressions.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.d.ts +2 -0
- package/dist/test/methoddeclaration.test.d.ts.map +1 -0
- package/dist/test/methoddeclaration.test.js +239 -0
- package/dist/test/methoddeclaration.test.js.map +1 -0
- package/dist/test/namepolicies.test.js +1 -2
- package/dist/test/namepolicies.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.d.ts +2 -0
- package/dist/test/propertydeclaration.test.d.ts.map +1 -0
- package/dist/test/propertydeclaration.test.js +229 -0
- package/dist/test/propertydeclaration.test.js.map +1 -0
- package/dist/test/pydocs.test.js +926 -126
- package/dist/test/pydocs.test.js.map +1 -1
- package/dist/test/references.test.js +1 -5
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +90 -1
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/staticmethoddeclaration.test.d.ts +2 -0
- package/dist/test/staticmethoddeclaration.test.d.ts.map +1 -0
- package/dist/test/staticmethoddeclaration.test.js +61 -0
- package/dist/test/staticmethoddeclaration.test.js.map +1 -0
- package/dist/test/typereference.test.d.ts +2 -0
- package/dist/test/typereference.test.d.ts.map +1 -0
- package/dist/test/typereference.test.js +51 -0
- package/dist/test/typereference.test.js.map +1 -0
- package/dist/test/uniontypeexpression.test.js +152 -15
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/variables.test.js +28 -19
- package/dist/test/variables.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/builtins/python.ts +7 -0
- package/src/components/CallSignature.tsx +17 -69
- package/src/components/ClassMethodDeclaration.tsx +34 -0
- package/src/components/ConstructorDeclaration.tsx +37 -0
- package/src/components/DunderMethodDeclaration.tsx +30 -0
- package/src/components/EnumDeclaration.tsx +16 -44
- package/src/components/EnumMember.tsx +3 -3
- package/src/components/FunctionBase.tsx +88 -0
- package/src/components/FunctionDeclaration.tsx +18 -82
- package/src/components/MethodBase.tsx +53 -0
- package/src/components/MethodDeclaration.tsx +27 -0
- package/src/components/PropertyDeclaration.tsx +264 -0
- package/src/components/PyDoc.tsx +795 -195
- package/src/components/SourceFile.tsx +29 -0
- package/src/components/StaticMethodDeclaration.tsx +34 -0
- package/src/components/TypeArguments.tsx +24 -0
- package/src/components/TypeReference.tsx +33 -0
- package/src/components/UnionTypeExpression.tsx +4 -15
- package/src/components/VariableDeclaration.tsx +1 -3
- package/src/components/index.ts +10 -0
- package/src/parameter-descriptor.ts +6 -5
- package/src/symbol-creation.ts +17 -0
- package/src/symbols/factories.ts +39 -0
- package/src/symbols/index.ts +1 -0
- package/src/symbols/reference.tsx +3 -5
- package/src/utils.ts +0 -2
- package/temp/api.json +5281 -2273
- package/test/callsignatures.test.tsx +102 -74
- package/test/class-method-declaration.test.tsx +53 -0
- package/test/classdeclarations.test.tsx +7 -9
- package/test/constructordeclaration.test.tsx +48 -0
- package/test/dundermethoddeclaration.test.tsx +53 -0
- package/test/enums.test.tsx +14 -16
- package/test/externals.test.tsx +5 -7
- package/test/factories.test.tsx +72 -0
- package/test/functiondeclaration.test.tsx +196 -44
- package/test/memberexpressions.test.tsx +7 -2
- package/test/methoddeclaration.test.tsx +202 -0
- package/test/namepolicies.test.tsx +1 -2
- package/test/propertydeclaration.test.tsx +192 -0
- package/test/pydocs.test.tsx +1093 -129
- package/test/references.test.tsx +1 -1
- package/test/sourcefiles.test.tsx +100 -1
- package/test/staticmethoddeclaration.test.tsx +49 -0
- package/test/typereference.test.tsx +52 -0
- package/test/uniontypeexpression.test.tsx +169 -34
- package/test/variables.test.tsx +27 -16
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import * as py from "../src/index.js";
|
|
5
|
+
import { abcModule } from "../src/index.js";
|
|
6
|
+
import { toSourceText } from "./utils.js";
|
|
7
|
+
describe("Method-like Declarations", () => {
|
|
8
|
+
it("renders an instance function with a body", () => {
|
|
9
|
+
const result = toSourceText([_$createComponent(py.ClassDeclaration, {
|
|
10
|
+
name: "MyClass",
|
|
11
|
+
get children() {
|
|
12
|
+
return _$createComponent(py.MethodDeclaration, {
|
|
13
|
+
name: "bar",
|
|
14
|
+
children: "print('hi')"
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
})]);
|
|
18
|
+
expect(result).toRenderTo(d`
|
|
19
|
+
class MyClass:
|
|
20
|
+
def bar(self):
|
|
21
|
+
print('hi')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
`);
|
|
26
|
+
});
|
|
27
|
+
it("can be an async method", () => {
|
|
28
|
+
const decl = _$createComponent(py.StatementList, {
|
|
29
|
+
get children() {
|
|
30
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
31
|
+
name: "MyClass",
|
|
32
|
+
get children() {
|
|
33
|
+
return _$createComponent(py.StatementList, {
|
|
34
|
+
get children() {
|
|
35
|
+
return _$createComponent(py.MethodDeclaration, {
|
|
36
|
+
async: true,
|
|
37
|
+
name: "my_method",
|
|
38
|
+
returnType: "str",
|
|
39
|
+
children: "return \"async result\""
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
expect(toSourceText([decl])).toBe(d`
|
|
48
|
+
class MyClass:
|
|
49
|
+
async def my_method(self) -> str:
|
|
50
|
+
return "async result"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
`);
|
|
54
|
+
});
|
|
55
|
+
it("can be an async class method", () => {
|
|
56
|
+
const decl = _$createComponent(py.StatementList, {
|
|
57
|
+
get children() {
|
|
58
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
59
|
+
name: "MyClass",
|
|
60
|
+
get children() {
|
|
61
|
+
return _$createComponent(py.StatementList, {
|
|
62
|
+
get children() {
|
|
63
|
+
return _$createComponent(py.ClassMethodDeclaration, {
|
|
64
|
+
async: true,
|
|
65
|
+
name: "create_async",
|
|
66
|
+
returnType: "MyClass",
|
|
67
|
+
children: "return cls()"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
expect(toSourceText([decl])).toBe(d`
|
|
76
|
+
class MyClass:
|
|
77
|
+
@classmethod
|
|
78
|
+
async def create_async(cls) -> MyClass:
|
|
79
|
+
return cls()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
`);
|
|
83
|
+
});
|
|
84
|
+
it("can be an async static method", () => {
|
|
85
|
+
const decl = _$createComponent(py.StatementList, {
|
|
86
|
+
get children() {
|
|
87
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
88
|
+
name: "MyClass",
|
|
89
|
+
get children() {
|
|
90
|
+
return _$createComponent(py.StatementList, {
|
|
91
|
+
get children() {
|
|
92
|
+
return _$createComponent(py.StaticMethodDeclaration, {
|
|
93
|
+
async: true,
|
|
94
|
+
name: "utility",
|
|
95
|
+
returnType: "str",
|
|
96
|
+
children: "return \"utility result\""
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
expect(toSourceText([decl])).toBe(d`
|
|
105
|
+
class MyClass:
|
|
106
|
+
@staticmethod
|
|
107
|
+
async def utility() -> str:
|
|
108
|
+
return "utility result"
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
`);
|
|
112
|
+
});
|
|
113
|
+
it("renders method with parameters", () => {
|
|
114
|
+
const parameters = [{
|
|
115
|
+
name: "x",
|
|
116
|
+
type: "int"
|
|
117
|
+
}];
|
|
118
|
+
const decl = _$createComponent(py.ClassDeclaration, {
|
|
119
|
+
name: "MyClass",
|
|
120
|
+
get children() {
|
|
121
|
+
return _$createComponent(py.MethodDeclaration, {
|
|
122
|
+
name: "foo",
|
|
123
|
+
parameters: parameters,
|
|
124
|
+
children: "self.attribute = \"value\""
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
expect(toSourceText([decl])).toBe(d`
|
|
129
|
+
class MyClass:
|
|
130
|
+
def foo(self, x: int):
|
|
131
|
+
self.attribute = "value"
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
`);
|
|
135
|
+
});
|
|
136
|
+
it("renders class method with parameters", () => {
|
|
137
|
+
const parameters = [{
|
|
138
|
+
name: "x",
|
|
139
|
+
type: "int"
|
|
140
|
+
}];
|
|
141
|
+
const decl = _$createComponent(py.ClassDeclaration, {
|
|
142
|
+
name: "MyClass",
|
|
143
|
+
get children() {
|
|
144
|
+
return _$createComponent(py.ClassMethodDeclaration, {
|
|
145
|
+
name: "foo",
|
|
146
|
+
parameters: parameters,
|
|
147
|
+
children: "self.attribute = \"value\""
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
expect(toSourceText([decl])).toBe(d`
|
|
152
|
+
class MyClass:
|
|
153
|
+
@classmethod
|
|
154
|
+
def foo(cls, x: int):
|
|
155
|
+
self.attribute = "value"
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
`);
|
|
159
|
+
});
|
|
160
|
+
it("renders static method with parameters", () => {
|
|
161
|
+
const parameters = [{
|
|
162
|
+
name: "x",
|
|
163
|
+
type: "int"
|
|
164
|
+
}];
|
|
165
|
+
const decl = _$createComponent(py.ClassDeclaration, {
|
|
166
|
+
name: "MyClass",
|
|
167
|
+
get children() {
|
|
168
|
+
return _$createComponent(py.StaticMethodDeclaration, {
|
|
169
|
+
name: "foo",
|
|
170
|
+
parameters: parameters,
|
|
171
|
+
children: "attribute = \"value\""
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
expect(toSourceText([decl])).toBe(d`
|
|
176
|
+
class MyClass:
|
|
177
|
+
@staticmethod
|
|
178
|
+
def foo(x: int):
|
|
179
|
+
attribute = "value"
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
`);
|
|
183
|
+
});
|
|
184
|
+
it("renders abstract methods", () => {
|
|
185
|
+
const parameters = [{
|
|
186
|
+
name: "x",
|
|
187
|
+
type: "int"
|
|
188
|
+
}];
|
|
189
|
+
const decl = _$createComponent(py.StatementList, {
|
|
190
|
+
get children() {
|
|
191
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
192
|
+
name: "MyClass",
|
|
193
|
+
get children() {
|
|
194
|
+
return _$createComponent(py.StatementList, {
|
|
195
|
+
get children() {
|
|
196
|
+
return [_$createComponent(py.MethodDeclaration, {
|
|
197
|
+
name: "methoddef",
|
|
198
|
+
parameters: parameters,
|
|
199
|
+
abstract: true
|
|
200
|
+
}), _$createComponent(py.ClassMethodDeclaration, {
|
|
201
|
+
name: "classdef",
|
|
202
|
+
parameters: parameters,
|
|
203
|
+
abstract: true
|
|
204
|
+
}), _$createComponent(py.StaticMethodDeclaration, {
|
|
205
|
+
name: "staticdef",
|
|
206
|
+
parameters: parameters,
|
|
207
|
+
abstract: true
|
|
208
|
+
})];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
expect(toSourceText([decl], {
|
|
216
|
+
externals: [abcModule]
|
|
217
|
+
})).toBe(d`
|
|
218
|
+
from abc import abstractmethod
|
|
219
|
+
|
|
220
|
+
class MyClass:
|
|
221
|
+
@abstractmethod
|
|
222
|
+
def methoddef(self, x: int):
|
|
223
|
+
pass
|
|
224
|
+
|
|
225
|
+
@classmethod
|
|
226
|
+
@abstractmethod
|
|
227
|
+
def classdef(cls, x: int):
|
|
228
|
+
pass
|
|
229
|
+
|
|
230
|
+
@staticmethod
|
|
231
|
+
@abstractmethod
|
|
232
|
+
def staticdef(x: int):
|
|
233
|
+
pass
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
`);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
//# sourceMappingURL=methoddeclaration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["d","describe","expect","it","py","abcModule","toSourceText","result","_$createComponent","ClassDeclaration","name","children","MethodDeclaration","toRenderTo","decl","StatementList","async","returnType","toBe","ClassMethodDeclaration","StaticMethodDeclaration","parameters","type","abstract","externals"],"sources":["../../test/methoddeclaration.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,YAAY;AAEzCL,QAAQ,CAAC,0BAA0B,EAAE,MAAM;EACzCE,EAAE,CAAC,0CAA0C,EAAE,MAAM;IACnD,MAAMI,MAAM,GAAGD,YAAY,CAAC,CAAAE,iBAAA,CACzBJ,EAAE,CAACK,gBAAgB;MAACC,IAAI;MAAA,IAAAC,SAAA;QAAA,OAAAH,iBAAA,CACtBJ,EAAE,CAACQ,iBAAiB;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AACC,IAAI;UAAA,IAAAC,SAAA;YAAA,OAAAH,iBAAA,CACtBJ,EAAE,CAACW,aAAa;cAAA,IAAAJ,SAAA;gBAAA,QAAAH,iBAAA,CACdJ,EAAE,CAACQ,iBAAiB;kBACnBF,IAAI;kBACJW,UAAU,EAAEA,UAAU;kBACtBE,QAAQ;gBAAA,IAAAf,iBAAA,CAETJ,EAAE,CAACe,sBAAsB;kBACxBT,IAAI;kBACJW,UAAU,EAAEA,UAAU;kBACtBE,QAAQ;gBAAA,IAAAf,iBAAA,CAETJ,EAAE,CAACgB,uBAAuB;kBACzBV,IAAI;kBACJW,UAAU,EAAEA,UAAU;kBACtBE,QAAQ;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA,EAKjB;IAEDrB,MAAM,CAACI,YAAY,CAAC,CAACQ,IAAI,CAAC,EAAE;MAAEU,SAAS,EAAE,CAACnB,SAAS;IAAE,CAAC,CAAC,CAAC,CAACa,IAAI,CAAClB,CAAC;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -17,9 +17,8 @@ it("correct formatting of class name", () => {
|
|
|
17
17
|
expect(result).toRenderTo(expected);
|
|
18
18
|
});
|
|
19
19
|
it("correct formatting of Enum name and EnumMember names", () => {
|
|
20
|
-
const result = toSourceText([_$createComponent(py.
|
|
20
|
+
const result = toSourceText([_$createComponent(py.FunctionalEnumDeclaration, {
|
|
21
21
|
name: "priority",
|
|
22
|
-
style: "functional",
|
|
23
22
|
members: [{
|
|
24
23
|
name: "high",
|
|
25
24
|
value: 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["d","expect","it","enumModule","py","toSourceText","result","_$createComponent","ClassDeclaration","name","expected","toRenderTo","
|
|
1
|
+
{"version":3,"names":["d","expect","it","enumModule","py","toSourceText","result","_$createComponent","ClassDeclaration","name","expected","toRenderTo","FunctionalEnumDeclaration","members","value","externals","FunctionDeclaration","parameters","type","args","kwargs","children","CallSignatureParameters","StatementList","ClassInstantiation","target","VariableDeclaration","initializer","Atom","jsValue","callStatementVar","res","toBe"],"sources":["../../test/namepolicies.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACnC,SAASC,UAAU,QAAQ,2BAA2B;AACtD,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,YAAY;AAErBH,EAAE,CAAC,kCAAkC,EAAE,MAAM;EAC3C,MAAMI,MAAM,GAAGD,YAAY,CAAC,CAAAE,iBAAA,CACzBH,EAAE,CAACI,gBAAgB;IAACC,IAAI;EAAA,GAC1B,CAAC;EACF,MAAMC,QAAQ,GAAGV,CAAC;AACpB;AACA;AACA;AACA;AACA,GAAG;EACDC,MAAM,CAACK,MAAM,CAAC,CAACK,UAAU,CAACD,QAAQ,CAAC;AACrC,CAAC,CAAC;AAEFR,EAAE,CAAC,sDAAsD,EAAE,MAAM;EAC/D,MAAMI,MAAM,GAAGD,YAAY,CACzB,CAAAE,iBAAA,CACGH,EAAE,CAACQ,yBAAyB;IAC3BH,IAAI;IACJI,OAAO,EAAE,CACP;MAAEJ,IAAI,EAAE,MAAM;MAAEK,KAAK,EAAE;IAAE,CAAC,EAC1B;MAAEL,IAAI,EAAE,QAAQ;MAAEK,KAAK,EAAE;IAAE,CAAC,EAC5B;MAAEL,IAAI,EAAE,UAAU;MAAEK,KAAK,EAAE;IAAE,CAAC;EAC/B,GAEJ,EACD;IAAEC,SAAS,EAAE,CAACZ,UAAU;EAAE,CAC5B,CAAC;EACD,MAAMO,QAAQ,GAAGV,CAAC;AACpB;AACA;AACA;AACA,GAAG;EACDC,MAAM,CAACK,MAAM,CAAC,CAACK,UAAU,CAACD,QAAQ,CAAC;AACrC,CAAC,CAA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H,EAAE,CAACsB,mBAAmB;YACrBjB,IAAI;YAAA,IACJkB,WAAWA,CAAA;cAAA,OAAApB,iBAAA,CAAGH,EAAE,CAACwB,IAAI;gBAACC,OAAO,EAAE;cAAE;YAAA;YACjCC,gBAAgB;UAAA,GAEnB;QAAA;MAAA;IAAA;EAAA,GAGN,CAAC;EACF7B,MAAM,CAACK,MAAM,CAAC,CAACK,UAAU,CACvB,6DACF,CAAC;AACH,CAAC,CAAC;AAEFT,EAAE,CAAC,qCAAqC,EAAE,MAAM;EAC9C,MAAM6B,GAAG,GAAG1B,YAAY,CAAC,CAAAE,iBAAA,CACtBH,EAAE,CAACsB,mBAAmB;IAACjB,IAAI;IAASS,IAAI;IAAOS,WAAW,EAAE;EAAE,GAChE,CAAC;EACF1B,MAAM,CAAC8B,GAAG,CAAC,CAACC,IAAI,CAAC,kBAAkB,CAAC;AACtC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propertydeclaration.test.d.ts","sourceRoot":"","sources":["../../test/propertydeclaration.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Prose } from "@alloy-js/core";
|
|
3
|
+
import { d } from "@alloy-js/core/testing";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import * as py from "../src/index.js";
|
|
6
|
+
import { abcModule } from "../src/index.js";
|
|
7
|
+
import { toSourceText } from "./utils.js";
|
|
8
|
+
describe("PropertyDeclaration", () => {
|
|
9
|
+
it("renders empty property, setter, deleter", () => {
|
|
10
|
+
const decl = _$createComponent(py.StatementList, {
|
|
11
|
+
get children() {
|
|
12
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
13
|
+
name: "MyClass",
|
|
14
|
+
get children() {
|
|
15
|
+
return _$createComponent(py.StatementList, {
|
|
16
|
+
get children() {
|
|
17
|
+
return _$createComponent(py.PropertyDeclaration, {
|
|
18
|
+
name: "x",
|
|
19
|
+
get children() {
|
|
20
|
+
return [_$createComponent(py.PropertyDeclaration.Setter, {}), _$createComponent(py.PropertyDeclaration.Deleter, {})];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
expect(toSourceText([decl], {
|
|
30
|
+
externals: [abcModule]
|
|
31
|
+
})).toBe(d`
|
|
32
|
+
class MyClass:
|
|
33
|
+
@property
|
|
34
|
+
def x(self):
|
|
35
|
+
raise NotImplementedError
|
|
36
|
+
|
|
37
|
+
@x.setter
|
|
38
|
+
def x(self, value) -> None:
|
|
39
|
+
raise NotImplementedError
|
|
40
|
+
|
|
41
|
+
@x.deleter
|
|
42
|
+
def x(self) -> None:
|
|
43
|
+
raise NotImplementedError
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
`);
|
|
47
|
+
});
|
|
48
|
+
it("renders normal property, setter, deleter with children and type", () => {
|
|
49
|
+
const decl = _$createComponent(py.StatementList, {
|
|
50
|
+
get children() {
|
|
51
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
52
|
+
name: "MyClass",
|
|
53
|
+
get children() {
|
|
54
|
+
return _$createComponent(py.StatementList, {
|
|
55
|
+
get children() {
|
|
56
|
+
return _$createComponent(py.PropertyDeclaration, {
|
|
57
|
+
name: "x",
|
|
58
|
+
type: "int",
|
|
59
|
+
get children() {
|
|
60
|
+
return ["something", _$createComponent(py.PropertyDeclaration.Setter, {
|
|
61
|
+
children: "something else"
|
|
62
|
+
}), _$createComponent(py.PropertyDeclaration.Deleter, {
|
|
63
|
+
children: "some other thing"
|
|
64
|
+
})];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
expect(toSourceText([decl], {
|
|
74
|
+
externals: [abcModule]
|
|
75
|
+
})).toBe(d`
|
|
76
|
+
class MyClass:
|
|
77
|
+
@property
|
|
78
|
+
def x(self) -> int:
|
|
79
|
+
something
|
|
80
|
+
|
|
81
|
+
@x.setter
|
|
82
|
+
def x(self, value: int) -> None:
|
|
83
|
+
something else
|
|
84
|
+
|
|
85
|
+
@x.deleter
|
|
86
|
+
def x(self) -> None:
|
|
87
|
+
some other thing
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
`);
|
|
91
|
+
});
|
|
92
|
+
it("renders normal property, setter, deleter with children and type, overriding the setter type", () => {
|
|
93
|
+
const propertyDoc = _$createComponent(py.FunctionDoc, {
|
|
94
|
+
get description() {
|
|
95
|
+
return [_$createComponent(Prose, {
|
|
96
|
+
children: "Property documentation."
|
|
97
|
+
})];
|
|
98
|
+
},
|
|
99
|
+
style: "google"
|
|
100
|
+
});
|
|
101
|
+
const setterDoc = _$createComponent(py.FunctionDoc, {
|
|
102
|
+
get description() {
|
|
103
|
+
return [_$createComponent(Prose, {
|
|
104
|
+
children: "We can receive a string, a float, or a str."
|
|
105
|
+
})];
|
|
106
|
+
},
|
|
107
|
+
style: "google"
|
|
108
|
+
});
|
|
109
|
+
const deleterDoc = _$createComponent(py.FunctionDoc, {
|
|
110
|
+
get description() {
|
|
111
|
+
return [_$createComponent(Prose, {
|
|
112
|
+
children: "Deleter documentation."
|
|
113
|
+
})];
|
|
114
|
+
},
|
|
115
|
+
style: "google"
|
|
116
|
+
});
|
|
117
|
+
const decl = _$createComponent(py.StatementList, {
|
|
118
|
+
get children() {
|
|
119
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
120
|
+
name: "MyClass",
|
|
121
|
+
get children() {
|
|
122
|
+
return _$createComponent(py.StatementList, {
|
|
123
|
+
get children() {
|
|
124
|
+
return _$createComponent(py.PropertyDeclaration, {
|
|
125
|
+
name: "x",
|
|
126
|
+
type: "int",
|
|
127
|
+
doc: propertyDoc,
|
|
128
|
+
get children() {
|
|
129
|
+
return ["something", _$createComponent(py.PropertyDeclaration.Setter, {
|
|
130
|
+
get type() {
|
|
131
|
+
return _$createComponent(py.UnionTypeExpression, {
|
|
132
|
+
children: ["int", "float", "str"]
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
doc: setterDoc,
|
|
136
|
+
children: "self._string = str(value)"
|
|
137
|
+
}), _$createComponent(py.PropertyDeclaration.Deleter, {
|
|
138
|
+
doc: deleterDoc,
|
|
139
|
+
children: "some other thing"
|
|
140
|
+
})];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
expect(toSourceText([decl], {
|
|
150
|
+
externals: [abcModule]
|
|
151
|
+
})).toBe(d`
|
|
152
|
+
class MyClass:
|
|
153
|
+
@property
|
|
154
|
+
def x(self) -> int:
|
|
155
|
+
"""
|
|
156
|
+
Property documentation.
|
|
157
|
+
"""
|
|
158
|
+
something
|
|
159
|
+
|
|
160
|
+
@x.setter
|
|
161
|
+
def x(self, value: int | float | str) -> None:
|
|
162
|
+
"""
|
|
163
|
+
We can receive a string, a float, or a str.
|
|
164
|
+
"""
|
|
165
|
+
self._string = str(value)
|
|
166
|
+
|
|
167
|
+
@x.deleter
|
|
168
|
+
def x(self) -> None:
|
|
169
|
+
"""
|
|
170
|
+
Deleter documentation.
|
|
171
|
+
"""
|
|
172
|
+
some other thing
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
`);
|
|
176
|
+
});
|
|
177
|
+
it("renders abstract property with getter, setter, deleter", () => {
|
|
178
|
+
const decl = _$createComponent(py.StatementList, {
|
|
179
|
+
get children() {
|
|
180
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
181
|
+
name: "MyClass",
|
|
182
|
+
get children() {
|
|
183
|
+
return _$createComponent(py.StatementList, {
|
|
184
|
+
get children() {
|
|
185
|
+
return _$createComponent(py.PropertyDeclaration, {
|
|
186
|
+
name: "value",
|
|
187
|
+
type: "int",
|
|
188
|
+
abstract: true,
|
|
189
|
+
get children() {
|
|
190
|
+
return ["return self._value", _$createComponent(py.PropertyDeclaration.Setter, {
|
|
191
|
+
type: "int",
|
|
192
|
+
children: "self._value = value"
|
|
193
|
+
}), _$createComponent(py.PropertyDeclaration.Deleter, {
|
|
194
|
+
children: "del self._value"
|
|
195
|
+
})];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
expect(toSourceText([decl], {
|
|
205
|
+
externals: [abcModule]
|
|
206
|
+
})).toBe(d`
|
|
207
|
+
from abc import abstractmethod
|
|
208
|
+
|
|
209
|
+
class MyClass:
|
|
210
|
+
@property
|
|
211
|
+
@abstractmethod
|
|
212
|
+
def value(self) -> int:
|
|
213
|
+
return self._value
|
|
214
|
+
|
|
215
|
+
@value.setter
|
|
216
|
+
@abstractmethod
|
|
217
|
+
def value(self, value: int) -> None:
|
|
218
|
+
self._value = value
|
|
219
|
+
|
|
220
|
+
@value.deleter
|
|
221
|
+
@abstractmethod
|
|
222
|
+
def value(self) -> None:
|
|
223
|
+
del self._value
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
`);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
//# sourceMappingURL=propertydeclaration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Prose","d","describe","expect","it","py","abcModule","toSourceText","decl","_$createComponent","StatementList","children","ClassDeclaration","name","PropertyDeclaration","Setter","Deleter","externals","toBe","type","propertyDoc","FunctionDoc","description","style","setterDoc","deleterDoc","doc","UnionTypeExpression","abstract"],"sources":["../../test/propertydeclaration.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,KAAK,QAAQ,gBAAgB;AACtC,SAASC,CAAC,QAAQ,wBAAwB;AAC1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