@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
package/src/components/PyDoc.tsx
CHANGED
|
@@ -1,331 +1,931 @@
|
|
|
1
1
|
import { For, Indent, List, Prose, Show, childrenArray } from "@alloy-js/core";
|
|
2
2
|
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
3
|
import { ParameterDescriptor } from "../parameter-descriptor.js";
|
|
4
|
-
import { Atom } from "./
|
|
4
|
+
import { Atom } from "./Atom.jsx";
|
|
5
5
|
|
|
6
|
-
interface
|
|
6
|
+
export interface FunctionDocProps {
|
|
7
|
+
description: Children[];
|
|
8
|
+
parameters?: ParameterDescriptor[];
|
|
9
|
+
returns?: string;
|
|
10
|
+
yields?: string;
|
|
11
|
+
raises?: string[];
|
|
12
|
+
examples?: Children[];
|
|
13
|
+
seeAlso?: string[];
|
|
14
|
+
warning?: string;
|
|
15
|
+
deprecated?: string;
|
|
16
|
+
note?: string;
|
|
17
|
+
style?: "google";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A component that creates a FunctionDoc block for functions.
|
|
22
|
+
*/
|
|
23
|
+
export function FunctionDoc(props: FunctionDocProps) {
|
|
24
|
+
const {
|
|
25
|
+
style = "google",
|
|
26
|
+
...rest
|
|
27
|
+
}: { style?: "google" } & GoogleStyleFunctionDocProps = props;
|
|
28
|
+
switch (style) {
|
|
29
|
+
case "google":
|
|
30
|
+
return <GoogleStyleFunctionDoc {...rest} />;
|
|
31
|
+
default:
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ClassDocProps {
|
|
37
|
+
description: Children[];
|
|
38
|
+
parameters?: ParameterDescriptor[];
|
|
39
|
+
attributes?: GoogleStyleDocAttributeProps[];
|
|
40
|
+
examples?: Children[];
|
|
41
|
+
seeAlso?: string[];
|
|
42
|
+
warning?: string;
|
|
43
|
+
deprecated?: string;
|
|
44
|
+
note?: string;
|
|
45
|
+
style?: "google";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A component that creates a ClassDoc block for classes.
|
|
50
|
+
*/
|
|
51
|
+
export function ClassDoc(props: ClassDocProps) {
|
|
52
|
+
const {
|
|
53
|
+
style = "google",
|
|
54
|
+
...rest
|
|
55
|
+
}: { style?: "google" } & GoogleStyleClassDocProps = props;
|
|
56
|
+
switch (style) {
|
|
57
|
+
case "google":
|
|
58
|
+
return <GoogleStyleClassDoc {...rest} />;
|
|
59
|
+
default:
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ModuleDocProps {
|
|
65
|
+
description: Children[];
|
|
66
|
+
attributes?: GoogleStyleDocAttributeProps[];
|
|
67
|
+
examples?: Children[];
|
|
68
|
+
seeAlso?: string[];
|
|
69
|
+
warning?: string;
|
|
70
|
+
deprecated?: string;
|
|
71
|
+
todo?: string[];
|
|
72
|
+
style?: "google";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A component that creates a ModuleDoc block for module-level documentation.
|
|
77
|
+
*/
|
|
78
|
+
export function ModuleDoc(props: ModuleDocProps) {
|
|
79
|
+
const {
|
|
80
|
+
style = "google",
|
|
81
|
+
...rest
|
|
82
|
+
}: { style?: "google" } & GoogleStyleModuleDocProps = props;
|
|
83
|
+
switch (style) {
|
|
84
|
+
case "google":
|
|
85
|
+
return <GoogleStyleModuleDoc {...rest} />;
|
|
86
|
+
default:
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface PropertyDocProps {
|
|
92
|
+
description: Children[];
|
|
93
|
+
returns?: string;
|
|
94
|
+
examples?: Children[];
|
|
95
|
+
seeAlso?: string[];
|
|
96
|
+
warning?: string;
|
|
97
|
+
deprecated?: string;
|
|
98
|
+
note?: string;
|
|
99
|
+
style?: "google";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A component that creates a PropertyDoc block for `@property` decorated methods.
|
|
104
|
+
*/
|
|
105
|
+
export function PropertyDoc(props: PropertyDocProps) {
|
|
106
|
+
const {
|
|
107
|
+
style = "google",
|
|
108
|
+
...rest
|
|
109
|
+
}: { style?: "google" } & GoogleStylePropertyDocProps = props;
|
|
110
|
+
switch (style) {
|
|
111
|
+
case "google":
|
|
112
|
+
return <GoogleStylePropertyDoc {...rest} />;
|
|
113
|
+
default:
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface GeneratorDocProps {
|
|
119
|
+
description: Children[];
|
|
120
|
+
parameters?: ParameterDescriptor[];
|
|
121
|
+
yields?: string;
|
|
122
|
+
raises?: string[];
|
|
123
|
+
examples?: Children[];
|
|
124
|
+
seeAlso?: string[];
|
|
125
|
+
warning?: string;
|
|
126
|
+
deprecated?: string;
|
|
127
|
+
note?: string;
|
|
128
|
+
style?: "google";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A component that creates a GeneratorDoc block for generator functions.
|
|
133
|
+
*/
|
|
134
|
+
export function GeneratorDoc(props: GeneratorDocProps) {
|
|
135
|
+
const {
|
|
136
|
+
style = "google",
|
|
137
|
+
...rest
|
|
138
|
+
}: { style?: "google" } & GoogleStyleGeneratorDocProps = props;
|
|
139
|
+
switch (style) {
|
|
140
|
+
case "google":
|
|
141
|
+
return <GoogleStyleGeneratorDoc {...rest} />;
|
|
142
|
+
default:
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface ExceptionDocProps {
|
|
148
|
+
description: Children[];
|
|
149
|
+
parameters?: ParameterDescriptor[];
|
|
150
|
+
attributes?: GoogleStyleDocAttributeProps[];
|
|
151
|
+
examples?: Children[];
|
|
152
|
+
seeAlso?: string[];
|
|
153
|
+
warning?: string;
|
|
154
|
+
deprecated?: string;
|
|
155
|
+
note?: string;
|
|
156
|
+
style?: "google";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A component that creates an ExceptionDoc block for custom exception classes.
|
|
161
|
+
*/
|
|
162
|
+
export function ExceptionDoc(props: ExceptionDocProps) {
|
|
163
|
+
const {
|
|
164
|
+
style = "google",
|
|
165
|
+
...rest
|
|
166
|
+
}: { style?: "google" } & GoogleStyleExceptionDocProps = props;
|
|
167
|
+
switch (style) {
|
|
168
|
+
case "google":
|
|
169
|
+
return <GoogleStyleExceptionDoc {...rest} />;
|
|
170
|
+
default:
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface AttributeDocProps {
|
|
176
|
+
name: Children;
|
|
7
177
|
type?: Children;
|
|
8
|
-
|
|
178
|
+
children?: Children;
|
|
179
|
+
style?: "google";
|
|
9
180
|
}
|
|
10
181
|
|
|
11
|
-
|
|
182
|
+
/**
|
|
183
|
+
* A component that creates documentation for a single attribute.
|
|
184
|
+
* This can be used for both inline and block attribute documentation.
|
|
185
|
+
*/
|
|
186
|
+
export function AttributeDoc(props: AttributeDocProps) {
|
|
187
|
+
const {
|
|
188
|
+
style = "google",
|
|
189
|
+
...rest
|
|
190
|
+
}: { style?: "google" } & GoogleStyleAttributeDocProps = props;
|
|
191
|
+
switch (style) {
|
|
192
|
+
case "google":
|
|
193
|
+
return <GoogleStyleAttributeDoc {...rest} />;
|
|
194
|
+
default:
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface MethodDocProps {
|
|
200
|
+
description: Children[];
|
|
201
|
+
parameters?: ParameterDescriptor[];
|
|
202
|
+
returns?: string;
|
|
203
|
+
raises?: string[];
|
|
204
|
+
examples?: Children[];
|
|
205
|
+
seeAlso?: string[];
|
|
206
|
+
warning?: string;
|
|
207
|
+
deprecated?: string;
|
|
208
|
+
note?: string;
|
|
209
|
+
overrides?: string;
|
|
210
|
+
style?: "google";
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A component that creates a MethodDoc block for class methods.
|
|
215
|
+
* Automatically adds a note about not including 'self' parameter if no custom note is provided.
|
|
216
|
+
*/
|
|
217
|
+
export function MethodDoc(props: MethodDocProps) {
|
|
218
|
+
const {
|
|
219
|
+
style = "google",
|
|
220
|
+
...rest
|
|
221
|
+
}: { style?: "google" } & GoogleStyleMethodDocProps = props;
|
|
222
|
+
switch (style) {
|
|
223
|
+
case "google": {
|
|
224
|
+
return <GoogleStyleMethodDoc {...rest} />;
|
|
225
|
+
}
|
|
226
|
+
default:
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface PyDocProps {
|
|
232
|
+
children: Children;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* A PyDoc comment. The children of this component are joined with two hard
|
|
237
|
+
* linebreaks. This is useful for creating PyDoc comments with multiple paragraphs.
|
|
238
|
+
*/
|
|
239
|
+
export function PyDoc(props: PyDocProps) {
|
|
240
|
+
const children = childrenArray(() => props.children);
|
|
12
241
|
return (
|
|
13
242
|
<>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
243
|
+
{'"""'}
|
|
244
|
+
<hbr />
|
|
245
|
+
<List doubleHardline>{children}</List>
|
|
246
|
+
<hbr />
|
|
247
|
+
{'"""'}
|
|
248
|
+
<hbr />
|
|
249
|
+
</>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface PyDocExampleProps {
|
|
254
|
+
children: Children;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Create a PyDoc example, which is prepended by \>\>.
|
|
259
|
+
*/
|
|
260
|
+
export function PyDocExample(props: PyDocExampleProps) {
|
|
261
|
+
const children = childrenArray(() => props.children);
|
|
262
|
+
let lines: string[] = [];
|
|
263
|
+
|
|
264
|
+
if (children.length === 1 && typeof children[0] === "string") {
|
|
265
|
+
// Split, trim each line, and filter out empty lines
|
|
266
|
+
lines = children[0]
|
|
267
|
+
.split(/\r?\n/)
|
|
268
|
+
.map((line) => line.trim())
|
|
269
|
+
.filter((line) => line.length > 0);
|
|
270
|
+
} else {
|
|
271
|
+
// For non-string children, filter out empty/whitespace-only strings
|
|
272
|
+
lines = children
|
|
273
|
+
.map((child) => (typeof child === "string" ? child : ""))
|
|
274
|
+
.map((line) => line.trim())
|
|
275
|
+
.filter((line) => line.length > 0);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<>
|
|
280
|
+
<For each={lines}>
|
|
281
|
+
{(line) => (
|
|
282
|
+
<>
|
|
283
|
+
{">> "}
|
|
284
|
+
{line}
|
|
285
|
+
</>
|
|
286
|
+
)}
|
|
287
|
+
</For>
|
|
288
|
+
</>
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface SimpleCommentBlockProps {
|
|
293
|
+
children: Children;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function SimpleCommentBlock(props: SimpleCommentBlockProps) {
|
|
297
|
+
return (
|
|
298
|
+
<>
|
|
299
|
+
#{" "}
|
|
300
|
+
<align string="# ">
|
|
301
|
+
<Prose>{props.children}</Prose>
|
|
302
|
+
</align>
|
|
303
|
+
</>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface SimpleInlineCommentProps {
|
|
308
|
+
children: Children;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function SimpleInlineComment(props: SimpleInlineCommentProps) {
|
|
312
|
+
return (
|
|
313
|
+
<>
|
|
314
|
+
{" "}# <Prose>{props.children}</Prose>
|
|
20
315
|
</>
|
|
21
316
|
);
|
|
22
317
|
}
|
|
23
318
|
|
|
24
|
-
interface
|
|
25
|
-
|
|
319
|
+
export interface SimpleInlineCommentProps {
|
|
320
|
+
children: Children;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function SimpleInlineMemberComment(props: SimpleInlineCommentProps) {
|
|
324
|
+
return (
|
|
325
|
+
<>
|
|
326
|
+
{" "}#: <Prose>{props.children}</Prose>
|
|
327
|
+
</>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
interface GoogleStyleFunctionDocProps extends Omit<FunctionDocProps, "style"> {}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* A component that creates a GoogleStyleFunctionDoc block for functions.
|
|
335
|
+
*/
|
|
336
|
+
function GoogleStyleFunctionDoc(props: GoogleStyleFunctionDocProps) {
|
|
337
|
+
// We are creating a list instead of relying on <Show> because otherwise
|
|
338
|
+
// <List> would render spaces between the elements even if <Show> evaluates to false.
|
|
339
|
+
const children = [];
|
|
340
|
+
if (props.description !== undefined) {
|
|
341
|
+
children.push(<List doubleHardline>{props.description}</List>);
|
|
342
|
+
}
|
|
343
|
+
if (props.parameters?.length) {
|
|
344
|
+
children.push(<GoogleStyleDocParams parameters={props.parameters} />);
|
|
345
|
+
}
|
|
346
|
+
if (props.returns) {
|
|
347
|
+
children.push(<GoogleStyleDocReturn message={props.returns} />);
|
|
348
|
+
}
|
|
349
|
+
if (props.yields) {
|
|
350
|
+
children.push(<GoogleStyleDocYields message={props.yields} />);
|
|
351
|
+
}
|
|
352
|
+
if (props.raises?.length) {
|
|
353
|
+
children.push(
|
|
354
|
+
props.raises!.map((param) => <GoogleStyleDocRaises message={param} />),
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
if (props.examples?.length) {
|
|
358
|
+
children.push(<GoogleStyleDocExamples items={props.examples} />);
|
|
359
|
+
}
|
|
360
|
+
if (props.seeAlso?.length) {
|
|
361
|
+
children.push(<GoogleStyleDocSeeAlso items={props.seeAlso} />);
|
|
362
|
+
}
|
|
363
|
+
if (props.warning) {
|
|
364
|
+
children.push(<GoogleStyleDocWarning message={props.warning} />);
|
|
365
|
+
}
|
|
366
|
+
if (props.deprecated) {
|
|
367
|
+
children.push(<GoogleStyleDocDeprecated message={props.deprecated} />);
|
|
368
|
+
}
|
|
369
|
+
if (props.note) {
|
|
370
|
+
children.push(<GoogleStyleDocNote message={props.note} />);
|
|
371
|
+
}
|
|
372
|
+
return <PyDoc>{children}</PyDoc>;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
interface GoogleStyleClassDocProps extends Omit<ClassDocProps, "style"> {}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* A component that creates a GoogleStyleClassDoc block for classes.
|
|
379
|
+
*/
|
|
380
|
+
function GoogleStyleClassDoc(props: GoogleStyleClassDocProps) {
|
|
381
|
+
// We are creating a list instead of relying on <Show> because otherwise
|
|
382
|
+
// <List> would render spaces between the elements even if <Show> evaluates to false.
|
|
383
|
+
const children = [];
|
|
384
|
+
if (props.description !== undefined) {
|
|
385
|
+
children.push(<List doubleHardline>{props.description}</List>);
|
|
386
|
+
}
|
|
387
|
+
if (props.attributes?.length) {
|
|
388
|
+
children.push(<GoogleStyleDocAttributes attributes={props.attributes} />);
|
|
389
|
+
}
|
|
390
|
+
if (props.parameters?.length) {
|
|
391
|
+
children.push(<GoogleStyleDocParams parameters={props.parameters} />);
|
|
392
|
+
}
|
|
393
|
+
if (props.examples?.length) {
|
|
394
|
+
children.push(<GoogleStyleDocExamples items={props.examples} />);
|
|
395
|
+
}
|
|
396
|
+
if (props.seeAlso?.length) {
|
|
397
|
+
children.push(<GoogleStyleDocSeeAlso items={props.seeAlso} />);
|
|
398
|
+
}
|
|
399
|
+
if (props.warning) {
|
|
400
|
+
children.push(<GoogleStyleDocWarning message={props.warning} />);
|
|
401
|
+
}
|
|
402
|
+
if (props.deprecated) {
|
|
403
|
+
children.push(<GoogleStyleDocDeprecated message={props.deprecated} />);
|
|
404
|
+
}
|
|
405
|
+
if (props.note) {
|
|
406
|
+
children.push(<GoogleStyleDocNote message={props.note} />);
|
|
407
|
+
}
|
|
408
|
+
return <PyDoc>{children}</PyDoc>;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
interface GoogleStyleModuleDocProps extends Omit<ModuleDocProps, "style"> {}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* A component that creates a GoogleStyleModuleDoc block for modules.
|
|
415
|
+
*/
|
|
416
|
+
function GoogleStyleModuleDoc(props: GoogleStyleModuleDocProps) {
|
|
417
|
+
const children = [];
|
|
418
|
+
if (props.description !== undefined) {
|
|
419
|
+
children.push(<List doubleHardline>{props.description}</List>);
|
|
420
|
+
}
|
|
421
|
+
if (props.attributes?.length) {
|
|
422
|
+
children.push(<GoogleStyleDocAttributes attributes={props.attributes} />);
|
|
423
|
+
}
|
|
424
|
+
if (props.examples?.length) {
|
|
425
|
+
children.push(<GoogleStyleDocExamples items={props.examples} />);
|
|
426
|
+
}
|
|
427
|
+
if (props.seeAlso?.length) {
|
|
428
|
+
children.push(<GoogleStyleDocSeeAlso items={props.seeAlso} />);
|
|
429
|
+
}
|
|
430
|
+
if (props.warning) {
|
|
431
|
+
children.push(<GoogleStyleDocWarning message={props.warning} />);
|
|
432
|
+
}
|
|
433
|
+
if (props.deprecated) {
|
|
434
|
+
children.push(<GoogleStyleDocDeprecated message={props.deprecated} />);
|
|
435
|
+
}
|
|
436
|
+
if (props.todo?.length) {
|
|
437
|
+
children.push(<GoogleStyleDocTodo items={props.todo} />);
|
|
438
|
+
}
|
|
439
|
+
return <PyDoc>{children}</PyDoc>;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
interface GoogleStylePropertyDocProps extends Omit<PropertyDocProps, "style"> {}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* A component that creates a GoogleStylePropertyDoc block for properties.
|
|
446
|
+
*/
|
|
447
|
+
function GoogleStylePropertyDoc(props: GoogleStylePropertyDocProps) {
|
|
448
|
+
const children = [];
|
|
449
|
+
if (props.description !== undefined) {
|
|
450
|
+
children.push(<List doubleHardline>{props.description}</List>);
|
|
451
|
+
}
|
|
452
|
+
if (props.returns) {
|
|
453
|
+
children.push(<GoogleStyleDocReturn message={props.returns} />);
|
|
454
|
+
}
|
|
455
|
+
if (props.examples?.length) {
|
|
456
|
+
children.push(<GoogleStyleDocExamples items={props.examples} />);
|
|
457
|
+
}
|
|
458
|
+
if (props.seeAlso?.length) {
|
|
459
|
+
children.push(<GoogleStyleDocSeeAlso items={props.seeAlso} />);
|
|
460
|
+
}
|
|
461
|
+
if (props.warning) {
|
|
462
|
+
children.push(<GoogleStyleDocWarning message={props.warning} />);
|
|
463
|
+
}
|
|
464
|
+
if (props.deprecated) {
|
|
465
|
+
children.push(<GoogleStyleDocDeprecated message={props.deprecated} />);
|
|
466
|
+
}
|
|
467
|
+
if (props.note) {
|
|
468
|
+
children.push(<GoogleStyleDocNote message={props.note} />);
|
|
469
|
+
}
|
|
470
|
+
return <PyDoc>{children}</PyDoc>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
interface GoogleStyleGeneratorDocProps
|
|
474
|
+
extends Omit<GeneratorDocProps, "style"> {}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* A component that creates a GoogleStyleGeneratorDoc block for generators.
|
|
478
|
+
*/
|
|
479
|
+
function GoogleStyleGeneratorDoc(props: GoogleStyleGeneratorDocProps) {
|
|
480
|
+
const children = [];
|
|
481
|
+
if (props.description !== undefined) {
|
|
482
|
+
children.push(<List doubleHardline>{props.description}</List>);
|
|
483
|
+
}
|
|
484
|
+
if (props.parameters?.length) {
|
|
485
|
+
children.push(<GoogleStyleDocParams parameters={props.parameters} />);
|
|
486
|
+
}
|
|
487
|
+
if (props.yields) {
|
|
488
|
+
children.push(<GoogleStyleDocYields message={props.yields} />);
|
|
489
|
+
}
|
|
490
|
+
if (props.raises?.length) {
|
|
491
|
+
children.push(
|
|
492
|
+
props.raises!.map((param) => <GoogleStyleDocRaises message={param} />),
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
if (props.examples?.length) {
|
|
496
|
+
children.push(<GoogleStyleDocExamples items={props.examples} />);
|
|
497
|
+
}
|
|
498
|
+
if (props.seeAlso?.length) {
|
|
499
|
+
children.push(<GoogleStyleDocSeeAlso items={props.seeAlso} />);
|
|
500
|
+
}
|
|
501
|
+
if (props.warning) {
|
|
502
|
+
children.push(<GoogleStyleDocWarning message={props.warning} />);
|
|
503
|
+
}
|
|
504
|
+
if (props.deprecated) {
|
|
505
|
+
children.push(<GoogleStyleDocDeprecated message={props.deprecated} />);
|
|
506
|
+
}
|
|
507
|
+
if (props.note) {
|
|
508
|
+
children.push(<GoogleStyleDocNote message={props.note} />);
|
|
509
|
+
}
|
|
510
|
+
return <PyDoc>{children}</PyDoc>;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
interface GoogleStyleExceptionDocProps
|
|
514
|
+
extends Omit<ExceptionDocProps, "style"> {}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* A component that creates a GoogleStyleExceptionDoc block for exceptions.
|
|
518
|
+
*/
|
|
519
|
+
function GoogleStyleExceptionDoc(props: GoogleStyleExceptionDocProps) {
|
|
520
|
+
const children = [];
|
|
521
|
+
if (props.description !== undefined) {
|
|
522
|
+
children.push(<List doubleHardline>{props.description}</List>);
|
|
523
|
+
}
|
|
524
|
+
if (props.parameters?.length) {
|
|
525
|
+
children.push(<GoogleStyleDocParams parameters={props.parameters} />);
|
|
526
|
+
}
|
|
527
|
+
if (props.attributes?.length) {
|
|
528
|
+
children.push(<GoogleStyleDocAttributes attributes={props.attributes} />);
|
|
529
|
+
}
|
|
530
|
+
if (props.examples?.length) {
|
|
531
|
+
children.push(<GoogleStyleDocExamples items={props.examples} />);
|
|
532
|
+
}
|
|
533
|
+
if (props.seeAlso?.length) {
|
|
534
|
+
children.push(<GoogleStyleDocSeeAlso items={props.seeAlso} />);
|
|
535
|
+
}
|
|
536
|
+
if (props.warning) {
|
|
537
|
+
children.push(<GoogleStyleDocWarning message={props.warning} />);
|
|
538
|
+
}
|
|
539
|
+
if (props.deprecated) {
|
|
540
|
+
children.push(<GoogleStyleDocDeprecated message={props.deprecated} />);
|
|
541
|
+
}
|
|
542
|
+
if (props.note) {
|
|
543
|
+
children.push(<GoogleStyleDocNote message={props.note} />);
|
|
544
|
+
}
|
|
545
|
+
return <PyDoc>{children}</PyDoc>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
interface GoogleStyleAttributeDocProps
|
|
549
|
+
extends Omit<AttributeDocProps, "style"> {}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* A component that creates a GoogleStyleAttributeDoc block for attributes.
|
|
553
|
+
*/
|
|
554
|
+
function GoogleStyleAttributeDoc(props: GoogleStyleAttributeDocProps) {
|
|
555
|
+
return (
|
|
556
|
+
<GoogleStyleDocAttribute name={props.name} type={props.type}>
|
|
557
|
+
{props.children}
|
|
558
|
+
</GoogleStyleDocAttribute>
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
interface GoogleStyleMethodDocProps extends Omit<MethodDocProps, "style"> {}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* A component that creates a GoogleStyleMethodDoc block for methods.
|
|
566
|
+
*/
|
|
567
|
+
function GoogleStyleMethodDoc(props: GoogleStyleMethodDocProps) {
|
|
568
|
+
const children = [];
|
|
569
|
+
if (props.description !== undefined) {
|
|
570
|
+
children.push(<List doubleHardline>{props.description}</List>);
|
|
571
|
+
}
|
|
572
|
+
if (props.parameters?.length) {
|
|
573
|
+
children.push(<GoogleStyleDocParams parameters={props.parameters} />);
|
|
574
|
+
}
|
|
575
|
+
if (props.returns) {
|
|
576
|
+
children.push(<GoogleStyleDocReturn message={props.returns} />);
|
|
577
|
+
}
|
|
578
|
+
if (props.raises?.length) {
|
|
579
|
+
children.push(
|
|
580
|
+
props.raises!.map((param) => <GoogleStyleDocRaises message={param} />),
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
if (props.examples?.length) {
|
|
584
|
+
children.push(<GoogleStyleDocExamples items={props.examples} />);
|
|
585
|
+
}
|
|
586
|
+
if (props.seeAlso?.length) {
|
|
587
|
+
children.push(<GoogleStyleDocSeeAlso items={props.seeAlso} />);
|
|
588
|
+
}
|
|
589
|
+
if (props.warning) {
|
|
590
|
+
children.push(<GoogleStyleDocWarning message={props.warning} />);
|
|
591
|
+
}
|
|
592
|
+
if (props.deprecated) {
|
|
593
|
+
children.push(<GoogleStyleDocDeprecated message={props.deprecated} />);
|
|
594
|
+
}
|
|
595
|
+
if (props.overrides) {
|
|
596
|
+
children.push(<GoogleStyleDocOverrides parentClass={props.overrides} />);
|
|
597
|
+
}
|
|
598
|
+
if (props.note) {
|
|
599
|
+
children.push(<GoogleStyleDocNote message={props.note} />);
|
|
600
|
+
}
|
|
601
|
+
return <PyDoc>{children}</PyDoc>;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
interface GoogleStyleDocParamsProps {
|
|
605
|
+
parameters: ParameterDescriptor[];
|
|
26
606
|
}
|
|
27
607
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
608
|
+
/**
|
|
609
|
+
* A component that creates a GoogleStyleDoc block for parameters.
|
|
610
|
+
*/
|
|
611
|
+
function GoogleStyleDocParams(props: GoogleStyleDocParamsProps) {
|
|
612
|
+
const parameters = props.parameters;
|
|
31
613
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
614
|
+
// Don't render anything if there are no parameters
|
|
615
|
+
if (!parameters || parameters.length === 0) {
|
|
616
|
+
return null;
|
|
617
|
+
}
|
|
36
618
|
|
|
37
|
-
function GoogleStyleDocParamDescription(
|
|
38
|
-
props: GoogleStyleDocParamDescriptionProps,
|
|
39
|
-
) {
|
|
40
619
|
return (
|
|
41
|
-
|
|
42
|
-
{":
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
620
|
+
<>
|
|
621
|
+
{"Args:"}
|
|
622
|
+
<Indent>
|
|
623
|
+
<List doubleHardline>
|
|
624
|
+
{parameters.map((param) => (
|
|
625
|
+
<GoogleStyleDocParam
|
|
626
|
+
name={param.name}
|
|
627
|
+
type={param.type}
|
|
628
|
+
default={param.default}
|
|
629
|
+
>
|
|
630
|
+
{param.doc}
|
|
631
|
+
</GoogleStyleDocParam>
|
|
632
|
+
))}
|
|
633
|
+
</List>
|
|
634
|
+
</Indent>
|
|
635
|
+
</>
|
|
51
636
|
);
|
|
52
637
|
}
|
|
53
638
|
|
|
54
|
-
|
|
639
|
+
interface GoogleStyleDocParamProps {
|
|
55
640
|
name: Children;
|
|
56
641
|
type?: Children;
|
|
57
642
|
children?: Children;
|
|
58
|
-
|
|
59
|
-
defaultValue?: Children;
|
|
643
|
+
default?: Children;
|
|
60
644
|
}
|
|
61
645
|
|
|
62
646
|
/**
|
|
63
647
|
* Create a GoogleStyleDoc parameter.
|
|
64
648
|
*/
|
|
65
|
-
|
|
649
|
+
function GoogleStyleDocParam(props: GoogleStyleDocParamProps) {
|
|
66
650
|
return (
|
|
67
651
|
<>
|
|
68
652
|
<GoogleStyleDocParamName name={props.name} />
|
|
69
|
-
<GoogleStyleDocParamType
|
|
653
|
+
<GoogleStyleDocParamType
|
|
654
|
+
type={props.type}
|
|
655
|
+
default={Boolean(props.default)}
|
|
656
|
+
/>
|
|
70
657
|
<GoogleStyleDocParamDescription
|
|
71
658
|
children={props.children}
|
|
72
|
-
|
|
659
|
+
default={props.default}
|
|
73
660
|
/>
|
|
74
661
|
</>
|
|
75
662
|
);
|
|
76
663
|
}
|
|
77
664
|
|
|
78
|
-
|
|
79
|
-
|
|
665
|
+
interface GoogleStyleDocReturnProps {
|
|
666
|
+
message: string;
|
|
80
667
|
}
|
|
81
668
|
|
|
82
669
|
/**
|
|
83
670
|
* A component that creates a GoogleStyleDoc block for parameters.
|
|
84
671
|
*/
|
|
85
|
-
|
|
86
|
-
const parameters = normalizeParametersForDoc(props.parameters);
|
|
672
|
+
function GoogleStyleDocReturn(props: GoogleStyleDocReturnProps) {
|
|
87
673
|
return (
|
|
88
674
|
<>
|
|
89
|
-
{"
|
|
90
|
-
<Indent>
|
|
91
|
-
<List doubleHardline>
|
|
92
|
-
{parameters.map((param) => (
|
|
93
|
-
<GoogleStyleDocParam
|
|
94
|
-
name={param.name}
|
|
95
|
-
type={param.type}
|
|
96
|
-
optional={param.optional}
|
|
97
|
-
>
|
|
98
|
-
{param.doc}
|
|
99
|
-
</GoogleStyleDocParam>
|
|
100
|
-
))}
|
|
101
|
-
</List>
|
|
102
|
-
</Indent>
|
|
675
|
+
{"Returns:"}
|
|
676
|
+
<Indent>{props.message}</Indent>
|
|
103
677
|
</>
|
|
104
678
|
);
|
|
105
679
|
}
|
|
106
680
|
|
|
107
|
-
|
|
681
|
+
interface GoogleStyleDocRaisesProps {
|
|
108
682
|
message: string;
|
|
109
683
|
}
|
|
110
684
|
|
|
111
685
|
/**
|
|
112
|
-
* A component that creates a GoogleStyleDoc block for
|
|
686
|
+
* A component that creates a GoogleStyleDoc block for exceptions.
|
|
113
687
|
*/
|
|
114
|
-
|
|
688
|
+
function GoogleStyleDocRaises(props: GoogleStyleDocRaisesProps) {
|
|
115
689
|
return (
|
|
116
690
|
<>
|
|
117
|
-
{"
|
|
691
|
+
{"Raises:"}
|
|
118
692
|
<Indent>{props.message}</Indent>
|
|
119
693
|
</>
|
|
120
694
|
);
|
|
121
695
|
}
|
|
122
696
|
|
|
123
|
-
|
|
697
|
+
interface GoogleStyleDocYieldsProps {
|
|
124
698
|
message: string;
|
|
125
699
|
}
|
|
126
700
|
|
|
127
701
|
/**
|
|
128
|
-
* A component that creates a GoogleStyleDoc block for
|
|
702
|
+
* A component that creates a GoogleStyleDoc block for generator yields.
|
|
129
703
|
*/
|
|
130
|
-
|
|
704
|
+
function GoogleStyleDocYields(props: GoogleStyleDocYieldsProps) {
|
|
131
705
|
return (
|
|
132
706
|
<>
|
|
133
|
-
{"
|
|
707
|
+
{"Yields:"}
|
|
134
708
|
<Indent>{props.message}</Indent>
|
|
135
709
|
</>
|
|
136
710
|
);
|
|
137
711
|
}
|
|
138
712
|
|
|
139
|
-
export interface
|
|
140
|
-
|
|
713
|
+
export interface GoogleStyleDocAttributeProps {
|
|
714
|
+
name: Children;
|
|
715
|
+
type?: Children;
|
|
716
|
+
children?: Children;
|
|
717
|
+
}
|
|
141
718
|
|
|
142
719
|
/**
|
|
143
|
-
*
|
|
720
|
+
* Create a GoogleStyleDoc attribute entry.
|
|
144
721
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
if (props.parameters !== undefined && props.parameters.length > 0) {
|
|
155
|
-
children.push(<GoogleStyleDocParams parameters={props.parameters} />);
|
|
156
|
-
}
|
|
157
|
-
if (props.returns !== undefined) {
|
|
158
|
-
children.push(<GoogleStyleDocReturn message={props.returns} />);
|
|
159
|
-
}
|
|
160
|
-
if (props.raises !== undefined && props.raises.length > 0) {
|
|
161
|
-
children.push(
|
|
162
|
-
props.raises!.map((param) => <GoogleStyleDocRaises message={param} />),
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
return <PyDoc>{children}</PyDoc>;
|
|
722
|
+
function GoogleStyleDocAttribute(props: GoogleStyleDocAttributeProps) {
|
|
723
|
+
return (
|
|
724
|
+
<>
|
|
725
|
+
<GoogleStyleDocParamName name={props.name} />
|
|
726
|
+
<GoogleStyleDocParamType type={props.type} />
|
|
727
|
+
<GoogleStyleDocParamDescription children={props.children} />
|
|
728
|
+
</>
|
|
729
|
+
);
|
|
166
730
|
}
|
|
167
731
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
parameters?: ParameterDescriptor[] | string[];
|
|
171
|
-
returns?: string;
|
|
172
|
-
raises?: string[];
|
|
173
|
-
style?: "google";
|
|
732
|
+
interface GoogleStyleDocAttributesProps {
|
|
733
|
+
attributes: GoogleStyleDocAttributeProps[];
|
|
174
734
|
}
|
|
175
735
|
|
|
176
736
|
/**
|
|
177
|
-
* A component that creates a
|
|
737
|
+
* A component that creates a GoogleStyleDoc block for attributes.
|
|
178
738
|
*/
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
739
|
+
function GoogleStyleDocAttributes(props: GoogleStyleDocAttributesProps) {
|
|
740
|
+
return (
|
|
741
|
+
<>
|
|
742
|
+
{"Attributes:"}
|
|
743
|
+
<Indent>
|
|
744
|
+
<List doubleHardline>
|
|
745
|
+
{props.attributes.map((attr) => (
|
|
746
|
+
<GoogleStyleDocAttribute name={attr.name} type={attr.type}>
|
|
747
|
+
{attr.children}
|
|
748
|
+
</GoogleStyleDocAttribute>
|
|
749
|
+
))}
|
|
750
|
+
</List>
|
|
751
|
+
</Indent>
|
|
752
|
+
</>
|
|
753
|
+
);
|
|
191
754
|
}
|
|
192
755
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
parameters?: ParameterDescriptor[] | string[];
|
|
196
|
-
style?: "google";
|
|
756
|
+
interface GoogleStyleDocNoteProps {
|
|
757
|
+
message: string;
|
|
197
758
|
}
|
|
198
759
|
|
|
199
760
|
/**
|
|
200
|
-
* A component that creates a
|
|
761
|
+
* A component that creates a GoogleStyleDoc block for notes.
|
|
201
762
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
<
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
/>
|
|
210
|
-
);
|
|
211
|
-
}
|
|
763
|
+
function GoogleStyleDocNote(props: GoogleStyleDocNoteProps) {
|
|
764
|
+
return (
|
|
765
|
+
<>
|
|
766
|
+
{"Note:"}
|
|
767
|
+
<Indent>{props.message}</Indent>
|
|
768
|
+
</>
|
|
769
|
+
);
|
|
212
770
|
}
|
|
213
771
|
|
|
214
|
-
|
|
215
|
-
|
|
772
|
+
interface GoogleStyleDocTodoProps {
|
|
773
|
+
items: string[];
|
|
774
|
+
}
|
|
216
775
|
|
|
217
776
|
/**
|
|
218
|
-
* A component that creates a
|
|
777
|
+
* A component that creates a GoogleStyleDoc block for todo items.
|
|
219
778
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
779
|
+
function GoogleStyleDocTodo(props: GoogleStyleDocTodoProps) {
|
|
780
|
+
return (
|
|
781
|
+
<>
|
|
782
|
+
{"Todo:"}
|
|
783
|
+
<Indent>
|
|
784
|
+
<List hardline>
|
|
785
|
+
{props.items.map((item) => (
|
|
786
|
+
<>* {item}</>
|
|
787
|
+
))}
|
|
788
|
+
</List>
|
|
789
|
+
</Indent>
|
|
790
|
+
</>
|
|
791
|
+
);
|
|
233
792
|
}
|
|
234
793
|
|
|
235
|
-
|
|
236
|
-
|
|
794
|
+
interface GoogleStyleDocExamplesProps {
|
|
795
|
+
items: Children[];
|
|
237
796
|
}
|
|
238
797
|
|
|
239
798
|
/**
|
|
240
|
-
*
|
|
799
|
+
* A component that creates a GoogleStyleDoc block for examples.
|
|
241
800
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
801
|
+
function GoogleStyleDocExamples(props: GoogleStyleDocExamplesProps) {
|
|
802
|
+
return (
|
|
803
|
+
<>
|
|
804
|
+
{"Examples:"}
|
|
805
|
+
<Indent>
|
|
806
|
+
<List doubleHardline>{props.items.map((item) => item)}</List>
|
|
807
|
+
</Indent>
|
|
808
|
+
</>
|
|
809
|
+
);
|
|
810
|
+
}
|
|
245
811
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
.split(/\r?\n/)
|
|
250
|
-
.map((line) => line.trim())
|
|
251
|
-
.filter((line) => line.length > 0);
|
|
252
|
-
} else {
|
|
253
|
-
// For non-string children, filter out empty/whitespace-only strings
|
|
254
|
-
lines = children
|
|
255
|
-
.map((child) => (typeof child === "string" ? child : ""))
|
|
256
|
-
.map((line) => line.trim())
|
|
257
|
-
.filter((line) => line.length > 0);
|
|
258
|
-
}
|
|
812
|
+
interface GoogleStyleDocSeeAlsoProps {
|
|
813
|
+
items: string[];
|
|
814
|
+
}
|
|
259
815
|
|
|
816
|
+
/**
|
|
817
|
+
* A component that creates a GoogleStyleDoc block for see also references.
|
|
818
|
+
*/
|
|
819
|
+
function GoogleStyleDocSeeAlso(props: GoogleStyleDocSeeAlsoProps) {
|
|
260
820
|
return (
|
|
261
821
|
<>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
{
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
</
|
|
822
|
+
{"See Also:"}
|
|
823
|
+
<Indent>
|
|
824
|
+
<List hardline>
|
|
825
|
+
{props.items.map((item) => (
|
|
826
|
+
<>{item}</>
|
|
827
|
+
))}
|
|
828
|
+
</List>
|
|
829
|
+
</Indent>
|
|
270
830
|
</>
|
|
271
831
|
);
|
|
272
832
|
}
|
|
273
833
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (parameters.some((p) => typeof p === "string")) {
|
|
278
|
-
return [];
|
|
279
|
-
}
|
|
834
|
+
interface GoogleStyleDocWarningProps {
|
|
835
|
+
message: string;
|
|
836
|
+
}
|
|
280
837
|
|
|
281
|
-
|
|
838
|
+
/**
|
|
839
|
+
* A component that creates a GoogleStyleDoc block for warnings.
|
|
840
|
+
*/
|
|
841
|
+
function GoogleStyleDocWarning(props: GoogleStyleDocWarningProps) {
|
|
842
|
+
return (
|
|
843
|
+
<>
|
|
844
|
+
{"Warning:"}
|
|
845
|
+
<Indent>{props.message}</Indent>
|
|
846
|
+
</>
|
|
847
|
+
);
|
|
282
848
|
}
|
|
283
849
|
|
|
284
|
-
|
|
285
|
-
|
|
850
|
+
interface GoogleStyleDocDeprecatedProps {
|
|
851
|
+
message: string;
|
|
286
852
|
}
|
|
287
853
|
|
|
288
854
|
/**
|
|
289
|
-
* A
|
|
290
|
-
* linebreaks. This is useful for creating PyDoc comments with multiple paragraphs.
|
|
855
|
+
* A component that creates a GoogleStyleDoc block for deprecation notices.
|
|
291
856
|
*/
|
|
292
|
-
|
|
293
|
-
const children = childrenArray(() => props.children);
|
|
857
|
+
function GoogleStyleDocDeprecated(props: GoogleStyleDocDeprecatedProps) {
|
|
294
858
|
return (
|
|
295
859
|
<>
|
|
296
|
-
{
|
|
297
|
-
<
|
|
298
|
-
<List doubleHardline>{children}</List>
|
|
299
|
-
<hbr />
|
|
300
|
-
{'"""'}
|
|
301
|
-
<hbr />
|
|
860
|
+
{"Deprecated:"}
|
|
861
|
+
<Indent>{props.message}</Indent>
|
|
302
862
|
</>
|
|
303
863
|
);
|
|
304
864
|
}
|
|
305
865
|
|
|
306
|
-
|
|
307
|
-
|
|
866
|
+
interface GoogleStyleDocOverridesProps {
|
|
867
|
+
parentClass: string;
|
|
308
868
|
}
|
|
309
869
|
|
|
310
|
-
|
|
870
|
+
/**
|
|
871
|
+
* A component that creates a GoogleStyleDoc block for overridden methods.
|
|
872
|
+
* This indicates that the method overrides a parent class method.
|
|
873
|
+
*/
|
|
874
|
+
function GoogleStyleDocOverrides(props: GoogleStyleDocOverridesProps) {
|
|
311
875
|
return (
|
|
312
876
|
<>
|
|
313
|
-
|
|
314
|
-
<
|
|
315
|
-
<Prose>{props.children}</Prose>
|
|
316
|
-
</align>
|
|
877
|
+
{"Overrides:"}
|
|
878
|
+
<Indent>{props.parentClass}</Indent>
|
|
317
879
|
</>
|
|
318
880
|
);
|
|
319
881
|
}
|
|
320
882
|
|
|
321
|
-
|
|
322
|
-
|
|
883
|
+
interface GoogleStyleDocParamTypeProps {
|
|
884
|
+
type?: Children;
|
|
885
|
+
default?: boolean;
|
|
323
886
|
}
|
|
324
887
|
|
|
325
|
-
|
|
888
|
+
function GoogleStyleDocParamType(props: GoogleStyleDocParamTypeProps) {
|
|
326
889
|
return (
|
|
327
890
|
<>
|
|
328
|
-
|
|
891
|
+
<Show when={Boolean(props.type)}>
|
|
892
|
+
{" ("}
|
|
893
|
+
{props.type}
|
|
894
|
+
<Show when={props.default}>{", optional"}</Show>
|
|
895
|
+
{")"}
|
|
896
|
+
</Show>
|
|
329
897
|
</>
|
|
330
898
|
);
|
|
331
899
|
}
|
|
900
|
+
|
|
901
|
+
interface GoogleStyleDocParamNameProps {
|
|
902
|
+
name: Children;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
function GoogleStyleDocParamName(props: GoogleStyleDocParamNameProps) {
|
|
906
|
+
return <>{props.name}</>;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
interface GoogleStyleDocParamDescriptionProps {
|
|
910
|
+
children?: Children;
|
|
911
|
+
default?: Children;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function GoogleStyleDocParamDescription(
|
|
915
|
+
props: GoogleStyleDocParamDescriptionProps,
|
|
916
|
+
) {
|
|
917
|
+
return (
|
|
918
|
+
<Show when={Boolean(props.children)}>
|
|
919
|
+
{": "}
|
|
920
|
+
<align width={4}>
|
|
921
|
+
<Prose>
|
|
922
|
+
{props.children}
|
|
923
|
+
<Show when={Boolean(props.default)}>
|
|
924
|
+
<br />
|
|
925
|
+
Defaults to <Atom jsValue={props.default} />.
|
|
926
|
+
</Show>
|
|
927
|
+
</Prose>
|
|
928
|
+
</align>
|
|
929
|
+
</Show>
|
|
930
|
+
);
|
|
931
|
+
}
|