@alloy-js/csharp 0.18.0-dev.2 → 0.18.0-dev.21

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 (158) hide show
  1. package/LICENSE +7 -0
  2. package/dist/src/components/ClassDeclaration.d.ts +74 -0
  3. package/dist/src/components/ClassDeclaration.d.ts.map +1 -0
  4. package/dist/src/components/{Class.js → ClassDeclaration.js} +64 -38
  5. package/dist/src/components/ClassMethod.d.ts +26 -5
  6. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  7. package/dist/src/components/ClassMethod.js +27 -9
  8. package/dist/src/components/EnumDeclaration.d.ts +34 -0
  9. package/dist/src/components/EnumDeclaration.d.ts.map +1 -0
  10. package/dist/src/components/{Enum.js → EnumDeclaration.js} +25 -5
  11. package/dist/src/components/doc/comment.d.ts +70 -0
  12. package/dist/src/components/doc/comment.d.ts.map +1 -0
  13. package/dist/src/components/doc/comment.js +88 -0
  14. package/dist/src/components/doc/comment.test.d.ts +2 -0
  15. package/dist/src/components/doc/comment.test.d.ts.map +1 -0
  16. package/dist/src/components/doc/comment.test.js +348 -0
  17. package/dist/src/components/doc/from-markdown.d.ts +6 -0
  18. package/dist/src/components/doc/from-markdown.d.ts.map +1 -0
  19. package/dist/src/components/doc/from-markdown.js +58 -0
  20. package/dist/src/components/doc/from-markdown.test.d.ts +2 -0
  21. package/dist/src/components/doc/from-markdown.test.d.ts.map +1 -0
  22. package/dist/src/components/doc/from-markdown.test.js +83 -0
  23. package/dist/src/components/index.d.ts +13 -4
  24. package/dist/src/components/index.d.ts.map +1 -1
  25. package/dist/src/components/index.js +14 -5
  26. package/dist/src/components/interface/declaration.d.ts +47 -0
  27. package/dist/src/components/interface/declaration.d.ts.map +1 -0
  28. package/dist/src/components/interface/declaration.js +77 -0
  29. package/dist/src/components/interface/declaration.test.d.ts +2 -0
  30. package/dist/src/components/interface/declaration.test.d.ts.map +1 -0
  31. package/dist/src/components/interface/declaration.test.js +153 -0
  32. package/dist/src/components/interface/method.d.ts +32 -0
  33. package/dist/src/components/interface/method.d.ts.map +1 -0
  34. package/dist/src/components/interface/method.js +68 -0
  35. package/dist/src/components/interface/method.test.d.ts +2 -0
  36. package/dist/src/components/interface/method.test.d.ts.map +1 -0
  37. package/dist/src/components/interface/method.test.js +279 -0
  38. package/dist/src/components/interface/property.d.ts +38 -0
  39. package/dist/src/components/interface/property.d.ts.map +1 -0
  40. package/dist/src/components/interface/property.js +67 -0
  41. package/dist/src/components/interface/property.test.d.ts +2 -0
  42. package/dist/src/components/interface/property.test.d.ts.map +1 -0
  43. package/dist/src/components/interface/property.test.js +165 -0
  44. package/dist/src/components/parameters/parameters.d.ts +19 -0
  45. package/dist/src/components/parameters/parameters.d.ts.map +1 -0
  46. package/dist/src/components/parameters/parameters.js +43 -0
  47. package/dist/src/components/property/property.d.ts +57 -0
  48. package/dist/src/components/property/property.d.ts.map +1 -0
  49. package/dist/src/components/property/property.js +70 -0
  50. package/dist/src/components/property/property.test.d.ts +2 -0
  51. package/dist/src/components/property/property.test.d.ts.map +1 -0
  52. package/dist/src/components/property/property.test.js +218 -0
  53. package/dist/src/components/record/declaration.d.ts +35 -0
  54. package/dist/src/components/record/declaration.d.ts.map +1 -0
  55. package/dist/src/components/record/declaration.js +90 -0
  56. package/dist/src/components/record/declaration.test.d.ts +2 -0
  57. package/dist/src/components/record/declaration.test.d.ts.map +1 -0
  58. package/dist/src/components/record/declaration.test.js +94 -0
  59. package/dist/src/components/stc/index.d.ts +2 -2
  60. package/dist/src/components/stc/index.d.ts.map +1 -1
  61. package/dist/src/components/stc/index.js +2 -2
  62. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +8 -0
  63. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +1 -0
  64. package/dist/src/components/type-parameters/type-parameter-constraints.js +44 -0
  65. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +2 -0
  66. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +1 -0
  67. package/dist/src/components/type-parameters/type-parameter-constraints.test.js +67 -0
  68. package/dist/src/components/type-parameters/type-parameter.d.ts +20 -0
  69. package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -0
  70. package/dist/src/components/type-parameters/type-parameter.js +22 -0
  71. package/dist/src/components/type-parameters/type-parameters.d.ts +17 -0
  72. package/dist/src/components/type-parameters/type-parameters.d.ts.map +1 -0
  73. package/dist/src/components/type-parameters/type-parameters.js +54 -0
  74. package/dist/src/components/type-parameters/type-parameters.test.d.ts +2 -0
  75. package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +1 -0
  76. package/dist/src/components/type-parameters/type-parameters.test.js +48 -0
  77. package/dist/src/components/var/declaration.d.ts +35 -0
  78. package/dist/src/components/var/declaration.d.ts.map +1 -0
  79. package/dist/src/components/var/declaration.js +40 -0
  80. package/dist/src/components/var/declaration.test.d.ts +2 -0
  81. package/dist/src/components/var/declaration.test.d.ts.map +1 -0
  82. package/dist/src/components/var/declaration.test.js +73 -0
  83. package/dist/src/modifiers.d.ts +10 -4
  84. package/dist/src/modifiers.d.ts.map +1 -1
  85. package/dist/src/modifiers.js +9 -32
  86. package/dist/src/name-policy.d.ts +1 -1
  87. package/dist/src/name-policy.d.ts.map +1 -1
  88. package/dist/src/name-policy.js +2 -0
  89. package/dist/test/class-declaration.test.d.ts +2 -0
  90. package/dist/test/class-declaration.test.d.ts.map +1 -0
  91. package/dist/test/class-declaration.test.js +463 -0
  92. package/dist/test/class-method.test.js +37 -14
  93. package/dist/test/enum.test.js +12 -12
  94. package/dist/test/namespace.test.js +8 -8
  95. package/dist/test/project-directory.test.d.ts +2 -0
  96. package/dist/test/project-directory.test.d.ts.map +1 -0
  97. package/dist/test/{projectdirectory.test.js → project-directory.test.js} +8 -8
  98. package/dist/test/sourcefile.test.js +4 -4
  99. package/dist/test/using.test.js +9 -9
  100. package/dist/test/vitest.setup.d.ts +2 -0
  101. package/dist/test/vitest.setup.d.ts.map +1 -0
  102. package/dist/test/vitest.setup.js +1 -0
  103. package/dist/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +21 -21
  105. package/src/components/ClassDeclaration.tsx +213 -0
  106. package/src/components/ClassMethod.tsx +54 -15
  107. package/src/components/{Enum.tsx → EnumDeclaration.tsx} +30 -6
  108. package/src/components/doc/comment.test.tsx +337 -0
  109. package/src/components/doc/comment.tsx +152 -0
  110. package/src/components/doc/from-markdown.test.tsx +103 -0
  111. package/src/components/doc/from-markdown.tsx +58 -0
  112. package/src/components/index.ts +13 -4
  113. package/src/components/interface/declaration.test.tsx +143 -0
  114. package/src/components/interface/declaration.tsx +105 -0
  115. package/src/components/interface/method.test.tsx +278 -0
  116. package/src/components/interface/method.tsx +102 -0
  117. package/src/components/interface/property.test.tsx +144 -0
  118. package/src/components/interface/property.tsx +107 -0
  119. package/src/components/parameters/parameters.tsx +74 -0
  120. package/src/components/property/property.test.tsx +187 -0
  121. package/src/components/property/property.tsx +146 -0
  122. package/src/components/record/declaration.test.tsx +73 -0
  123. package/src/components/record/declaration.tsx +109 -0
  124. package/src/components/stc/index.ts +2 -2
  125. package/src/components/type-parameters/type-parameter-constraints.test.tsx +93 -0
  126. package/src/components/type-parameters/type-parameter-constraints.tsx +46 -0
  127. package/src/components/type-parameters/type-parameter.tsx +35 -0
  128. package/src/components/type-parameters/type-parameters.test.tsx +46 -0
  129. package/src/components/type-parameters/type-parameters.tsx +63 -0
  130. package/src/components/var/declaration.test.tsx +59 -0
  131. package/src/components/var/declaration.tsx +47 -0
  132. package/src/modifiers.ts +25 -42
  133. package/src/name-policy.ts +5 -0
  134. package/temp/api.json +5228 -686
  135. package/test/class-declaration.test.tsx +418 -0
  136. package/test/class-method.test.tsx +24 -14
  137. package/test/enum.test.tsx +11 -11
  138. package/test/namespace.test.tsx +4 -4
  139. package/test/{projectdirectory.test.tsx → project-directory.test.tsx} +4 -4
  140. package/test/sourcefile.test.tsx +2 -2
  141. package/test/using.test.tsx +9 -9
  142. package/test/vitest.setup.ts +1 -0
  143. package/vitest.config.ts +3 -0
  144. package/dist/src/components/Class.d.ts +0 -26
  145. package/dist/src/components/Class.d.ts.map +0 -1
  146. package/dist/src/components/Enum.d.ts +0 -15
  147. package/dist/src/components/Enum.d.ts.map +0 -1
  148. package/dist/src/components/Parameters.d.ts +0 -13
  149. package/dist/src/components/Parameters.d.ts.map +0 -1
  150. package/dist/src/components/Parameters.js +0 -34
  151. package/dist/test/class.test.d.ts +0 -2
  152. package/dist/test/class.test.d.ts.map +0 -1
  153. package/dist/test/class.test.js +0 -298
  154. package/dist/test/projectdirectory.test.d.ts +0 -2
  155. package/dist/test/projectdirectory.test.d.ts.map +0 -1
  156. package/src/components/Class.tsx +0 -149
  157. package/src/components/Parameters.tsx +0 -51
  158. package/test/class.test.tsx +0 -292
@@ -0,0 +1,348 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { describe, expect, it } from "vitest";
3
+ import { DocC, DocCode, DocComment, DocDescription, DocExample, DocException, DocInclude, DocList, DocPara, DocParam, DocParamRef, DocPermission, DocRemarks, DocReturns, DocSee, DocSeeAlso, DocSummary, DocTypeParam, DocTypeParamRef, DocValue } from "./comment.js";
4
+ it("define summary", () => {
5
+ expect(_$createComponent(DocComment, {
6
+ get children() {
7
+ return _$createComponent(DocSummary, {
8
+ children: "This is a sample doc comment"
9
+ });
10
+ }
11
+ })).toRenderTo(`
12
+ /// <summary>
13
+ /// This is a sample doc comment
14
+ /// </summary>
15
+ `);
16
+ });
17
+ it("define code", () => {
18
+ expect(_$createComponent(DocComment, {
19
+ get children() {
20
+ return _$createComponent(DocCode, {
21
+ children: "code sample"
22
+ });
23
+ }
24
+ })).toRenderTo(`
25
+ /// <code>
26
+ /// code sample
27
+ /// </code>
28
+ `);
29
+ });
30
+ it("define c", () => {
31
+ expect(_$createComponent(DocComment, {
32
+ get children() {
33
+ return _$createComponent(DocC, {
34
+ children: "inline code"
35
+ });
36
+ }
37
+ })).toRenderTo(`
38
+ /// <c>inline code</c>
39
+ `);
40
+ });
41
+ it("define example", () => {
42
+ expect(_$createComponent(DocComment, {
43
+ get children() {
44
+ return _$createComponent(DocExample, {
45
+ children: "example usage"
46
+ });
47
+ }
48
+ })).toRenderTo(`
49
+ /// <example>
50
+ /// example usage
51
+ /// </example>
52
+ `);
53
+ });
54
+ it("define exception", () => {
55
+ expect(_$createComponent(DocComment, {
56
+ get children() {
57
+ return _$createComponent(DocException, {
58
+ children: "exception info"
59
+ });
60
+ }
61
+ })).toRenderTo(`
62
+ /// <exception>
63
+ /// exception info
64
+ /// </exception>
65
+ `);
66
+ });
67
+ it("define include", () => {
68
+ expect(_$createComponent(DocComment, {
69
+ get children() {
70
+ return _$createComponent(DocInclude, {
71
+ file: "external.xml",
72
+ path: "/doc/summary"
73
+ });
74
+ }
75
+ })).toRenderTo(`
76
+ /// <include file="external.xml" path="/doc/summary" />
77
+ `);
78
+ });
79
+ it("define param", () => {
80
+ expect(_$createComponent(DocComment, {
81
+ get children() {
82
+ return _$createComponent(DocParam, {
83
+ name: "x",
84
+ children: "parameter x"
85
+ });
86
+ }
87
+ })).toRenderTo(`
88
+ /// <param name="x">parameter x</param>
89
+ `);
90
+ });
91
+ it("define typeparam", () => {
92
+ expect(_$createComponent(DocComment, {
93
+ get children() {
94
+ return _$createComponent(DocTypeParam, {
95
+ name: "T",
96
+ children: "type parameter T"
97
+ });
98
+ }
99
+ })).toRenderTo(`
100
+ /// <typeparam name="T">type parameter T</typeparam>
101
+ `);
102
+ });
103
+ it("define returns", () => {
104
+ expect(_$createComponent(DocComment, {
105
+ get children() {
106
+ return _$createComponent(DocReturns, {
107
+ children: "return value"
108
+ });
109
+ }
110
+ })).toRenderTo(`
111
+ /// <returns>
112
+ /// return value
113
+ /// </returns>
114
+ `);
115
+ });
116
+ it("define remarks", () => {
117
+ expect(_$createComponent(DocComment, {
118
+ get children() {
119
+ return _$createComponent(DocRemarks, {
120
+ children: "remarks here"
121
+ });
122
+ }
123
+ })).toRenderTo(`
124
+ /// <remarks>
125
+ /// remarks here
126
+ /// </remarks>
127
+ `);
128
+ });
129
+ it("define value", () => {
130
+ expect(_$createComponent(DocComment, {
131
+ get children() {
132
+ return _$createComponent(DocValue, {
133
+ children: "property value"
134
+ });
135
+ }
136
+ })).toRenderTo(`
137
+ /// <value>
138
+ /// property value
139
+ /// </value>
140
+ `);
141
+ });
142
+ it("define permission", () => {
143
+ expect(_$createComponent(DocComment, {
144
+ get children() {
145
+ return _$createComponent(DocPermission, {
146
+ children: "permission info"
147
+ });
148
+ }
149
+ })).toRenderTo(`
150
+ /// <permission>
151
+ /// permission info
152
+ /// </permission>
153
+ `);
154
+ });
155
+ it("define list", () => {
156
+ expect(_$createComponent(DocComment, {
157
+ get children() {
158
+ return _$createComponent(DocList, {
159
+ type: "bullet",
160
+ items: ["item 1", "item 2", "item 3"]
161
+ });
162
+ }
163
+ })).toRenderTo(`
164
+ /// <list type="bullet">
165
+ /// <item><description>item 1</description></item>
166
+ /// <item><description>item 2</description></item>
167
+ /// <item><description>item 3</description></item>
168
+ /// </list>
169
+ `);
170
+ });
171
+ it("define description", () => {
172
+ expect(_$createComponent(DocComment, {
173
+ get children() {
174
+ return _$createComponent(DocDescription, {
175
+ children: "description content"
176
+ });
177
+ }
178
+ })).toRenderTo(`
179
+ /// <description>
180
+ /// description content
181
+ /// </description>
182
+ `);
183
+ });
184
+ it("define para", () => {
185
+ expect(_$createComponent(DocComment, {
186
+ get children() {
187
+ return _$createComponent(DocPara, {
188
+ children: "paragraph content"
189
+ });
190
+ }
191
+ })).toRenderTo(`
192
+ /// <para>
193
+ /// paragraph content
194
+ /// </para>
195
+ `);
196
+ });
197
+ describe("define see", () => {
198
+ it("with cref", () => {
199
+ expect(_$createComponent(DocComment, {
200
+ get children() {
201
+ return _$createComponent(DocSee, {
202
+ cref: "T:MyType"
203
+ });
204
+ }
205
+ })).toRenderTo(`
206
+ /// <see cref="T:MyType" />
207
+ `);
208
+ });
209
+ it("with href", () => {
210
+ expect(_$createComponent(DocComment, {
211
+ get children() {
212
+ return _$createComponent(DocSee, {
213
+ href: "https://github.com"
214
+ });
215
+ }
216
+ })).toRenderTo(`
217
+ /// <see href="https://github.com" />
218
+ `);
219
+ });
220
+ it("with href and children", () => {
221
+ expect(_$createComponent(DocComment, {
222
+ get children() {
223
+ return _$createComponent(DocSee, {
224
+ href: "https://github.com",
225
+ children: "GitHub"
226
+ });
227
+ }
228
+ })).toRenderTo(`
229
+ /// <see href="https://github.com">GitHub</see>
230
+ `);
231
+ });
232
+ it("with langword", () => {
233
+ expect(_$createComponent(DocComment, {
234
+ get children() {
235
+ return _$createComponent(DocSee, {
236
+ langword: "keyword"
237
+ });
238
+ }
239
+ })).toRenderTo(`
240
+ /// <see langword="keyword" />
241
+ `);
242
+ });
243
+ });
244
+ describe("define seealso", () => {
245
+ it("with cref", () => {
246
+ expect(_$createComponent(DocComment, {
247
+ get children() {
248
+ return _$createComponent(DocSeeAlso, {
249
+ cref: "T:OtherType"
250
+ });
251
+ }
252
+ })).toRenderTo(`
253
+ /// <seealso cref="T:OtherType" />
254
+ `);
255
+ });
256
+ it("with href", () => {
257
+ expect(_$createComponent(DocComment, {
258
+ get children() {
259
+ return _$createComponent(DocSeeAlso, {
260
+ href: "https://github.com"
261
+ });
262
+ }
263
+ })).toRenderTo(`
264
+ /// <seealso href="https://github.com" />
265
+ `);
266
+ });
267
+ it("with children", () => {
268
+ expect(_$createComponent(DocComment, {
269
+ get children() {
270
+ return _$createComponent(DocSeeAlso, {
271
+ cref: "T:OtherType",
272
+ children: "OtherType"
273
+ });
274
+ }
275
+ })).toRenderTo(`
276
+ /// <seealso cref="T:OtherType">OtherType</seealso>
277
+ `);
278
+ });
279
+ });
280
+ it("define paramref", () => {
281
+ expect(_$createComponent(DocComment, {
282
+ get children() {
283
+ return _$createComponent(DocParamRef, {
284
+ name: "x"
285
+ });
286
+ }
287
+ })).toRenderTo(`
288
+ /// <paramref name="${"x"}" />
289
+ `);
290
+ });
291
+ it("define typeparamref", () => {
292
+ expect(_$createComponent(DocComment, {
293
+ get children() {
294
+ return _$createComponent(DocTypeParamRef, {
295
+ name: "T"
296
+ });
297
+ }
298
+ })).toRenderTo(`
299
+ /// <typeparamref name="T" />
300
+ `);
301
+ });
302
+ it("wrap long summary", () => {
303
+ expect(_$createComponent(DocComment, {
304
+ get children() {
305
+ return _$createComponent(DocSummary, {
306
+ children: "This is a very long sample doc comment that exceeds the typical line length limit and should be wrapped appropriately in the generated documentation."
307
+ });
308
+ }
309
+ })).toRenderTo(`
310
+ /// <summary>
311
+ /// This is a very long sample doc comment that exceeds the typical line length limit
312
+ /// and should be wrapped appropriately in the generated documentation.
313
+ /// </summary>
314
+ `);
315
+ });
316
+ it("combine multiple tags", () => {
317
+ expect(_$createComponent(DocComment, {
318
+ get children() {
319
+ return [_$createComponent(DocSummary, {
320
+ children: "This operator determines whether two Points have the same location."
321
+ }), _$createComponent(DocParam, {
322
+ name: "p1",
323
+ children: "The first Point to be compared."
324
+ }), _$createComponent(DocParam, {
325
+ name: "p2",
326
+ children: "The second Point to be compared."
327
+ }), _$createComponent(DocReturns, {
328
+ children: "True if the Points do not have the same location and the exact same type; otherwise, false."
329
+ }), _$createComponent(DocSeeAlso, {
330
+ cref: "Equals"
331
+ }), _$createComponent(DocSeeAlso, {
332
+ cref: "operator=="
333
+ })];
334
+ }
335
+ })).toRenderTo(`
336
+ /// <summary>
337
+ /// This operator determines whether two Points have the same location.
338
+ /// </summary>
339
+ /// <param name="p1">The first Point to be compared.</param>
340
+ /// <param name="p2">The second Point to be compared.</param>
341
+ /// <returns>
342
+ /// True if the Points do not have the same location and the exact same type; otherwise,
343
+ /// false.
344
+ /// </returns>
345
+ /// <seealso cref="Equals" />
346
+ /// <seealso cref="operator==" />
347
+ `);
348
+ });
@@ -0,0 +1,6 @@
1
+ export interface DocFromMarkdownProps {
2
+ markdown: string;
3
+ }
4
+ /** Convert markdown to a Csharp doc comment */
5
+ export declare function DocFromMarkdown(props: DocFromMarkdownProps): import("@alloy-js/core/jsx-runtime").Children;
6
+ //# sourceMappingURL=from-markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from-markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/from-markdown.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,iDAG1D"}
@@ -0,0 +1,58 @@
1
+ import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
+ import { marked } from "marked";
3
+ import { DocC, DocCode, DocList, DocSee } from "./comment.js";
4
+ /** Convert markdown to a Csharp doc comment */
5
+ export function DocFromMarkdown(props) {
6
+ const tokens = marked.lexer(props.markdown);
7
+ return renderTokens(tokens);
8
+ }
9
+ function renderTokens(tokens) {
10
+ return [_$memo(() => tokens.map((token, index) => [_$createComponent(DocFromMarkedToken, {
11
+ token: token
12
+ }), _$memo(() => _$memo(() => !!(token.type === "paragraph" && index !== tokens.length - 1))() && _$createIntrinsic("br", {}))]))];
13
+ }
14
+ function DocFromMarkedToken(props) {
15
+ const {
16
+ token
17
+ } = props;
18
+ switch (token.type) {
19
+ case "paragraph":
20
+ return token.tokens ? renderTokens(token.tokens) : null;
21
+ case "code":
22
+ return _$createComponent(DocCode, {
23
+ get children() {
24
+ return token.text;
25
+ }
26
+ });
27
+ case "codespan":
28
+ return _$createComponent(DocC, {
29
+ get children() {
30
+ return token.text;
31
+ }
32
+ });
33
+ case "list":
34
+ return _$createComponent(DocList, {
35
+ get type() {
36
+ return token.ordered ? "number" : "bullet";
37
+ },
38
+ get items() {
39
+ return token.items.map(x => [_$memo(() => renderTokens(x.tokens))]);
40
+ }
41
+ });
42
+ case "link":
43
+ return _$createComponent(DocSee, {
44
+ get href() {
45
+ return token.href;
46
+ },
47
+ get children() {
48
+ return _$memo(() => !!token.tokens)() && renderTokens(token.tokens);
49
+ }
50
+ });
51
+ case "strong":
52
+ case "em":
53
+ return token.text;
54
+ case "text":
55
+ default:
56
+ return token.raw;
57
+ }
58
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=from-markdown.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from-markdown.test.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/from-markdown.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { d } from "@alloy-js/core/testing";
3
+ import { describe, expect, it } from "vitest";
4
+ import { DocFromMarkdown } from "./from-markdown.js";
5
+ it("convert code block to <code>", () => {
6
+ expect(_$createComponent(DocFromMarkdown, {
7
+ markdown: d`
8
+ Some markdown with code
9
+ \`\`\`csharp
10
+ var foo = "bar";
11
+ \`\`\`
12
+ `
13
+ })).toRenderTo(`
14
+ Some markdown with code
15
+ <code>
16
+ var foo = "bar";
17
+ </code>
18
+ `);
19
+ });
20
+ it("convert inline code block to <c>", () => {
21
+ expect(_$createComponent(DocFromMarkdown, {
22
+ markdown: d`
23
+ Some markdown with \`inline\` code
24
+ `
25
+ })).toRenderTo(`
26
+ Some markdown with <c>inline</c> code
27
+ `);
28
+ });
29
+ it("convert link to <see>", () => {
30
+ expect(_$createComponent(DocFromMarkdown, {
31
+ markdown: d`
32
+ Some markdown with [link](https://example.com)
33
+ `
34
+ })).toRenderTo(`
35
+ Some markdown with <see href="https://example.com">link</see>
36
+ `);
37
+ });
38
+ it("convert bullet list to <list>", () => {
39
+ expect(_$createComponent(DocFromMarkdown, {
40
+ markdown: d`
41
+ - Item 1
42
+ - Item 2
43
+ - Item 3
44
+ `
45
+ })).toRenderTo(`
46
+ <list type="bullet">
47
+ <item><description>Item 1</description></item>
48
+ <item><description>Item 2</description></item>
49
+ <item><description>Item 3</description></item>
50
+ </list>
51
+ `);
52
+ });
53
+ it("convert numbered list to <list>", () => {
54
+ expect(_$createComponent(DocFromMarkdown, {
55
+ markdown: d`
56
+ 1. Item 1
57
+ 2. Item 2
58
+ 3. Item 3
59
+ `
60
+ })).toRenderTo(`
61
+ <list type="number">
62
+ <item><description>Item 1</description></item>
63
+ <item><description>Item 2</description></item>
64
+ <item><description>Item 3</description></item>
65
+ </list>
66
+ `);
67
+ });
68
+ describe("strip unsupported elements", () => {
69
+ it("bold", () => {
70
+ expect(_$createComponent(DocFromMarkdown, {
71
+ markdown: d`
72
+ Some markdown with **bold** text
73
+ `
74
+ })).toRenderTo(`Some markdown with bold text`);
75
+ });
76
+ it("italic", () => {
77
+ expect(_$createComponent(DocFromMarkdown, {
78
+ markdown: d`
79
+ Some markdown with *italic* text
80
+ `
81
+ })).toRenderTo(`Some markdown with italic text`);
82
+ });
83
+ });
@@ -1,12 +1,21 @@
1
- export * from "./Class.js";
2
- export { ClassMethod, type ClassMethodProps } from "./ClassMethod.jsx";
1
+ export * from "./ClassDeclaration.jsx";
2
+ export * from "./ClassMethod.jsx";
3
3
  export * from "./Declaration.js";
4
- export * from "./Enum.js";
4
+ export * from "./doc/comment.jsx";
5
+ export * from "./doc/from-markdown.jsx";
6
+ export * from "./EnumDeclaration.jsx";
7
+ export * from "./interface/declaration.js";
8
+ export * from "./interface/method.js";
9
+ export * from "./interface/property.js";
5
10
  export * from "./Name.js";
6
11
  export * from "./Namespace.js";
7
- export * from "./Parameters.js";
12
+ export * from "./parameters/parameters.jsx";
8
13
  export * from "./ProjectDirectory.js";
14
+ export * from "./property/property.jsx";
15
+ export * from "./record/declaration.js";
9
16
  export * from "./Reference.js";
10
17
  export * from "./SourceFile.js";
18
+ export type { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
11
19
  export * from "./UsingDirective.js";
20
+ export * from "./var/declaration.jsx";
12
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
@@ -1,11 +1,20 @@
1
- export * from "./Class.js";
2
- export { ClassMethod } from "./ClassMethod.js";
1
+ export * from "./ClassDeclaration.js";
2
+ export * from "./ClassMethod.js";
3
3
  export * from "./Declaration.js";
4
- export * from "./Enum.js";
4
+ export * from "./doc/comment.js";
5
+ export * from "./doc/from-markdown.js";
6
+ export * from "./EnumDeclaration.js";
7
+ export * from "./interface/declaration.js";
8
+ export * from "./interface/method.js";
9
+ export * from "./interface/property.js";
5
10
  export * from "./Name.js";
6
11
  export * from "./Namespace.js";
7
- export * from "./Parameters.js";
12
+ export * from "./parameters/parameters.js";
8
13
  export * from "./ProjectDirectory.js";
14
+ export * from "./property/property.js";
15
+ export * from "./record/declaration.js";
9
16
  export * from "./Reference.js";
10
17
  export * from "./SourceFile.js";
11
- export * from "./UsingDirective.js";
18
+ export * from "./UsingDirective.js";
19
+ export * from "./var/declaration.js";
20
+ export {};
@@ -0,0 +1,47 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifiers } from "../../modifiers.js";
3
+ import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
4
+ export interface InterfaceModifiers {
5
+ readonly partial?: boolean;
6
+ }
7
+ export interface InterfaceDeclarationProps extends Omit<core.DeclarationProps, "nameKind">, AccessModifiers, InterfaceModifiers {
8
+ name: string;
9
+ /** Doc comment */
10
+ doc?: core.Children;
11
+ refkey?: core.Refkey;
12
+ /**
13
+ * Type parameters for the interface
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <InterfaceDeclaration name="IList" typeParameters={["T"]} />
18
+ * ```
19
+ * This will produce:
20
+ * ```csharp
21
+ * public interface IList<T>
22
+ * ```
23
+ */
24
+ typeParameters?: (TypeParameterProps | string)[];
25
+ }
26
+ /**
27
+ * CSharp interface declaration.
28
+ * @example
29
+ * ```tsx
30
+ * <InterfaceDeclaration public name="IMyInterface">
31
+ * <InterfaceMember public name="MyProperty" type="int" />
32
+ * <InterfaceMethod public name="MyMethod" returnType="void">
33
+ * <Parameter name="value" type="int" />
34
+ * </InterfaceMethod>
35
+ * </InterfaceDeclaration>
36
+ * ```
37
+ * This will produce:
38
+ * ```csharp
39
+ * public interface MyIface
40
+ * {
41
+ * public int MyProperty { get; set; }
42
+ * public void MyMethod(int value);
43
+ * }
44
+ * ```
45
+ */
46
+ export declare function InterfaceDeclaration(props: InterfaceDeclarationProps): core.Children;
47
+ //# sourceMappingURL=declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAKD,MAAM,WAAW,yBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,kBAAkB;IACpB,IAAI,EAAE,MAAM,CAAC;IAEb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,iBAoCpE"}