@alloy-js/python 0.2.0-dev.3 → 0.2.0-dev.5
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/Atom.d.ts +1 -0
- package/dist/src/components/Atom.d.ts.map +1 -1
- package/dist/src/components/Atom.js +3 -0
- package/dist/src/components/Atom.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/values.test.js +35 -0
- package/dist/test/values.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/Atom.tsx +4 -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 +5323 -2288
- 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/values.test.tsx +34 -0
- package/test/variables.test.tsx +27 -16
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Prose } from "@alloy-js/core";
|
|
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
|
+
|
|
8
|
+
describe("PropertyDeclaration", () => {
|
|
9
|
+
it("renders empty property, setter, deleter", () => {
|
|
10
|
+
const decl = (
|
|
11
|
+
<py.StatementList>
|
|
12
|
+
<py.ClassDeclaration name="MyClass">
|
|
13
|
+
<py.StatementList>
|
|
14
|
+
<py.PropertyDeclaration name="x">
|
|
15
|
+
<py.PropertyDeclaration.Setter />
|
|
16
|
+
<py.PropertyDeclaration.Deleter />
|
|
17
|
+
</py.PropertyDeclaration>
|
|
18
|
+
</py.StatementList>
|
|
19
|
+
</py.ClassDeclaration>
|
|
20
|
+
</py.StatementList>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect(toSourceText([decl], { externals: [abcModule] })).toBe(d`
|
|
24
|
+
class MyClass:
|
|
25
|
+
@property
|
|
26
|
+
def x(self):
|
|
27
|
+
raise NotImplementedError
|
|
28
|
+
|
|
29
|
+
@x.setter
|
|
30
|
+
def x(self, value) -> None:
|
|
31
|
+
raise NotImplementedError
|
|
32
|
+
|
|
33
|
+
@x.deleter
|
|
34
|
+
def x(self) -> None:
|
|
35
|
+
raise NotImplementedError
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("renders normal property, setter, deleter with children and type", () => {
|
|
42
|
+
const decl = (
|
|
43
|
+
<py.StatementList>
|
|
44
|
+
<py.ClassDeclaration name="MyClass">
|
|
45
|
+
<py.StatementList>
|
|
46
|
+
<py.PropertyDeclaration name="x" type="int">
|
|
47
|
+
something
|
|
48
|
+
<py.PropertyDeclaration.Setter>
|
|
49
|
+
something else
|
|
50
|
+
</py.PropertyDeclaration.Setter>
|
|
51
|
+
<py.PropertyDeclaration.Deleter>
|
|
52
|
+
some other thing
|
|
53
|
+
</py.PropertyDeclaration.Deleter>
|
|
54
|
+
</py.PropertyDeclaration>
|
|
55
|
+
</py.StatementList>
|
|
56
|
+
</py.ClassDeclaration>
|
|
57
|
+
</py.StatementList>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect(toSourceText([decl], { externals: [abcModule] })).toBe(d`
|
|
61
|
+
class MyClass:
|
|
62
|
+
@property
|
|
63
|
+
def x(self) -> int:
|
|
64
|
+
something
|
|
65
|
+
|
|
66
|
+
@x.setter
|
|
67
|
+
def x(self, value: int) -> None:
|
|
68
|
+
something else
|
|
69
|
+
|
|
70
|
+
@x.deleter
|
|
71
|
+
def x(self) -> None:
|
|
72
|
+
some other thing
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
`);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("renders normal property, setter, deleter with children and type, overriding the setter type", () => {
|
|
79
|
+
const propertyDoc = (
|
|
80
|
+
<py.FunctionDoc
|
|
81
|
+
description={[<Prose>Property documentation.</Prose>]}
|
|
82
|
+
style="google"
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
const setterDoc = (
|
|
86
|
+
<py.FunctionDoc
|
|
87
|
+
description={[
|
|
88
|
+
<Prose>We can receive a string, a float, or a str.</Prose>,
|
|
89
|
+
]}
|
|
90
|
+
style="google"
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
const deleterDoc = (
|
|
94
|
+
<py.FunctionDoc
|
|
95
|
+
description={[<Prose>Deleter documentation.</Prose>]}
|
|
96
|
+
style="google"
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
const decl = (
|
|
100
|
+
<py.StatementList>
|
|
101
|
+
<py.ClassDeclaration name="MyClass">
|
|
102
|
+
<py.StatementList>
|
|
103
|
+
<py.PropertyDeclaration name="x" type="int" doc={propertyDoc}>
|
|
104
|
+
something
|
|
105
|
+
<py.PropertyDeclaration.Setter
|
|
106
|
+
type={
|
|
107
|
+
<py.UnionTypeExpression>
|
|
108
|
+
{["int", "float", "str"]}
|
|
109
|
+
</py.UnionTypeExpression>
|
|
110
|
+
}
|
|
111
|
+
doc={setterDoc}
|
|
112
|
+
>
|
|
113
|
+
self._string = str(value)
|
|
114
|
+
</py.PropertyDeclaration.Setter>
|
|
115
|
+
<py.PropertyDeclaration.Deleter doc={deleterDoc}>
|
|
116
|
+
some other thing
|
|
117
|
+
</py.PropertyDeclaration.Deleter>
|
|
118
|
+
</py.PropertyDeclaration>
|
|
119
|
+
</py.StatementList>
|
|
120
|
+
</py.ClassDeclaration>
|
|
121
|
+
</py.StatementList>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expect(toSourceText([decl], { externals: [abcModule] })).toBe(d`
|
|
125
|
+
class MyClass:
|
|
126
|
+
@property
|
|
127
|
+
def x(self) -> int:
|
|
128
|
+
"""
|
|
129
|
+
Property documentation.
|
|
130
|
+
"""
|
|
131
|
+
something
|
|
132
|
+
|
|
133
|
+
@x.setter
|
|
134
|
+
def x(self, value: int | float | str) -> None:
|
|
135
|
+
"""
|
|
136
|
+
We can receive a string, a float, or a str.
|
|
137
|
+
"""
|
|
138
|
+
self._string = str(value)
|
|
139
|
+
|
|
140
|
+
@x.deleter
|
|
141
|
+
def x(self) -> None:
|
|
142
|
+
"""
|
|
143
|
+
Deleter documentation.
|
|
144
|
+
"""
|
|
145
|
+
some other thing
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
`);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("renders abstract property with getter, setter, deleter", () => {
|
|
152
|
+
const decl = (
|
|
153
|
+
<py.StatementList>
|
|
154
|
+
<py.ClassDeclaration name="MyClass">
|
|
155
|
+
<py.StatementList>
|
|
156
|
+
<py.PropertyDeclaration name="value" type="int" abstract>
|
|
157
|
+
return self._value
|
|
158
|
+
<py.PropertyDeclaration.Setter type="int">
|
|
159
|
+
self._value = value
|
|
160
|
+
</py.PropertyDeclaration.Setter>
|
|
161
|
+
<py.PropertyDeclaration.Deleter>
|
|
162
|
+
del self._value
|
|
163
|
+
</py.PropertyDeclaration.Deleter>
|
|
164
|
+
</py.PropertyDeclaration>
|
|
165
|
+
</py.StatementList>
|
|
166
|
+
</py.ClassDeclaration>
|
|
167
|
+
</py.StatementList>
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
expect(toSourceText([decl], { externals: [abcModule] })).toBe(d`
|
|
171
|
+
from abc import abstractmethod
|
|
172
|
+
|
|
173
|
+
class MyClass:
|
|
174
|
+
@property
|
|
175
|
+
@abstractmethod
|
|
176
|
+
def value(self) -> int:
|
|
177
|
+
return self._value
|
|
178
|
+
|
|
179
|
+
@value.setter
|
|
180
|
+
@abstractmethod
|
|
181
|
+
def value(self, value: int) -> None:
|
|
182
|
+
self._value = value
|
|
183
|
+
|
|
184
|
+
@value.deleter
|
|
185
|
+
@abstractmethod
|
|
186
|
+
def value(self) -> None:
|
|
187
|
+
del self._value
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
`);
|
|
191
|
+
});
|
|
192
|
+
});
|