@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
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { SymbolCreator } from "@alloy-js/core";
|
|
2
|
+
export declare const abcModule: import("../create-module.js").ModuleRefkeys<{
|
|
3
|
+
readonly ".": ["abstractmethod"];
|
|
4
|
+
}> & SymbolCreator;
|
|
2
5
|
export declare const enumModule: import("../create-module.js").ModuleRefkeys<{
|
|
3
6
|
readonly ".": ["auto", "Enum", "Flag", "IntEnum", "IntFlag", "StrEnum"];
|
|
4
7
|
}> & SymbolCreator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../src/builtins/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,eAAO,MAAM,UAAU;;kBAKrB,CAAC;AAEH,eAAO,MAAM,cAAc;;;kBAMzB,CAAC"}
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../src/builtins/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,eAAO,MAAM,SAAS;;kBAKpB,CAAC;AAEH,eAAO,MAAM,UAAU;;kBAKrB,CAAC;AAEH,eAAO,MAAM,cAAc;;;kBAMzB,CAAC"}
|
|
@@ -2,6 +2,12 @@ import { createModule } from "../create-module.js";
|
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
4
|
|
|
5
|
+
export const abcModule = createModule({
|
|
6
|
+
name: "abc",
|
|
7
|
+
descriptor: {
|
|
8
|
+
".": ["abstractmethod"]
|
|
9
|
+
}
|
|
10
|
+
});
|
|
5
11
|
export const enumModule = createModule({
|
|
6
12
|
name: "enum",
|
|
7
13
|
descriptor: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createModule","
|
|
1
|
+
{"version":3,"names":["createModule","abcModule","name","descriptor","enumModule","requestsModule","models"],"sources":["../../../src/builtins/python.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,YAAY,QAAQ,qBAAqB;;AAElD;;AAGA,OAAO,MAAMC,SAAS,GAAGD,YAAY,CAAC;EACpCE,IAAI,EAAE,KAAK;EACXC,UAAU,EAAE;IACV,GAAG,EAAE,CAAC,gBAAgB;EACxB;AACF,CAAC,CAAC;AAEF,OAAO,MAAMC,UAAU,GAAGJ,YAAY,CAAC;EACrCE,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE;IACV,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;EAC/D;AACF,CAAC,CAAC;AAEF,OAAO,MAAME,cAAc,GAAGL,YAAY,CAAC;EACzCE,IAAI,EAAE,UAAU;EAChBC,UAAU,EAAE;IACV,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC;IACjEG,MAAM,EAAE,CAAC,UAAU,EAAE,SAAS;EAChC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Atom.d.ts","sourceRoot":"","sources":["../../../src/components/Atom.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"Atom.d.ts","sourceRoot":"","sources":["../../../src/components/Atom.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CA0D1C"}
|
|
@@ -20,6 +20,9 @@ export function Atom(props) {
|
|
|
20
20
|
if (typeof jsValue === "undefined") {
|
|
21
21
|
return "None";
|
|
22
22
|
} else if (typeof jsValue === "number") {
|
|
23
|
+
if (props.asFloat && Number.isInteger(jsValue)) {
|
|
24
|
+
return jsValue.toFixed(1);
|
|
25
|
+
}
|
|
23
26
|
return String(jsValue);
|
|
24
27
|
} else if (typeof jsValue === "boolean") {
|
|
25
28
|
return jsValue ? "True" : "False";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["For","Indent","memo","Atom","props","jsValue","String","replace","Array","isArray","_$createIntrinsic","children","_$createComponent","softline","trailingBreak","each","comma","line","v","entries","Object","length","k"],"sources":["../../../src/components/Atom.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,IAAI,QAAQ,gBAAgB;
|
|
1
|
+
{"version":3,"names":["For","Indent","memo","Atom","props","jsValue","asFloat","Number","isInteger","toFixed","String","replace","Array","isArray","_$createIntrinsic","children","_$createComponent","softline","trailingBreak","each","comma","line","v","entries","Object","length","k"],"sources":["../../../src/components/Atom.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,IAAI,QAAQ,gBAAgB;AAOlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,IAAIA,CAACC,KAAgB,EAAO;EAC1C,OAAOF,IAAI,CAAC,MAAM;IAChB,MAAMG,OAAO,GAAGD,KAAK,CAACC,OAAO;IAE7B,IAAI,OAAOA,OAAO,KAAK,WAAW,EAAE;MAClC,OAAO,MAAM;IACf,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MACtC,IAAID,KAAK,CAACE,OAAO,IAAIC,MAAM,CAACC,SAAS,CAACH,OAAO,CAAC,EAAE;QAC9C,OAAOA,OAAO,CAACI,OAAO,CAAC,CAAC,CAAC;MAC3B;MACA,OAAOC,MAAM,CAACL,OAAO,CAAC;IACxB,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,SAAS,EAAE;MACvC,OAAOA,OAAO,GAAG,MAAM,GAAG,OAAO;IACnC,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MACtC,OAAO,IAAIA,OAAO,CAACM,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG;IAC5C,CAAC,MAAM,IAAI,OAAON,OAAO,KAAK,UAAU,EAAE;MACxC;MACA,OAAOA,OAAO;IAChB,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MACtC,IAAIA,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,MAAM;MACf,CAAC,MAAM,IAAIO,KAAK,CAACC,OAAO,CAACR,OAAO,CAAC,EAAE;QACjC;QACA,OAAAS,iBAAA;UAAA,IAAAC,SAAA;YAAA,QAEK,GAAG,EAAAC,iBAAA,CACHf,MAAM;cAACgB,QAAQ;cAACC,aAAa;cAAA,IAAAH,SAAA;gBAAA,OAAAC,iBAAA,CAC3BhB,GAAG;kBAACmB,IAAI,EAAEd,OAAO;kBAAEe,KAAK;kBAACC,IAAI;kBAAAN,QAAA,EAC1BO,CAAC,IAAAN,iBAAA,CAAMb,IAAI;oBAACE,OAAO,EAAEiB;kBAAC;gBAAI;cAAA;YAAA,IAG/B,GAAG;UAAA;QAAA;MAGV,CAAC,MAAM;QACL,MAAMC,OAAO,GAAGC,MAAM,CAACD,OAAO,CAAClB,OAAO,CAAC;QACvC,IAAIkB,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;UACxB,OAAO,IAAI;QACb;QACA;QACA,OAAAX,iBAAA;UAAA,IAAAC,SAAA;YAAA,QAEK,GAAG,EAAAC,iBAAA,CACHf,MAAM;cAACgB,QAAQ;cAAA,IAAAF,SAAA;gBAAA,OAAAC,iBAAA,CACbhB,GAAG;kBAACmB,IAAI,EAAEI,OAAO;kBAAEH,KAAK;kBAACC,IAAI;kBAAAN,QAAA,EAC3BA,CAAC,CAACW,CAAC,EAAEJ,CAAC,CAAC,MAAAN,iBAAA,CAEHb,IAAI;oBAACE,OAAO,EAAEqB;kBAAC,UAAAV,iBAAA,CAAOb,IAAI;oBAACE,OAAO,EAAEiB;kBAAC;gBAEzC;cAAA;YAAA,IAGJ,GAAG;UAAA;QAAA;MAGV;IACF;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
2
|
import { ParameterDescriptor } from "../parameter-descriptor.js";
|
|
3
3
|
export interface CallSignatureParametersProps {
|
|
4
|
-
readonly parameters?: ParameterDescriptor
|
|
4
|
+
readonly parameters?: (ParameterDescriptor | string)[];
|
|
5
5
|
readonly args?: boolean;
|
|
6
6
|
readonly kwargs?: boolean;
|
|
7
|
-
readonly instanceFunction?: boolean;
|
|
8
|
-
readonly classFunction?: boolean;
|
|
9
7
|
}
|
|
10
8
|
/**
|
|
11
9
|
* A call signature parameters declaration, which can be used to define the
|
|
@@ -23,11 +21,10 @@ export interface CallSignatureParametersProps {
|
|
|
23
21
|
export declare function CallSignatureParameters(props: CallSignatureParametersProps): Children;
|
|
24
22
|
export interface CallSignatureProps {
|
|
25
23
|
/**
|
|
26
|
-
* The parameters to the call signature. Can be an array of strings for parameters
|
|
27
|
-
* which don't have a type or a default value
|
|
28
|
-
* {@link ParameterDescriptor}s.
|
|
24
|
+
* The parameters to the call signature. Can be an array of strings (for parameters
|
|
25
|
+
* which don't have a type or a default value) or {@link ParameterDescriptor}s.
|
|
29
26
|
*/
|
|
30
|
-
parameters?: ParameterDescriptor
|
|
27
|
+
parameters?: (ParameterDescriptor | string)[];
|
|
31
28
|
/**
|
|
32
29
|
* The type parameters of the call signature, e.g. for a generic function.
|
|
33
30
|
* This is only supported in Python 3.12+.
|
|
@@ -41,14 +38,6 @@ export interface CallSignatureProps {
|
|
|
41
38
|
* Indicates if there are keyword arguments (`**kwargs`) in the function
|
|
42
39
|
*/
|
|
43
40
|
kwargs?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Indicates that this is an instance function.
|
|
46
|
-
*/
|
|
47
|
-
instanceFunction?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Indicates that this is a class function.
|
|
50
|
-
*/
|
|
51
|
-
classFunction?: boolean;
|
|
52
41
|
/**
|
|
53
42
|
* The return type of the function.
|
|
54
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallSignature.d.ts","sourceRoot":"","sources":["../../../src/components/CallSignature.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"CallSignature.d.ts","sourceRoot":"","sources":["../../../src/components/CallSignature.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAKpC,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC;IACvD,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,YA4B1E;AAuDD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC;IAE9C;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC;CACvB;AACD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,YAuBtD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { computed, createSymbolSlot, For, Show
|
|
2
|
+
import { computed, createSymbolSlot, For, Show } from "@alloy-js/core";
|
|
3
|
+
import { isParameterDescriptor } from "../parameter-descriptor.js";
|
|
3
4
|
import { createPythonSymbol } from "../symbol-creation.js";
|
|
4
5
|
import { Atom } from "./Atom.js";
|
|
5
|
-
import { PythonSourceFileContext } from "./SourceFile.js";
|
|
6
6
|
/**
|
|
7
7
|
* A call signature parameters declaration, which can be used to define the
|
|
8
8
|
* parameters of a function or other callables.
|
|
@@ -17,31 +17,9 @@ import { PythonSourceFileContext } from "./SourceFile.js";
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export function CallSignatureParameters(props) {
|
|
20
|
-
// Validate that only one of instanceFunction or classFunction is true
|
|
21
|
-
if (props.instanceFunction && props.classFunction) {
|
|
22
|
-
throw new Error("Cannot be both an instance function and a class function");
|
|
23
|
-
}
|
|
24
|
-
const sfContext = useContext(PythonSourceFileContext);
|
|
25
|
-
const module = sfContext?.module;
|
|
26
20
|
const parameters = normalizeAndDeclareParameters(props.parameters ?? []);
|
|
27
21
|
const parameterList = computed(() => {
|
|
28
22
|
const params = [];
|
|
29
|
-
|
|
30
|
-
// Add self/cls parameter if instance or class function
|
|
31
|
-
if (props.instanceFunction) {
|
|
32
|
-
params.push(parameter({
|
|
33
|
-
symbol: createPythonSymbol("self", {
|
|
34
|
-
module: module
|
|
35
|
-
})
|
|
36
|
-
}));
|
|
37
|
-
} else if (props.classFunction) {
|
|
38
|
-
params.push(parameter({
|
|
39
|
-
symbol: createPythonSymbol("cls", {
|
|
40
|
-
module: module
|
|
41
|
-
})
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
23
|
// Add regular parameters
|
|
46
24
|
parameters.forEach(param => {
|
|
47
25
|
params.push(parameter(param));
|
|
@@ -82,28 +60,7 @@ function parameter(param) {
|
|
|
82
60
|
}
|
|
83
61
|
}), _$createComponent(Show, {
|
|
84
62
|
get when() {
|
|
85
|
-
return
|
|
86
|
-
},
|
|
87
|
-
get children() {
|
|
88
|
-
return [_$createComponent(Show, {
|
|
89
|
-
get when() {
|
|
90
|
-
return !param.type;
|
|
91
|
-
},
|
|
92
|
-
children: "="
|
|
93
|
-
}), _$createComponent(Show, {
|
|
94
|
-
get when() {
|
|
95
|
-
return !!param.type;
|
|
96
|
-
},
|
|
97
|
-
children: " = "
|
|
98
|
-
}), [_$memo(() => _$memo(() => !!param.default)() ? _$createComponent(Atom, {
|
|
99
|
-
get jsValue() {
|
|
100
|
-
return param.default;
|
|
101
|
-
}
|
|
102
|
-
}) : "None")]];
|
|
103
|
-
}
|
|
104
|
-
}), _$createComponent(Show, {
|
|
105
|
-
get when() {
|
|
106
|
-
return !param.optional && param.default !== undefined;
|
|
63
|
+
return param.default !== undefined;
|
|
107
64
|
},
|
|
108
65
|
get children() {
|
|
109
66
|
return [_$createComponent(Show, {
|
|
@@ -127,19 +84,8 @@ function parameter(param) {
|
|
|
127
84
|
});
|
|
128
85
|
}
|
|
129
86
|
function normalizeAndDeclareParameters(parameters) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
if (typeof parameters[0] === "string") {
|
|
134
|
-
return parameters.map(paramName => {
|
|
135
|
-
const symbol = createPythonSymbol(paramName, {}, "parameter");
|
|
136
|
-
return {
|
|
137
|
-
refkeys: symbol.refkeys,
|
|
138
|
-
symbol
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
} else {
|
|
142
|
-
return parameters.map(param => {
|
|
87
|
+
return parameters.map(param => {
|
|
88
|
+
if (isParameterDescriptor(param)) {
|
|
143
89
|
const TypeSlot = createSymbolSlot();
|
|
144
90
|
const symbol = createPythonSymbol(param.name, {
|
|
145
91
|
refkeys: param.refkey,
|
|
@@ -150,8 +96,14 @@ function normalizeAndDeclareParameters(parameters) {
|
|
|
150
96
|
symbol,
|
|
151
97
|
TypeSlot
|
|
152
98
|
};
|
|
153
|
-
}
|
|
154
|
-
|
|
99
|
+
} else {
|
|
100
|
+
const symbol = createPythonSymbol(param, {}, "parameter");
|
|
101
|
+
return {
|
|
102
|
+
refkeys: symbol.refkeys,
|
|
103
|
+
symbol
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
});
|
|
155
107
|
}
|
|
156
108
|
/**
|
|
157
109
|
* A Python call signature, e.g. the part after the `def` keyword and the name in a
|
|
@@ -184,12 +136,6 @@ export function CallSignature(props) {
|
|
|
184
136
|
},
|
|
185
137
|
get kwargs() {
|
|
186
138
|
return props.kwargs;
|
|
187
|
-
},
|
|
188
|
-
get instanceFunction() {
|
|
189
|
-
return props.instanceFunction;
|
|
190
|
-
},
|
|
191
|
-
get classFunction() {
|
|
192
|
-
return props.classFunction;
|
|
193
139
|
}
|
|
194
140
|
});
|
|
195
141
|
const typeParams = props.typeParameters ? `[${props.typeParameters.join(", ")}]` : "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["computed","createSymbolSlot","For","Show","
|
|
1
|
+
{"version":3,"names":["computed","createSymbolSlot","For","Show","isParameterDescriptor","createPythonSymbol","Atom","CallSignatureParameters","props","parameters","normalizeAndDeclareParameters","parameterList","params","forEach","param","push","parameter","args","kwargs","_$createComponent","each","comma","space","children","TypeSlot","_$createIntrinsic","_$memo","symbol","name","when","type","default","undefined","jsValue","map","refkeys","refkey","firstSymbol","CallSignature","sParams","typeParams","typeParameters","join","sReturnType","returnType"],"sources":["../../../src/components/CallSignature.tsx"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommonFunctionProps } from "./FunctionBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* A Python class method declaration component.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <py.ClassMethodDeclaration name="create" parameters={[{ name: "value", type: "str" }]}>
|
|
8
|
+
* return cls(value)
|
|
9
|
+
* </py.ClassMethodDeclaration>
|
|
10
|
+
* ```
|
|
11
|
+
* Generates:
|
|
12
|
+
* ```python
|
|
13
|
+
* @classmethod
|
|
14
|
+
* def create(cls, value: str) -> None:
|
|
15
|
+
* return cls(value)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface ClassMethodDeclarationProps extends CommonFunctionProps {
|
|
19
|
+
abstract?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function ClassMethodDeclaration(props: ClassMethodDeclarationProps): import("@alloy-js/core/jsx-runtime").Children;
|
|
22
|
+
//# sourceMappingURL=ClassMethodDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassMethodDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethodDeclaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,iDASxE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createIntrinsic as _$createIntrinsic, 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 class method declaration component.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <py.ClassMethodDeclaration name="create" parameters={[{ name: "value", type: "str" }]}>
|
|
11
|
+
* return cls(value)
|
|
12
|
+
* </py.ClassMethodDeclaration>
|
|
13
|
+
* ```
|
|
14
|
+
* Generates:
|
|
15
|
+
* ```python
|
|
16
|
+
* @classmethod
|
|
17
|
+
* def create(cls, value: str) -> None:
|
|
18
|
+
* return cls(value)
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export function ClassMethodDeclaration(props) {
|
|
23
|
+
const sym = createMethodSymbol(props.name, {
|
|
24
|
+
refkeys: props.refkey
|
|
25
|
+
});
|
|
26
|
+
return ["@classmethod", _$createIntrinsic("hbr", {}), _$createComponent(MethodDeclarationBase, _$mergeProps({
|
|
27
|
+
functionType: "class"
|
|
28
|
+
}, props, {
|
|
29
|
+
sym: sym
|
|
30
|
+
}))];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ClassMethodDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createMethodSymbol","MethodDeclarationBase","ClassMethodDeclaration","props","sym","name","refkeys","refkey","_$createIntrinsic","_$createComponent","_$mergeProps","functionType"],"sources":["../../../src/components/ClassMethodDeclaration.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;;AAKA,OAAO,SAASC,sBAAsBA,CAACC,KAAkC,EAAE;EACzE,MAAMC,GAAG,GAAGJ,kBAAkB,CAACG,KAAK,CAACE,IAAI,EAAE;IAAEC,OAAO,EAAEH,KAAK,CAACI;EAAO,CAAC,CAAC;EACrE,QAEK,cAAc,EAAAC,iBAAA,aAAAC,iBAAA,CAEdR,qBAAqB,EAAAS,YAAA;IAACC,YAAY;EAAA,GAAaR,KAAK;IAAEC,GAAG,EAAEA;EAAG;AAGrE","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CommonFunctionProps } from "./FunctionBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* A Python constructor declaration for `__new__`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <py.ConstructorDeclaration parameters={[{ name: "value", type: "int" }]}>
|
|
8
|
+
* pass
|
|
9
|
+
* </py.ConstructorDeclaration>
|
|
10
|
+
* ```
|
|
11
|
+
* Generates:
|
|
12
|
+
* ```python
|
|
13
|
+
* def __new__(cls, value: int):
|
|
14
|
+
* pass
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface ConstructorDeclarationProps extends Omit<CommonFunctionProps, "name"> {
|
|
18
|
+
abstract?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function ConstructorDeclaration(props: ConstructorDeclarationProps): import("@alloy-js/core").Children;
|
|
21
|
+
//# sourceMappingURL=ConstructorDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConstructorDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ConstructorDeclaration.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,2BACf,SAAQ,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,qCAWxE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { namekey } from "@alloy-js/core";
|
|
3
|
+
import { createMethodSymbol } from "../symbols/factories.js";
|
|
4
|
+
import { MethodDeclarationBase } from "./MethodBase.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Python constructor declaration for `__new__`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <py.ConstructorDeclaration parameters={[{ name: "value", type: "int" }]}>
|
|
12
|
+
* pass
|
|
13
|
+
* </py.ConstructorDeclaration>
|
|
14
|
+
* ```
|
|
15
|
+
* Generates:
|
|
16
|
+
* ```python
|
|
17
|
+
* def __new__(cls, value: int):
|
|
18
|
+
* pass
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export function ConstructorDeclaration(props) {
|
|
23
|
+
const name = namekey("__new__", {
|
|
24
|
+
ignoreNamePolicy: true
|
|
25
|
+
});
|
|
26
|
+
const sym = createMethodSymbol(name, {
|
|
27
|
+
refkeys: props.refkey
|
|
28
|
+
});
|
|
29
|
+
return _$createComponent(MethodDeclarationBase, _$mergeProps(props, {
|
|
30
|
+
name: name,
|
|
31
|
+
functionType: "class",
|
|
32
|
+
sym: sym
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ConstructorDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["namekey","createMethodSymbol","MethodDeclarationBase","ConstructorDeclaration","props","name","ignoreNamePolicy","sym","refkeys","refkey","_$createComponent","_$mergeProps","functionType"],"sources":["../../../src/components/ConstructorDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,OAAO,QAAQ,gBAAgB;AACxC,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,qBAAqB,QAAQ,iBAAiB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,SAASC,sBAAsBA,CAACC,KAAkC,EAAE;EACzE,MAAMC,IAAI,GAAGL,OAAO,CAAC,SAAS,EAAE;IAAEM,gBAAgB,EAAE;EAAK,CAAC,CAAC;EAC3D,MAAMC,GAAG,GAAGN,kBAAkB,CAACI,IAAI,EAAE;IAAEG,OAAO,EAAEJ,KAAK,CAACK;EAAO,CAAC,CAAC;EAC/D,OAAAC,iBAAA,CACGR,qBAAqB,EAAAS,YAAA,CAChBP,KAAK;IACTC,IAAI,EAAEA,IAAI;IACVO,YAAY;IACZL,GAAG,EAAEA;EAAG;AAGd","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CommonFunctionProps } from "./FunctionBase.js";
|
|
2
|
+
/**
|
|
3
|
+
* A Python dunder method declaration.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* <py.DunderMethodDeclaration name="__repr__" returnType="str">
|
|
8
|
+
* return f"<MyType>"
|
|
9
|
+
* </py.DunderMethodDeclaration>
|
|
10
|
+
* ```
|
|
11
|
+
* Generates:
|
|
12
|
+
* ```python
|
|
13
|
+
* def __repr__(self) -> str:
|
|
14
|
+
* return f"<MyType>"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface DunderMethodDeclarationProps extends CommonFunctionProps {
|
|
18
|
+
abstract?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function DunderMethodDeclaration(props: DunderMethodDeclarationProps): import("@alloy-js/core").Children;
|
|
21
|
+
//# sourceMappingURL=DunderMethodDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DunderMethodDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/DunderMethodDeclaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,4BAA6B,SAAQ,mBAAmB;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,qCAM1E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { isNamekey, namekey } from "@alloy-js/core";
|
|
3
|
+
import { MethodDeclaration } from "./MethodDeclaration.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A Python dunder method declaration.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <py.DunderMethodDeclaration name="__repr__" returnType="str">
|
|
11
|
+
* return f"<MyType>"
|
|
12
|
+
* </py.DunderMethodDeclaration>
|
|
13
|
+
* ```
|
|
14
|
+
* Generates:
|
|
15
|
+
* ```python
|
|
16
|
+
* def __repr__(self) -> str:
|
|
17
|
+
* return f"<MyType>"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export function DunderMethodDeclaration(props) {
|
|
22
|
+
const finalName = isNamekey(props.name) ? props.name : namekey(props.name, {
|
|
23
|
+
ignoreNamePolicy: true
|
|
24
|
+
});
|
|
25
|
+
return _$createComponent(MethodDeclaration, _$mergeProps(props, {
|
|
26
|
+
name: finalName
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=DunderMethodDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isNamekey","namekey","MethodDeclaration","DunderMethodDeclaration","props","finalName","name","ignoreNamePolicy","_$createComponent","_$mergeProps"],"sources":["../../../src/components/DunderMethodDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,gBAAgB;AAEnD,SAASC,iBAAiB,QAAQ,wBAAwB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASC,uBAAuBA,CAACC,KAAmC,EAAE;EAC3E,MAAMC,SAAS,GACbL,SAAS,CAACI,KAAK,CAACE,IAAI,CAAC,GACnBF,KAAK,CAACE,IAAI,GACVL,OAAO,CAACG,KAAK,CAACE,IAAI,EAAY;IAAEC,gBAAgB,EAAE;EAAK,CAAC,CAAC;EAC7D,OAAAC,iBAAA,CAAQN,iBAAiB,EAAAO,YAAA,CAAKL,KAAK;IAAEE,IAAI,EAAED;EAAS;AACtD","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
2
|
import { BaseDeclarationProps } from "./Declaration.js";
|
|
3
3
|
import { EnumMemberProps } from "./EnumMember.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface EnumPropsBase extends BaseDeclarationProps {
|
|
5
5
|
/**
|
|
6
6
|
* The base type of the enum. One of: 'Enum', 'IntEnum', 'StrEnum', 'Flag', 'IntFlag'.
|
|
7
7
|
* Defaults to 'Enum'.
|
|
@@ -11,40 +11,13 @@ export interface EnumProps extends BaseDeclarationProps {
|
|
|
11
11
|
* Members of the enum as an array of objects.
|
|
12
12
|
*/
|
|
13
13
|
members?: Array<EnumMemberProps>;
|
|
14
|
-
/**
|
|
15
|
-
* The enum style: 'classic' (default), 'auto', or 'functional'.
|
|
16
|
-
*/
|
|
17
|
-
style?: "classic" | "auto" | "functional";
|
|
18
14
|
/**
|
|
19
15
|
* Optional docstring for the enum.
|
|
20
16
|
*/
|
|
21
17
|
doc?: Children;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```tsx
|
|
28
|
-
* <EnumDeclaration name="Direction" style="functional">
|
|
29
|
-
* members={[
|
|
30
|
-
* { name: "NORTH" },
|
|
31
|
-
* { name: "SOUTH" },
|
|
32
|
-
* { name: "EAST" },
|
|
33
|
-
* { name: "WEST" },
|
|
34
|
-
* ]}
|
|
35
|
-
* />
|
|
36
|
-
* ```
|
|
37
|
-
* This will generate:
|
|
38
|
-
* ```python
|
|
39
|
-
* from enum import Enum
|
|
40
|
-
* class Direction(Enum):
|
|
41
|
-
* NORTH = "NORTH"
|
|
42
|
-
* SOUTH = "SOUTH"
|
|
43
|
-
* EAST = "EAST"
|
|
44
|
-
* WEST = "WEST"
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare function EnumDeclaration(props: EnumProps): Children;
|
|
19
|
+
export interface FunctionalEnumProps extends EnumPropsBase {
|
|
20
|
+
}
|
|
48
21
|
/**
|
|
49
22
|
* Create a Python enum using the functional syntax.
|
|
50
23
|
*
|
|
@@ -86,7 +59,13 @@ export declare function EnumDeclaration(props: EnumProps): Children;
|
|
|
86
59
|
* Status = Enum('Status', {'PENDING': 1, 'ACTIVE': 2, 'INACTIVE': 3})
|
|
87
60
|
* ```
|
|
88
61
|
*/
|
|
89
|
-
export declare function FunctionalEnumDeclaration(props:
|
|
62
|
+
export declare function FunctionalEnumDeclaration(props: FunctionalEnumProps): Children;
|
|
63
|
+
export interface ClassEnumProps extends EnumPropsBase {
|
|
64
|
+
/**
|
|
65
|
+
* Indicates that the enum members should be auto-generated.
|
|
66
|
+
*/
|
|
67
|
+
auto?: boolean;
|
|
68
|
+
}
|
|
90
69
|
/**
|
|
91
70
|
* Create a Python enum using the class-based syntax.
|
|
92
71
|
*
|
|
@@ -156,5 +135,5 @@ export declare function FunctionalEnumDeclaration(props: EnumProps): Children;
|
|
|
156
135
|
* BLUE = auto()
|
|
157
136
|
* ```
|
|
158
137
|
*/
|
|
159
|
-
export declare function ClassEnumDeclaration(props:
|
|
138
|
+
export declare function ClassEnumDeclaration(props: ClassEnumProps): Children;
|
|
160
139
|
//# sourceMappingURL=EnumDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/EnumDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAc,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"EnumDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/EnumDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAc,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI9D,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACzD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IAC/D;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACjC;;OAEG;IACH,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;CAAG;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,YAoCnE;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,YA0CzD"}
|
|
@@ -3,41 +3,8 @@ import { Declaration as CoreDeclaration, For, Show } from "@alloy-js/core";
|
|
|
3
3
|
import { enumModule } from "../builtins/python.js";
|
|
4
4
|
import { createPythonSymbol } from "../symbol-creation.js";
|
|
5
5
|
import { EnumMember } from "./EnumMember.js";
|
|
6
|
-
import { SimpleCommentBlock } from "./index.js";
|
|
7
6
|
import { MemberScope } from "./MemberScope.js";
|
|
8
7
|
import { PythonBlock } from "./PythonBlock.js";
|
|
9
|
-
/**
|
|
10
|
-
* A Python enum declaration, following https://docs.python.org/3.11/library/enum.html.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```tsx
|
|
14
|
-
* <EnumDeclaration name="Direction" style="functional">
|
|
15
|
-
* members={[
|
|
16
|
-
* { name: "NORTH" },
|
|
17
|
-
* { name: "SOUTH" },
|
|
18
|
-
* { name: "EAST" },
|
|
19
|
-
* { name: "WEST" },
|
|
20
|
-
* ]}
|
|
21
|
-
* />
|
|
22
|
-
* ```
|
|
23
|
-
* This will generate:
|
|
24
|
-
* ```python
|
|
25
|
-
* from enum import Enum
|
|
26
|
-
* class Direction(Enum):
|
|
27
|
-
* NORTH = "NORTH"
|
|
28
|
-
* SOUTH = "SOUTH"
|
|
29
|
-
* EAST = "EAST"
|
|
30
|
-
* WEST = "WEST"
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export function EnumDeclaration(props) {
|
|
34
|
-
// Handle enum styles
|
|
35
|
-
if (props.style === "functional") {
|
|
36
|
-
return _$createComponent(FunctionalEnumDeclaration, props);
|
|
37
|
-
}
|
|
38
|
-
return _$createComponent(ClassEnumDeclaration, props);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
8
|
/**
|
|
42
9
|
* Create a Python enum using the functional syntax.
|
|
43
10
|
*
|
|
@@ -117,7 +84,6 @@ export function FunctionalEnumDeclaration(props) {
|
|
|
117
84
|
}
|
|
118
85
|
})];
|
|
119
86
|
}
|
|
120
|
-
|
|
121
87
|
/**
|
|
122
88
|
* Create a Python enum using the class-based syntax.
|
|
123
89
|
*
|
|
@@ -196,7 +162,7 @@ export function ClassEnumDeclaration(props) {
|
|
|
196
162
|
...m,
|
|
197
163
|
auto: false
|
|
198
164
|
} : m);
|
|
199
|
-
if (props.
|
|
165
|
+
if (props.auto) {
|
|
200
166
|
memberList = memberList.map(m => m.value === undefined ? {
|
|
201
167
|
name: m.name,
|
|
202
168
|
auto: true
|
|
@@ -205,24 +171,20 @@ export function ClassEnumDeclaration(props) {
|
|
|
205
171
|
return _$createComponent(CoreDeclaration, {
|
|
206
172
|
symbol: sym,
|
|
207
173
|
get children() {
|
|
208
|
-
return [_$createComponent(
|
|
209
|
-
get when() {
|
|
210
|
-
return Boolean(props.doc);
|
|
211
|
-
},
|
|
212
|
-
get children() {
|
|
213
|
-
return [_$createComponent(SimpleCommentBlock, {
|
|
214
|
-
get children() {
|
|
215
|
-
return props.doc;
|
|
216
|
-
}
|
|
217
|
-
}), _$createIntrinsic("hbr", {})];
|
|
218
|
-
}
|
|
219
|
-
}), "class ", _$memo(() => sym.name), "(", _$memo(() => enumModule["."][baseType]), ")", _$createComponent(MemberScope, {
|
|
174
|
+
return ["class ", _$memo(() => sym.name), "(", _$memo(() => enumModule["."][baseType]), ")", _$createComponent(MemberScope, {
|
|
220
175
|
ownerSymbol: sym,
|
|
221
176
|
get children() {
|
|
222
177
|
return _$createComponent(PythonBlock, {
|
|
223
178
|
opener: ":",
|
|
224
179
|
get children() {
|
|
225
|
-
return [_$createComponent(
|
|
180
|
+
return [_$createComponent(Show, {
|
|
181
|
+
get when() {
|
|
182
|
+
return Boolean(props.doc);
|
|
183
|
+
},
|
|
184
|
+
get children() {
|
|
185
|
+
return [_$memo(() => props.doc), _$createIntrinsic("hbr", {})];
|
|
186
|
+
}
|
|
187
|
+
}), _$createComponent(For, {
|
|
226
188
|
each: memberList,
|
|
227
189
|
hardline: true,
|
|
228
190
|
children: member => _$createComponent(EnumMember, {
|