@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
|
@@ -3,7 +3,7 @@ import { Show } from "@alloy-js/core";
|
|
|
3
3
|
import { enumModule } from "../builtins/python.js";
|
|
4
4
|
import { createPythonSymbol } from "../symbol-creation.js";
|
|
5
5
|
import { Atom } from "./Atom.js";
|
|
6
|
-
import {
|
|
6
|
+
import { SimpleInlineMemberComment } from "./PyDoc.js";
|
|
7
7
|
/**
|
|
8
8
|
* A Python enum member.
|
|
9
9
|
*
|
|
@@ -38,7 +38,7 @@ export function EnumMember(props) {
|
|
|
38
38
|
return props.doc !== undefined;
|
|
39
39
|
},
|
|
40
40
|
get children() {
|
|
41
|
-
return _$createComponent(
|
|
41
|
+
return _$createComponent(SimpleInlineMemberComment, {
|
|
42
42
|
get children() {
|
|
43
43
|
return props.doc;
|
|
44
44
|
}
|
|
@@ -56,7 +56,7 @@ export function EnumMember(props) {
|
|
|
56
56
|
return props.doc !== undefined;
|
|
57
57
|
},
|
|
58
58
|
get children() {
|
|
59
|
-
return _$createComponent(
|
|
59
|
+
return _$createComponent(SimpleInlineMemberComment, {
|
|
60
60
|
get children() {
|
|
61
61
|
return props.doc;
|
|
62
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Show","enumModule","createPythonSymbol","Atom","
|
|
1
|
+
{"version":3,"names":["Show","enumModule","createPythonSymbol","Atom","SimpleInlineMemberComment","EnumMember","props","autoReference","auto","undefined","value","sym","name","refkeys","refkey","valueCode","jsValue","_$createComponent","functional","_$memo","when","children","doc"],"sources":["../../../src/components/EnumMember.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAoCA,IAAI,QAAQ,gBAAgB;AAChE,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,SAASC,IAAI;AACb,SAASC,yBAAyB;AAwClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAAsB,EAAE;EACjD,MAAMC,aAAa,GAAGD,KAAK,CAACE,IAAI,KAAK,IAAI,GAAGP,UAAU,CAAC,GAAG,CAAC,CAACO,IAAI,GAAGC,SAAS;EAC5E,MAAMC,KAAK,GAAGJ,KAAK,CAACE,IAAI,KAAK,IAAI,IAAMD,aAAa,UAASD,KAAK,CAACI,KAAK;EACxE,MAAMC,GAAuB,GAAGT,kBAAkB,CAChDI,KAAK,CAACM,IAAI,EACV;IACEC,OAAO,EAAEP,KAAK,CAACQ;EACjB,CAAC,EACD,aACF,CAAC;EACD,MAAMC,SAAS,GACbT,KAAK,CAACU,OAAO,KAAKP,SAAS,GAAAQ,iBAAA,CAAId,IAAI;IAAA,IAACa,OAAOA,CAAA;MAAA,OAAEV,KAAK,CAACU,OAAO;IAAA;EAAA,KAAON,KAAK;EAExE,IAAIJ,KAAK,CAACY,UAAU,EAAE;IACpB,aAAAC,MAAA,OAEMR,GAAG,CAACC,IAAI,QAAAK,iBAAA,CAAGjB,IAAI;MAACoB,IAAI,EAAEL,SAAS,KAAKN,SAAS;MAAA,IAAAY,SAAA;QAAA,eAAMN,SAAS;MAAA;IAAA,IAAAE,iBAAA,CAC7DjB,IAAI;MAAA,IAACoB,IAAIA,CAAA;QAAA,OAAEd,KAAK,CAACgB,GAAG,KAAKb,SAAS;MAAA;MAAA,IAAAY,SAAA;QAAA,OAAAJ,iBAAA,CAChCb,yBAAyB;UAAA,IAAAiB,SAAA;YAAA,OAAEf,KAAK,CAACgB,GAAG;UAAA;QAAA;MAAA;IAAA;EAI7C;EACA,QAAAH,MAAA,OAEKR,GAAG,CAACC,IAAI,GAAAK,iBAAA,CACRjB,IAAI;IAACoB,IAAI,EAAEL,SAAS,KAAKN,SAAS;IAAA,IAAAY,SAAA;MAAA,eAAMN,SAAS;IAAA;EAAA,IAAAE,iBAAA,CACjDjB,IAAI;IAAA,IAACoB,IAAIA,CAAA;MAAA,OAAEd,KAAK,CAACgB,GAAG,KAAKb,SAAS;IAAA;IAAA,IAAAY,SAAA;MAAA,OAAAJ,iBAAA,CAChCb,yBAAyB;QAAA,IAAAiB,SAAA;UAAA,OAAEf,KAAK,CAACgB,GAAG;QAAA;MAAA;IAAA;EAAA;AAI7C","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PythonOutputSymbol } from "../index.js";
|
|
2
|
+
import { CallSignatureProps } from "./CallSignature.jsx";
|
|
3
|
+
import { BaseDeclarationProps } from "./Declaration.js";
|
|
4
|
+
/**
|
|
5
|
+
* Shared base interface for function-like components.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This interface is consumed by public components like `FunctionDeclaration`,
|
|
9
|
+
* `MethodDeclaration`, and property method helpers. It combines declaration
|
|
10
|
+
* metadata with call signature shape.
|
|
11
|
+
*/
|
|
12
|
+
export interface CommonFunctionProps extends BaseDeclarationProps, CallSignatureProps {
|
|
13
|
+
/** Indicates that the function is async. */
|
|
14
|
+
async?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Props for `BaseFunctionDeclaration`.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This low-level component powers function/method-like declarations by
|
|
21
|
+
* handling symbol creation, parameter injection for instance/class methods,
|
|
22
|
+
* and common rendering concerns. Intended primarily for internal reuse.
|
|
23
|
+
*/
|
|
24
|
+
export interface BaseFunctionDeclarationProps extends CommonFunctionProps {
|
|
25
|
+
/** Indicates the type of function. */
|
|
26
|
+
functionType?: "instance" | "class" | "static";
|
|
27
|
+
/** Pre-created symbol to render. Must be provided by caller. */
|
|
28
|
+
sym: PythonOutputSymbol;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Base function declaration that handles instance/class/static parameter injection
|
|
32
|
+
* and symbol creation. Exported for internal reuse by method-like components.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* // Not typically used directly. Prefer higher-level components.
|
|
37
|
+
* <BaseFunctionDeclaration name="helper" parameters={[{ name: "x" }]}>
|
|
38
|
+
* return x
|
|
39
|
+
* </BaseFunctionDeclaration>
|
|
40
|
+
* ```
|
|
41
|
+
* Generates:
|
|
42
|
+
* ```python
|
|
43
|
+
* def helper(x):
|
|
44
|
+
* return x
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function BaseFunctionDeclaration(props: BaseFunctionDeclarationProps): import("@alloy-js/core").Children;
|
|
48
|
+
//# sourceMappingURL=FunctionBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionBase.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionBase.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAe,MAAM,kBAAkB,CAAC;AAIrE;;;;;;;GAOG;AACH,MAAM,WAAW,mBACf,SAAQ,oBAAoB,EAC1B,kBAAkB;IACpB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,sCAAsC;IACtC,YAAY,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC/C,gEAAgE;IAChE,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,qCAgC1E"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Name, Show } from "@alloy-js/core";
|
|
3
|
+
import { getCallSignatureProps } from "../utils.js";
|
|
4
|
+
import { CallSignature } from "./CallSignature.js";
|
|
5
|
+
import { Declaration } from "./Declaration.js";
|
|
6
|
+
import { LexicalScope } from "./LexicalScope.js";
|
|
7
|
+
import { PythonBlock } from "./PythonBlock.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Shared base interface for function-like components.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* This interface is consumed by public components like `FunctionDeclaration`,
|
|
14
|
+
* `MethodDeclaration`, and property method helpers. It combines declaration
|
|
15
|
+
* metadata with call signature shape.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Props for `BaseFunctionDeclaration`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* This low-level component powers function/method-like declarations by
|
|
23
|
+
* handling symbol creation, parameter injection for instance/class methods,
|
|
24
|
+
* and common rendering concerns. Intended primarily for internal reuse.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Base function declaration that handles instance/class/static parameter injection
|
|
29
|
+
* and symbol creation. Exported for internal reuse by method-like components.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Not typically used directly. Prefer higher-level components.
|
|
34
|
+
* <BaseFunctionDeclaration name="helper" parameters={[{ name: "x" }]}>
|
|
35
|
+
* return x
|
|
36
|
+
* </BaseFunctionDeclaration>
|
|
37
|
+
* ```
|
|
38
|
+
* Generates:
|
|
39
|
+
* ```python
|
|
40
|
+
* def helper(x):
|
|
41
|
+
* return x
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function BaseFunctionDeclaration(props) {
|
|
45
|
+
const asyncKwd = props.async ? "async " : "";
|
|
46
|
+
let parameters;
|
|
47
|
+
switch (props.functionType) {
|
|
48
|
+
case "instance":
|
|
49
|
+
parameters = [{
|
|
50
|
+
name: "self"
|
|
51
|
+
}, ...(props.parameters || [])];
|
|
52
|
+
break;
|
|
53
|
+
case "class":
|
|
54
|
+
parameters = [{
|
|
55
|
+
name: "cls"
|
|
56
|
+
}, ...(props.parameters || [])];
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
parameters = props.parameters;
|
|
60
|
+
}
|
|
61
|
+
const sym = props.sym;
|
|
62
|
+
return [_$createComponent(Declaration, _$mergeProps(props, {
|
|
63
|
+
nameKind: "function",
|
|
64
|
+
symbol: sym,
|
|
65
|
+
get children() {
|
|
66
|
+
return [asyncKwd, "def ", _$createComponent(Name, {}), _$createComponent(LexicalScope, {
|
|
67
|
+
get name() {
|
|
68
|
+
return sym.name;
|
|
69
|
+
},
|
|
70
|
+
get children() {
|
|
71
|
+
return [_$createComponent(CallSignature, _$mergeProps(() => getCallSignatureProps(props, {}), {
|
|
72
|
+
parameters: parameters
|
|
73
|
+
})), _$createComponent(PythonBlock, {
|
|
74
|
+
opener: ":",
|
|
75
|
+
get children() {
|
|
76
|
+
return [_$createComponent(Show, {
|
|
77
|
+
get when() {
|
|
78
|
+
return Boolean(props.doc);
|
|
79
|
+
},
|
|
80
|
+
get children() {
|
|
81
|
+
return props.doc;
|
|
82
|
+
}
|
|
83
|
+
}), _$memo(() => props.children ?? "pass")];
|
|
84
|
+
}
|
|
85
|
+
})];
|
|
86
|
+
}
|
|
87
|
+
})];
|
|
88
|
+
}
|
|
89
|
+
}))];
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=FunctionBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Name","Show","getCallSignatureProps","CallSignature","Declaration","LexicalScope","PythonBlock","BaseFunctionDeclaration","props","asyncKwd","async","parameters","functionType","name","sym","_$createComponent","_$mergeProps","nameKind","symbol","children","opener","when","Boolean","doc","_$memo"],"sources":["../../../src/components/FunctionBase.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,IAAI,EAAEC,IAAI,QAAQ,gBAAgB;AAE3C,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,aAAa;AACtB,SAA+BC,WAAW,QAAQ,kBAAkB;AACpE,SAASC,YAAY;AACrB,SAASC,WAAW;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,KAAmC,EAAE;EAC3E,MAAMC,QAAQ,GAAGD,KAAK,CAACE,KAAK,GAAG,QAAQ,GAAG,EAAE;EAC5C,IAAIC,UAAU;EACd,QAAQH,KAAK,CAACI,YAAY;IACxB,KAAK,UAAU;MACbD,UAAU,GAAG,CAAC;QAAEE,IAAI,EAAE;MAAO,CAAC,EAAE,IAAIL,KAAK,CAACG,UAAU,IAAI,EAAE,CAAC,CAAC;MAC5D;IACF,KAAK,OAAO;MACVA,UAAU,GAAG,CAAC;QAAEE,IAAI,EAAE;MAAM,CAAC,EAAE,IAAIL,KAAK,CAACG,UAAU,IAAI,EAAE,CAAC,CAAC;MAC3D;IACF;MACEA,UAAU,GAAGH,KAAK,CAACG,UAAU;EACjC;EACA,MAAMG,GAAuB,GAAGN,KAAK,CAACM,GAAG;EAEzC,QAAAC,iBAAA,CAEKX,WAAW,EAAAY,YAAA,CAAKR,KAAK;IAAES,QAAQ;IAAYC,MAAM,EAAEJ,GAAG;IAAA,IAAAK,SAAA;MAAA,QACpDV,QAAQ,UAAAM,iBAAA,CAAMf,IAAI,OAAAe,iBAAA,CAClBV,YAAY;QAAA,IAACQ,IAAIA,CAAA;UAAA,OAAEC,GAAG,CAACD,IAAI;QAAA;QAAA,IAAAM,SAAA;UAAA,QAAAJ,iBAAA,CACzBZ,aAAa,EAAAa,YAAA,OACRd,qBAAqB,CAACM,KAAK,EAAE,CAAC,CAAC,CAAC;YACpCG,UAAU,EAAEA;UAAU,KAAAI,iBAAA,CAEvBT,WAAW;YAACc,MAAM;YAAA,IAAAD,SAAA;cAAA,QAAAJ,iBAAA,CAChBd,IAAI;gBAAA,IAACoB,IAAIA,CAAA;kBAAA,OAAEC,OAAO,CAACd,KAAK,CAACe,GAAG,CAAC;gBAAA;gBAAA,IAAAJ,SAAA;kBAAA,OAAGX,KAAK,CAACe,GAAG;gBAAA;cAAA,IAAAC,MAAA,OACzChB,KAAK,CAACW,QAAQ,IAAI,MAAM;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAMrC","ignoreList":[]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface FunctionDeclarationProps extends BaseDeclarationProps, CallSignatureProps {
|
|
4
|
-
async?: boolean;
|
|
1
|
+
import type { CommonFunctionProps } from "./FunctionBase.js";
|
|
2
|
+
export interface FunctionDeclarationProps extends CommonFunctionProps {
|
|
5
3
|
}
|
|
6
4
|
/**
|
|
7
5
|
* A Python function declaration.
|
|
@@ -9,41 +7,23 @@ export interface FunctionDeclarationProps extends BaseDeclarationProps, CallSign
|
|
|
9
7
|
* @example
|
|
10
8
|
* ```tsx
|
|
11
9
|
* <FunctionDeclaration
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* name="my_function"
|
|
11
|
+
* returnType="int"
|
|
12
|
+
* parameters={[{ name: "a", type: { children: "int" } }, { name: "b", type: { children: "str" } }]}
|
|
13
|
+
* >
|
|
15
14
|
* return a + b
|
|
16
15
|
* </FunctionDeclaration>
|
|
17
16
|
* ```
|
|
18
17
|
* This will generate:
|
|
19
18
|
* ```python
|
|
20
19
|
* def my_function(a: int, b: str) -> int:
|
|
21
|
-
*
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function FunctionDeclaration(props: FunctionDeclarationProps): import("@alloy-js/core").Children;
|
|
25
|
-
export interface InitFunctionDeclarationProps extends Omit<FunctionDeclarationProps, "name" | "instanceFunction" | "classFunction"> {
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* A Python `__init__` function declaration.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```tsx
|
|
32
|
-
* <InitFunctionDeclaration>
|
|
33
|
-
* self.attribute = "value"
|
|
34
|
-
* </InitFunctionDeclaration>
|
|
35
|
-
* ```
|
|
36
|
-
* This will generate:
|
|
37
|
-
* ```python
|
|
38
|
-
* def __init__(self: MyClass) -> None:
|
|
39
|
-
* self.attribute = "value"
|
|
20
|
+
* return a + b
|
|
40
21
|
* ```
|
|
41
22
|
*
|
|
42
23
|
* @remarks
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* the name policy.
|
|
24
|
+
* This component creates a Python function declaration with optional type annotations,
|
|
25
|
+
* parameters, and return types. It supports async functions and automatically
|
|
26
|
+
* handles symbol creation and emission.
|
|
47
27
|
*/
|
|
48
|
-
export declare function
|
|
28
|
+
export declare function FunctionDeclaration(props: FunctionDeclarationProps): import("@alloy-js/core/jsx-runtime").Children;
|
|
49
29
|
//# sourceMappingURL=FunctionDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionDeclaration.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FunctionDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/FunctionDeclaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAM7D,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;CAAG;AAExE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,iDAGlE"}
|
|
@@ -1,98 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { createFunctionSymbol } from "../symbols/factories.js";
|
|
3
|
+
import { BaseFunctionDeclaration } from "./FunctionBase.js";
|
|
4
|
+
|
|
5
|
+
// Types are sourced from FunctionBase to avoid duplicate exports
|
|
6
|
+
|
|
7
|
+
// Clean public interface extending common properties
|
|
8
|
+
|
|
9
9
|
/**
|
|
10
10
|
* A Python function declaration.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```tsx
|
|
14
14
|
* <FunctionDeclaration
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* name="my_function"
|
|
16
|
+
* returnType="int"
|
|
17
|
+
* parameters={[{ name: "a", type: { children: "int" } }, { name: "b", type: { children: "str" } }]}
|
|
18
|
+
* >
|
|
18
19
|
* return a + b
|
|
19
20
|
* </FunctionDeclaration>
|
|
20
21
|
* ```
|
|
21
22
|
* This will generate:
|
|
22
23
|
* ```python
|
|
23
24
|
* def my_function(a: int, b: str) -> int:
|
|
24
|
-
*
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export function FunctionDeclaration(props) {
|
|
28
|
-
const asyncKwd = props.async ? "async " : "";
|
|
29
|
-
const callSignatureProps = getCallSignatureProps(props, {});
|
|
30
|
-
const sym = createPythonSymbol(props.name, {
|
|
31
|
-
instance: props.instanceFunction,
|
|
32
|
-
refkeys: props.refkey
|
|
33
|
-
}, "function");
|
|
34
|
-
emitSymbol(sym);
|
|
35
|
-
return [_$createComponent(Declaration, _$mergeProps(props, {
|
|
36
|
-
nameKind: "function",
|
|
37
|
-
symbol: sym,
|
|
38
|
-
get children() {
|
|
39
|
-
return [asyncKwd, "def ", _$createComponent(Name, {}), _$createComponent(LexicalScope, {
|
|
40
|
-
get name() {
|
|
41
|
-
return sym.name;
|
|
42
|
-
},
|
|
43
|
-
get children() {
|
|
44
|
-
return [_$createComponent(CallSignature, _$mergeProps(callSignatureProps, {
|
|
45
|
-
get returnType() {
|
|
46
|
-
return props.returnType;
|
|
47
|
-
}
|
|
48
|
-
})), _$createComponent(PythonBlock, {
|
|
49
|
-
opener: ":",
|
|
50
|
-
get children() {
|
|
51
|
-
return [_$createComponent(Show, {
|
|
52
|
-
get when() {
|
|
53
|
-
return Boolean(props.doc);
|
|
54
|
-
},
|
|
55
|
-
get children() {
|
|
56
|
-
return props.doc;
|
|
57
|
-
}
|
|
58
|
-
}), _$memo(() => props.children ?? "pass")];
|
|
59
|
-
}
|
|
60
|
-
})];
|
|
61
|
-
}
|
|
62
|
-
})];
|
|
63
|
-
}
|
|
64
|
-
}))];
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A Python `__init__` function declaration.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```tsx
|
|
71
|
-
* <InitFunctionDeclaration>
|
|
72
|
-
* self.attribute = "value"
|
|
73
|
-
* </InitFunctionDeclaration>
|
|
74
|
-
* ```
|
|
75
|
-
* This will generate:
|
|
76
|
-
* ```python
|
|
77
|
-
* def __init__(self: MyClass) -> None:
|
|
78
|
-
* self.attribute = "value"
|
|
25
|
+
* return a + b
|
|
79
26
|
* ```
|
|
80
27
|
*
|
|
81
28
|
* @remarks
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* the name policy.
|
|
29
|
+
* This component creates a Python function declaration with optional type annotations,
|
|
30
|
+
* parameters, and return types. It supports async functions and automatically
|
|
31
|
+
* handles symbol creation and emission.
|
|
86
32
|
*/
|
|
87
|
-
export function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
instanceFunction: true,
|
|
95
|
-
classFunction: false
|
|
33
|
+
export function FunctionDeclaration(props) {
|
|
34
|
+
const sym = createFunctionSymbol(props.name, {
|
|
35
|
+
refkeys: props.refkey
|
|
36
|
+
});
|
|
37
|
+
return _$createComponent(BaseFunctionDeclaration, _$mergeProps(props, {
|
|
38
|
+
sym: sym
|
|
96
39
|
}));
|
|
97
40
|
}
|
|
98
41
|
//# sourceMappingURL=FunctionDeclaration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createFunctionSymbol","BaseFunctionDeclaration","FunctionDeclaration","props","sym","name","refkeys","refkey","_$createComponent","_$mergeProps"],"sources":["../../../src/components/FunctionDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,oBAAoB,QAAQ,yBAAyB;AAE9D,SAASC,uBAAuB,QAAQ,mBAAmB;;AAE3D;;AAEA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,KAA+B,EAAE;EACnE,MAAMC,GAAG,GAAGJ,oBAAoB,CAACG,KAAK,CAACE,IAAI,EAAE;IAAEC,OAAO,EAAEH,KAAK,CAACI;EAAO,CAAC,CAAC;EACvE,OAAAC,iBAAA,CAAQP,uBAAuB,EAAAQ,YAAA,CAAKN,KAAK;IAAEC,GAAG,EAAEA;EAAG;AACrD","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseFunctionDeclarationProps, CommonFunctionProps } from "./FunctionBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared base props for all method-like declarations.
|
|
4
|
+
*/
|
|
5
|
+
export interface MethodDeclarationBaseProps extends CommonFunctionProps {
|
|
6
|
+
/** Indicates that the method is abstract. */
|
|
7
|
+
abstract?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Internal base for method-like components.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Applies `@abstractmethod` when requested and delegates to
|
|
14
|
+
* `BaseFunctionDeclaration` for the function/method body.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <MethodDeclarationBase name="do_work" functionType="instance">
|
|
19
|
+
* return 1
|
|
20
|
+
* </MethodDeclarationBase>
|
|
21
|
+
* ```
|
|
22
|
+
* Generates:
|
|
23
|
+
* ```python
|
|
24
|
+
* def do_work(self):
|
|
25
|
+
* return 1
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function MethodDeclarationBase(props: MethodDeclarationBaseProps & Pick<BaseFunctionDeclarationProps, "functionType" | "sym">): import("@alloy-js/core/jsx-runtime").Children;
|
|
29
|
+
//# sourceMappingURL=MethodBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodBase.d.ts","sourceRoot":"","sources":["../../../src/components/MethodBase.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,4BAA4B,EAC5B,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,GAC/B,IAAI,CAAC,4BAA4B,EAAE,cAAc,GAAG,KAAK,CAAC,iDAgB7D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { memo as _$memo, createIntrinsic as _$createIntrinsic, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { abcModule } from "../builtins/python.js";
|
|
3
|
+
import { BaseFunctionDeclaration } from "./FunctionBase.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared base props for all method-like declarations.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal base for method-like components.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Applies `@abstractmethod` when requested and delegates to
|
|
14
|
+
* `BaseFunctionDeclaration` for the function/method body.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <MethodDeclarationBase name="do_work" functionType="instance">
|
|
19
|
+
* return 1
|
|
20
|
+
* </MethodDeclarationBase>
|
|
21
|
+
* ```
|
|
22
|
+
* Generates:
|
|
23
|
+
* ```python
|
|
24
|
+
* def do_work(self):
|
|
25
|
+
* return 1
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function MethodDeclarationBase(props) {
|
|
29
|
+
const abstractMethod = props.abstract ? ["@", _$memo(() => abcModule["."].abstractmethod), _$createIntrinsic("hbr", {})] : undefined;
|
|
30
|
+
return [abstractMethod, _$createComponent(BaseFunctionDeclaration, props)];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=MethodBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["abcModule","BaseFunctionDeclaration","MethodDeclarationBase","props","abstractMethod","abstract","_$memo","abstractmethod","_$createIntrinsic","undefined","_$createComponent"],"sources":["../../../src/components/MethodBase.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SACEC,uBAAuB,QAGlB,mBAAmB;;AAE1B;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,KAC4D,EAC5D;EACA,MAAMC,cAAc,GAClBD,KAAK,CAACE,QAAQ,SAAAC,MAAA,OAERN,SAAS,CAAC,GAAG,CAAC,CAACO,cAAc,GAAAC,iBAAA,eAGjCC,SAAS;EAEb,QAEKL,cAAc,EAAAM,iBAAA,CACdT,uBAAuB,EAAKE,KAAK;AAGxC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MethodDeclarationBaseProps } from "./MethodBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* A Python instance method declaration component.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <py.MethodDeclaration name="do_work" parameters={[{ name: "value", type: "int" }]}>
|
|
8
|
+
* return value * 2
|
|
9
|
+
* </py.MethodDeclaration>
|
|
10
|
+
* ```
|
|
11
|
+
* Generates:
|
|
12
|
+
* ```python
|
|
13
|
+
* def do_work(self, value: int) -> None:
|
|
14
|
+
* return value * 2
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Automatically injects the `self` parameter for instance methods and enforces
|
|
19
|
+
* that the declaration appears within a class body.
|
|
20
|
+
*/
|
|
21
|
+
export declare function MethodDeclaration(props: MethodDeclarationBaseProps): import("@alloy-js/core/jsx-runtime").Children;
|
|
22
|
+
//# sourceMappingURL=MethodDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/MethodDeclaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,0BAA0B,iDAGlE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { createMethodSymbol } from "../symbols/factories.js";
|
|
3
|
+
import { MethodDeclarationBase } from "./MethodBase.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A Python instance method declaration component.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <py.MethodDeclaration name="do_work" parameters={[{ name: "value", type: "int" }]}>
|
|
11
|
+
* return value * 2
|
|
12
|
+
* </py.MethodDeclaration>
|
|
13
|
+
* ```
|
|
14
|
+
* Generates:
|
|
15
|
+
* ```python
|
|
16
|
+
* def do_work(self, value: int) -> None:
|
|
17
|
+
* return value * 2
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Automatically injects the `self` parameter for instance methods and enforces
|
|
22
|
+
* that the declaration appears within a class body.
|
|
23
|
+
*/
|
|
24
|
+
export function MethodDeclaration(props) {
|
|
25
|
+
const sym = createMethodSymbol(props.name, {
|
|
26
|
+
refkeys: props.refkey
|
|
27
|
+
});
|
|
28
|
+
return _$createComponent(MethodDeclarationBase, _$mergeProps({
|
|
29
|
+
functionType: "instance"
|
|
30
|
+
}, props, {
|
|
31
|
+
sym: sym
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=MethodDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createMethodSymbol","MethodDeclarationBase","MethodDeclaration","props","sym","name","refkeys","refkey","_$createComponent","_$mergeProps","functionType"],"sources":["../../../src/components/MethodDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,qBAAqB,QAAQ,iBAAiB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,KAAiC,EAAE;EACnE,MAAMC,GAAG,GAAGJ,kBAAkB,CAACG,KAAK,CAACE,IAAI,EAAE;IAAEC,OAAO,EAAEH,KAAK,CAACI;EAAO,CAAC,CAAC;EACrE,OAAAC,iBAAA,CAAQP,qBAAqB,EAAAQ,YAAA;IAACC,YAAY;EAAA,GAAgBP,KAAK;IAAEC,GAAG,EAAEA;EAAG;AAC3E","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
+
import { CommonFunctionProps } from "./FunctionBase.js";
|
|
3
|
+
/**
|
|
4
|
+
* Declares a Python property with optional getter, setter, and deleter methods.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <py.PropertyDeclaration name="name" type={{ children: "str" }}>
|
|
9
|
+
* return self._name
|
|
10
|
+
* </py.PropertyDeclaration>
|
|
11
|
+
* ```
|
|
12
|
+
* Generates:
|
|
13
|
+
* ```python
|
|
14
|
+
* @property
|
|
15
|
+
* def name(self) -> str:
|
|
16
|
+
* return self._name
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example Setter and deleter
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <py.PropertyDeclaration name="value" type={{ children: "int" }}>
|
|
22
|
+
* return self._value
|
|
23
|
+
* <py.PropertyDeclaration.Setter type={{ children: "int" }}>
|
|
24
|
+
* self._value = value
|
|
25
|
+
* </py.PropertyDeclaration.Setter>
|
|
26
|
+
* <py.PropertyDeclaration.Deleter>
|
|
27
|
+
* del self._value
|
|
28
|
+
* </py.PropertyDeclaration.Deleter>
|
|
29
|
+
* </py.PropertyDeclaration>
|
|
30
|
+
* ```
|
|
31
|
+
* Generates:
|
|
32
|
+
* ```python
|
|
33
|
+
* @property
|
|
34
|
+
* def value(self) -> int:
|
|
35
|
+
* return self._value
|
|
36
|
+
*
|
|
37
|
+
* @value.setter
|
|
38
|
+
* def value(self, value: int) -> None:
|
|
39
|
+
* self._value = value
|
|
40
|
+
*
|
|
41
|
+
* @value.deleter
|
|
42
|
+
* def value(self) -> None:
|
|
43
|
+
* del self._value
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* The property must be declared within a class. The getter method is
|
|
48
|
+
* automatically generated using the `@property` decorator. Use the nested
|
|
49
|
+
* `Setter` and `Deleter` components to add mutators.
|
|
50
|
+
*/
|
|
51
|
+
export interface PropertyDeclarationProps {
|
|
52
|
+
name: string;
|
|
53
|
+
type?: Children;
|
|
54
|
+
children?: Children;
|
|
55
|
+
refkey?: Refkey;
|
|
56
|
+
abstract?: boolean;
|
|
57
|
+
doc?: Children;
|
|
58
|
+
}
|
|
59
|
+
export declare function PropertyDeclaration(props: PropertyDeclarationProps): Children;
|
|
60
|
+
export declare namespace PropertyDeclaration {
|
|
61
|
+
var Setter: import("@alloy-js/core").Component<PropertyMethodDeclarationProps & {
|
|
62
|
+
type?: Children;
|
|
63
|
+
}> & Required<Pick<import("@alloy-js/core").Component<PropertyMethodDeclarationProps & {
|
|
64
|
+
type?: Children;
|
|
65
|
+
}>, "tag">>;
|
|
66
|
+
var Deleter: import("@alloy-js/core").Component<Omit<PropertyMethodDeclarationProps, "returnType">> & Required<Pick<import("@alloy-js/core").Component<Omit<PropertyMethodDeclarationProps, "returnType">>, "tag">>;
|
|
67
|
+
}
|
|
68
|
+
export interface PropertyMethodDeclarationProps extends Omit<CommonFunctionProps, "name"> {
|
|
69
|
+
abstract?: boolean;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=PropertyDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/PropertyDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,MAAM,EASP,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YA+DlE;yBA/De,mBAAmB;;eA6IkB,QAAQ;;eAAR,QAAQ;;;;AA5E7D,MAAM,WAAW,8BACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|