@alloy-js/python 0.2.0-dev.3 → 0.2.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/dist/src/builtins/python.d.ts +3 -0
  2. package/dist/src/builtins/python.d.ts.map +1 -1
  3. package/dist/src/builtins/python.js +6 -0
  4. package/dist/src/builtins/python.js.map +1 -1
  5. package/dist/src/components/CallSignature.d.ts +4 -15
  6. package/dist/src/components/CallSignature.d.ts.map +1 -1
  7. package/dist/src/components/CallSignature.js +13 -67
  8. package/dist/src/components/CallSignature.js.map +1 -1
  9. package/dist/src/components/ClassMethodDeclaration.d.ts +22 -0
  10. package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -0
  11. package/dist/src/components/ClassMethodDeclaration.js +32 -0
  12. package/dist/src/components/ClassMethodDeclaration.js.map +1 -0
  13. package/dist/src/components/ConstructorDeclaration.d.ts +21 -0
  14. package/dist/src/components/ConstructorDeclaration.d.ts.map +1 -0
  15. package/dist/src/components/ConstructorDeclaration.js +35 -0
  16. package/dist/src/components/ConstructorDeclaration.js.map +1 -0
  17. package/dist/src/components/DunderMethodDeclaration.d.ts +21 -0
  18. package/dist/src/components/DunderMethodDeclaration.d.ts.map +1 -0
  19. package/dist/src/components/DunderMethodDeclaration.js +29 -0
  20. package/dist/src/components/DunderMethodDeclaration.js.map +1 -0
  21. package/dist/src/components/EnumDeclaration.d.ts +11 -32
  22. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  23. package/dist/src/components/EnumDeclaration.js +10 -48
  24. package/dist/src/components/EnumDeclaration.js.map +1 -1
  25. package/dist/src/components/EnumMember.js +3 -3
  26. package/dist/src/components/EnumMember.js.map +1 -1
  27. package/dist/src/components/FunctionBase.d.ts +48 -0
  28. package/dist/src/components/FunctionBase.d.ts.map +1 -0
  29. package/dist/src/components/FunctionBase.js +91 -0
  30. package/dist/src/components/FunctionBase.js.map +1 -0
  31. package/dist/src/components/FunctionDeclaration.d.ts +11 -31
  32. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  33. package/dist/src/components/FunctionDeclaration.js +22 -79
  34. package/dist/src/components/FunctionDeclaration.js.map +1 -1
  35. package/dist/src/components/MethodBase.d.ts +29 -0
  36. package/dist/src/components/MethodBase.d.ts.map +1 -0
  37. package/dist/src/components/MethodBase.js +32 -0
  38. package/dist/src/components/MethodBase.js.map +1 -0
  39. package/dist/src/components/MethodDeclaration.d.ts +22 -0
  40. package/dist/src/components/MethodDeclaration.d.ts.map +1 -0
  41. package/dist/src/components/MethodDeclaration.js +34 -0
  42. package/dist/src/components/MethodDeclaration.js.map +1 -0
  43. package/dist/src/components/PropertyDeclaration.d.ts +71 -0
  44. package/dist/src/components/PropertyDeclaration.d.ts.map +1 -0
  45. package/dist/src/components/PropertyDeclaration.js +227 -0
  46. package/dist/src/components/PropertyDeclaration.js.map +1 -0
  47. package/dist/src/components/PyDoc.d.ts +107 -42
  48. package/dist/src/components/PyDoc.d.ts.map +1 -1
  49. package/dist/src/components/PyDoc.js +845 -181
  50. package/dist/src/components/PyDoc.js.map +1 -1
  51. package/dist/src/components/SourceFile.d.ts +24 -0
  52. package/dist/src/components/SourceFile.d.ts.map +1 -1
  53. package/dist/src/components/SourceFile.js +28 -1
  54. package/dist/src/components/SourceFile.js.map +1 -1
  55. package/dist/src/components/StaticMethodDeclaration.d.ts +22 -0
  56. package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -0
  57. package/dist/src/components/StaticMethodDeclaration.js +32 -0
  58. package/dist/src/components/StaticMethodDeclaration.js.map +1 -0
  59. package/dist/src/components/TypeArguments.d.ts +9 -0
  60. package/dist/src/components/TypeArguments.d.ts.map +1 -0
  61. package/dist/src/components/TypeArguments.js +18 -0
  62. package/dist/src/components/TypeArguments.js.map +1 -0
  63. package/dist/src/components/TypeReference.d.ts +14 -0
  64. package/dist/src/components/TypeReference.d.ts.map +1 -0
  65. package/dist/src/components/TypeReference.js +29 -0
  66. package/dist/src/components/TypeReference.js.map +1 -0
  67. package/dist/src/components/UnionTypeExpression.d.ts +1 -2
  68. package/dist/src/components/UnionTypeExpression.d.ts.map +1 -1
  69. package/dist/src/components/UnionTypeExpression.js +3 -11
  70. package/dist/src/components/UnionTypeExpression.js.map +1 -1
  71. package/dist/src/components/VariableDeclaration.d.ts.map +1 -1
  72. package/dist/src/components/VariableDeclaration.js +3 -3
  73. package/dist/src/components/VariableDeclaration.js.map +1 -1
  74. package/dist/src/components/index.d.ts +10 -0
  75. package/dist/src/components/index.d.ts.map +1 -1
  76. package/dist/src/components/index.js +9 -0
  77. package/dist/src/components/index.js.map +1 -1
  78. package/dist/src/parameter-descriptor.d.ts +1 -4
  79. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  80. package/dist/src/parameter-descriptor.js +7 -1
  81. package/dist/src/parameter-descriptor.js.map +1 -1
  82. package/dist/src/symbol-creation.d.ts +4 -0
  83. package/dist/src/symbol-creation.d.ts.map +1 -1
  84. package/dist/src/symbol-creation.js +12 -0
  85. package/dist/src/symbol-creation.js.map +1 -1
  86. package/dist/src/symbols/factories.d.ts +15 -0
  87. package/dist/src/symbols/factories.d.ts.map +1 -0
  88. package/dist/src/symbols/factories.js +28 -0
  89. package/dist/src/symbols/factories.js.map +1 -0
  90. package/dist/src/symbols/index.d.ts +1 -0
  91. package/dist/src/symbols/index.d.ts.map +1 -1
  92. package/dist/src/symbols/index.js +1 -0
  93. package/dist/src/symbols/index.js.map +1 -1
  94. package/dist/src/symbols/reference.d.ts +1 -1
  95. package/dist/src/symbols/reference.d.ts.map +1 -1
  96. package/dist/src/symbols/reference.js +1 -1
  97. package/dist/src/symbols/reference.js.map +1 -1
  98. package/dist/src/utils.d.ts.map +1 -1
  99. package/dist/src/utils.js +1 -1
  100. package/dist/src/utils.js.map +1 -1
  101. package/dist/test/callsignatures.test.js +42 -64
  102. package/dist/test/callsignatures.test.js.map +1 -1
  103. package/dist/test/class-method-declaration.test.d.ts +2 -0
  104. package/dist/test/class-method-declaration.test.d.ts.map +1 -0
  105. package/dist/test/class-method-declaration.test.js +61 -0
  106. package/dist/test/class-method-declaration.test.js.map +1 -0
  107. package/dist/test/classdeclarations.test.js +6 -8
  108. package/dist/test/classdeclarations.test.js.map +1 -1
  109. package/dist/test/constructordeclaration.test.d.ts +2 -0
  110. package/dist/test/constructordeclaration.test.d.ts.map +1 -0
  111. package/dist/test/constructordeclaration.test.js +58 -0
  112. package/dist/test/constructordeclaration.test.js.map +1 -0
  113. package/dist/test/dundermethoddeclaration.test.d.ts +2 -0
  114. package/dist/test/dundermethoddeclaration.test.d.ts.map +1 -0
  115. package/dist/test/dundermethoddeclaration.test.js +65 -0
  116. package/dist/test/dundermethoddeclaration.test.js.map +1 -0
  117. package/dist/test/enums.test.js +14 -16
  118. package/dist/test/enums.test.js.map +1 -1
  119. package/dist/test/externals.test.js +2 -4
  120. package/dist/test/externals.test.js.map +1 -1
  121. package/dist/test/factories.test.d.ts +2 -0
  122. package/dist/test/factories.test.d.ts.map +1 -0
  123. package/dist/test/factories.test.js +78 -0
  124. package/dist/test/factories.test.js.map +1 -0
  125. package/dist/test/functiondeclaration.test.js +213 -59
  126. package/dist/test/functiondeclaration.test.js.map +1 -1
  127. package/dist/test/memberexpressions.test.js +1 -1
  128. package/dist/test/memberexpressions.test.js.map +1 -1
  129. package/dist/test/methoddeclaration.test.d.ts +2 -0
  130. package/dist/test/methoddeclaration.test.d.ts.map +1 -0
  131. package/dist/test/methoddeclaration.test.js +239 -0
  132. package/dist/test/methoddeclaration.test.js.map +1 -0
  133. package/dist/test/namepolicies.test.js +1 -2
  134. package/dist/test/namepolicies.test.js.map +1 -1
  135. package/dist/test/propertydeclaration.test.d.ts +2 -0
  136. package/dist/test/propertydeclaration.test.d.ts.map +1 -0
  137. package/dist/test/propertydeclaration.test.js +229 -0
  138. package/dist/test/propertydeclaration.test.js.map +1 -0
  139. package/dist/test/pydocs.test.js +926 -126
  140. package/dist/test/pydocs.test.js.map +1 -1
  141. package/dist/test/references.test.js +1 -5
  142. package/dist/test/references.test.js.map +1 -1
  143. package/dist/test/sourcefiles.test.js +90 -1
  144. package/dist/test/sourcefiles.test.js.map +1 -1
  145. package/dist/test/staticmethoddeclaration.test.d.ts +2 -0
  146. package/dist/test/staticmethoddeclaration.test.d.ts.map +1 -0
  147. package/dist/test/staticmethoddeclaration.test.js +61 -0
  148. package/dist/test/staticmethoddeclaration.test.js.map +1 -0
  149. package/dist/test/typereference.test.d.ts +2 -0
  150. package/dist/test/typereference.test.d.ts.map +1 -0
  151. package/dist/test/typereference.test.js +51 -0
  152. package/dist/test/typereference.test.js.map +1 -0
  153. package/dist/test/uniontypeexpression.test.js +152 -15
  154. package/dist/test/uniontypeexpression.test.js.map +1 -1
  155. package/dist/test/variables.test.js +28 -19
  156. package/dist/test/variables.test.js.map +1 -1
  157. package/dist/tsconfig.tsbuildinfo +1 -1
  158. package/package.json +2 -2
  159. package/src/builtins/python.ts +7 -0
  160. package/src/components/CallSignature.tsx +17 -69
  161. package/src/components/ClassMethodDeclaration.tsx +34 -0
  162. package/src/components/ConstructorDeclaration.tsx +37 -0
  163. package/src/components/DunderMethodDeclaration.tsx +30 -0
  164. package/src/components/EnumDeclaration.tsx +16 -44
  165. package/src/components/EnumMember.tsx +3 -3
  166. package/src/components/FunctionBase.tsx +88 -0
  167. package/src/components/FunctionDeclaration.tsx +18 -82
  168. package/src/components/MethodBase.tsx +53 -0
  169. package/src/components/MethodDeclaration.tsx +27 -0
  170. package/src/components/PropertyDeclaration.tsx +264 -0
  171. package/src/components/PyDoc.tsx +795 -195
  172. package/src/components/SourceFile.tsx +29 -0
  173. package/src/components/StaticMethodDeclaration.tsx +34 -0
  174. package/src/components/TypeArguments.tsx +24 -0
  175. package/src/components/TypeReference.tsx +33 -0
  176. package/src/components/UnionTypeExpression.tsx +4 -15
  177. package/src/components/VariableDeclaration.tsx +1 -3
  178. package/src/components/index.ts +10 -0
  179. package/src/parameter-descriptor.ts +6 -5
  180. package/src/symbol-creation.ts +17 -0
  181. package/src/symbols/factories.ts +39 -0
  182. package/src/symbols/index.ts +1 -0
  183. package/src/symbols/reference.tsx +3 -5
  184. package/src/utils.ts +0 -2
  185. package/temp/api.json +5281 -2273
  186. package/test/callsignatures.test.tsx +102 -74
  187. package/test/class-method-declaration.test.tsx +53 -0
  188. package/test/classdeclarations.test.tsx +7 -9
  189. package/test/constructordeclaration.test.tsx +48 -0
  190. package/test/dundermethoddeclaration.test.tsx +53 -0
  191. package/test/enums.test.tsx +14 -16
  192. package/test/externals.test.tsx +5 -7
  193. package/test/factories.test.tsx +72 -0
  194. package/test/functiondeclaration.test.tsx +196 -44
  195. package/test/memberexpressions.test.tsx +7 -2
  196. package/test/methoddeclaration.test.tsx +202 -0
  197. package/test/namepolicies.test.tsx +1 -2
  198. package/test/propertydeclaration.test.tsx +192 -0
  199. package/test/pydocs.test.tsx +1093 -129
  200. package/test/references.test.tsx +1 -1
  201. package/test/sourcefiles.test.tsx +100 -1
  202. package/test/staticmethoddeclaration.test.tsx +49 -0
  203. package/test/typereference.test.tsx +52 -0
  204. package/test/uniontypeexpression.test.tsx +169 -34
  205. package/test/variables.test.tsx +27 -16
@@ -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 "./index.js";
4
+ import { Atom } from "./Atom.jsx";
5
5
 
6
- interface GoogleStyleDocParamTypeProps {
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
- optional?: boolean;
178
+ children?: Children;
179
+ style?: "google";
9
180
  }
10
181
 
11
- function GoogleStyleDocParamType(props: GoogleStyleDocParamTypeProps) {
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
- <Show when={Boolean(props.type)}>
15
- {" ("}
16
- {props.type}
17
- <Show when={props.optional}>{", optional"}</Show>
18
- {")"}
19
- </Show>
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 GoogleStyleDocParamNameProps {
25
- name: Children;
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
- function GoogleStyleDocParamName(props: GoogleStyleDocParamNameProps) {
29
- return <>{props.name}</>;
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
- interface GoogleStyleDocParamDescriptionProps {
33
- children?: Children;
34
- defaultValue?: Children;
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
- <Show when={Boolean(props.children)}>
42
- {": "}
43
- <align width={4}>
44
- <Prose>{props.children}</Prose>
45
- <Show when={Boolean(props.defaultValue)}>
46
- {" "}
47
- Defaults to <Atom jsValue={props.defaultValue}></Atom>.
48
- </Show>
49
- </align>
50
- </Show>
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
- export interface GoogleStyleDocParamProps {
639
+ interface GoogleStyleDocParamProps {
55
640
  name: Children;
56
641
  type?: Children;
57
642
  children?: Children;
58
- optional?: boolean;
59
- defaultValue?: Children;
643
+ default?: Children;
60
644
  }
61
645
 
62
646
  /**
63
647
  * Create a GoogleStyleDoc parameter.
64
648
  */
65
- export function GoogleStyleDocParam(props: GoogleStyleDocParamProps) {
649
+ function GoogleStyleDocParam(props: GoogleStyleDocParamProps) {
66
650
  return (
67
651
  <>
68
652
  <GoogleStyleDocParamName name={props.name} />
69
- <GoogleStyleDocParamType type={props.type} optional={props.optional} />
653
+ <GoogleStyleDocParamType
654
+ type={props.type}
655
+ default={Boolean(props.default)}
656
+ />
70
657
  <GoogleStyleDocParamDescription
71
658
  children={props.children}
72
- defaultValue={props.defaultValue}
659
+ default={props.default}
73
660
  />
74
661
  </>
75
662
  );
76
663
  }
77
664
 
78
- export interface GoogleStyleDocParamsProps {
79
- parameters: ParameterDescriptor[] | string[];
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
- export function GoogleStyleDocParams(props: GoogleStyleDocParamsProps) {
86
- const parameters = normalizeParametersForDoc(props.parameters);
672
+ function GoogleStyleDocReturn(props: GoogleStyleDocReturnProps) {
87
673
  return (
88
674
  <>
89
- {"Args:"}
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
- export interface GoogleStyleDocReturnProps {
681
+ interface GoogleStyleDocRaisesProps {
108
682
  message: string;
109
683
  }
110
684
 
111
685
  /**
112
- * A component that creates a GoogleStyleDoc block for parameters.
686
+ * A component that creates a GoogleStyleDoc block for exceptions.
113
687
  */
114
- export function GoogleStyleDocReturn(props: GoogleStyleDocReturnProps) {
688
+ function GoogleStyleDocRaises(props: GoogleStyleDocRaisesProps) {
115
689
  return (
116
690
  <>
117
- {"Returns:"}
691
+ {"Raises:"}
118
692
  <Indent>{props.message}</Indent>
119
693
  </>
120
694
  );
121
695
  }
122
696
 
123
- export interface GoogleStyleDocRaisesProps {
697
+ interface GoogleStyleDocYieldsProps {
124
698
  message: string;
125
699
  }
126
700
 
127
701
  /**
128
- * A component that creates a GoogleStyleDoc block for parameters.
702
+ * A component that creates a GoogleStyleDoc block for generator yields.
129
703
  */
130
- export function GoogleStyleDocRaises(props: GoogleStyleDocRaisesProps) {
704
+ function GoogleStyleDocYields(props: GoogleStyleDocYieldsProps) {
131
705
  return (
132
706
  <>
133
- {"Raises:"}
707
+ {"Yields:"}
134
708
  <Indent>{props.message}</Indent>
135
709
  </>
136
710
  );
137
711
  }
138
712
 
139
- export interface GoogleStyleFunctionDocProps
140
- extends Omit<FunctionDocProps, "style"> {}
713
+ export interface GoogleStyleDocAttributeProps {
714
+ name: Children;
715
+ type?: Children;
716
+ children?: Children;
717
+ }
141
718
 
142
719
  /**
143
- * A component that creates a GoogleStyleFunctionDoc block for parameters.
720
+ * Create a GoogleStyleDoc attribute entry.
144
721
  */
145
- export function GoogleStyleFunctionDoc(props: GoogleStyleFunctionDocProps) {
146
- // We are creating a list instead of relying on <Show> because otherwise
147
- // <List> would render spaces between the elements even if <Show> evaluates to false.
148
- const children = [];
149
- if (props.description !== undefined) {
150
- children.push(
151
- <List doubleHardline>{props.description.map((param) => param)}</List>,
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
- export interface FunctionDocProps {
169
- description: Children[];
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 FunctionDoc block for parameters.
737
+ * A component that creates a GoogleStyleDoc block for attributes.
178
738
  */
179
- export function FunctionDoc(props: FunctionDocProps) {
180
- const style = props.style ?? "google";
181
- if (style === "google") {
182
- return (
183
- <GoogleStyleFunctionDoc
184
- description={props.description}
185
- parameters={props.parameters}
186
- returns={props.returns}
187
- raises={props.raises}
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
- export interface ClassDocProps {
194
- description: Children[];
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 ClassDoc block for parameters.
761
+ * A component that creates a GoogleStyleDoc block for notes.
201
762
  */
202
- export function ClassDoc(props: ClassDocProps) {
203
- const style = props.style ?? "google";
204
- if (style === "google") {
205
- return (
206
- <GoogleStyleClassDoc
207
- description={props.description}
208
- parameters={props.parameters}
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
- export interface GoogleStyleClassDocProps
215
- extends Omit<ClassDocProps, "style"> {}
772
+ interface GoogleStyleDocTodoProps {
773
+ items: string[];
774
+ }
216
775
 
217
776
  /**
218
- * A component that creates a GoogleStyleClassDoc block for parameters.
777
+ * A component that creates a GoogleStyleDoc block for todo items.
219
778
  */
220
- export function GoogleStyleClassDoc(props: GoogleStyleClassDocProps) {
221
- // We are creating a list instead of relying on <Show> because otherwise
222
- // <List> would render spaces between the elements even if <Show> evaluates to false.
223
- const children = [];
224
- if (props.description !== undefined) {
225
- children.push(
226
- <List doubleHardline>{props.description.map((param) => param)}</List>,
227
- );
228
- }
229
- if (props.parameters !== undefined && props.parameters.length > 0) {
230
- children.push(<GoogleStyleDocParams parameters={props.parameters} />);
231
- }
232
- return <PyDoc>{children}</PyDoc>;
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
- export interface PyDocExampleProps {
236
- children: Children;
794
+ interface GoogleStyleDocExamplesProps {
795
+ items: Children[];
237
796
  }
238
797
 
239
798
  /**
240
- * Create a PyDoc example, which is prepended by \>\>.
799
+ * A component that creates a GoogleStyleDoc block for examples.
241
800
  */
242
- export function PyDocExample(props: PyDocExampleProps) {
243
- const children = childrenArray(() => props.children);
244
- let lines: string[] = [];
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
- if (children.length === 1 && typeof children[0] === "string") {
247
- // Split, trim each line, and filter out empty lines
248
- lines = children[0]
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
- <For each={lines}>
263
- {(line) => (
264
- <>
265
- {">> "}
266
- {line}
267
- </>
268
- )}
269
- </For>
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
- function normalizeParametersForDoc(
275
- parameters: ParameterDescriptor[] | string[],
276
- ): ParameterDescriptor[] {
277
- if (parameters.some((p) => typeof p === "string")) {
278
- return [];
279
- }
834
+ interface GoogleStyleDocWarningProps {
835
+ message: string;
836
+ }
280
837
 
281
- return parameters as ParameterDescriptor[];
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
- export interface PyDocProps {
285
- children: Children;
850
+ interface GoogleStyleDocDeprecatedProps {
851
+ message: string;
286
852
  }
287
853
 
288
854
  /**
289
- * A PyDoc comment. The children of this component are joined with two hard
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
- export function PyDoc(props: PyDocProps) {
293
- const children = childrenArray(() => props.children);
857
+ function GoogleStyleDocDeprecated(props: GoogleStyleDocDeprecatedProps) {
294
858
  return (
295
859
  <>
296
- {'"""'}
297
- <hbr />
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
- export interface SimpleCommentBlockProps {
307
- children: Children;
866
+ interface GoogleStyleDocOverridesProps {
867
+ parentClass: string;
308
868
  }
309
869
 
310
- export function SimpleCommentBlock(props: SimpleCommentBlockProps) {
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
- <align string="# ">
315
- <Prose>{props.children}</Prose>
316
- </align>
877
+ {"Overrides:"}
878
+ <Indent>{props.parentClass}</Indent>
317
879
  </>
318
880
  );
319
881
  }
320
882
 
321
- export interface SimpleInlineCommentProps {
322
- children: Children;
883
+ interface GoogleStyleDocParamTypeProps {
884
+ type?: Children;
885
+ default?: boolean;
323
886
  }
324
887
 
325
- export function SimpleInlineComment(props: SimpleInlineCommentProps) {
888
+ function GoogleStyleDocParamType(props: GoogleStyleDocParamTypeProps) {
326
889
  return (
327
890
  <>
328
- {" "}# <Prose>{props.children}</Prose>
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
+ }