@alloy-js/csharp 0.17.0 → 0.18.0-dev.11
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/ClassDeclaration.d.ts +57 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -0
- package/dist/src/components/{Class.js → ClassDeclaration.js} +42 -53
- package/dist/src/components/ClassMethod.d.ts +25 -0
- package/dist/src/components/ClassMethod.d.ts.map +1 -0
- package/dist/src/components/ClassMethod.js +60 -0
- package/dist/src/components/EnumDeclaration.d.ts +34 -0
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -0
- package/dist/src/components/{Enum.js → EnumDeclaration.js} +25 -5
- package/dist/src/components/class/property.d.ts +55 -0
- package/dist/src/components/class/property.d.ts.map +1 -0
- package/dist/src/components/class/property.js +67 -0
- package/dist/src/components/class/property.test.d.ts +2 -0
- package/dist/src/components/class/property.test.d.ts.map +1 -0
- package/dist/src/components/class/property.test.js +201 -0
- package/dist/src/components/doc/comment.d.ts +70 -0
- package/dist/src/components/doc/comment.d.ts.map +1 -0
- package/dist/src/components/doc/comment.js +88 -0
- package/dist/src/components/doc/comment.test.d.ts +2 -0
- package/dist/src/components/doc/comment.test.d.ts.map +1 -0
- package/dist/src/components/doc/comment.test.js +348 -0
- 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 -2
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +9 -2
- package/dist/src/components/interface/declaration.d.ts +34 -0
- package/dist/src/components/interface/declaration.d.ts.map +1 -0
- package/dist/src/components/interface/declaration.js +90 -0
- package/dist/src/components/interface/declaration.test.d.ts +2 -0
- package/dist/src/components/interface/declaration.test.d.ts.map +1 -0
- package/dist/src/components/interface/declaration.test.js +69 -0
- package/dist/src/components/interface/method.d.ts +18 -0
- package/dist/src/components/interface/method.d.ts.map +1 -0
- package/dist/src/components/interface/method.js +59 -0
- package/dist/src/components/interface/method.test.d.ts +2 -0
- package/dist/src/components/interface/method.test.d.ts.map +1 -0
- package/dist/src/components/interface/method.test.js +131 -0
- package/dist/src/components/interface/property.d.ts +38 -0
- package/dist/src/components/interface/property.d.ts.map +1 -0
- package/dist/src/components/interface/property.js +67 -0
- package/dist/src/components/interface/property.test.d.ts +2 -0
- package/dist/src/components/interface/property.test.d.ts.map +1 -0
- package/dist/src/components/interface/property.test.js +165 -0
- 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 +13 -4
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +13 -27
- 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} +123 -73
- package/dist/test/class-method.test.d.ts +2 -0
- package/dist/test/class-method.test.d.ts.map +1 -0
- package/dist/test/class-method.test.js +161 -0
- package/dist/test/enum.test.js +12 -12
- package/dist/test/namespace.test.js +8 -8
- package/dist/test/project-directory.test.d.ts +2 -0
- package/dist/test/project-directory.test.d.ts.map +1 -0
- package/dist/test/{projectdirectory.test.js → project-directory.test.js} +8 -8
- package/dist/test/sourcefile.test.js +4 -4
- package/dist/test/using.test.js +9 -9
- package/dist/test/utils.d.ts +3 -0
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +15 -0
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/components/{Class.tsx → ClassDeclaration.tsx} +68 -66
- package/src/components/ClassMethod.tsx +94 -0
- package/src/components/{Enum.tsx → EnumDeclaration.tsx} +30 -6
- package/src/components/class/property.test.tsx +180 -0
- package/src/components/class/property.tsx +135 -0
- package/src/components/doc/comment.test.tsx +337 -0
- package/src/components/doc/comment.tsx +152 -0
- 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 -2
- package/src/components/interface/declaration.test.tsx +56 -0
- package/src/components/interface/declaration.tsx +109 -0
- package/src/components/interface/method.test.tsx +120 -0
- package/src/components/interface/method.tsx +82 -0
- package/src/components/interface/property.test.tsx +144 -0
- package/src/components/interface/property.tsx +107 -0
- package/src/components/stc/index.ts +2 -2
- package/src/modifiers.ts +32 -37
- package/src/name-policy.ts +2 -0
- package/temp/api.json +4419 -567
- package/test/{class.test.tsx → class-declaration.test.tsx} +103 -99
- package/test/class-method.test.tsx +147 -0
- package/test/enum.test.tsx +11 -11
- package/test/namespace.test.tsx +4 -4
- package/test/{projectdirectory.test.tsx → project-directory.test.tsx} +4 -4
- package/test/sourcefile.test.tsx +2 -2
- package/test/using.test.tsx +9 -9
- package/test/utils.tsx +9 -0
- package/test/vitest.setup.ts +1 -0
- package/tsconfig.json +2 -1
- package/vitest.config.ts +3 -0
- package/dist/src/components/Class.d.ts +0 -36
- package/dist/src/components/Class.d.ts.map +0 -1
- package/dist/src/components/Enum.d.ts +0 -15
- package/dist/src/components/Enum.d.ts.map +0 -1
- 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
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { TestNamespace } from "../../../test/utils.js";
|
|
4
|
+
import { ClassDeclaration } from "../ClassDeclaration.js";
|
|
5
|
+
import { ClassProperty } from "./property.js";
|
|
6
|
+
const Wrapper = props => _$createComponent(TestNamespace, {
|
|
7
|
+
get children() {
|
|
8
|
+
return _$createComponent(ClassDeclaration, {
|
|
9
|
+
"public": true,
|
|
10
|
+
name: "TestClass",
|
|
11
|
+
get children() {
|
|
12
|
+
return props.children;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
describe("modifiers", () => {
|
|
18
|
+
describe("access modifiers", () => {
|
|
19
|
+
it.each(["public", "private", "protected", "internal"])("%s", accessModifier => {
|
|
20
|
+
expect(_$createComponent(Wrapper, {
|
|
21
|
+
get children() {
|
|
22
|
+
return _$createComponent(ClassProperty, _$mergeProps({
|
|
23
|
+
[accessModifier]: true
|
|
24
|
+
}, {
|
|
25
|
+
name: "TestProp",
|
|
26
|
+
type: "string",
|
|
27
|
+
get: true
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
})).toRenderTo(`
|
|
31
|
+
public class TestClass
|
|
32
|
+
{
|
|
33
|
+
${accessModifier} string TestProp { get; }
|
|
34
|
+
}
|
|
35
|
+
`);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe("property modifiers", () => {
|
|
39
|
+
it.each(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly"])("%s", methodModifier => {
|
|
40
|
+
expect(_$createComponent(Wrapper, {
|
|
41
|
+
get children() {
|
|
42
|
+
return _$createComponent(ClassProperty, _$mergeProps({
|
|
43
|
+
[methodModifier]: true
|
|
44
|
+
}, {
|
|
45
|
+
name: "TestProp",
|
|
46
|
+
type: "string",
|
|
47
|
+
get: true
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
})).toRenderTo(`
|
|
51
|
+
public class TestClass
|
|
52
|
+
{
|
|
53
|
+
${methodModifier} string TestProp { get; }
|
|
54
|
+
}
|
|
55
|
+
`);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it("combine modifiers", () => {
|
|
59
|
+
expect(_$createComponent(Wrapper, {
|
|
60
|
+
get children() {
|
|
61
|
+
return _$createComponent(ClassProperty, {
|
|
62
|
+
"public": true,
|
|
63
|
+
"new": true,
|
|
64
|
+
name: "TestProp",
|
|
65
|
+
type: "string",
|
|
66
|
+
get: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
})).toRenderTo(`
|
|
70
|
+
public class TestClass
|
|
71
|
+
{
|
|
72
|
+
public new string TestProp { get; }
|
|
73
|
+
}
|
|
74
|
+
`);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
it("applies PascalCase naming policy", () => {
|
|
78
|
+
expect(_$createComponent(Wrapper, {
|
|
79
|
+
get children() {
|
|
80
|
+
return _$createComponent(ClassProperty, {
|
|
81
|
+
name: "test_prop",
|
|
82
|
+
type: "string",
|
|
83
|
+
get: true
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
})).toRenderTo(`
|
|
87
|
+
public class TestClass
|
|
88
|
+
{
|
|
89
|
+
string TestProp { get; }
|
|
90
|
+
}
|
|
91
|
+
`);
|
|
92
|
+
});
|
|
93
|
+
it("has getter only", () => {
|
|
94
|
+
expect(_$createComponent(Wrapper, {
|
|
95
|
+
get children() {
|
|
96
|
+
return _$createComponent(ClassProperty, {
|
|
97
|
+
name: "TestProp",
|
|
98
|
+
type: "string",
|
|
99
|
+
get: true
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
})).toRenderTo(`
|
|
103
|
+
public class TestClass
|
|
104
|
+
{
|
|
105
|
+
string TestProp { get; }
|
|
106
|
+
}
|
|
107
|
+
`);
|
|
108
|
+
});
|
|
109
|
+
it("has setter only", () => {
|
|
110
|
+
expect(_$createComponent(Wrapper, {
|
|
111
|
+
get children() {
|
|
112
|
+
return _$createComponent(ClassProperty, {
|
|
113
|
+
name: "TestProp",
|
|
114
|
+
type: "string",
|
|
115
|
+
set: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
})).toRenderTo(`
|
|
119
|
+
public class TestClass
|
|
120
|
+
{
|
|
121
|
+
string TestProp { set; }
|
|
122
|
+
}
|
|
123
|
+
`);
|
|
124
|
+
});
|
|
125
|
+
it("has getter and setter", () => {
|
|
126
|
+
expect(_$createComponent(Wrapper, {
|
|
127
|
+
get children() {
|
|
128
|
+
return _$createComponent(ClassProperty, {
|
|
129
|
+
name: "TestProp",
|
|
130
|
+
type: "string",
|
|
131
|
+
get: true,
|
|
132
|
+
set: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
})).toRenderTo(`
|
|
136
|
+
public class TestClass
|
|
137
|
+
{
|
|
138
|
+
string TestProp { get; set; }
|
|
139
|
+
}
|
|
140
|
+
`);
|
|
141
|
+
});
|
|
142
|
+
it("specify doc comment", () => {
|
|
143
|
+
expect(_$createComponent(TestNamespace, {
|
|
144
|
+
get children() {
|
|
145
|
+
return _$createComponent(ClassDeclaration, {
|
|
146
|
+
name: "Test",
|
|
147
|
+
get children() {
|
|
148
|
+
return _$createComponent(ClassProperty, {
|
|
149
|
+
name: "Method",
|
|
150
|
+
type: "string",
|
|
151
|
+
get: true,
|
|
152
|
+
set: true,
|
|
153
|
+
doc: "This is a test"
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
})).toRenderTo(`
|
|
159
|
+
class Test
|
|
160
|
+
{
|
|
161
|
+
/// This is a test
|
|
162
|
+
string Method { get; set; }
|
|
163
|
+
}
|
|
164
|
+
`);
|
|
165
|
+
});
|
|
166
|
+
it("specify nullable property", () => {
|
|
167
|
+
expect(_$createComponent(Wrapper, {
|
|
168
|
+
get children() {
|
|
169
|
+
return _$createComponent(ClassProperty, {
|
|
170
|
+
name: "TestProp",
|
|
171
|
+
type: "string",
|
|
172
|
+
nullable: true,
|
|
173
|
+
get: true,
|
|
174
|
+
set: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
})).toRenderTo(`
|
|
178
|
+
public class TestClass
|
|
179
|
+
{
|
|
180
|
+
string? TestProp { get; set; }
|
|
181
|
+
}
|
|
182
|
+
`);
|
|
183
|
+
});
|
|
184
|
+
it("specify initializer", () => {
|
|
185
|
+
expect(_$createComponent(Wrapper, {
|
|
186
|
+
get children() {
|
|
187
|
+
return _$createComponent(ClassProperty, {
|
|
188
|
+
name: "TestProp",
|
|
189
|
+
type: "string",
|
|
190
|
+
get: true,
|
|
191
|
+
set: true,
|
|
192
|
+
init: `"abc"`
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
})).toRenderTo(`
|
|
196
|
+
public class TestClass
|
|
197
|
+
{
|
|
198
|
+
string TestProp { get; set; } = "abc";
|
|
199
|
+
}
|
|
200
|
+
`);
|
|
201
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
|
+
export interface DocCommentProps {
|
|
3
|
+
children: Children;
|
|
4
|
+
}
|
|
5
|
+
export declare function DocComment(props: DocCommentProps): Children;
|
|
6
|
+
export interface DocWhenProps {
|
|
7
|
+
doc: Children | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** Conditionally render the given doc in a <DocComment /> component and tail with a line */
|
|
10
|
+
export declare function DocWhen(props: DocWhenProps): Children;
|
|
11
|
+
export interface DocCommentTagProps {
|
|
12
|
+
children: Children;
|
|
13
|
+
}
|
|
14
|
+
export declare function makeDocCommentTag(name: string): (props: DocCommentProps) => Children;
|
|
15
|
+
export declare function makeInlineDocCommentTag(name: string): (props: DocCommentProps) => string;
|
|
16
|
+
export declare const DocSummary: (props: DocCommentProps) => Children;
|
|
17
|
+
export declare const DocCode: (props: DocCommentProps) => Children;
|
|
18
|
+
export declare const DocC: (props: DocCommentProps) => string;
|
|
19
|
+
export declare const DocExample: (props: DocCommentProps) => Children;
|
|
20
|
+
export declare const DocException: (props: DocCommentProps) => Children;
|
|
21
|
+
export interface DocIncludeProps {
|
|
22
|
+
/** is the file name of an external XML file. The file name is interpreted relative to the file that contains the include tag. */
|
|
23
|
+
file: string;
|
|
24
|
+
/** is an XPath expression that selects some of the XML in the external XML file. */
|
|
25
|
+
path?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const DocInclude: (props: DocIncludeProps) => string;
|
|
28
|
+
export interface DocParamProps {
|
|
29
|
+
name: string;
|
|
30
|
+
children: Children;
|
|
31
|
+
}
|
|
32
|
+
export declare const DocParam: (props: DocParamProps) => Children;
|
|
33
|
+
export interface DocTypeParamProps {
|
|
34
|
+
name: string;
|
|
35
|
+
children: Children;
|
|
36
|
+
}
|
|
37
|
+
export declare const DocTypeParam: (props: DocTypeParamProps) => Children;
|
|
38
|
+
export declare const DocReturns: (props: DocCommentProps) => Children;
|
|
39
|
+
export declare const DocRemarks: (props: DocCommentProps) => Children;
|
|
40
|
+
export declare const DocValue: (props: DocCommentProps) => Children;
|
|
41
|
+
export declare const DocPermission: (props: DocCommentProps) => Children;
|
|
42
|
+
export declare const DocDescription: (props: DocCommentProps) => Children;
|
|
43
|
+
export declare const DocPara: (props: DocCommentProps) => Children;
|
|
44
|
+
export interface DocSeeProps {
|
|
45
|
+
cref?: string;
|
|
46
|
+
href?: string;
|
|
47
|
+
langword?: string;
|
|
48
|
+
children?: Children;
|
|
49
|
+
}
|
|
50
|
+
export declare const DocSee: (props: DocSeeProps) => Children;
|
|
51
|
+
export interface DocSeeAlsoProps {
|
|
52
|
+
cref?: string;
|
|
53
|
+
href?: string;
|
|
54
|
+
children?: Children;
|
|
55
|
+
}
|
|
56
|
+
export declare const DocSeeAlso: (props: DocSeeAlsoProps) => Children;
|
|
57
|
+
export interface DocParamRefProps {
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
export declare const DocParamRef: (props: DocParamRefProps) => string;
|
|
61
|
+
export interface DocTypeParamRefProps {
|
|
62
|
+
name: string;
|
|
63
|
+
}
|
|
64
|
+
export declare const DocTypeParamRef: (props: DocTypeParamRefProps) => string;
|
|
65
|
+
export interface DocListProps {
|
|
66
|
+
type?: "bullet" | "number";
|
|
67
|
+
items: Children[];
|
|
68
|
+
}
|
|
69
|
+
export declare function DocList(props: DocListProps): Children;
|
|
70
|
+
//# sourceMappingURL=comment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/comment.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code, For, Indent, List, Prose, Show } from "@alloy-js/core";
|
|
3
|
+
export function DocComment(props) {
|
|
4
|
+
return ["/// ", _$createIntrinsic("align", {
|
|
5
|
+
string: "/// ",
|
|
6
|
+
get children() {
|
|
7
|
+
return _$createComponent(List, {
|
|
8
|
+
get children() {
|
|
9
|
+
return props.children;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
})];
|
|
14
|
+
}
|
|
15
|
+
/** Conditionally render the given doc in a <DocComment /> component and tail with a line */
|
|
16
|
+
export function DocWhen(props) {
|
|
17
|
+
return _$createComponent(Show, {
|
|
18
|
+
get when() {
|
|
19
|
+
return Boolean(props.doc);
|
|
20
|
+
},
|
|
21
|
+
get children() {
|
|
22
|
+
return [_$createComponent(DocComment, {
|
|
23
|
+
get children() {
|
|
24
|
+
return props.doc;
|
|
25
|
+
}
|
|
26
|
+
}), _$createIntrinsic("hbr", {})];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function makeDocCommentTag(name) {
|
|
31
|
+
return function DocCommentTag(props) {
|
|
32
|
+
return _$createComponent(Prose, {
|
|
33
|
+
get children() {
|
|
34
|
+
return code`
|
|
35
|
+
<${name}>
|
|
36
|
+
${props.children}
|
|
37
|
+
</${name}>`;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function makeInlineDocCommentTag(name) {
|
|
43
|
+
return function DocCommentTag(props) {
|
|
44
|
+
return `<${name}>${props.children}</${name}>`;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export const DocSummary = makeDocCommentTag("summary");
|
|
48
|
+
export const DocCode = makeDocCommentTag("code");
|
|
49
|
+
export const DocC = makeInlineDocCommentTag("c");
|
|
50
|
+
export const DocExample = makeDocCommentTag("example");
|
|
51
|
+
export const DocException = makeDocCommentTag("exception");
|
|
52
|
+
export const DocInclude = props => {
|
|
53
|
+
return `<include file="${props.file}" path="${props.path}" />`;
|
|
54
|
+
};
|
|
55
|
+
export const DocParam = props => code`<param name="${props.name}">${props.children}</param>`;
|
|
56
|
+
export const DocTypeParam = props => code`<typeparam name="${props.name}">${props.children}</typeparam>`;
|
|
57
|
+
export const DocReturns = makeDocCommentTag("returns");
|
|
58
|
+
export const DocRemarks = makeDocCommentTag("remarks");
|
|
59
|
+
export const DocValue = makeDocCommentTag("value");
|
|
60
|
+
export const DocPermission = makeDocCommentTag("permission");
|
|
61
|
+
export const DocDescription = makeDocCommentTag("description");
|
|
62
|
+
export const DocPara = makeDocCommentTag("para");
|
|
63
|
+
export const DocSee = props => {
|
|
64
|
+
const attributes = [props.cref ? `cref="${props.cref}"` : undefined, props.href ? `href="${props.href}"` : undefined, props.langword ? `langword="${props.langword}"` : undefined].filter(Boolean).join(" ");
|
|
65
|
+
return code`<see ${attributes}${props.children ? code`>${props.children}</see>` : " />"}`;
|
|
66
|
+
};
|
|
67
|
+
export const DocSeeAlso = props => {
|
|
68
|
+
const attributes = [props.cref ? `cref="${props.cref}"` : undefined, props.href ? `href="${props.href}"` : undefined].filter(Boolean).join(" ");
|
|
69
|
+
return code`<seealso ${attributes}${props.children ? code`>${props.children}</seealso>` : " />"}`;
|
|
70
|
+
};
|
|
71
|
+
export const DocParamRef = props => `<paramref name="${props.name}" />`;
|
|
72
|
+
export const DocTypeParamRef = props => `<typeparamref name="${props.name}" />`;
|
|
73
|
+
export function DocList(props) {
|
|
74
|
+
return _$createComponent(Prose, {
|
|
75
|
+
get children() {
|
|
76
|
+
return [_$memo(() => `<list type="${props.type ?? "bullet"}">`), _$createComponent(Indent, {
|
|
77
|
+
get children() {
|
|
78
|
+
return _$createComponent(For, {
|
|
79
|
+
get each() {
|
|
80
|
+
return props.items;
|
|
81
|
+
},
|
|
82
|
+
children: item => code`<item><description>${item}</description></item>`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}), _$createIntrinsic("hbr", {}), `</list>`];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comment.test.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/comment.test.tsx"],"names":[],"mappings":""}
|