@typespec/emitter-framework 0.15.0-dev.3 → 0.15.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/CHANGELOG.md +1 -16
- package/dist/src/python/builtins.d.ts +14 -0
- package/dist/src/python/builtins.d.ts.map +1 -0
- package/dist/src/python/builtins.js +29 -0
- package/dist/src/python/builtins.js.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.d.ts +6 -0
- package/dist/src/python/components/array-expression/array-expression.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.js +11 -0
- package/dist/src/python/components/array-expression/array-expression.js.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.test.d.ts +2 -0
- package/dist/src/python/components/array-expression/array-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.test.js +19 -0
- package/dist/src/python/components/array-expression/array-expression.test.js.map +1 -0
- package/dist/src/python/components/array-expression/index.d.ts +2 -0
- package/dist/src/python/components/array-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/index.js +2 -0
- package/dist/src/python/components/array-expression/index.js.map +1 -0
- package/dist/src/python/components/atom/atom.d.ts +33 -0
- package/dist/src/python/components/atom/atom.d.ts.map +1 -0
- package/dist/src/python/components/atom/atom.js +88 -0
- package/dist/src/python/components/atom/atom.js.map +1 -0
- package/dist/src/python/components/atom/atom.test.d.ts +2 -0
- package/dist/src/python/components/atom/atom.test.d.ts.map +1 -0
- package/dist/src/python/components/atom/atom.test.js +224 -0
- package/dist/src/python/components/atom/atom.test.js.map +1 -0
- package/dist/src/python/components/atom/index.d.ts +2 -0
- package/dist/src/python/components/atom/index.d.ts.map +1 -0
- package/dist/src/python/components/atom/index.js +2 -0
- package/dist/src/python/components/atom/index.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-bases.d.ts +45 -0
- package/dist/src/python/components/class-declaration/class-bases.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-bases.js +84 -0
- package/dist/src/python/components/class-declaration/class-bases.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-body.d.ts +16 -0
- package/dist/src/python/components/class-declaration/class-body.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-body.js +52 -0
- package/dist/src/python/components/class-declaration/class-body.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.d.ts +23 -0
- package/dist/src/python/components/class-declaration/class-declaration.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.js +118 -0
- package/dist/src/python/components/class-declaration/class-declaration.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.js +1527 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.d.ts +16 -0
- package/dist/src/python/components/class-declaration/class-member.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.js +71 -0
- package/dist/src/python/components/class-declaration/class-member.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-member.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.test.js +202 -0
- package/dist/src/python/components/class-declaration/class-member.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.d.ts +22 -0
- package/dist/src/python/components/class-declaration/class-method.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.js +76 -0
- package/dist/src/python/components/class-declaration/class-method.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-method.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.test.js +298 -0
- package/dist/src/python/components/class-declaration/class-method.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/index.d.ts +7 -0
- package/dist/src/python/components/class-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/index.js +7 -0
- package/dist/src/python/components/class-declaration/index.js.map +1 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.d.ts +22 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.js +67 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.js.map +1 -0
- package/dist/src/python/components/doc-element/doc-element.d.ts +46 -0
- package/dist/src/python/components/doc-element/doc-element.d.ts.map +1 -0
- package/dist/src/python/components/doc-element/doc-element.js +59 -0
- package/dist/src/python/components/doc-element/doc-element.js.map +1 -0
- package/dist/src/python/components/doc-element/index.d.ts +2 -0
- package/dist/src/python/components/doc-element/index.d.ts.map +1 -0
- package/dist/src/python/components/doc-element/index.js +2 -0
- package/dist/src/python/components/doc-element/index.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.d.ts +8 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.js +80 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts +2 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js +344 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-member.d.ts +9 -0
- package/dist/src/python/components/enum-declaration/enum-member.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-member.js +22 -0
- package/dist/src/python/components/enum-declaration/enum-member.js.map +1 -0
- package/dist/src/python/components/enum-declaration/index.d.ts +3 -0
- package/dist/src/python/components/enum-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/index.js +3 -0
- package/dist/src/python/components/enum-declaration/index.js.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.d.ts +24 -0
- package/dist/src/python/components/function-declaration/function-declaration.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.js +68 -0
- package/dist/src/python/components/function-declaration/function-declaration.js.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.d.ts +2 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.js +682 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.js.map +1 -0
- package/dist/src/python/components/function-declaration/index.d.ts +2 -0
- package/dist/src/python/components/function-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/index.js +2 -0
- package/dist/src/python/components/function-declaration/index.js.map +1 -0
- package/dist/src/python/components/index.d.ts +12 -0
- package/dist/src/python/components/index.d.ts.map +1 -0
- package/dist/src/python/components/index.js +12 -0
- package/dist/src/python/components/index.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts +25 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.js +33 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/index.d.ts +3 -0
- package/dist/src/python/components/protocol-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/index.js +3 -0
- package/dist/src/python/components/protocol-declaration/index.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts +8 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.js +86 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts +2 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js +117 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js.map +1 -0
- package/dist/src/python/components/record-expression/index.d.ts +2 -0
- package/dist/src/python/components/record-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/index.js +2 -0
- package/dist/src/python/components/record-expression/index.js.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.d.ts +6 -0
- package/dist/src/python/components/record-expression/record-expression.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.js +13 -0
- package/dist/src/python/components/record-expression/record-expression.js.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.test.d.ts +2 -0
- package/dist/src/python/components/record-expression/record-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.test.js +19 -0
- package/dist/src/python/components/record-expression/record-expression.test.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/index.d.ts +2 -0
- package/dist/src/python/components/type-alias-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/index.js +2 -0
- package/dist/src/python/components/type-alias-declaration/index.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts +16 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js +75 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts +2 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js +140 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js.map +1 -0
- package/dist/src/python/components/type-declaration/index.d.ts +2 -0
- package/dist/src/python/components/type-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/index.js +2 -0
- package/dist/src/python/components/type-declaration/index.js.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.d.ts +11 -0
- package/dist/src/python/components/type-declaration/type-declaration.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.js +31 -0
- package/dist/src/python/components/type-declaration/type-declaration.js.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.d.ts +2 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.js +69 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.js.map +1 -0
- package/dist/src/python/components/type-expression/index.d.ts +2 -0
- package/dist/src/python/components/type-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/index.js +2 -0
- package/dist/src/python/components/type-expression/index.js.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.d.ts +12 -0
- package/dist/src/python/components/type-expression/type-expression.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.js +348 -0
- package/dist/src/python/components/type-expression/type-expression.js.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.test.d.ts +2 -0
- package/dist/src/python/components/type-expression/type-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.test.js +503 -0
- package/dist/src/python/components/type-expression/type-expression.test.js.map +1 -0
- package/dist/src/python/index.d.ts +4 -0
- package/dist/src/python/index.d.ts.map +1 -0
- package/dist/src/python/index.js +4 -0
- package/dist/src/python/index.js.map +1 -0
- package/dist/src/python/lib.d.ts +68 -0
- package/dist/src/python/lib.d.ts.map +1 -0
- package/dist/src/python/lib.js +38 -0
- package/dist/src/python/lib.js.map +1 -0
- package/dist/src/python/test-utils.d.ts +8 -0
- package/dist/src/python/test-utils.d.ts.map +1 -0
- package/dist/src/python/test-utils.js +25 -0
- package/dist/src/python/test-utils.js.map +1 -0
- package/dist/src/python/utils/index.d.ts +4 -0
- package/dist/src/python/utils/index.d.ts.map +1 -0
- package/dist/src/python/utils/index.js +4 -0
- package/dist/src/python/utils/index.js.map +1 -0
- package/dist/src/python/utils/operation.d.ts +27 -0
- package/dist/src/python/utils/operation.d.ts.map +1 -0
- package/dist/src/python/utils/operation.js +139 -0
- package/dist/src/python/utils/operation.js.map +1 -0
- package/dist/src/python/utils/refkey.d.ts +23 -0
- package/dist/src/python/utils/refkey.d.ts.map +1 -0
- package/dist/src/python/utils/refkey.js +36 -0
- package/dist/src/python/utils/refkey.js.map +1 -0
- package/dist/src/python/utils/type.d.ts +19 -0
- package/dist/src/python/utils/type.d.ts.map +1 -0
- package/dist/src/python/utils/type.js +24 -0
- package/dist/src/python/utils/type.js.map +1 -0
- package/package.json +9 -1
- package/package.json.bak +10 -1
- package/src/python/builtins.ts +43 -0
- package/src/python/components/array-expression/array-expression.test.tsx +14 -0
- package/src/python/components/array-expression/array-expression.tsx +11 -0
- package/src/python/components/array-expression/index.ts +1 -0
- package/src/python/components/atom/atom.test.tsx +244 -0
- package/src/python/components/atom/atom.tsx +95 -0
- package/src/python/components/atom/index.ts +1 -0
- package/src/python/components/class-declaration/class-bases.tsx +92 -0
- package/src/python/components/class-declaration/class-body.tsx +56 -0
- package/src/python/components/class-declaration/class-declaration.test.tsx +1414 -0
- package/src/python/components/class-declaration/class-declaration.tsx +116 -0
- package/src/python/components/class-declaration/class-member.test.tsx +194 -0
- package/src/python/components/class-declaration/class-member.tsx +67 -0
- package/src/python/components/class-declaration/class-method.test.tsx +250 -0
- package/src/python/components/class-declaration/class-method.tsx +97 -0
- package/src/python/components/class-declaration/index.ts +6 -0
- package/src/python/components/class-declaration/primitive-initializer.tsx +62 -0
- package/src/python/components/doc-element/doc-element.tsx +83 -0
- package/src/python/components/doc-element/index.ts +1 -0
- package/src/python/components/enum-declaration/enum-declaration.test.tsx +319 -0
- package/src/python/components/enum-declaration/enum-declaration.tsx +77 -0
- package/src/python/components/enum-declaration/enum-member.tsx +21 -0
- package/src/python/components/enum-declaration/index.ts +2 -0
- package/src/python/components/function-declaration/function-declaration.test.tsx +582 -0
- package/src/python/components/function-declaration/function-declaration.tsx +90 -0
- package/src/python/components/function-declaration/index.ts +1 -0
- package/src/python/components/index.ts +11 -0
- package/src/python/components/protocol-declaration/callable-parameters.tsx +44 -0
- package/src/python/components/protocol-declaration/index.ts +2 -0
- package/src/python/components/protocol-declaration/protocol-declaration.test.tsx +106 -0
- package/src/python/components/protocol-declaration/protocol-declaration.tsx +73 -0
- package/src/python/components/record-expression/index.ts +1 -0
- package/src/python/components/record-expression/record-expression.test.tsx +14 -0
- package/src/python/components/record-expression/record-expression.tsx +13 -0
- package/src/python/components/type-alias-declaration/index.ts +1 -0
- package/src/python/components/type-alias-declaration/type-alias-declaration.test.tsx +117 -0
- package/src/python/components/type-alias-declaration/type-alias-declaration.tsx +67 -0
- package/src/python/components/type-declaration/index.ts +1 -0
- package/src/python/components/type-declaration/type-declaration.test.tsx +58 -0
- package/src/python/components/type-declaration/type-declaration.tsx +26 -0
- package/src/python/components/type-expression/index.ts +1 -0
- package/src/python/components/type-expression/type-expression.test.tsx +463 -0
- package/src/python/components/type-expression/type-expression.tsx +333 -0
- package/src/python/index.ts +3 -0
- package/src/python/lib.ts +40 -0
- package/src/python/test-utils.tsx +31 -0
- package/src/python/utils/index.ts +3 -0
- package/src/python/utils/operation.ts +161 -0
- package/src/python/utils/refkey.ts +36 -0
- package/src/python/utils/type.ts +31 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useTsp","For","Prose","py","reportDiagnostic","declarationRefkeys","efRefkey","EnumMember","determineEnumType","members","allInteger","every","member","value","Number","isInteger","allString","EnumDeclaration","props","$","type","union","is","isValidEnum","Error","enum","createFromUnion","name","program","code","target","refkeys","refkey","usePythonNamePolicy","getName","Array","from","entries","doc","getDoc","docElement","_$createComponent","ClassDoc","description","children","undefined","enumType","ClassEnumDeclaration","baseType","each","hardline","key","memberDoc","_$memo","variants","get"],"sources":["../../../../../src/python/components/enum-declaration/enum-declaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,GAAG,EAAEC,KAAK,QAAQ,gBAAgB;AAC3C,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AAEtC,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IAAI,CAACmB,MAAM,CAAC1B,KAAK,CAAC;UACtC,OAAA4B,iBAAA,CACGlC,UAAU;YACT+B,GAAG,EAAEc,SAAS;YACdhC,IAAI,EAAEP,KAAK;YAAA,IACXmB,MAAMA,CAAA;cAAA,OACJqB,MAAA,SAAAlC,CAAC,CAACE,KAAK,CAACC,EAAE,CAACJ,KAAK,CAACE,IAAI,CAAC,MAAGd,QAAQ,CAACY,KAAK,CAACE,IAAI,CAACkC,QAAQ,CAACC,GAAG,CAACJ,GAAG,CAAC,CAAC,GAAG7C,QAAQ,CAACO,KAAK,CAAC;YAAA;UAAA;QAIzF;MAAC;IAAA;EAAA;AAIT","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum-declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/enum-declaration/enum-declaration.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { efRefkey } from "#python/utils/refkey.js";
|
|
3
|
+
import { Tester } from "#test/test-host.js";
|
|
4
|
+
import { d } from "@alloy-js/core/testing";
|
|
5
|
+
import * as py from "@alloy-js/python";
|
|
6
|
+
import { t } from "@typespec/compiler/testing";
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import { getOutput } from "../../test-utils.js";
|
|
9
|
+
import { EnumDeclaration } from "./enum-declaration.js";
|
|
10
|
+
describe("Python Enum Declaration", () => {
|
|
11
|
+
it("takes an enum type parameter", async () => {
|
|
12
|
+
const {
|
|
13
|
+
program,
|
|
14
|
+
Foo
|
|
15
|
+
} = await Tester.compile(t.code`
|
|
16
|
+
enum ${t.enum("Foo")} {
|
|
17
|
+
one: 1,
|
|
18
|
+
two: 2,
|
|
19
|
+
three: 3
|
|
20
|
+
}
|
|
21
|
+
`);
|
|
22
|
+
expect(getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
23
|
+
type: Foo
|
|
24
|
+
})])).toRenderTo(d`
|
|
25
|
+
from enum import IntEnum
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Foo(IntEnum):
|
|
29
|
+
ONE = 1
|
|
30
|
+
TWO = 2
|
|
31
|
+
THREE = 3
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
`);
|
|
35
|
+
});
|
|
36
|
+
it("adds Python doc from TypeSpec", async () => {
|
|
37
|
+
const {
|
|
38
|
+
program,
|
|
39
|
+
Foo
|
|
40
|
+
} = await Tester.compile(t.code`
|
|
41
|
+
/**
|
|
42
|
+
* This is a test enum
|
|
43
|
+
*/
|
|
44
|
+
enum ${t.enum("Foo")} {
|
|
45
|
+
@doc("This is one")
|
|
46
|
+
one: 1,
|
|
47
|
+
two: 2,
|
|
48
|
+
three: 3
|
|
49
|
+
}
|
|
50
|
+
`);
|
|
51
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
52
|
+
type: Foo
|
|
53
|
+
})]);
|
|
54
|
+
expect(output).toRenderTo(d`
|
|
55
|
+
from enum import IntEnum
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Foo(IntEnum):
|
|
59
|
+
"""
|
|
60
|
+
This is a test enum
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
ONE = 1
|
|
64
|
+
"""
|
|
65
|
+
This is one
|
|
66
|
+
"""
|
|
67
|
+
TWO = 2
|
|
68
|
+
THREE = 3
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
`);
|
|
72
|
+
});
|
|
73
|
+
it("explicit doc take precedence", async () => {
|
|
74
|
+
const {
|
|
75
|
+
program,
|
|
76
|
+
Foo
|
|
77
|
+
} = await Tester.compile(t.code`
|
|
78
|
+
/**
|
|
79
|
+
* This is a test enum
|
|
80
|
+
*/
|
|
81
|
+
enum ${t.enum("Foo")} {
|
|
82
|
+
@doc("This is one")
|
|
83
|
+
one: 1,
|
|
84
|
+
two: 2,
|
|
85
|
+
three: 3
|
|
86
|
+
}
|
|
87
|
+
`);
|
|
88
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
89
|
+
type: Foo,
|
|
90
|
+
doc: ["This is an explicit doc"]
|
|
91
|
+
})]);
|
|
92
|
+
expect(output).toRenderTo(d`
|
|
93
|
+
from enum import IntEnum
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class Foo(IntEnum):
|
|
97
|
+
"""
|
|
98
|
+
This is an explicit doc
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
ONE = 1
|
|
102
|
+
"""
|
|
103
|
+
This is one
|
|
104
|
+
"""
|
|
105
|
+
TWO = 2
|
|
106
|
+
THREE = 3
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
`);
|
|
110
|
+
});
|
|
111
|
+
it("takes a union type parameter", async () => {
|
|
112
|
+
const {
|
|
113
|
+
program,
|
|
114
|
+
Foo
|
|
115
|
+
} = await Tester.compile(t.code`
|
|
116
|
+
union ${t.union("Foo")} {
|
|
117
|
+
one: 1,
|
|
118
|
+
two: 2,
|
|
119
|
+
three: 3
|
|
120
|
+
}
|
|
121
|
+
`);
|
|
122
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
123
|
+
type: Foo
|
|
124
|
+
})]);
|
|
125
|
+
expect(output).toRenderTo(d`
|
|
126
|
+
from enum import IntEnum
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class Foo(IntEnum):
|
|
130
|
+
ONE = 1
|
|
131
|
+
TWO = 2
|
|
132
|
+
THREE = 3
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
`);
|
|
136
|
+
});
|
|
137
|
+
it("can be referenced", async () => {
|
|
138
|
+
const {
|
|
139
|
+
program,
|
|
140
|
+
Foo
|
|
141
|
+
} = await Tester.compile(t.code`
|
|
142
|
+
enum ${t.enum("Foo")} {
|
|
143
|
+
one: 1,
|
|
144
|
+
two: 2,
|
|
145
|
+
three: 3
|
|
146
|
+
}
|
|
147
|
+
`);
|
|
148
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
149
|
+
type: Foo
|
|
150
|
+
}), _$createComponent(py.StatementList, {
|
|
151
|
+
get children() {
|
|
152
|
+
return [_$memo(() => efRefkey(Foo)), _$memo(() => efRefkey(Foo.members.get("one")))];
|
|
153
|
+
}
|
|
154
|
+
})]);
|
|
155
|
+
expect(output).toRenderTo(d`
|
|
156
|
+
from enum import IntEnum
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class Foo(IntEnum):
|
|
160
|
+
ONE = 1
|
|
161
|
+
TWO = 2
|
|
162
|
+
THREE = 3
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
Foo
|
|
166
|
+
Foo.ONE
|
|
167
|
+
`);
|
|
168
|
+
});
|
|
169
|
+
it("can be referenced using union", async () => {
|
|
170
|
+
const {
|
|
171
|
+
program,
|
|
172
|
+
Foo
|
|
173
|
+
} = await Tester.compile(t.code`
|
|
174
|
+
union ${t.union("Foo")} {
|
|
175
|
+
one: 1,
|
|
176
|
+
two: 2,
|
|
177
|
+
three: 3
|
|
178
|
+
}
|
|
179
|
+
`);
|
|
180
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
181
|
+
type: Foo
|
|
182
|
+
}), _$createComponent(py.StatementList, {
|
|
183
|
+
get children() {
|
|
184
|
+
return [_$memo(() => efRefkey(Foo)), _$memo(() => efRefkey(Foo.variants.get("one")))];
|
|
185
|
+
}
|
|
186
|
+
})]);
|
|
187
|
+
expect(output).toRenderTo(d`
|
|
188
|
+
from enum import IntEnum
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class Foo(IntEnum):
|
|
192
|
+
ONE = 1
|
|
193
|
+
TWO = 2
|
|
194
|
+
THREE = 3
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
Foo
|
|
198
|
+
Foo.ONE
|
|
199
|
+
`);
|
|
200
|
+
});
|
|
201
|
+
describe("Enum Type Detection", () => {
|
|
202
|
+
it("generates IntEnum if all values are integer values", async () => {
|
|
203
|
+
const {
|
|
204
|
+
program,
|
|
205
|
+
StatusCode
|
|
206
|
+
} = await Tester.compile(t.code`
|
|
207
|
+
enum ${t.enum("StatusCode")} {
|
|
208
|
+
success: 200,
|
|
209
|
+
notFound: 404,
|
|
210
|
+
serverError: 500
|
|
211
|
+
}
|
|
212
|
+
`);
|
|
213
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
214
|
+
type: StatusCode
|
|
215
|
+
})]);
|
|
216
|
+
expect(output).toRenderTo(d`
|
|
217
|
+
from enum import IntEnum
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class StatusCode(IntEnum):
|
|
221
|
+
SUCCESS = 200
|
|
222
|
+
NOT_FOUND = 404
|
|
223
|
+
SERVER_ERROR = 500
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
`);
|
|
227
|
+
});
|
|
228
|
+
it("generates StrEnum if all values are string values", async () => {
|
|
229
|
+
const {
|
|
230
|
+
program,
|
|
231
|
+
Color
|
|
232
|
+
} = await Tester.compile(t.code`
|
|
233
|
+
enum ${t.enum("Color")} {
|
|
234
|
+
red: "red",
|
|
235
|
+
green: "green",
|
|
236
|
+
blue: "blue"
|
|
237
|
+
}
|
|
238
|
+
`);
|
|
239
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
240
|
+
type: Color
|
|
241
|
+
})]);
|
|
242
|
+
expect(output).toRenderTo(d`
|
|
243
|
+
from enum import StrEnum
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class Color(StrEnum):
|
|
247
|
+
RED = "red"
|
|
248
|
+
GREEN = "green"
|
|
249
|
+
BLUE = "blue"
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
`);
|
|
253
|
+
});
|
|
254
|
+
it("generates StrEnum if all values are string values with custom values", async () => {
|
|
255
|
+
const {
|
|
256
|
+
program,
|
|
257
|
+
Color
|
|
258
|
+
} = await Tester.compile(t.code`
|
|
259
|
+
enum ${t.enum("Color")} {
|
|
260
|
+
red: "This is red",
|
|
261
|
+
green: "This is green",
|
|
262
|
+
blue: "This is blue"
|
|
263
|
+
}
|
|
264
|
+
`);
|
|
265
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
266
|
+
type: Color
|
|
267
|
+
}), _$createComponent(py.StatementList, {
|
|
268
|
+
get children() {
|
|
269
|
+
return [_$memo(() => efRefkey(Color.members.get("red"))), _$memo(() => efRefkey(Color.members.get("green"))), _$memo(() => efRefkey(Color.members.get("blue")))];
|
|
270
|
+
}
|
|
271
|
+
})]);
|
|
272
|
+
expect(output).toRenderTo(d`
|
|
273
|
+
from enum import StrEnum
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
class Color(StrEnum):
|
|
277
|
+
RED = "This is red"
|
|
278
|
+
GREEN = "This is green"
|
|
279
|
+
BLUE = "This is blue"
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
Color.RED
|
|
283
|
+
Color.GREEN
|
|
284
|
+
Color.BLUE
|
|
285
|
+
|
|
286
|
+
`);
|
|
287
|
+
});
|
|
288
|
+
it("generates Enum for mixed value types", async () => {
|
|
289
|
+
const {
|
|
290
|
+
program,
|
|
291
|
+
Mixed
|
|
292
|
+
} = await Tester.compile(t.code`
|
|
293
|
+
enum ${t.enum("Mixed")} {
|
|
294
|
+
stringValue: "hello",
|
|
295
|
+
numericValue: 42,
|
|
296
|
+
autoValue
|
|
297
|
+
}
|
|
298
|
+
`);
|
|
299
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
300
|
+
type: Mixed
|
|
301
|
+
})]);
|
|
302
|
+
expect(output).toRenderTo(d`
|
|
303
|
+
from enum import auto
|
|
304
|
+
from enum import Enum
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
class Mixed(Enum):
|
|
308
|
+
STRING_VALUE = "hello"
|
|
309
|
+
NUMERIC_VALUE = 42
|
|
310
|
+
AUTO_VALUE = auto()
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
`);
|
|
314
|
+
});
|
|
315
|
+
it("handles correctly enums without values", async () => {
|
|
316
|
+
const {
|
|
317
|
+
program,
|
|
318
|
+
EnumWithoutValues
|
|
319
|
+
} = await Tester.compile(t.code`
|
|
320
|
+
enum ${t.enum("EnumWithoutValues")} {
|
|
321
|
+
someValue,
|
|
322
|
+
anotherValue,
|
|
323
|
+
yetAnotherValue
|
|
324
|
+
}
|
|
325
|
+
`);
|
|
326
|
+
const output = getOutput(program, [_$createComponent(EnumDeclaration, {
|
|
327
|
+
type: EnumWithoutValues
|
|
328
|
+
})]);
|
|
329
|
+
expect(output).toRenderTo(d`
|
|
330
|
+
from enum import auto
|
|
331
|
+
from enum import Enum
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
class EnumWithoutValues(Enum):
|
|
335
|
+
SOME_VALUE = auto()
|
|
336
|
+
ANOTHER_VALUE = auto()
|
|
337
|
+
YET_ANOTHER_VALUE = auto()
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
`);
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
//# sourceMappingURL=enum-declaration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["efRefkey","Tester","d","py","t","describe","expect","it","getOutput","EnumDeclaration","program","Foo","compile","code","enum","_$createComponent","type","toRenderTo","output","doc","union","StatementList","children","_$memo","members","get","variants","StatusCode","Color","Mixed","EnumWithoutValues"],"sources":["../../../../../src/python/components/enum-declaration/enum-declaration.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,QAAQ,QAAQ,yBAAyB;AAClD,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,CAAC,QAAQ,wBAAwB;AAC1C,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,SAASC,CAAC,QAAQ,4BAA4B;AAC9C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,SAAS,QAAQ,qB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AAE,CAAAK,iBAAA,CAAEN,eAAe;QAACO,IAAI,EAAEc;MAAiB,GAAK,CAAC;MAEjFxB,MAAM,CAACY,MAAM,CAAC,CAACD,UAAU,CAACf,CAAC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Children, type Refkey } from "@alloy-js/core";
|
|
2
|
+
import type { EnumMember as TspEnumMember } from "@typespec/compiler";
|
|
3
|
+
export interface EnumMemberProps {
|
|
4
|
+
type: TspEnumMember;
|
|
5
|
+
doc?: Children;
|
|
6
|
+
refkey?: Refkey;
|
|
7
|
+
}
|
|
8
|
+
export declare function EnumMember(props: EnumMemberProps): Children;
|
|
9
|
+
//# sourceMappingURL=enum-member.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum-member.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/enum-declaration/enum-member.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAUhD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import * as py from "@alloy-js/python";
|
|
3
|
+
export function EnumMember(props) {
|
|
4
|
+
return _$createComponent(py.EnumMember, {
|
|
5
|
+
get doc() {
|
|
6
|
+
return props.doc;
|
|
7
|
+
},
|
|
8
|
+
get name() {
|
|
9
|
+
return props.type.name;
|
|
10
|
+
},
|
|
11
|
+
get jsValue() {
|
|
12
|
+
return props.type.value;
|
|
13
|
+
},
|
|
14
|
+
get refkey() {
|
|
15
|
+
return props.refkey;
|
|
16
|
+
},
|
|
17
|
+
get auto() {
|
|
18
|
+
return props.type.value === undefined;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=enum-member.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["py","EnumMember","props","_$createComponent","doc","name","type","jsValue","value","refkey","auto","undefined"],"sources":["../../../../../src/python/components/enum-declaration/enum-member.tsx"],"sourcesContent":[null],"mappings":";AACA,OAAO,KAAKA,EAAE,MAAM,kBAAkB;AAStC,OAAO,SAASC,UAAUA,CAACC,KAAsB,EAAE;EACjD,OAAAC,iBAAA,CACGH,EAAE,CAACC,UAAU;IAAA,IACZG,GAAGA,CAAA;MAAA,OAAEF,KAAK,CAACE,GAAG;IAAA;IAAA,IACdC,IAAIA,CAAA;MAAA,OAAEH,KAAK,CAACI,IAAI,CAACD,IAAI;IAAA;IAAA,IACrBE,OAAOA,CAAA;MAAA,OAAEL,KAAK,CAACI,IAAI,CAACE,KAAK;IAAA;IAAA,IACzBC,MAAMA,CAAA;MAAA,OAAEP,KAAK,CAACO,MAAM;IAAA;IAAA,IACpBC,IAAIA,CAAA;MAAA,OAAER,KAAK,CAACI,IAAI,CAACE,KAAK,KAAKG,SAAS;IAAA;EAAA;AAG1C","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/enum-declaration/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../../src/python/components/enum-declaration/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as py from "@alloy-js/python";
|
|
2
|
+
import type { Model, Operation } from "@typespec/compiler";
|
|
3
|
+
export interface FunctionDeclarationPropsWithType extends Omit<py.FunctionDeclarationProps, "name"> {
|
|
4
|
+
type: Operation;
|
|
5
|
+
name?: string;
|
|
6
|
+
parametersModel?: Model;
|
|
7
|
+
/** If true, parameters replaces operation parameters instead of adding to them as keyword-only */
|
|
8
|
+
replaceParameters?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type FunctionDeclarationProps = FunctionDeclarationPropsWithType | py.FunctionDeclarationProps;
|
|
11
|
+
/**
|
|
12
|
+
* A Python function declaration. Pass the `type` prop to create the
|
|
13
|
+
* function declaration by converting from a TypeSpec Operation. Any other props
|
|
14
|
+
* provided will take precedence.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* - `parametersModel`: When provided, it replaces the function parameters, ignoring
|
|
18
|
+
* the `parameters` option.
|
|
19
|
+
* - Model-derived parameters include default values when present on the model, and
|
|
20
|
+
* emit `= None` for optional parameters without an explicit default.
|
|
21
|
+
* - Additional parameters (from `parameters` prop) are always keyword-only.
|
|
22
|
+
*/
|
|
23
|
+
export declare function FunctionDeclaration(props: FunctionDeclarationProps): import("@alloy-js/core").Children;
|
|
24
|
+
//# sourceMappingURL=function-declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-declaration.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/function-declaration/function-declaration.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI3D,MAAM,WAAW,gCAAiC,SAAQ,IAAI,CAC5D,EAAE,CAAC,wBAAwB,EAC3B,MAAM,CACP;IACC,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,kGAAkG;IAClG,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,wBAAwB,GAChC,gCAAgC,GAChC,EAAE,CAAC,wBAAwB,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qCAgDlE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { useTsp } from "#core/index.js";
|
|
3
|
+
import { buildParameterDescriptors } from "#python/utils/operation.js";
|
|
4
|
+
import { declarationRefkeys } from "#python/utils/refkey.js";
|
|
5
|
+
import * as py from "@alloy-js/python";
|
|
6
|
+
import { DocElement } from "../doc-element/doc-element.js";
|
|
7
|
+
import { TypeExpression } from "../type-expression/type-expression.js";
|
|
8
|
+
/**
|
|
9
|
+
* A Python function declaration. Pass the `type` prop to create the
|
|
10
|
+
* function declaration by converting from a TypeSpec Operation. Any other props
|
|
11
|
+
* provided will take precedence.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* - `parametersModel`: When provided, it replaces the function parameters, ignoring
|
|
15
|
+
* the `parameters` option.
|
|
16
|
+
* - Model-derived parameters include default values when present on the model, and
|
|
17
|
+
* emit `= None` for optional parameters without an explicit default.
|
|
18
|
+
* - Additional parameters (from `parameters` prop) are always keyword-only.
|
|
19
|
+
*/
|
|
20
|
+
export function FunctionDeclaration(props) {
|
|
21
|
+
const {
|
|
22
|
+
$
|
|
23
|
+
} = useTsp();
|
|
24
|
+
if (!isTypedFunctionDeclarationProps(props)) {
|
|
25
|
+
return _$createComponent(py.FunctionDeclaration, props);
|
|
26
|
+
}
|
|
27
|
+
const refkeys = declarationRefkeys(props.refkey, props.type);
|
|
28
|
+
const name = props.name ? props.name : py.usePythonNamePolicy().getName(props.type.name, "function");
|
|
29
|
+
const returnType = props.returnType ?? _$createComponent(TypeExpression, {
|
|
30
|
+
get type() {
|
|
31
|
+
return props.type.returnType;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
let allParameters;
|
|
35
|
+
if (props.parametersModel) {
|
|
36
|
+
// When a parametersModel is provided, it always replaces parameters,
|
|
37
|
+
// ignoring extra parameters.
|
|
38
|
+
allParameters = buildParameterDescriptors(props.parametersModel) ?? [];
|
|
39
|
+
} else {
|
|
40
|
+
allParameters = buildParameterDescriptors(props.type.parameters, {
|
|
41
|
+
params: props.parameters,
|
|
42
|
+
replaceParameters: props.replaceParameters
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const docSource = props.doc ?? $.type.getDoc(props.type);
|
|
46
|
+
const docElement = docSource ? _$createComponent(DocElement, {
|
|
47
|
+
doc: docSource,
|
|
48
|
+
component: py.FunctionDoc
|
|
49
|
+
}) : undefined;
|
|
50
|
+
const doc = docElement ? [docElement, _$createIntrinsic("hbr", {})] : undefined;
|
|
51
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
52
|
+
doc: doc,
|
|
53
|
+
refkey: refkeys,
|
|
54
|
+
name: name,
|
|
55
|
+
get async() {
|
|
56
|
+
return props.async;
|
|
57
|
+
},
|
|
58
|
+
returnType: returnType,
|
|
59
|
+
parameters: allParameters,
|
|
60
|
+
get children() {
|
|
61
|
+
return props.children;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function isTypedFunctionDeclarationProps(props) {
|
|
66
|
+
return "type" in props;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=function-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useTsp","buildParameterDescriptors","declarationRefkeys","py","DocElement","TypeExpression","FunctionDeclaration","props","$","isTypedFunctionDeclarationProps","_$createComponent","refkeys","refkey","type","name","usePythonNamePolicy","getName","returnType","allParameters","parametersModel","parameters","params","replaceParameters","docSource","doc","getDoc","docElement","component","FunctionDoc","undefined","_$createIntrinsic","async","children"],"sources":["../../../../../src/python/components/function-declaration/function-declaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,yBAAyB,QAAQ,4BAA4B;AACtE,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AAEtC,SAASC,UAAU,QAAQ,+BAA+B;AAC1D,SAASC,cAAc,QAAQ,uCAAuC;AAiBtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,KAA+B,EAAE;EACnE,MAAM;IAAEC;EAAE,CAAC,GAAGR,MAAM,CAAC,CAAC;EAEtB,IAAI,CAACS,+BAA+B,CAACF,KAAK,CAAC,EAAE;IAC3C,OAAAG,iBAAA,CAAQP,EAAE,CAACG,mBAAmB,EAAKC,KAAK;EAC1C;EAEA,MAAMI,OAAO,GAAGT,kBAAkB,CAACK,KAAK,CAACK,MAAM,EAAEL,KAAK,CAACM,IAAI,CAAC;EAE5D,MAAMC,IAAI,GAAGP,KAAK,CAACO,IAAI,GACnBP,KAAK,CAACO,IAAI,GACVX,EAAE,CAACY,mBAAmB,CAAC,CAAC,CAACC,OAAO,CAACT,KAAK,CAACM,IAAI,CAACC,IAAI,EAAE,UAAU,CAAC;EAEjE,MAAMG,UAAU,GAAGV,KAAK,CAACU,UAAU,IAAAP,iBAAA,CAAKL,cAAc;IAAA,IAACQ,IAAIA,CAAA;MAAA,OAAEN,KAAK,CAACM,IAAI,CAACI,UAAU;IAAA;EAAA,EAAI;EACtF,IAAIC,aAA8D;EAClE,IAAIX,KAAK,CAACY,eAAe,EAAE;IACzB;IACA;IACAD,aAAa,GAAGjB,yBAAyB,CAACM,KAAK,CAACY,eAAe,CAAC,IAAI,EAAE;EACxE,CAAC,MAAM;IACLD,aAAa,GAAGjB,yBAAyB,CAACM,KAAK,CAACM,IAAI,CAACO,UAAU,EAAE;MAC/DC,MAAM,EAAEd,KAAK,CAACa,UAAU;MACxBE,iBAAiB,EAAEf,KAAK,CAACe;IAC3B,CAAC,CAAC;EACJ;EACA,MAAMC,SAAS,GAAGhB,KAAK,CAACiB,GAAG,IAAIhB,CAAC,CAACK,IAAI,CAACY,MAAM,CAAClB,KAAK,CAACM,IAAI,CAAC;EACxD,MAAMa,UAAU,GAAGH,SAAS,GAAAb,iBAAA,CACzBN,UAAU;IAACoB,GAAG,EAAED,SAAS;IAAEI,SAAS,EAAExB,EAAE,CAACyB;EAAW,KACnDC,SAAS;EACb,MAAML,GAAG,GAAGE,UAAU,IAEjBA,UAAU,EAAAI,iBAAA,eAGXD,SAAS;EAEb,OAAAnB,iBAAA,CACGP,EAAE,CAACG,mBAAmB;IACrBkB,GAAG,EAAEA,GAAG;IACRZ,MAAM,EAAED,OAAO;IACfG,IAAI,EAAEA,IAAI;IAAA,IACViB,KAAKA,CAAA;MAAA,OAAExB,KAAK,CAACwB,KAAK;IAAA;IAClBd,UAAU,EAAEA,UAAU;IACtBG,UAAU,EAAEF,aAAa;IAAA,IAAAc,SAAA;MAAA,OAExBzB,KAAK,CAACyB,QAAQ;IAAA;EAAA;AAGrB;AAEA,SAASvB,+BAA+BA,CACtCF,KAA+B,EACY;EAC3C,OAAO,MAAM,IAAIA,KAAK;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/function-declaration/function-declaration.test.tsx"],"names":[],"mappings":""}
|