@alloy-js/csharp 0.18.0-dev.7 → 0.18.0-dev.9

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 (58) hide show
  1. package/dist/src/components/ClassDeclaration.d.ts +2 -0
  2. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  3. package/dist/src/components/ClassDeclaration.js +6 -1
  4. package/dist/src/components/ClassMethod.d.ts +2 -0
  5. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  6. package/dist/src/components/ClassMethod.js +6 -1
  7. package/dist/src/components/doc/comment.d.ts +70 -0
  8. package/dist/src/components/doc/comment.d.ts.map +1 -0
  9. package/dist/src/components/doc/comment.js +88 -0
  10. package/dist/src/components/doc/comment.test.d.ts +2 -0
  11. package/dist/src/components/doc/comment.test.d.ts.map +1 -0
  12. package/dist/src/components/doc/comment.test.js +348 -0
  13. package/dist/src/components/doc/from-markdown.d.ts +6 -0
  14. package/dist/src/components/doc/from-markdown.d.ts.map +1 -0
  15. package/dist/src/components/doc/from-markdown.js +58 -0
  16. package/dist/src/components/doc/from-markdown.test.d.ts +2 -0
  17. package/dist/src/components/doc/from-markdown.test.d.ts.map +1 -0
  18. package/dist/src/components/doc/from-markdown.test.js +83 -0
  19. package/dist/src/components/index.d.ts +2 -0
  20. package/dist/src/components/index.d.ts.map +1 -1
  21. package/dist/src/components/index.js +2 -0
  22. package/dist/src/components/interface/declaration.d.ts +2 -0
  23. package/dist/src/components/interface/declaration.d.ts.map +1 -1
  24. package/dist/src/components/interface/declaration.js +6 -1
  25. package/dist/src/components/interface/declaration.test.js +13 -0
  26. package/dist/src/components/interface/method.d.ts +2 -0
  27. package/dist/src/components/interface/method.d.ts.map +1 -1
  28. package/dist/src/components/interface/method.js +6 -1
  29. package/dist/src/components/interface/method.test.js +21 -0
  30. package/dist/src/components/interface/property.d.ts +2 -0
  31. package/dist/src/components/interface/property.d.ts.map +1 -1
  32. package/dist/src/components/interface/property.js +7 -2
  33. package/dist/src/components/interface/property.test.js +24 -0
  34. package/dist/test/class-method.test.js +21 -0
  35. package/dist/test/class.test.js +13 -0
  36. package/dist/test/vitest.setup.d.ts +2 -0
  37. package/dist/test/vitest.setup.d.ts.map +1 -0
  38. package/dist/test/vitest.setup.js +1 -0
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +3 -2
  41. package/src/components/ClassDeclaration.tsx +4 -0
  42. package/src/components/ClassMethod.tsx +5 -0
  43. package/src/components/doc/comment.test.tsx +337 -0
  44. package/src/components/doc/comment.tsx +152 -0
  45. package/src/components/doc/from-markdown.test.tsx +103 -0
  46. package/src/components/doc/from-markdown.tsx +58 -0
  47. package/src/components/index.ts +2 -0
  48. package/src/components/interface/declaration.test.tsx +11 -0
  49. package/src/components/interface/declaration.tsx +5 -0
  50. package/src/components/interface/method.test.tsx +16 -0
  51. package/src/components/interface/method.tsx +5 -0
  52. package/src/components/interface/property.test.tsx +22 -0
  53. package/src/components/interface/property.tsx +5 -0
  54. package/temp/api.json +2140 -154
  55. package/test/class-method.test.tsx +16 -0
  56. package/test/class.test.tsx +11 -0
  57. package/test/vitest.setup.ts +1 -0
  58. package/vitest.config.ts +3 -0
@@ -0,0 +1,337 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import {
3
+ DocC,
4
+ DocCode,
5
+ DocComment,
6
+ DocDescription,
7
+ DocExample,
8
+ DocException,
9
+ DocInclude,
10
+ DocList,
11
+ DocPara,
12
+ DocParam,
13
+ DocParamRef,
14
+ DocPermission,
15
+ DocRemarks,
16
+ DocReturns,
17
+ DocSee,
18
+ DocSeeAlso,
19
+ DocSummary,
20
+ DocTypeParam,
21
+ DocTypeParamRef,
22
+ DocValue,
23
+ } from "./comment.jsx";
24
+
25
+ it("define summary", () => {
26
+ expect(
27
+ <DocComment>
28
+ <DocSummary>This is a sample doc comment</DocSummary>
29
+ </DocComment>,
30
+ ).toRenderTo(`
31
+ /// <summary>
32
+ /// This is a sample doc comment
33
+ /// </summary>
34
+ `);
35
+ });
36
+
37
+ it("define code", () => {
38
+ expect(
39
+ <DocComment>
40
+ <DocCode>code sample</DocCode>
41
+ </DocComment>,
42
+ ).toRenderTo(`
43
+ /// <code>
44
+ /// code sample
45
+ /// </code>
46
+ `);
47
+ });
48
+
49
+ it("define c", () => {
50
+ expect(
51
+ <DocComment>
52
+ <DocC>inline code</DocC>
53
+ </DocComment>,
54
+ ).toRenderTo(`
55
+ /// <c>inline code</c>
56
+ `);
57
+ });
58
+
59
+ it("define example", () => {
60
+ expect(
61
+ <DocComment>
62
+ <DocExample>example usage</DocExample>
63
+ </DocComment>,
64
+ ).toRenderTo(`
65
+ /// <example>
66
+ /// example usage
67
+ /// </example>
68
+ `);
69
+ });
70
+
71
+ it("define exception", () => {
72
+ expect(
73
+ <DocComment>
74
+ <DocException>exception info</DocException>
75
+ </DocComment>,
76
+ ).toRenderTo(`
77
+ /// <exception>
78
+ /// exception info
79
+ /// </exception>
80
+ `);
81
+ });
82
+
83
+ it("define include", () => {
84
+ expect(
85
+ <DocComment>
86
+ <DocInclude file="external.xml" path="/doc/summary" />
87
+ </DocComment>,
88
+ ).toRenderTo(`
89
+ /// <include file="external.xml" path="/doc/summary" />
90
+ `);
91
+ });
92
+
93
+ it("define param", () => {
94
+ expect(
95
+ <DocComment>
96
+ <DocParam name="x">parameter x</DocParam>
97
+ </DocComment>,
98
+ ).toRenderTo(`
99
+ /// <param name="x">parameter x</param>
100
+ `);
101
+ });
102
+
103
+ it("define typeparam", () => {
104
+ expect(
105
+ <DocComment>
106
+ <DocTypeParam name="T">type parameter T</DocTypeParam>
107
+ </DocComment>,
108
+ ).toRenderTo(`
109
+ /// <typeparam name="T">type parameter T</typeparam>
110
+ `);
111
+ });
112
+
113
+ it("define returns", () => {
114
+ expect(
115
+ <DocComment>
116
+ <DocReturns>return value</DocReturns>
117
+ </DocComment>,
118
+ ).toRenderTo(`
119
+ /// <returns>
120
+ /// return value
121
+ /// </returns>
122
+ `);
123
+ });
124
+
125
+ it("define remarks", () => {
126
+ expect(
127
+ <DocComment>
128
+ <DocRemarks>remarks here</DocRemarks>
129
+ </DocComment>,
130
+ ).toRenderTo(`
131
+ /// <remarks>
132
+ /// remarks here
133
+ /// </remarks>
134
+ `);
135
+ });
136
+
137
+ it("define value", () => {
138
+ expect(
139
+ <DocComment>
140
+ <DocValue>property value</DocValue>
141
+ </DocComment>,
142
+ ).toRenderTo(`
143
+ /// <value>
144
+ /// property value
145
+ /// </value>
146
+ `);
147
+ });
148
+
149
+ it("define permission", () => {
150
+ expect(
151
+ <DocComment>
152
+ <DocPermission>permission info</DocPermission>
153
+ </DocComment>,
154
+ ).toRenderTo(`
155
+ /// <permission>
156
+ /// permission info
157
+ /// </permission>
158
+ `);
159
+ });
160
+
161
+ it("define list", () => {
162
+ expect(
163
+ <DocComment>
164
+ <DocList type="bullet" items={["item 1", "item 2", "item 3"]} />
165
+ </DocComment>,
166
+ ).toRenderTo(`
167
+ /// <list type="bullet">
168
+ /// <item><description>item 1</description></item>
169
+ /// <item><description>item 2</description></item>
170
+ /// <item><description>item 3</description></item>
171
+ /// </list>
172
+ `);
173
+ });
174
+
175
+ it("define description", () => {
176
+ expect(
177
+ <DocComment>
178
+ <DocDescription>description content</DocDescription>
179
+ </DocComment>,
180
+ ).toRenderTo(`
181
+ /// <description>
182
+ /// description content
183
+ /// </description>
184
+ `);
185
+ });
186
+
187
+ it("define para", () => {
188
+ expect(
189
+ <DocComment>
190
+ <DocPara>paragraph content</DocPara>
191
+ </DocComment>,
192
+ ).toRenderTo(`
193
+ /// <para>
194
+ /// paragraph content
195
+ /// </para>
196
+ `);
197
+ });
198
+
199
+ describe("define see", () => {
200
+ it("with cref", () => {
201
+ expect(
202
+ <DocComment>
203
+ <DocSee cref="T:MyType" />
204
+ </DocComment>,
205
+ ).toRenderTo(`
206
+ /// <see cref="T:MyType" />
207
+ `);
208
+ });
209
+
210
+ it("with href", () => {
211
+ expect(
212
+ <DocComment>
213
+ <DocSee href="https://github.com" />
214
+ </DocComment>,
215
+ ).toRenderTo(`
216
+ /// <see href="https://github.com" />
217
+ `);
218
+ });
219
+ it("with href and children", () => {
220
+ expect(
221
+ <DocComment>
222
+ <DocSee href="https://github.com">GitHub</DocSee>
223
+ </DocComment>,
224
+ ).toRenderTo(`
225
+ /// <see href="https://github.com">GitHub</see>
226
+ `);
227
+ });
228
+
229
+ it("with langword", () => {
230
+ expect(
231
+ <DocComment>
232
+ <DocSee langword="keyword" />
233
+ </DocComment>,
234
+ ).toRenderTo(`
235
+ /// <see langword="keyword" />
236
+ `);
237
+ });
238
+ });
239
+
240
+ describe("define seealso", () => {
241
+ it("with cref", () => {
242
+ expect(
243
+ <DocComment>
244
+ <DocSeeAlso cref="T:OtherType" />
245
+ </DocComment>,
246
+ ).toRenderTo(`
247
+ /// <seealso cref="T:OtherType" />
248
+ `);
249
+ });
250
+
251
+ it("with href", () => {
252
+ expect(
253
+ <DocComment>
254
+ <DocSeeAlso href="https://github.com" />
255
+ </DocComment>,
256
+ ).toRenderTo(`
257
+ /// <seealso href="https://github.com" />
258
+ `);
259
+ });
260
+
261
+ it("with children", () => {
262
+ expect(
263
+ <DocComment>
264
+ <DocSeeAlso cref="T:OtherType">OtherType</DocSeeAlso>
265
+ </DocComment>,
266
+ ).toRenderTo(`
267
+ /// <seealso cref="T:OtherType">OtherType</seealso>
268
+ `);
269
+ });
270
+ });
271
+
272
+ it("define paramref", () => {
273
+ expect(
274
+ <DocComment>
275
+ <DocParamRef name="x" />
276
+ </DocComment>,
277
+ ).toRenderTo(`
278
+ /// <paramref name="${"x"}" />
279
+ `);
280
+ });
281
+
282
+ it("define typeparamref", () => {
283
+ expect(
284
+ <DocComment>
285
+ <DocTypeParamRef name="T" />
286
+ </DocComment>,
287
+ ).toRenderTo(`
288
+ /// <typeparamref name="T" />
289
+ `);
290
+ });
291
+
292
+ it("wrap long summary", () => {
293
+ expect(
294
+ <DocComment>
295
+ <DocSummary>
296
+ This is a very long sample doc comment that exceeds the typical line
297
+ length limit and should be wrapped appropriately in the generated
298
+ documentation.
299
+ </DocSummary>
300
+ </DocComment>,
301
+ ).toRenderTo(`
302
+ /// <summary>
303
+ /// This is a very long sample doc comment that exceeds the typical line length limit
304
+ /// and should be wrapped appropriately in the generated documentation.
305
+ /// </summary>
306
+ `);
307
+ });
308
+
309
+ it("combine multiple tags", () => {
310
+ expect(
311
+ <DocComment>
312
+ <DocSummary>
313
+ This operator determines whether two Points have the same location.
314
+ </DocSummary>
315
+ <DocParam name="p1">The first Point to be compared.</DocParam>
316
+ <DocParam name="p2">The second Point to be compared.</DocParam>
317
+ <DocReturns>
318
+ True if the Points do not have the same location and the exact same
319
+ type; otherwise, false.
320
+ </DocReturns>
321
+ <DocSeeAlso cref="Equals" />
322
+ <DocSeeAlso cref="operator==" />
323
+ </DocComment>,
324
+ ).toRenderTo(`
325
+ /// <summary>
326
+ /// This operator determines whether two Points have the same location.
327
+ /// </summary>
328
+ /// <param name="p1">The first Point to be compared.</param>
329
+ /// <param name="p2">The second Point to be compared.</param>
330
+ /// <returns>
331
+ /// True if the Points do not have the same location and the exact same type; otherwise,
332
+ /// false.
333
+ /// </returns>
334
+ /// <seealso cref="Equals" />
335
+ /// <seealso cref="operator==" />
336
+ `);
337
+ });
@@ -0,0 +1,152 @@
1
+ import { Children, code, For, Indent, List, Prose, Show } from "@alloy-js/core";
2
+
3
+ export interface DocCommentProps {
4
+ children: Children;
5
+ }
6
+
7
+ export function DocComment(props: DocCommentProps) {
8
+ return (
9
+ <>
10
+ {"/// "}
11
+ <align string="/// ">
12
+ <List>{props.children}</List>
13
+ </align>
14
+ </>
15
+ );
16
+ }
17
+
18
+ export interface DocWhenProps {
19
+ doc: Children | undefined;
20
+ }
21
+
22
+ /** Conditionally render the given doc in a <DocComment /> component and tail with a line */
23
+ export function DocWhen(props: DocWhenProps) {
24
+ return (
25
+ <Show when={Boolean(props.doc)}>
26
+ <DocComment children={props.doc} />
27
+ <hbr />
28
+ </Show>
29
+ );
30
+ }
31
+
32
+ export interface DocCommentTagProps {
33
+ children: Children;
34
+ }
35
+
36
+ export function makeDocCommentTag(name: string) {
37
+ return function DocCommentTag(props: DocCommentProps) {
38
+ return (
39
+ <Prose>
40
+ {code`
41
+ <${name}>
42
+ ${props.children}
43
+ </${name}>`}
44
+ </Prose>
45
+ );
46
+ };
47
+ }
48
+ export function makeInlineDocCommentTag(name: string) {
49
+ return function DocCommentTag(props: DocCommentProps) {
50
+ return `<${name}>${props.children}</${name}>`;
51
+ };
52
+ }
53
+
54
+ export const DocSummary = makeDocCommentTag("summary");
55
+ export const DocCode = makeDocCommentTag("code");
56
+ export const DocC = makeInlineDocCommentTag("c");
57
+ export const DocExample = makeDocCommentTag("example");
58
+ export const DocException = makeDocCommentTag("exception");
59
+
60
+ export interface DocIncludeProps {
61
+ /** is the file name of an external XML file. The file name is interpreted relative to the file that contains the include tag. */
62
+ file: string;
63
+ /** is an XPath expression that selects some of the XML in the external XML file. */
64
+ path?: string;
65
+ }
66
+ export const DocInclude = (props: DocIncludeProps) => {
67
+ return `<include file="${props.file}" path="${props.path}" />`;
68
+ };
69
+
70
+ export interface DocParamProps {
71
+ name: string;
72
+ children: Children;
73
+ }
74
+ export const DocParam = (props: DocParamProps) =>
75
+ code`<param name="${props.name}">${props.children}</param>`;
76
+
77
+ export interface DocTypeParamProps {
78
+ name: string;
79
+ children: Children;
80
+ }
81
+ export const DocTypeParam = (props: DocTypeParamProps) =>
82
+ code`<typeparam name="${props.name}">${props.children}</typeparam>`;
83
+
84
+ export const DocReturns = makeDocCommentTag("returns");
85
+ export const DocRemarks = makeDocCommentTag("remarks");
86
+ export const DocValue = makeDocCommentTag("value");
87
+ export const DocPermission = makeDocCommentTag("permission");
88
+ export const DocDescription = makeDocCommentTag("description");
89
+ export const DocPara = makeDocCommentTag("para");
90
+
91
+ export interface DocSeeProps {
92
+ cref?: string;
93
+ href?: string;
94
+ langword?: string;
95
+ children?: Children;
96
+ }
97
+ export const DocSee = (props: DocSeeProps) => {
98
+ const attributes = [
99
+ props.cref ? `cref="${props.cref}"` : undefined,
100
+ props.href ? `href="${props.href}"` : undefined,
101
+ props.langword ? `langword="${props.langword}"` : undefined,
102
+ ]
103
+ .filter(Boolean)
104
+ .join(" ");
105
+ return code`<see ${attributes}${props.children ? code`>${props.children}</see>` : " />"}`;
106
+ };
107
+
108
+ export interface DocSeeAlsoProps {
109
+ cref?: string;
110
+ href?: string;
111
+ children?: Children;
112
+ }
113
+ export const DocSeeAlso = (props: DocSeeAlsoProps) => {
114
+ const attributes = [
115
+ props.cref ? `cref="${props.cref}"` : undefined,
116
+ props.href ? `href="${props.href}"` : undefined,
117
+ ]
118
+ .filter(Boolean)
119
+ .join(" ");
120
+ return code`<seealso ${attributes}${props.children ? code`>${props.children}</seealso>` : " />"}`;
121
+ };
122
+
123
+ export interface DocParamRefProps {
124
+ name: string;
125
+ }
126
+ export const DocParamRef = (props: DocParamRefProps) =>
127
+ `<paramref name="${props.name}" />`;
128
+
129
+ export interface DocTypeParamRefProps {
130
+ name: string;
131
+ }
132
+ export const DocTypeParamRef = (props: DocTypeParamRefProps) =>
133
+ `<typeparamref name="${props.name}" />`;
134
+
135
+ export interface DocListProps {
136
+ type?: "bullet" | "number";
137
+ items: Children[];
138
+ }
139
+ export function DocList(props: DocListProps) {
140
+ return (
141
+ <Prose>
142
+ {`<list type="${props.type ?? "bullet"}">`}
143
+ <Indent>
144
+ <For each={props.items}>
145
+ {(item) => code`<item><description>${item}</description></item>`}
146
+ </For>
147
+ </Indent>
148
+ <hbr />
149
+ {`</list>`}
150
+ </Prose>
151
+ );
152
+ }
@@ -0,0 +1,103 @@
1
+ import { d } from "@alloy-js/core/testing";
2
+ import { describe, expect, it } from "vitest";
3
+ import { DocFromMarkdown } from "./from-markdown.jsx";
4
+
5
+ it("convert code block to <code>", () => {
6
+ expect(
7
+ <DocFromMarkdown
8
+ markdown={d`
9
+ Some markdown with code
10
+ \`\`\`csharp
11
+ var foo = "bar";
12
+ \`\`\`
13
+ `}
14
+ />,
15
+ ).toRenderTo(`
16
+ Some markdown with code
17
+ <code>
18
+ var foo = "bar";
19
+ </code>
20
+ `);
21
+ });
22
+
23
+ it("convert inline code block to <c>", () => {
24
+ expect(
25
+ <DocFromMarkdown
26
+ markdown={d`
27
+ Some markdown with \`inline\` code
28
+ `}
29
+ />,
30
+ ).toRenderTo(`
31
+ Some markdown with <c>inline</c> code
32
+ `);
33
+ });
34
+
35
+ it("convert link to <see>", () => {
36
+ expect(
37
+ <DocFromMarkdown
38
+ markdown={d`
39
+ Some markdown with [link](https://example.com)
40
+ `}
41
+ />,
42
+ ).toRenderTo(`
43
+ Some markdown with <see href="https://example.com">link</see>
44
+ `);
45
+ });
46
+
47
+ it("convert bullet list to <list>", () => {
48
+ expect(
49
+ <DocFromMarkdown
50
+ markdown={d`
51
+ - Item 1
52
+ - Item 2
53
+ - Item 3
54
+ `}
55
+ />,
56
+ ).toRenderTo(`
57
+ <list type="bullet">
58
+ <item><description>Item 1</description></item>
59
+ <item><description>Item 2</description></item>
60
+ <item><description>Item 3</description></item>
61
+ </list>
62
+ `);
63
+ });
64
+
65
+ it("convert numbered list to <list>", () => {
66
+ expect(
67
+ <DocFromMarkdown
68
+ markdown={d`
69
+ 1. Item 1
70
+ 2. Item 2
71
+ 3. Item 3
72
+ `}
73
+ />,
74
+ ).toRenderTo(`
75
+ <list type="number">
76
+ <item><description>Item 1</description></item>
77
+ <item><description>Item 2</description></item>
78
+ <item><description>Item 3</description></item>
79
+ </list>
80
+ `);
81
+ });
82
+
83
+ describe("strip unsupported elements", () => {
84
+ it("bold", () => {
85
+ expect(
86
+ <DocFromMarkdown
87
+ markdown={d`
88
+ Some markdown with **bold** text
89
+ `}
90
+ />,
91
+ ).toRenderTo(`Some markdown with bold text`);
92
+ });
93
+
94
+ it("italic", () => {
95
+ expect(
96
+ <DocFromMarkdown
97
+ markdown={d`
98
+ Some markdown with *italic* text
99
+ `}
100
+ />,
101
+ ).toRenderTo(`Some markdown with italic text`);
102
+ });
103
+ });
@@ -0,0 +1,58 @@
1
+ import { marked, Tokens, type Token } from "marked";
2
+ import { DocC, DocCode, DocList, DocSee } from "./comment.jsx";
3
+
4
+ export interface DocFromMarkdownProps {
5
+ markdown: string;
6
+ }
7
+
8
+ /** Convert markdown to a Csharp doc comment */
9
+ export function DocFromMarkdown(props: DocFromMarkdownProps) {
10
+ const tokens = marked.lexer(props.markdown);
11
+ return renderTokens(tokens);
12
+ }
13
+
14
+ function renderTokens(tokens: Token[]) {
15
+ return (
16
+ <>
17
+ {tokens.map((token, index) => (
18
+ <>
19
+ <DocFromMarkedToken token={token} />
20
+ {token.type === "paragraph" && index !== tokens.length - 1 && <br />}
21
+ </>
22
+ ))}
23
+ </>
24
+ );
25
+ }
26
+
27
+ function DocFromMarkedToken(props: { token: Token }) {
28
+ const { token } = props;
29
+ switch (token.type) {
30
+ case "paragraph":
31
+ return token.tokens ? renderTokens(token.tokens) : null;
32
+ case "code":
33
+ return <DocCode>{token.text}</DocCode>;
34
+ case "codespan":
35
+ return <DocC>{token.text}</DocC>;
36
+ case "list":
37
+ return (
38
+ <DocList
39
+ type={token.ordered ? "number" : "bullet"}
40
+ items={token.items.map((x: Tokens.ListItem) => (
41
+ <>{renderTokens(x.tokens)}</>
42
+ ))}
43
+ />
44
+ );
45
+ case "link":
46
+ return (
47
+ <DocSee href={token.href}>
48
+ {token.tokens && renderTokens(token.tokens)}
49
+ </DocSee>
50
+ );
51
+ case "strong":
52
+ case "em":
53
+ return token.text;
54
+ case "text":
55
+ default:
56
+ return token.raw;
57
+ }
58
+ }
@@ -1,6 +1,8 @@
1
1
  export * from "./ClassDeclaration.jsx";
2
2
  export * from "./ClassMethod.jsx";
3
3
  export * from "./Declaration.js";
4
+ export * from "./doc/comment.jsx";
5
+ export * from "./doc/from-markdown.jsx";
4
6
  export * from "./EnumDeclaration.jsx";
5
7
  export * from "./interface/declaration.js";
6
8
  export * from "./interface/method.js";
@@ -43,3 +43,14 @@ describe("modifiers", () => {
43
43
  `);
44
44
  });
45
45
  });
46
+
47
+ it("specify doc comment", () => {
48
+ expect(
49
+ <TestNamespace>
50
+ <InterfaceDeclaration name="TestInterface" doc="This is a test" />
51
+ </TestNamespace>,
52
+ ).toRenderTo(`
53
+ /// This is a test
54
+ interface TestInterface;
55
+ `);
56
+ });
@@ -8,6 +8,7 @@ import {
8
8
  import { useCSharpNamePolicy } from "../../name-policy.js";
9
9
  import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
10
10
  import { CSharpMemberScope } from "../../symbols/scopes.js";
11
+ import { DocWhen } from "../doc/comment.jsx";
11
12
  import { Name } from "../Name.jsx";
12
13
 
13
14
  export interface InterfaceModifiers {
@@ -22,6 +23,9 @@ export interface InterfaceDeclarationProps
22
23
  AccessModifiers,
23
24
  InterfaceModifiers {
24
25
  name: string;
26
+
27
+ /** Doc comment */
28
+ doc?: core.Children;
25
29
  refkey?: core.Refkey;
26
30
  typeParameters?: Record<string, core.Refkey>;
27
31
  }
@@ -92,6 +96,7 @@ export function InterfaceDeclaration(props: InterfaceDeclarationProps) {
92
96
  ]);
93
97
  return (
94
98
  <core.Declaration symbol={thisInterfaceSymbol}>
99
+ <DocWhen doc={props.doc} />
95
100
  {modifiers}interface <Name />
96
101
  {typeParams}
97
102
  {props.children ?