@alloy-js/csharp 0.18.0-dev.8 → 0.18.0
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/CHANGELOG.md +31 -0
- package/dist/src/components/ClassDeclaration.d.ts +39 -2
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +35 -34
- package/dist/src/components/ClassMethod.d.ts +33 -1
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +22 -7
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +1 -0
- package/dist/src/components/attributes/attributes.d.ts +39 -0
- package/dist/src/components/attributes/attributes.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.js +62 -0
- package/dist/src/components/attributes/attributes.test.d.ts +2 -0
- package/dist/src/components/attributes/attributes.test.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.test.js +75 -0
- package/dist/src/components/doc/comment.d.ts +12 -11
- package/dist/src/components/doc/comment.d.ts.map +1 -1
- package/dist/src/components/doc/comment.js +27 -10
- package/dist/src/components/doc/comment.test.js +98 -88
- package/dist/src/components/doc/from-markdown.d.ts +6 -0
- package/dist/src/components/doc/from-markdown.d.ts.map +1 -0
- package/dist/src/components/doc/from-markdown.js +58 -0
- package/dist/src/components/doc/from-markdown.test.d.ts +2 -0
- package/dist/src/components/doc/from-markdown.test.d.ts.map +1 -0
- package/dist/src/components/doc/from-markdown.test.js +83 -0
- package/dist/src/components/index.d.ts +9 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +10 -2
- package/dist/src/components/interface/declaration.d.ts +32 -1
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +18 -25
- package/dist/src/components/interface/declaration.test.js +102 -0
- package/dist/src/components/interface/method.d.ts +33 -1
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +22 -7
- package/dist/src/components/interface/method.test.js +169 -0
- package/dist/src/components/interface/property.d.ts +36 -1
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +18 -4
- package/dist/src/components/interface/property.test.js +24 -0
- package/dist/src/components/parameters/parameters.d.ts +19 -0
- package/dist/src/components/parameters/parameters.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.js +43 -0
- package/dist/src/components/property/property.d.ts +80 -0
- package/dist/src/components/property/property.d.ts.map +1 -0
- package/dist/src/components/property/property.js +76 -0
- package/dist/src/components/property/property.test.d.ts +2 -0
- package/dist/src/components/property/property.test.d.ts.map +1 -0
- package/dist/src/components/property/property.test.js +242 -0
- package/dist/src/components/record/declaration.d.ts +35 -0
- package/dist/src/components/record/declaration.d.ts.map +1 -0
- package/dist/src/components/record/declaration.js +90 -0
- package/dist/src/components/record/declaration.test.d.ts +2 -0
- package/dist/src/components/record/declaration.test.d.ts.map +1 -0
- package/dist/src/components/record/declaration.test.js +94 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +8 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.js +44 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +2 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +67 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts +20 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter.js +22 -0
- package/dist/src/components/type-parameters/type-parameters.d.ts +17 -0
- package/dist/src/components/type-parameters/type-parameters.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.js +54 -0
- package/dist/src/components/type-parameters/type-parameters.test.d.ts +2 -0
- package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.test.js +48 -0
- package/dist/src/components/var/declaration.d.ts +35 -0
- package/dist/src/components/var/declaration.d.ts.map +1 -0
- package/dist/src/components/var/declaration.js +40 -0
- package/dist/src/components/var/declaration.test.d.ts +2 -0
- package/dist/src/components/var/declaration.test.d.ts.map +1 -0
- package/dist/src/components/var/declaration.test.js +73 -0
- 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 +1 -0
- package/dist/test/class-declaration.test.d.ts +2 -0
- package/dist/test/class-declaration.test.d.ts.map +1 -0
- package/dist/test/{class.test.js → class-declaration.test.js} +161 -33
- package/dist/test/project-directory.test.d.ts +2 -0
- package/dist/test/project-directory.test.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/components/ClassDeclaration.tsx +65 -33
- package/src/components/ClassMethod.tsx +46 -4
- package/src/components/SourceFile.tsx +1 -0
- package/src/components/attributes/attributes.test.tsx +61 -0
- package/src/components/attributes/attributes.tsx +100 -0
- package/src/components/doc/comment.test.tsx +80 -79
- package/src/components/doc/comment.tsx +44 -14
- package/src/components/doc/from-markdown.test.tsx +103 -0
- package/src/components/doc/from-markdown.tsx +58 -0
- package/src/components/index.ts +9 -1
- package/src/components/interface/declaration.test.tsx +102 -0
- package/src/components/interface/declaration.tsx +43 -27
- package/src/components/interface/method.test.tsx +173 -0
- package/src/components/interface/method.tsx +45 -5
- package/src/components/interface/property.test.tsx +21 -0
- package/src/components/interface/property.tsx +43 -6
- package/src/components/parameters/parameters.tsx +74 -0
- package/src/components/property/property.test.tsx +209 -0
- package/src/components/property/property.tsx +172 -0
- package/src/components/record/declaration.test.tsx +73 -0
- package/src/components/record/declaration.tsx +109 -0
- package/src/components/type-parameters/type-parameter-constraints.test.tsx +93 -0
- package/src/components/type-parameters/type-parameter-constraints.tsx +46 -0
- package/src/components/type-parameters/type-parameter.tsx +35 -0
- package/src/components/type-parameters/type-parameters.test.tsx +46 -0
- package/src/components/type-parameters/type-parameters.tsx +63 -0
- package/src/components/var/declaration.test.tsx +59 -0
- package/src/components/var/declaration.tsx +47 -0
- package/src/name-policy.ts +3 -0
- package/temp/api.json +5838 -1626
- package/test/{class.test.tsx → class-declaration.test.tsx} +144 -26
- package/dist/src/components/Parameters.d.ts +0 -13
- package/dist/src/components/Parameters.d.ts.map +0 -1
- package/dist/src/components/Parameters.js +0 -34
- package/dist/test/class.test.d.ts +0 -2
- package/dist/test/class.test.d.ts.map +0 -1
- package/dist/test/projectdirectory.test.d.ts +0 -2
- package/dist/test/projectdirectory.test.d.ts.map +0 -1
- package/src/components/Parameters.tsx +0 -51
- /package/dist/test/{projectdirectory.test.js → project-directory.test.js} +0 -0
- /package/test/{projectdirectory.test.tsx → project-directory.test.tsx} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createComponent as _$createComponent
|
|
2
|
-
import { expect, it } from "vitest";
|
|
3
|
-
import { DocC, DocCode, DocComment,
|
|
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
4
|
it("define summary", () => {
|
|
5
5
|
expect(_$createComponent(DocComment, {
|
|
6
6
|
get children() {
|
|
@@ -35,9 +35,7 @@ it("define c", () => {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
})).toRenderTo(`
|
|
38
|
-
/// <c>
|
|
39
|
-
/// inline code
|
|
40
|
-
/// </c>
|
|
38
|
+
/// <c>inline code</c>
|
|
41
39
|
`);
|
|
42
40
|
});
|
|
43
41
|
it("define example", () => {
|
|
@@ -69,10 +67,10 @@ it("define exception", () => {
|
|
|
69
67
|
it("define include", () => {
|
|
70
68
|
expect(_$createComponent(DocComment, {
|
|
71
69
|
get children() {
|
|
72
|
-
return
|
|
70
|
+
return _$createComponent(DocInclude, {
|
|
73
71
|
file: "external.xml",
|
|
74
72
|
path: "/doc/summary"
|
|
75
|
-
})
|
|
73
|
+
});
|
|
76
74
|
}
|
|
77
75
|
})).toRenderTo(`
|
|
78
76
|
/// <include file="external.xml" path="/doc/summary" />
|
|
@@ -154,71 +152,22 @@ it("define permission", () => {
|
|
|
154
152
|
/// </permission>
|
|
155
153
|
`);
|
|
156
154
|
});
|
|
157
|
-
it("define response", () => {
|
|
158
|
-
expect(_$createComponent(DocComment, {
|
|
159
|
-
get children() {
|
|
160
|
-
return _$createComponent(DocResponse, {
|
|
161
|
-
children: "response info"
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
})).toRenderTo(`
|
|
165
|
-
/// <response>
|
|
166
|
-
/// response info
|
|
167
|
-
/// </response>
|
|
168
|
-
`);
|
|
169
|
-
});
|
|
170
|
-
it("define completionlist", () => {
|
|
171
|
-
expect(_$createComponent(DocComment, {
|
|
172
|
-
get children() {
|
|
173
|
-
return _$createComponent(DocCompletionList, {
|
|
174
|
-
children: "completion list"
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
})).toRenderTo(`
|
|
178
|
-
/// <completionlist>
|
|
179
|
-
/// completion list
|
|
180
|
-
/// </completionlist>
|
|
181
|
-
`);
|
|
182
|
-
});
|
|
183
155
|
it("define list", () => {
|
|
184
156
|
expect(_$createComponent(DocComment, {
|
|
185
157
|
get children() {
|
|
186
158
|
return _$createComponent(DocList, {
|
|
187
|
-
|
|
159
|
+
type: "bullet",
|
|
160
|
+
items: ["item 1", "item 2", "item 3"]
|
|
188
161
|
});
|
|
189
162
|
}
|
|
190
163
|
})).toRenderTo(`
|
|
191
|
-
/// <list>
|
|
192
|
-
///
|
|
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>
|
|
193
168
|
/// </list>
|
|
194
169
|
`);
|
|
195
170
|
});
|
|
196
|
-
it("define item", () => {
|
|
197
|
-
expect(_$createComponent(DocComment, {
|
|
198
|
-
get children() {
|
|
199
|
-
return _$createComponent(DocItem, {
|
|
200
|
-
children: "item content"
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
})).toRenderTo(`
|
|
204
|
-
/// <item>
|
|
205
|
-
/// item content
|
|
206
|
-
/// </item>
|
|
207
|
-
`);
|
|
208
|
-
});
|
|
209
|
-
it("define term", () => {
|
|
210
|
-
expect(_$createComponent(DocComment, {
|
|
211
|
-
get children() {
|
|
212
|
-
return _$createComponent(DocTerm, {
|
|
213
|
-
children: "term content"
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
})).toRenderTo(`
|
|
217
|
-
/// <term>
|
|
218
|
-
/// term content
|
|
219
|
-
/// </term>
|
|
220
|
-
`);
|
|
221
|
-
});
|
|
222
171
|
it("define description", () => {
|
|
223
172
|
expect(_$createComponent(DocComment, {
|
|
224
173
|
get children() {
|
|
@@ -245,45 +194,106 @@ it("define para", () => {
|
|
|
245
194
|
/// </para>
|
|
246
195
|
`);
|
|
247
196
|
});
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
+
});
|
|
258
243
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
+
});
|
|
269
279
|
});
|
|
270
280
|
it("define paramref", () => {
|
|
271
281
|
expect(_$createComponent(DocComment, {
|
|
272
282
|
get children() {
|
|
273
|
-
return
|
|
283
|
+
return _$createComponent(DocParamRef, {
|
|
274
284
|
name: "x"
|
|
275
|
-
})
|
|
285
|
+
});
|
|
276
286
|
}
|
|
277
287
|
})).toRenderTo(`
|
|
278
|
-
/// <paramref name="x" />
|
|
288
|
+
/// <paramref name="${"x"}" />
|
|
279
289
|
`);
|
|
280
290
|
});
|
|
281
291
|
it("define typeparamref", () => {
|
|
282
292
|
expect(_$createComponent(DocComment, {
|
|
283
293
|
get children() {
|
|
284
|
-
return
|
|
294
|
+
return _$createComponent(DocTypeParamRef, {
|
|
285
295
|
name: "T"
|
|
286
|
-
})
|
|
296
|
+
});
|
|
287
297
|
}
|
|
288
298
|
})).toRenderTo(`
|
|
289
299
|
/// <typeparamref name="T" />
|
|
@@ -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 @@
|
|
|
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,14 +1,22 @@
|
|
|
1
|
+
export * from "./attributes/attributes.jsx";
|
|
1
2
|
export * from "./ClassDeclaration.jsx";
|
|
2
3
|
export * from "./ClassMethod.jsx";
|
|
3
4
|
export * from "./Declaration.js";
|
|
5
|
+
export * from "./doc/comment.jsx";
|
|
6
|
+
export * from "./doc/from-markdown.jsx";
|
|
4
7
|
export * from "./EnumDeclaration.jsx";
|
|
5
8
|
export * from "./interface/declaration.js";
|
|
6
9
|
export * from "./interface/method.js";
|
|
10
|
+
export * from "./interface/property.js";
|
|
7
11
|
export * from "./Name.js";
|
|
8
12
|
export * from "./Namespace.js";
|
|
9
|
-
export * from "./
|
|
13
|
+
export * from "./parameters/parameters.jsx";
|
|
10
14
|
export * from "./ProjectDirectory.js";
|
|
15
|
+
export * from "./property/property.jsx";
|
|
16
|
+
export * from "./record/declaration.js";
|
|
11
17
|
export * from "./Reference.js";
|
|
12
18
|
export * from "./SourceFile.js";
|
|
19
|
+
export type { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
|
|
13
20
|
export * from "./UsingDirective.js";
|
|
21
|
+
export * from "./var/declaration.jsx";
|
|
14
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,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,13 +1,21 @@
|
|
|
1
|
+
export * from "./attributes/attributes.js";
|
|
1
2
|
export * from "./ClassDeclaration.js";
|
|
2
3
|
export * from "./ClassMethod.js";
|
|
3
4
|
export * from "./Declaration.js";
|
|
5
|
+
export * from "./doc/comment.js";
|
|
6
|
+
export * from "./doc/from-markdown.js";
|
|
4
7
|
export * from "./EnumDeclaration.js";
|
|
5
8
|
export * from "./interface/declaration.js";
|
|
6
9
|
export * from "./interface/method.js";
|
|
10
|
+
export * from "./interface/property.js";
|
|
7
11
|
export * from "./Name.js";
|
|
8
12
|
export * from "./Namespace.js";
|
|
9
|
-
export * from "./
|
|
13
|
+
export * from "./parameters/parameters.js";
|
|
10
14
|
export * from "./ProjectDirectory.js";
|
|
15
|
+
export * from "./property/property.js";
|
|
16
|
+
export * from "./record/declaration.js";
|
|
11
17
|
export * from "./Reference.js";
|
|
12
18
|
export * from "./SourceFile.js";
|
|
13
|
-
export * from "./UsingDirective.js";
|
|
19
|
+
export * from "./UsingDirective.js";
|
|
20
|
+
export * from "./var/declaration.js";
|
|
21
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
2
|
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
+
import { AttributesProp } from "../attributes/attributes.jsx";
|
|
4
|
+
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
3
5
|
export interface InterfaceModifiers {
|
|
4
6
|
readonly partial?: boolean;
|
|
5
7
|
}
|
|
@@ -8,7 +10,36 @@ export interface InterfaceDeclarationProps extends Omit<core.DeclarationProps, "
|
|
|
8
10
|
/** Doc comment */
|
|
9
11
|
doc?: core.Children;
|
|
10
12
|
refkey?: core.Refkey;
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Type parameters for the interface
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <InterfaceDeclaration name="IList" typeParameters={["T"]} />
|
|
19
|
+
* ```
|
|
20
|
+
* This will produce:
|
|
21
|
+
* ```csharp
|
|
22
|
+
* public interface IList<T>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
typeParameters?: (TypeParameterProps | string)[];
|
|
26
|
+
/**
|
|
27
|
+
* Define attributes to attach
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <InterfaceDeclaration name="MyInterface" attributes={[
|
|
31
|
+
* <Attribute name="Test" />
|
|
32
|
+
* <Attribute name="Test2" args={["arg1", "arg2"]} />
|
|
33
|
+
* ]} />
|
|
34
|
+
* ```
|
|
35
|
+
* This will produce:
|
|
36
|
+
* ```csharp
|
|
37
|
+
* [Test]
|
|
38
|
+
* [Test2("arg1", "arg2")]
|
|
39
|
+
* public interface MyInterface
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
attributes?: AttributesProp;
|
|
12
43
|
}
|
|
13
44
|
/**
|
|
14
45
|
* CSharp interface declaration.
|
|
@@ -1 +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;
|
|
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;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI7E,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;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,iBAqCpE"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { createComponent as _$createComponent,
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as core from "@alloy-js/core";
|
|
3
3
|
import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../modifiers.js";
|
|
4
4
|
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
5
5
|
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
6
6
|
import { CSharpMemberScope } from "../../symbols/scopes.js";
|
|
7
|
+
import { AttributeList } from "../attributes/attributes.js";
|
|
7
8
|
import { DocWhen } from "../doc/comment.js";
|
|
8
9
|
import { Name } from "../Name.js";
|
|
10
|
+
import { TypeParameterConstraints } from "../type-parameters/type-parameter-constraints.js";
|
|
11
|
+
import { TypeParameters } from "../type-parameters/type-parameters.js";
|
|
9
12
|
const getInterfaceModifiers = makeModifiers(["partial"]);
|
|
10
13
|
|
|
11
14
|
// properties for creating a class
|
|
@@ -43,29 +46,6 @@ export function InterfaceDeclaration(props) {
|
|
|
43
46
|
const thisInterfaceScope = new CSharpMemberScope("interface-decl", {
|
|
44
47
|
owner: thisInterfaceSymbol
|
|
45
48
|
});
|
|
46
|
-
let typeParams;
|
|
47
|
-
if (props.typeParameters) {
|
|
48
|
-
const typeParamNames = new Array();
|
|
49
|
-
for (const entry of Object.entries(props.typeParameters)) {
|
|
50
|
-
typeParamNames.push(useCSharpNamePolicy().getName(entry[0], "type-parameter"));
|
|
51
|
-
// create a symbol for each type param so its
|
|
52
|
-
// refkey resolves to the type param's name
|
|
53
|
-
new CSharpOutputSymbol(entry[0], {
|
|
54
|
-
scope: thisInterfaceScope,
|
|
55
|
-
refkeys: entry[1]
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
typeParams = _$createIntrinsic("group", {
|
|
59
|
-
get children() {
|
|
60
|
-
return ["<", _$createComponent(core.For, {
|
|
61
|
-
each: typeParamNames,
|
|
62
|
-
comma: true,
|
|
63
|
-
line: true,
|
|
64
|
-
children: name => name
|
|
65
|
-
}), ">"];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
49
|
const modifiers = computeModifiersPrefix([getAccessModifier(props), getInterfaceModifiers(props)]);
|
|
70
50
|
return _$createComponent(core.Declaration, {
|
|
71
51
|
symbol: thisInterfaceSymbol,
|
|
@@ -74,7 +54,20 @@ export function InterfaceDeclaration(props) {
|
|
|
74
54
|
get doc() {
|
|
75
55
|
return props.doc;
|
|
76
56
|
}
|
|
77
|
-
}),
|
|
57
|
+
}), _$createComponent(AttributeList, {
|
|
58
|
+
get attributes() {
|
|
59
|
+
return props.attributes;
|
|
60
|
+
},
|
|
61
|
+
endline: true
|
|
62
|
+
}), modifiers, "interface ", _$createComponent(Name, {}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
|
|
63
|
+
get parameters() {
|
|
64
|
+
return props.typeParameters;
|
|
65
|
+
}
|
|
66
|
+
})), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
|
|
67
|
+
get parameters() {
|
|
68
|
+
return props.typeParameters;
|
|
69
|
+
}
|
|
70
|
+
})), _$memo(() => _$memo(() => !!props.children)() ? _$createComponent(core.Block, {
|
|
78
71
|
newline: true,
|
|
79
72
|
get children() {
|
|
80
73
|
return _$createComponent(core.Scope, {
|