@alloy-js/csharp 0.18.0-dev.18 → 0.18.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/Class.d.ts +26 -0
- package/dist/src/components/Class.d.ts.map +1 -0
- package/dist/src/components/{ClassDeclaration.js → Class.js} +32 -59
- package/dist/src/components/ClassMethod.d.ts +4 -25
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +3 -22
- package/dist/src/components/Enum.d.ts +15 -0
- package/dist/src/components/Enum.d.ts.map +1 -0
- package/dist/src/components/{EnumDeclaration.js → Enum.js} +5 -25
- package/dist/src/components/Parameters.d.ts +1 -6
- package/dist/src/components/Parameters.d.ts.map +1 -1
- package/dist/src/components/Parameters.js +2 -3
- package/dist/src/components/index.d.ts +3 -12
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +4 -13
- package/dist/src/components/stc/index.d.ts +2 -2
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +2 -2
- package/dist/src/modifiers.d.ts +4 -10
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +32 -9
- package/dist/src/name-policy.d.ts +1 -1
- package/dist/src/name-policy.d.ts.map +1 -1
- package/dist/src/name-policy.js +0 -2
- package/dist/test/class-method.test.js +14 -37
- package/dist/test/class.test.d.ts +2 -0
- package/dist/test/class.test.d.ts.map +1 -0
- package/dist/test/class.test.js +298 -0
- package/dist/test/enum.test.js +12 -12
- package/dist/test/namespace.test.js +8 -8
- package/dist/test/projectdirectory.test.d.ts +2 -0
- package/dist/test/projectdirectory.test.d.ts.map +1 -0
- package/dist/test/{project-directory.test.js → projectdirectory.test.js} +8 -8
- package/dist/test/sourcefile.test.js +4 -4
- package/dist/test/using.test.js +9 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/components/{ClassDeclaration.tsx → Class.tsx} +43 -108
- package/src/components/ClassMethod.tsx +12 -53
- package/src/components/{EnumDeclaration.tsx → Enum.tsx} +6 -30
- package/src/components/Parameters.tsx +3 -10
- package/src/components/index.ts +3 -12
- package/src/components/stc/index.ts +2 -2
- package/src/modifiers.ts +42 -25
- package/src/name-policy.ts +0 -5
- package/temp/api.json +714 -5256
- package/test/class-method.test.tsx +14 -24
- package/test/class.test.tsx +292 -0
- package/test/enum.test.tsx +11 -11
- package/test/namespace.test.tsx +4 -4
- package/test/{project-directory.test.tsx → projectdirectory.test.tsx} +4 -4
- package/test/sourcefile.test.tsx +2 -2
- package/test/using.test.tsx +9 -9
- package/vitest.config.ts +0 -3
- package/LICENSE +0 -7
- package/dist/src/components/ClassDeclaration.d.ts +0 -74
- package/dist/src/components/ClassDeclaration.d.ts.map +0 -1
- package/dist/src/components/EnumDeclaration.d.ts +0 -34
- package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
- package/dist/src/components/doc/comment.d.ts +0 -70
- package/dist/src/components/doc/comment.d.ts.map +0 -1
- package/dist/src/components/doc/comment.js +0 -88
- package/dist/src/components/doc/comment.test.d.ts +0 -2
- package/dist/src/components/doc/comment.test.d.ts.map +0 -1
- package/dist/src/components/doc/comment.test.js +0 -348
- package/dist/src/components/doc/from-markdown.d.ts +0 -6
- package/dist/src/components/doc/from-markdown.d.ts.map +0 -1
- package/dist/src/components/doc/from-markdown.js +0 -58
- package/dist/src/components/doc/from-markdown.test.d.ts +0 -2
- package/dist/src/components/doc/from-markdown.test.d.ts.map +0 -1
- package/dist/src/components/doc/from-markdown.test.js +0 -83
- package/dist/src/components/interface/declaration.d.ts +0 -47
- package/dist/src/components/interface/declaration.d.ts.map +0 -1
- package/dist/src/components/interface/declaration.js +0 -77
- package/dist/src/components/interface/declaration.test.d.ts +0 -2
- package/dist/src/components/interface/declaration.test.d.ts.map +0 -1
- package/dist/src/components/interface/declaration.test.js +0 -153
- package/dist/src/components/interface/method.d.ts +0 -32
- package/dist/src/components/interface/method.d.ts.map +0 -1
- package/dist/src/components/interface/method.js +0 -69
- package/dist/src/components/interface/method.test.d.ts +0 -2
- package/dist/src/components/interface/method.test.d.ts.map +0 -1
- package/dist/src/components/interface/method.test.js +0 -254
- package/dist/src/components/interface/property.d.ts +0 -38
- package/dist/src/components/interface/property.d.ts.map +0 -1
- package/dist/src/components/interface/property.js +0 -67
- package/dist/src/components/interface/property.test.d.ts +0 -2
- package/dist/src/components/interface/property.test.d.ts.map +0 -1
- package/dist/src/components/interface/property.test.js +0 -165
- package/dist/src/components/property/property.d.ts +0 -57
- package/dist/src/components/property/property.d.ts.map +0 -1
- package/dist/src/components/property/property.js +0 -70
- package/dist/src/components/property/property.test.d.ts +0 -2
- package/dist/src/components/property/property.test.d.ts.map +0 -1
- package/dist/src/components/property/property.test.js +0 -218
- package/dist/src/components/record/declaration.d.ts +0 -35
- package/dist/src/components/record/declaration.d.ts.map +0 -1
- package/dist/src/components/record/declaration.js +0 -90
- package/dist/src/components/record/declaration.test.d.ts +0 -2
- package/dist/src/components/record/declaration.test.d.ts.map +0 -1
- package/dist/src/components/record/declaration.test.js +0 -94
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +0 -8
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.js +0 -44
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +0 -2
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +0 -67
- package/dist/src/components/type-parameters/type-parameter.d.ts +0 -20
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameter.js +0 -22
- package/dist/src/components/type-parameters/type-parameters.d.ts +0 -17
- package/dist/src/components/type-parameters/type-parameters.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameters.js +0 -65
- package/dist/src/components/type-parameters/type-parameters.test.d.ts +0 -2
- package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameters.test.js +0 -26
- package/dist/src/components/var/declaration.d.ts +0 -35
- package/dist/src/components/var/declaration.d.ts.map +0 -1
- package/dist/src/components/var/declaration.js +0 -40
- package/dist/src/components/var/declaration.test.d.ts +0 -2
- package/dist/src/components/var/declaration.test.d.ts.map +0 -1
- package/dist/src/components/var/declaration.test.js +0 -73
- package/dist/test/class-declaration.test.d.ts +0 -2
- package/dist/test/class-declaration.test.d.ts.map +0 -1
- package/dist/test/class-declaration.test.js +0 -463
- package/dist/test/project-directory.test.d.ts +0 -2
- package/dist/test/project-directory.test.d.ts.map +0 -1
- package/dist/test/vitest.setup.d.ts +0 -2
- package/dist/test/vitest.setup.d.ts.map +0 -1
- package/dist/test/vitest.setup.js +0 -1
- package/src/components/doc/comment.test.tsx +0 -337
- package/src/components/doc/comment.tsx +0 -152
- package/src/components/doc/from-markdown.test.tsx +0 -103
- package/src/components/doc/from-markdown.tsx +0 -58
- package/src/components/interface/declaration.test.tsx +0 -143
- package/src/components/interface/declaration.tsx +0 -105
- package/src/components/interface/method.test.tsx +0 -250
- package/src/components/interface/method.tsx +0 -105
- package/src/components/interface/property.test.tsx +0 -144
- package/src/components/interface/property.tsx +0 -107
- package/src/components/property/property.test.tsx +0 -187
- package/src/components/property/property.tsx +0 -146
- package/src/components/record/declaration.test.tsx +0 -73
- package/src/components/record/declaration.tsx +0 -109
- package/src/components/type-parameters/type-parameter-constraints.test.tsx +0 -93
- package/src/components/type-parameters/type-parameter-constraints.tsx +0 -46
- package/src/components/type-parameters/type-parameter.tsx +0 -35
- package/src/components/type-parameters/type-parameters.test.tsx +0 -19
- package/src/components/type-parameters/type-parameters.tsx +0 -72
- package/src/components/var/declaration.test.tsx +0 -59
- package/src/components/var/declaration.tsx +0 -47
- package/test/class-declaration.test.tsx +0 -418
- package/test/vitest.setup.ts +0 -1
|
@@ -1,337 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
}
|