@alloy-js/python 0.4.0-dev.5 → 0.4.0-dev.7

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.
Files changed (113) hide show
  1. package/dist/dev/src/name-conflict-resolver.js +6 -2
  2. package/dist/dev/src/name-conflict-resolver.js.map +1 -1
  3. package/dist/dev/test/name-conflict.test.js +38 -0
  4. package/dist/dev/test/name-conflict.test.js.map +1 -0
  5. package/dist/src/name-conflict-resolver.d.ts +2 -2
  6. package/dist/src/name-conflict-resolver.d.ts.map +1 -1
  7. package/dist/src/name-conflict-resolver.js +6 -2
  8. package/dist/src/name-conflict-resolver.js.map +1 -1
  9. package/dist/test/name-conflict.test.d.ts +2 -0
  10. package/dist/test/name-conflict.test.d.ts.map +1 -0
  11. package/dist/test/name-conflict.test.js +38 -0
  12. package/dist/test/name-conflict.test.js.map +1 -0
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/docs/api/components/AttributeDoc.md +36 -0
  15. package/docs/api/components/CallSignature.md +62 -0
  16. package/docs/api/components/CallSignatureParameters.md +49 -0
  17. package/docs/api/components/ClassDeclaration.md +67 -0
  18. package/docs/api/components/ClassDoc.md +55 -0
  19. package/docs/api/components/ClassEnumDeclaration.md +111 -0
  20. package/docs/api/components/ClassInstantiation.md +44 -0
  21. package/docs/api/components/ClassMethodDeclaration.md +31 -0
  22. package/docs/api/components/ConstructorDeclaration.md +27 -0
  23. package/docs/api/components/DataclassDeclaration.md +55 -0
  24. package/docs/api/components/Declaration.md +41 -0
  25. package/docs/api/components/DunderMethodDeclaration.md +31 -0
  26. package/docs/api/components/EnumMember.md +61 -0
  27. package/docs/api/components/ExceptionDoc.md +55 -0
  28. package/docs/api/components/FunctionCallExpression.md +43 -0
  29. package/docs/api/components/FunctionDeclaration.md +50 -0
  30. package/docs/api/components/FunctionDoc.md +61 -0
  31. package/docs/api/components/FunctionalEnumDeclaration.md +79 -0
  32. package/docs/api/components/FutureStatement.md +51 -0
  33. package/docs/api/components/GeneratorDoc.md +58 -0
  34. package/docs/api/components/InlineDoc.md +29 -0
  35. package/docs/api/components/LexicalScope.md +65 -0
  36. package/docs/api/components/MemberExpression.md +53 -0
  37. package/docs/api/components/MemberScope.md +28 -0
  38. package/docs/api/components/MethodDeclaration.md +49 -0
  39. package/docs/api/components/MethodDoc.md +61 -0
  40. package/docs/api/components/ModuleDoc.md +52 -0
  41. package/docs/api/components/PropertyDeclaration.md +46 -0
  42. package/docs/api/components/PropertyDoc.md +52 -0
  43. package/docs/api/components/PyDoc.md +29 -0
  44. package/docs/api/components/PyDocExample.md +29 -0
  45. package/docs/api/components/PythonBlock.md +47 -0
  46. package/docs/api/components/Reference.md +31 -0
  47. package/docs/api/components/SimpleCommentBlock.md +27 -0
  48. package/docs/api/components/SimpleInlineComment.md +27 -0
  49. package/docs/api/components/SourceFile.md +83 -0
  50. package/docs/api/components/StatementList.md +47 -0
  51. package/docs/api/components/StaticMethodDeclaration.md +31 -0
  52. package/docs/api/components/TypeArguments.md +27 -0
  53. package/docs/api/components/TypeRefContext.md +41 -0
  54. package/docs/api/components/TypeReference.md +37 -0
  55. package/docs/api/components/UnionTypeExpression.md +27 -0
  56. package/docs/api/components/VariableDeclaration.md +87 -0
  57. package/docs/api/components/index.md +46 -0
  58. package/docs/api/components/useSourceFile.md +19 -0
  59. package/docs/api/contexts/PythonSourceFile-context.md +18 -0
  60. package/docs/api/contexts/index.md +3 -0
  61. package/docs/api/functions/createFunctionSymbol.md +23 -0
  62. package/docs/api/functions/createMethodSymbol.md +23 -0
  63. package/docs/api/functions/createModule.md +18 -0
  64. package/docs/api/functions/createPythonNamePolicy.md +17 -0
  65. package/docs/api/functions/getCallSignatureProps.md +21 -0
  66. package/docs/api/functions/index.md +13 -0
  67. package/docs/api/functions/isParameterDescriptor.md +18 -0
  68. package/docs/api/functions/isTypeRefContext.md +17 -0
  69. package/docs/api/functions/ref.md +25 -0
  70. package/docs/api/functions/usePythonLexicalScope.md +17 -0
  71. package/docs/api/functions/usePythonNamePolicy.md +17 -0
  72. package/docs/api/functions/usePythonScope.md +17 -0
  73. package/docs/api/index.md +7 -0
  74. package/docs/api/types/AddImportOptions.md +7 -0
  75. package/docs/api/types/BaseDeclarationProps.md +10 -0
  76. package/docs/api/types/CommonFunctionProps.md +15 -0
  77. package/docs/api/types/CreateModuleProps.md +8 -0
  78. package/docs/api/types/CreatePythonSymbolFunctionOptions.md +9 -0
  79. package/docs/api/types/DataclassDecoratorKey.md +5 -0
  80. package/docs/api/types/DataclassDecoratorKwargs.md +5 -0
  81. package/docs/api/types/EnumPropsBase.md +11 -0
  82. package/docs/api/types/GoogleStyleDocAttributeProps.md +9 -0
  83. package/docs/api/types/ImportRecordProps.md +7 -0
  84. package/docs/api/types/ImportRecords.md +8 -0
  85. package/docs/api/types/ImportedSymbol.md +10 -0
  86. package/docs/api/types/LexicalScopeProps.md +5 -0
  87. package/docs/api/types/MemberExpressionPartProps.md +13 -0
  88. package/docs/api/types/ModuleDescriptor.md +7 -0
  89. package/docs/api/types/ModuleRefkeys.md +7 -0
  90. package/docs/api/types/NamedMap.md +7 -0
  91. package/docs/api/types/ParameterDescriptor.md +13 -0
  92. package/docs/api/types/ParameterMarker.md +5 -0
  93. package/docs/api/types/PropertyMethodDeclarationProps.md +9 -0
  94. package/docs/api/types/PythonElements.md +5 -0
  95. package/docs/api/types/PythonLexicalScope.md +11 -0
  96. package/docs/api/types/PythonMemberScope.md +9 -0
  97. package/docs/api/types/PythonModuleScope.md +13 -0
  98. package/docs/api/types/PythonOutputScope.md +5 -0
  99. package/docs/api/types/PythonOutputSymbol.md +21 -0
  100. package/docs/api/types/PythonOutputSymbolOptions.md +10 -0
  101. package/docs/api/types/RefOptions.md +7 -0
  102. package/docs/api/types/SubscriptionProps.md +9 -0
  103. package/docs/api/types/index.md +31 -0
  104. package/docs/api/variables/abcModule.md +7 -0
  105. package/docs/api/variables/dataclassDecoratorKeySet.md +5 -0
  106. package/docs/api/variables/dataclassDecoratorKeys.md +7 -0
  107. package/docs/api/variables/dataclassesModule.md +7 -0
  108. package/docs/api/variables/enumModule.md +7 -0
  109. package/docs/api/variables/index.md +8 -0
  110. package/docs/api/variables/requestsModule.md +8 -0
  111. package/package.json +4 -4
  112. package/src/name-conflict-resolver.ts +9 -11
  113. package/test/name-conflict.test.ts +37 -0
@@ -0,0 +1,36 @@
1
+ # AttributeDoc
2
+
3
+ A component that creates documentation for a single attribute. This can be used for both inline and block attribute documentation.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { AttributeDoc } from "@alloy-js/python";
9
+
10
+
11
+ <AttributeDoc name={Children} style={"google"} type={Children}>
12
+ {children}
13
+ </AttributeDoc>
14
+ ```
15
+
16
+ * stc
17
+
18
+ ```ts
19
+ import { AttributeDoc } from "@alloy-js/python/stc";
20
+
21
+
22
+ AttributeDoc({
23
+ name: Children,
24
+ style: "google",
25
+ type: Children,
26
+ }).children(children)
27
+ ```
28
+
29
+ ## Props
30
+
31
+ | | | |
32
+ | -------- | -------------------------------------------------- | - |
33
+ | children | optional [Children](../../../core/types/children/) | |
34
+ | name | [Children](../../../core/types/children/) | |
35
+ | style | optional “google” | |
36
+ | type | optional [Children](../../../core/types/children/) | |
@@ -0,0 +1,62 @@
1
+ # CallSignature
2
+
3
+ A Python call signature, e.g. the part after the `def` keyword and the name in a function expression.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { CallSignature } from "@alloy-js/python";
9
+
10
+
11
+ <CallSignature
12
+ args
13
+ kwargs
14
+ parameters={(ParameterDescriptor | ParameterMarker | string)[]}
15
+ returnType={Children}
16
+ typeParameters={string[]}
17
+ />
18
+ ```
19
+
20
+ * stc
21
+
22
+ ```ts
23
+ import { CallSignature } from "@alloy-js/python/stc";
24
+
25
+
26
+ CallSignature({
27
+ args: boolean,
28
+ kwargs: boolean,
29
+ parameters: (ParameterDescriptor | ParameterMarker | string)[],
30
+ returnType: Children,
31
+ typeParameters: string[],
32
+ }).children(children)
33
+ ```
34
+
35
+ ## Props
36
+
37
+ | | | |
38
+ | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
39
+ | args | optional boolean | Indicates if there are positional arguments (`*args`) in the function |
40
+ | kwargs | optional boolean | Indicates if there are keyword arguments (`**kwargs`) in the function |
41
+ | parameters | optional ([ParameterDescriptor](../../types/parameterdescriptor/) \| [ParameterMarker](../../types/parametermarker/) \| string)\[] | The parameters to the call signature. Can be an array of strings (for simple parameter names), [ParameterDescriptor](../../types/parameterdescriptor/)s, or special markers (”\*” for keyword-only, ”/” for positional-only). |
42
+ | returnType | optional [Children](../../../core/types/children/) | The return type of the function. |
43
+ | typeParameters | optional string\[] | The type parameters of the call signature, e.g. for a generic function. This is only supported in Python 3.12+. |
44
+
45
+ ## Remarks
46
+
47
+ Any parameters or type parameters declared in this signature will be placed in the current scope. This component does not make a scope to hold its parameters.
48
+
49
+ ## Example
50
+
51
+ ```tsx
52
+ <CallSignature
53
+ parameters={[{ name: "a", type: "int" }, { name: "b", type: "str" }]}
54
+ returnType="int"
55
+ />
56
+ ```
57
+
58
+ renders to
59
+
60
+ ```py
61
+ (a: int, b: str) -> int
62
+ ```
@@ -0,0 +1,49 @@
1
+ # CallSignatureParameters
2
+
3
+ A call signature parameters declaration, which can be used to define the parameters of a function or other callables.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { CallSignatureParameters } from "@alloy-js/python";
9
+
10
+
11
+ <CallSignatureParameters
12
+ args
13
+ kwargs
14
+ parameters={(ParameterDescriptor | ParameterMarker | string)[]}
15
+ />
16
+ ```
17
+
18
+ * stc
19
+
20
+ ```ts
21
+ import { CallSignatureParameters } from "@alloy-js/python/stc";
22
+
23
+
24
+ CallSignatureParameters({
25
+ args: boolean,
26
+ kwargs: boolean,
27
+ parameters: (ParameterDescriptor | ParameterMarker | string)[],
28
+ }).children(children)
29
+ ```
30
+
31
+ ## Props
32
+
33
+ | | | |
34
+ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- | - |
35
+ | args | optional boolean | |
36
+ | kwargs | optional boolean | |
37
+ | parameters | optional ([ParameterDescriptor](../../types/parameterdescriptor/) \| [ParameterMarker](../../types/parametermarker/) \| string)\[] | |
38
+
39
+ ## Example
40
+
41
+ ```tsx
42
+ <py.CallSignatureParameters parameters={[ "a", "b" ]} />
43
+ ```
44
+
45
+ This will generate:
46
+
47
+ ```python
48
+ a, b
49
+ ```
@@ -0,0 +1,67 @@
1
+ # ClassDeclaration
2
+
3
+ Create a Python class declaration.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { ClassDeclaration } from "@alloy-js/python";
9
+
10
+
11
+ <ClassDeclaration
12
+ bases={Children[]}
13
+ doc={Children}
14
+ name={string | Namekey}
15
+ refkey={Refkey | Refkey[]}
16
+ />
17
+ ```
18
+
19
+ * stc
20
+
21
+ ```ts
22
+ import { ClassDeclaration } from "@alloy-js/python/stc";
23
+
24
+
25
+ ClassDeclaration({
26
+ bases: Children[],
27
+ doc: Children,
28
+ name: string | Namekey,
29
+ refkey: Refkey | Refkey[],
30
+ }).children(children)
31
+ ```
32
+
33
+ ## Props
34
+
35
+ | | | |
36
+ | -------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
37
+ | bases | optional [Children](../../../core/types/children/)\[] | The base classes that this class inherits from. |
38
+ | children | optional [Children](../../../core/types/children/) | |
39
+ | doc | optional [Children](../../../core/types/children/) | Documentation for this declaration |
40
+ | name | string \| [Namekey](../../../core/types/namekey/) | The base name of this declaration. May change depending on naming policy and any conflicts. |
41
+ | refkey | optional [Refkey](../../../core/types/refkey/) \| [Refkey](../../../core/types/refkey/)\[] | The refkey or array of refkeys for this declaration. |
42
+
43
+ ## Remarks
44
+
45
+ Any child declarations (methods, fields, nested classes) will be placed in the class scope. This component creates a class scope to hold its members.
46
+
47
+ ## Example
48
+
49
+ ```tsx
50
+ <ClassDeclaration name="MyClass" bases={["BaseClass"]}>
51
+ <VariableDeclaration name="a" type="int" />
52
+ <VariableDeclaration name="b" type="str" />
53
+ <py.FunctionDeclaration name="my_method" parameters={[{ name: "a", type: "int" }, { name: "b", type: "str" }]} returnType="int">
54
+ return a + b
55
+ </py.FunctionDeclaration>
56
+ </ClassDeclaration>
57
+ ```
58
+
59
+ renders to
60
+
61
+ ```py
62
+ class MyClass(BaseClass):
63
+ a: int = None
64
+ b: str = None
65
+ def my_method(self, a: int, b: str) -> int:
66
+ return a + b
67
+ ```
@@ -0,0 +1,55 @@
1
+ # ClassDoc
2
+
3
+ A component that creates a ClassDoc block for classes.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { ClassDoc } from "@alloy-js/python";
9
+
10
+
11
+ <ClassDoc
12
+ attributes={GoogleStyleDocAttributeProps[]}
13
+ deprecated="string"
14
+ description={Children[]}
15
+ examples={Children[]}
16
+ note="string"
17
+ parameters={ParameterDescriptor[]}
18
+ seeAlso={string[]}
19
+ style={"google"}
20
+ warning="string"
21
+ />
22
+ ```
23
+
24
+ * stc
25
+
26
+ ```ts
27
+ import { ClassDoc } from "@alloy-js/python/stc";
28
+
29
+
30
+ ClassDoc({
31
+ attributes: GoogleStyleDocAttributeProps[],
32
+ deprecated: string,
33
+ description: Children[],
34
+ examples: Children[],
35
+ note: string,
36
+ parameters: ParameterDescriptor[],
37
+ seeAlso: string[],
38
+ style: "google",
39
+ warning: string,
40
+ }).children(children)
41
+ ```
42
+
43
+ ## Props
44
+
45
+ | | | |
46
+ | ----------- | ------------------------------------------------------------------------------------- | - |
47
+ | attributes | optional [GoogleStyleDocAttributeProps](../../types/googlestyledocattributeprops/)\[] | |
48
+ | deprecated | optional string | |
49
+ | description | [Children](../../../core/types/children/)\[] | |
50
+ | examples | optional [Children](../../../core/types/children/)\[] | |
51
+ | note | optional string | |
52
+ | parameters | optional [ParameterDescriptor](../../types/parameterdescriptor/)\[] | |
53
+ | seeAlso | optional string\[] | |
54
+ | style | optional “google” | |
55
+ | warning | optional string | |
@@ -0,0 +1,111 @@
1
+ # ClassEnumDeclaration
2
+
3
+ Create a Python enum using the class-based syntax.
4
+
5
+ This generates enums using the `class Name(Enum):` syntax with member definitions inside the class body. Supports various member value styles including auto-generated values, explicit values, and custom base types.
6
+
7
+ * jsx
8
+
9
+ ```tsx
10
+ import { ClassEnumDeclaration } from "@alloy-js/python";
11
+
12
+
13
+ <ClassEnumDeclaration
14
+ auto
15
+ baseType={"Enum" | "IntEnum" | "StrEnum" | "Flag" | "IntFlag"}
16
+ doc={Children}
17
+ members={Array<EnumMemberProps>}
18
+ />
19
+ ```
20
+
21
+ * stc
22
+
23
+ ```ts
24
+ import { ClassEnumDeclaration } from "@alloy-js/python/stc";
25
+
26
+
27
+ ClassEnumDeclaration({
28
+ auto: boolean,
29
+ baseType: "Enum" | "IntEnum" | "StrEnum" | "Flag" | "IntFlag",
30
+ doc: Children,
31
+ members: Array<EnumMemberProps>,
32
+ }).children(children)
33
+ ```
34
+
35
+ ## Props
36
+
37
+ | | | |
38
+ | -------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
39
+ | auto | optional boolean | Indicates that the enum members should be auto-generated. |
40
+ | baseType | optional “Enum” \| “IntEnum” \| “StrEnum” \| “Flag” \| “IntFlag” | The base type of the enum. One of: ‘Enum’, ‘IntEnum’, ‘StrEnum’, ‘Flag’, ‘IntFlag’. Defaults to ‘Enum’. |
41
+ | doc | optional [Children](../../../core/types/children/) | Optional docstring for the enum. |
42
+ | members | optional Array<[EnumMemberProps](../enummember/)> | Members of the enum as an array of objects. |
43
+
44
+ ## Examples
45
+
46
+ ```tsx
47
+ <ClassEnumDeclaration
48
+ name="Direction"
49
+ members={[
50
+ { name: "NORTH" },
51
+ { name: "SOUTH" },
52
+ { name: "EAST" },
53
+ { name: "WEST" }
54
+ ]}
55
+ />
56
+ ```
57
+
58
+ renders to:
59
+
60
+ ```python
61
+ class Direction(Enum):
62
+ NORTH = "NORTH"
63
+ SOUTH = "SOUTH"
64
+ EAST = "EAST"
65
+ WEST = "WEST"
66
+ ```
67
+
68
+ With explicit values:
69
+
70
+ ```tsx
71
+ <ClassEnumDeclaration
72
+ name="Status"
73
+ members={[
74
+ { name: "PENDING", value: 1 },
75
+ { name: "ACTIVE", value: 2 },
76
+ { name: "INACTIVE", value: 3 }
77
+ ]}
78
+ />
79
+ ```
80
+
81
+ renders to:
82
+
83
+ ```python
84
+ class Status(Enum):
85
+ PENDING = 1
86
+ ACTIVE = 2
87
+ INACTIVE = 3
88
+ ```
89
+
90
+ With auto() values:
91
+
92
+ ```tsx
93
+ <ClassEnumDeclaration
94
+ name="Color"
95
+ style="auto"
96
+ members={[
97
+ { name: "RED" },
98
+ { name: "GREEN" },
99
+ { name: "BLUE" }
100
+ ]}
101
+ />
102
+ ```
103
+
104
+ renders to:
105
+
106
+ ```python
107
+ class Color(Enum):
108
+ RED = auto()
109
+ GREEN = auto()
110
+ BLUE = auto()
111
+ ```
@@ -0,0 +1,44 @@
1
+ # ClassInstantiation
2
+
3
+ Used to create new instances of classes in Python.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { ClassInstantiation } from "@alloy-js/python";
9
+
10
+
11
+ <ClassInstantiation args={Children[]} target={Children} />
12
+ ```
13
+
14
+ * stc
15
+
16
+ ```ts
17
+ import { ClassInstantiation } from "@alloy-js/python/stc";
18
+
19
+
20
+ ClassInstantiation({ args: Children[], target: Children }).children(children)
21
+ ```
22
+
23
+ ## Props
24
+
25
+ | | | |
26
+ | ------ | ----------------------------------------------------- | - |
27
+ | args | optional [Children](../../../core/types/children/)\[] | |
28
+ | target | [Children](../../../core/types/children/) | |
29
+
30
+ ## Remarks
31
+
32
+ It is similar to FunctionCallExpression but specifically for class instantiation. Args should be a list arguments that can be either simple js values or py.Atoms, which will render as positional arguments, or py.VariableDeclarations, which will render as named arguments in the call statement. This component will not check for the correctness of the python grammar and will just work with any children you provide. It is up to you to ensure that the arguments you provide are valid in the context of a class instantiation.
33
+
34
+ ## Example
35
+
36
+ ```tsx
37
+ <ClassInstantiation target="MyClass" args={["arg1", "arg2"]} />
38
+ ```
39
+
40
+ This will generate:
41
+
42
+ ```python
43
+ MyClass(arg1, arg2)
44
+ ```
@@ -0,0 +1,31 @@
1
+ # ClassMethodDeclaration
2
+
3
+ A Python class method declaration component.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { ClassMethodDeclaration } from "@alloy-js/python";
9
+
10
+
11
+ <ClassMethodDeclaration abstract async />
12
+ ```
13
+
14
+ * stc
15
+
16
+ ```ts
17
+ import { ClassMethodDeclaration } from "@alloy-js/python/stc";
18
+
19
+
20
+ ClassMethodDeclaration({
21
+ abstract: boolean,
22
+ async: boolean,
23
+ }).children(children)
24
+ ```
25
+
26
+ ## Props
27
+
28
+ | | | |
29
+ | -------- | ---------------- | ------------------------------------- |
30
+ | abstract | optional boolean | |
31
+ | async | optional boolean | Indicates that the function is async. |
@@ -0,0 +1,27 @@
1
+ # ConstructorDeclaration
2
+
3
+ A Python constructor declaration for `__new__`.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { ConstructorDeclaration } from "@alloy-js/python";
9
+
10
+
11
+ <ConstructorDeclaration abstract />
12
+ ```
13
+
14
+ * stc
15
+
16
+ ```ts
17
+ import { ConstructorDeclaration } from "@alloy-js/python/stc";
18
+
19
+
20
+ ConstructorDeclaration({ abstract: boolean }).children(children)
21
+ ```
22
+
23
+ ## Props
24
+
25
+ | | | |
26
+ | -------- | ---------------- | - |
27
+ | abstract | optional boolean | |
@@ -0,0 +1,55 @@
1
+ # DataclassDeclaration
2
+
3
+ Renders a Python dataclass.
4
+
5
+ Example:
6
+
7
+ ```tsx
8
+ <py.DataclassDeclaration name="User" kwOnly>
9
+ <py.VariableDeclaration instanceVariable omitNone name="id" type="int" />
10
+ <py.VariableDeclaration instanceVariable name={namekey("_", { ignoreNamePolicy: true })} type={dataclassesModule["."].KW_ONLY} omitNone />
11
+ <py.VariableDeclaration
12
+ instanceVariable
13
+ name="name"
14
+ type="str"
15
+ initializer={"Anonymous"}
16
+ />
17
+ </py.DataclassDeclaration>
18
+ ```
19
+
20
+ Will render as:
21
+
22
+ ```py
23
+ from dataclasses import dataclass
24
+ from dataclasses import KW_ONLY
25
+
26
+ @dataclass(kw_only=True)
27
+ class User:
28
+ id: int
29
+ _: KW_ONLY
30
+ name: str = "Anonymous"
31
+ ```
32
+
33
+ * jsx
34
+
35
+ ```tsx
36
+ import { DataclassDeclaration } from "@alloy-js/python";
37
+
38
+
39
+ <DataclassDeclaration bases={Children[]} />
40
+ ```
41
+
42
+ * stc
43
+
44
+ ```ts
45
+ import { DataclassDeclaration } from "@alloy-js/python/stc";
46
+
47
+
48
+ DataclassDeclaration({ bases: Children[] }).children(children)
49
+ ```
50
+
51
+ ## Props
52
+
53
+ | | | |
54
+ | ----- | ----------------------------------------------------- | ----------------------------------------------- |
55
+ | bases | optional [Children](../../../core/types/children/)\[] | The base classes that this class inherits from. |
@@ -0,0 +1,41 @@
1
+ # Declaration
2
+
3
+ A Python declaration, which can be a class, function, variable, etc.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { Declaration } from "@alloy-js/python";
9
+
10
+
11
+ <Declaration
12
+ name={string | Namekey}
13
+ nameKind={PythonElements}
14
+ symbol={PythonOutputSymbol}
15
+ />
16
+ ```
17
+
18
+ * stc
19
+
20
+ ```ts
21
+ import { Declaration } from "@alloy-js/python/stc";
22
+
23
+
24
+ Declaration({
25
+ name: string | Namekey,
26
+ nameKind: PythonElements,
27
+ symbol: PythonOutputSymbol,
28
+ }).children(children)
29
+ ```
30
+
31
+ ## Props
32
+
33
+ | | | |
34
+ | -------- | -------------------------------------------------------------- | ------------------------------------------------- |
35
+ | name | optional string \| [Namekey](../../../core/types/namekey/) | The name of this declaration. |
36
+ | nameKind | optional [PythonElements](../../types/pythonelements/) | The name policy kind to apply to the declaration. |
37
+ | symbol | optional [PythonOutputSymbol](../../types/pythonoutputsymbol/) | The symbol to use for this declaration. |
38
+
39
+ ## Remarks
40
+
41
+ This component is used to create a declaration with a symbol that can be referenced in the code.
@@ -0,0 +1,31 @@
1
+ # DunderMethodDeclaration
2
+
3
+ A Python dunder method declaration.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { DunderMethodDeclaration } from "@alloy-js/python";
9
+
10
+
11
+ <DunderMethodDeclaration abstract async />
12
+ ```
13
+
14
+ * stc
15
+
16
+ ```ts
17
+ import { DunderMethodDeclaration } from "@alloy-js/python/stc";
18
+
19
+
20
+ DunderMethodDeclaration({
21
+ abstract: boolean,
22
+ async: boolean,
23
+ }).children(children)
24
+ ```
25
+
26
+ ## Props
27
+
28
+ | | | |
29
+ | -------- | ---------------- | ------------------------------------- |
30
+ | abstract | optional boolean | |
31
+ | async | optional boolean | Indicates that the function is async. |
@@ -0,0 +1,61 @@
1
+ # EnumMember
2
+
3
+ A Python enum member.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { EnumMember } from "@alloy-js/python";
9
+
10
+
11
+ <EnumMember
12
+ auto
13
+ doc={Children}
14
+ functional
15
+ jsValue={string | number}
16
+ name={string | Namekey}
17
+ refkey={Refkey}
18
+ value={Children}
19
+ />
20
+ ```
21
+
22
+ * stc
23
+
24
+ ```ts
25
+ import { EnumMember } from "@alloy-js/python/stc";
26
+
27
+
28
+ EnumMember({
29
+ auto: boolean,
30
+ doc: Children,
31
+ functional: boolean,
32
+ jsValue: string | number,
33
+ name: string | Namekey,
34
+ refkey: Refkey,
35
+ value: Children,
36
+ }).children(children)
37
+ ```
38
+
39
+ ## Props
40
+
41
+ | | | |
42
+ | ---------- | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | auto | optional boolean | Will use auto() to generate the value if set to true. |
44
+ | doc | optional [Children](../../../core/types/children/) | Documentation for the enum member. |
45
+ | functional | optional boolean | Functional mappings/list |
46
+ | jsValue | optional string \| number | The JS value of the enum member. |
47
+ | name | string \| [Namekey](../../../core/types/namekey/) | The name of the enum member. |
48
+ | refkey | optional [Refkey](../../../core/types/refkey/) | Refkey for the enum member symbol. If the refkey is not provided, a symbol will be created and the member cannot be referenced by refkey. |
49
+ | value | optional [Children](../../../core/types/children/) | The value of the enum member. |
50
+
51
+ ## Example
52
+
53
+ ```tsx
54
+ <EnumMember name="NORTH" />
55
+ ```
56
+
57
+ This will generate:
58
+
59
+ ```python
60
+ NORTH
61
+ ```