@alloy-js/csharp 0.18.0-dev.8 → 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.
@@ -15,7 +15,7 @@ export declare function makeDocCommentTag(name: string): (props: DocCommentProps
15
15
  export declare function makeInlineDocCommentTag(name: string): (props: DocCommentProps) => string;
16
16
  export declare const DocSummary: (props: DocCommentProps) => Children;
17
17
  export declare const DocCode: (props: DocCommentProps) => Children;
18
- export declare const DocC: (props: DocCommentProps) => Children;
18
+ export declare const DocC: (props: DocCommentProps) => string;
19
19
  export declare const DocExample: (props: DocCommentProps) => Children;
20
20
  export declare const DocException: (props: DocCommentProps) => Children;
21
21
  export interface DocIncludeProps {
@@ -39,25 +39,21 @@ export declare const DocReturns: (props: DocCommentProps) => Children;
39
39
  export declare const DocRemarks: (props: DocCommentProps) => Children;
40
40
  export declare const DocValue: (props: DocCommentProps) => Children;
41
41
  export declare const DocPermission: (props: DocCommentProps) => Children;
42
- export declare const DocResponse: (props: DocCommentProps) => Children;
43
- export declare const DocCompletionList: (props: DocCommentProps) => Children;
44
- export declare const DocList: (props: DocCommentProps) => Children;
45
- export declare const DocItem: (props: DocCommentProps) => Children;
46
- export declare const DocTerm: (props: DocCommentProps) => Children;
47
42
  export declare const DocDescription: (props: DocCommentProps) => Children;
48
43
  export declare const DocPara: (props: DocCommentProps) => Children;
49
44
  export interface DocSeeProps {
50
- cref: string;
45
+ cref?: string;
46
+ href?: string;
51
47
  langword?: string;
52
48
  children?: Children;
53
49
  }
54
- export declare const DocSee: (props: DocSeeProps) => string;
50
+ export declare const DocSee: (props: DocSeeProps) => Children;
55
51
  export interface DocSeeAlsoProps {
56
- cref: string;
57
- langword?: string;
52
+ cref?: string;
53
+ href?: string;
58
54
  children?: Children;
59
55
  }
60
- export declare const DocSeeAlso: (props: DocSeeAlsoProps) => string;
56
+ export declare const DocSeeAlso: (props: DocSeeAlsoProps) => Children;
61
57
  export interface DocParamRefProps {
62
58
  name: string;
63
59
  }
@@ -66,4 +62,9 @@ export interface DocTypeParamRefProps {
66
62
  name: string;
67
63
  }
68
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;
69
70
  //# sourceMappingURL=comment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/comment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AAEnE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAShD;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC3B;AAED,4FAA4F;AAC5F,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,YAO1C;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,IACd,OAAO,eAAe,cAUrD;AACD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,IACpB,OAAO,eAAe,YAGrD;AAED,eAAO,MAAM,UAAU,UAjBgB,eAAe,aAiBA,CAAC;AACvD,eAAO,MAAM,OAAO,UAlBmB,eAAe,aAkBN,CAAC;AACjD,eAAO,MAAM,IAAI,UAnBsB,eAAe,aAmBZ,CAAC;AAC3C,eAAO,MAAM,UAAU,UApBgB,eAAe,aAoBA,CAAC;AACvD,eAAO,MAAM,YAAY,UArBc,eAAe,aAqBI,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC9B,kIAAkI;IAClI,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;A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BAAgB,WACd,CAAC;AAEtC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,WAClB,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,YAa1C"}
@@ -1,5 +1,5 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { code, List, Prose, Show } from "@alloy-js/core";
2
+ import { code, For, Indent, List, Prose, Show } from "@alloy-js/core";
3
3
  export function DocComment(props) {
4
4
  return ["/// ", _$createIntrinsic("align", {
5
5
  string: "/// ",
@@ -46,7 +46,7 @@ export function makeInlineDocCommentTag(name) {
46
46
  }
47
47
  export const DocSummary = makeDocCommentTag("summary");
48
48
  export const DocCode = makeDocCommentTag("code");
49
- export const DocC = makeDocCommentTag("c");
49
+ export const DocC = makeInlineDocCommentTag("c");
50
50
  export const DocExample = makeDocCommentTag("example");
51
51
  export const DocException = makeDocCommentTag("exception");
52
52
  export const DocInclude = props => {
@@ -58,14 +58,31 @@ export const DocReturns = makeDocCommentTag("returns");
58
58
  export const DocRemarks = makeDocCommentTag("remarks");
59
59
  export const DocValue = makeDocCommentTag("value");
60
60
  export const DocPermission = makeDocCommentTag("permission");
61
- export const DocResponse = makeDocCommentTag("response");
62
- export const DocCompletionList = makeDocCommentTag("completionlist");
63
- export const DocList = makeDocCommentTag("list");
64
- export const DocItem = makeDocCommentTag("item");
65
- export const DocTerm = makeDocCommentTag("term");
66
61
  export const DocDescription = makeDocCommentTag("description");
67
62
  export const DocPara = makeDocCommentTag("para");
68
- export const DocSee = props => `<see cref="${props.cref}"${props.langword ? ` langword="${props.langword}"` : ""}${props.children ? `>${props.children}</see>` : " />"}`;
69
- export const DocSeeAlso = props => `<seealso cref="${props.cref}"${props.langword ? ` langword="${props.langword}"` : ""}${props.children ? `>${props.children}</seealso>` : " />"}`;
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
+ };
70
71
  export const DocParamRef = props => `<paramref name="${props.name}" />`;
71
- export const DocTypeParamRef = props => `<typeparamref 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
+ }
@@ -1,6 +1,6 @@
1
- import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { expect, it } from "vitest";
3
- import { DocC, DocCode, DocComment, DocCompletionList, DocDescription, DocExample, DocException, DocInclude, DocItem, DocList, DocPara, DocParam, DocParamRef, DocPermission, DocRemarks, DocResponse, DocReturns, DocSee, DocSeeAlso, DocSummary, DocTerm, DocTypeParam, DocTypeParamRef, DocValue } from "./comment.js";
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 [_$memo(() => DocInclude({
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
- children: "list content"
159
+ type: "bullet",
160
+ items: ["item 1", "item 2", "item 3"]
188
161
  });
189
162
  }
190
163
  })).toRenderTo(`
191
- /// <list>
192
- /// list content
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
- it("define see", () => {
249
- expect(_$createComponent(DocComment, {
250
- get children() {
251
- return [_$memo(() => DocSee({
252
- cref: "T:MyType"
253
- }))];
254
- }
255
- })).toRenderTo(`
256
- /// <see cref="T:MyType" />
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
- it("define seealso", () => {
260
- expect(_$createComponent(DocComment, {
261
- get children() {
262
- return [_$memo(() => DocSeeAlso({
263
- cref: "T:OtherType"
264
- }))];
265
- }
266
- })).toRenderTo(`
267
- /// <seealso cref="T:OtherType" />
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 [_$memo(() => DocParamRef({
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 [_$memo(() => DocTypeParamRef({
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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=from-markdown.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from-markdown.test.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/from-markdown.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { d } from "@alloy-js/core/testing";
3
+ import { describe, expect, it } from "vitest";
4
+ import { DocFromMarkdown } from "./from-markdown.js";
5
+ it("convert code block to <code>", () => {
6
+ expect(_$createComponent(DocFromMarkdown, {
7
+ markdown: d`
8
+ Some markdown with code
9
+ \`\`\`csharp
10
+ var foo = "bar";
11
+ \`\`\`
12
+ `
13
+ })).toRenderTo(`
14
+ Some markdown with code
15
+ <code>
16
+ var foo = "bar";
17
+ </code>
18
+ `);
19
+ });
20
+ it("convert inline code block to <c>", () => {
21
+ expect(_$createComponent(DocFromMarkdown, {
22
+ markdown: d`
23
+ Some markdown with \`inline\` code
24
+ `
25
+ })).toRenderTo(`
26
+ Some markdown with <c>inline</c> code
27
+ `);
28
+ });
29
+ it("convert link to <see>", () => {
30
+ expect(_$createComponent(DocFromMarkdown, {
31
+ markdown: d`
32
+ Some markdown with [link](https://example.com)
33
+ `
34
+ })).toRenderTo(`
35
+ Some markdown with <see href="https://example.com">link</see>
36
+ `);
37
+ });
38
+ it("convert bullet list to <list>", () => {
39
+ expect(_$createComponent(DocFromMarkdown, {
40
+ markdown: d`
41
+ - Item 1
42
+ - Item 2
43
+ - Item 3
44
+ `
45
+ })).toRenderTo(`
46
+ <list type="bullet">
47
+ <item><description>Item 1</description></item>
48
+ <item><description>Item 2</description></item>
49
+ <item><description>Item 3</description></item>
50
+ </list>
51
+ `);
52
+ });
53
+ it("convert numbered list to <list>", () => {
54
+ expect(_$createComponent(DocFromMarkdown, {
55
+ markdown: d`
56
+ 1. Item 1
57
+ 2. Item 2
58
+ 3. Item 3
59
+ `
60
+ })).toRenderTo(`
61
+ <list type="number">
62
+ <item><description>Item 1</description></item>
63
+ <item><description>Item 2</description></item>
64
+ <item><description>Item 3</description></item>
65
+ </list>
66
+ `);
67
+ });
68
+ describe("strip unsupported elements", () => {
69
+ it("bold", () => {
70
+ expect(_$createComponent(DocFromMarkdown, {
71
+ markdown: d`
72
+ Some markdown with **bold** text
73
+ `
74
+ })).toRenderTo(`Some markdown with bold text`);
75
+ });
76
+ it("italic", () => {
77
+ expect(_$createComponent(DocFromMarkdown, {
78
+ markdown: d`
79
+ Some markdown with *italic* text
80
+ `
81
+ })).toRenderTo(`Some markdown with italic text`);
82
+ });
83
+ });
@@ -1,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";
@@ -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,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export * from "./ClassDeclaration.js";
2
2
  export * from "./ClassMethod.js";
3
3
  export * from "./Declaration.js";
4
+ export * from "./doc/comment.js";
5
+ export * from "./doc/from-markdown.js";
4
6
  export * from "./EnumDeclaration.js";
5
7
  export * from "./interface/declaration.js";
6
8
  export * from "./interface/method.js";