@alloy-js/csharp 0.18.0-dev.2 → 0.18.0-dev.21
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/LICENSE +7 -0
- package/dist/src/components/ClassDeclaration.d.ts +74 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -0
- package/dist/src/components/{Class.js → ClassDeclaration.js} +64 -38
- package/dist/src/components/ClassMethod.d.ts +26 -5
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +27 -9
- 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/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 +13 -4
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +14 -5
- package/dist/src/components/interface/declaration.d.ts +47 -0
- package/dist/src/components/interface/declaration.d.ts.map +1 -0
- package/dist/src/components/interface/declaration.js +77 -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 +153 -0
- package/dist/src/components/interface/method.d.ts +32 -0
- package/dist/src/components/interface/method.d.ts.map +1 -0
- package/dist/src/components/interface/method.js +68 -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 +279 -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/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 +57 -0
- package/dist/src/components/property/property.d.ts.map +1 -0
- package/dist/src/components/property/property.js +70 -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 +218 -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/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/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/modifiers.d.ts +10 -4
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +9 -32
- 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 +2 -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-declaration.test.js +463 -0
- package/dist/test/class-method.test.js +37 -14
- 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/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 +21 -21
- package/src/components/ClassDeclaration.tsx +213 -0
- package/src/components/ClassMethod.tsx +54 -15
- package/src/components/{Enum.tsx → EnumDeclaration.tsx} +30 -6
- 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 +13 -4
- package/src/components/interface/declaration.test.tsx +143 -0
- package/src/components/interface/declaration.tsx +105 -0
- package/src/components/interface/method.test.tsx +278 -0
- package/src/components/interface/method.tsx +102 -0
- package/src/components/interface/property.test.tsx +144 -0
- package/src/components/interface/property.tsx +107 -0
- package/src/components/parameters/parameters.tsx +74 -0
- package/src/components/property/property.test.tsx +187 -0
- package/src/components/property/property.tsx +146 -0
- package/src/components/record/declaration.test.tsx +73 -0
- package/src/components/record/declaration.tsx +109 -0
- package/src/components/stc/index.ts +2 -2
- 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/modifiers.ts +25 -42
- package/src/name-policy.ts +5 -0
- package/temp/api.json +5228 -686
- package/test/class-declaration.test.tsx +418 -0
- package/test/class-method.test.tsx +24 -14
- 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/vitest.setup.ts +1 -0
- package/vitest.config.ts +3 -0
- package/dist/src/components/Class.d.ts +0 -26
- 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/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/class.test.js +0 -298
- package/dist/test/projectdirectory.test.d.ts +0 -2
- package/dist/test/projectdirectory.test.d.ts.map +0 -1
- package/src/components/Class.tsx +0 -149
- package/src/components/Parameters.tsx +0 -51
- package/test/class.test.tsx +0 -292
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024 Microsoft
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as core from "@alloy-js/core";
|
|
2
|
+
import { AccessModifiers } from "../modifiers.js";
|
|
3
|
+
import { ParameterProps } from "./parameters/parameters.jsx";
|
|
4
|
+
import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
|
|
5
|
+
export interface ClassModifiers {
|
|
6
|
+
readonly abstract?: boolean;
|
|
7
|
+
readonly partial?: boolean;
|
|
8
|
+
readonly sealed?: boolean;
|
|
9
|
+
readonly static?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ClassDeclarationProps extends Omit<core.DeclarationProps, "nameKind">, AccessModifiers, ClassModifiers {
|
|
12
|
+
name: string;
|
|
13
|
+
/** Doc comment */
|
|
14
|
+
doc?: core.Children;
|
|
15
|
+
refkey?: core.Refkey;
|
|
16
|
+
/**
|
|
17
|
+
* Type parameters for the class
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <ClassDeclaration name="MyClass" typeParameters={["T"]} />
|
|
22
|
+
* ```
|
|
23
|
+
* This will produce:
|
|
24
|
+
* ```csharp
|
|
25
|
+
* public class MyClass<T>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
typeParameters?: (string | TypeParameterProps)[];
|
|
29
|
+
/** Base class that this class extends */
|
|
30
|
+
baseType?: core.Children;
|
|
31
|
+
/** Interfaces this class implements */
|
|
32
|
+
interfaceTypes?: core.Children[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* CSharp class declaration.
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <ClassDeclaration public name="MyClass">
|
|
39
|
+
* <ClassMember public name="MyField" type="int" />
|
|
40
|
+
* <ClassConstructor>
|
|
41
|
+
* <Parameter name="value" type="int" />
|
|
42
|
+
* this.MyField = value;
|
|
43
|
+
* </ClassConstructor>
|
|
44
|
+
* </ClassDeclaration>
|
|
45
|
+
* ```
|
|
46
|
+
* This will produce:
|
|
47
|
+
* ```csharp
|
|
48
|
+
* public class MyClass
|
|
49
|
+
* {
|
|
50
|
+
* public int MyField;
|
|
51
|
+
* public MyClass(int value)
|
|
52
|
+
* {
|
|
53
|
+
* this.MyField = value;
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function ClassDeclaration(props: ClassDeclarationProps): core.Children;
|
|
59
|
+
export interface ClassConstructorProps extends AccessModifiers {
|
|
60
|
+
parameters?: Array<ParameterProps>;
|
|
61
|
+
refkey?: core.Refkey;
|
|
62
|
+
symbol?: core.OutputSymbol;
|
|
63
|
+
children?: core.Children;
|
|
64
|
+
}
|
|
65
|
+
export declare function ClassConstructor(props: ClassConstructorProps): core.Children;
|
|
66
|
+
export interface ClassMemberProps extends AccessModifiers {
|
|
67
|
+
name: string;
|
|
68
|
+
type: core.Children;
|
|
69
|
+
refkey?: core.Refkey;
|
|
70
|
+
/** Doc comment */
|
|
71
|
+
doc?: core.Children;
|
|
72
|
+
}
|
|
73
|
+
export declare function ClassMember(props: ClassMemberProps): core.Children;
|
|
74
|
+
//# sourceMappingURL=ClassDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAUD,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,cAAc;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAEjD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAEzB,uCAAuC;IACvC,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBA4C5D;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBAiC5D;AAGD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CACrB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,iBA0BlD"}
|
|
@@ -1,16 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as core from "@alloy-js/core";
|
|
3
|
-
import {
|
|
3
|
+
import { join } from "@alloy-js/core";
|
|
4
|
+
import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../modifiers.js";
|
|
4
5
|
import { useCSharpNamePolicy } from "../name-policy.js";
|
|
5
6
|
import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
|
|
6
7
|
import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
|
|
8
|
+
import { DocWhen } from "./doc/comment.js";
|
|
7
9
|
import { Name } from "./Name.js";
|
|
8
|
-
import { Parameters } from "./
|
|
10
|
+
import { Parameters } from "./parameters/parameters.js";
|
|
11
|
+
import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
|
|
12
|
+
import { TypeParameters } from "./type-parameters/type-parameters.js";
|
|
13
|
+
const getClassModifiers = makeModifiers(["abstract", "partial", "sealed", "static"]);
|
|
9
14
|
|
|
10
15
|
// properties for creating a class
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
/**
|
|
18
|
+
* CSharp class declaration.
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <ClassDeclaration public name="MyClass">
|
|
22
|
+
* <ClassMember public name="MyField" type="int" />
|
|
23
|
+
* <ClassConstructor>
|
|
24
|
+
* <Parameter name="value" type="int" />
|
|
25
|
+
* this.MyField = value;
|
|
26
|
+
* </ClassConstructor>
|
|
27
|
+
* </ClassDeclaration>
|
|
28
|
+
* ```
|
|
29
|
+
* This will produce:
|
|
30
|
+
* ```csharp
|
|
31
|
+
* public class MyClass
|
|
32
|
+
* {
|
|
33
|
+
* public int MyField;
|
|
34
|
+
* public MyClass(int value)
|
|
35
|
+
* {
|
|
36
|
+
* this.MyField = value;
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function ClassDeclaration(props) {
|
|
14
42
|
const name = useCSharpNamePolicy().getName(props.name, "class");
|
|
15
43
|
const thisClassSymbol = new CSharpOutputSymbol(name, {
|
|
16
44
|
refkeys: props.refkey
|
|
@@ -23,33 +51,27 @@ export function Class(props) {
|
|
|
23
51
|
const thisClassScope = new CSharpMemberScope("class-decl", {
|
|
24
52
|
owner: thisClassSymbol
|
|
25
53
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// create a symbol for each type param so its
|
|
32
|
-
// refkey resolves to the type param's name
|
|
33
|
-
new CSharpOutputSymbol(entry[0], {
|
|
34
|
-
scope: thisClassScope,
|
|
35
|
-
refkeys: entry[1]
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
typeParams = _$createIntrinsic("group", {
|
|
39
|
-
get children() {
|
|
40
|
-
return ["<", _$createComponent(core.For, {
|
|
41
|
-
each: typeParamNames,
|
|
42
|
-
comma: true,
|
|
43
|
-
line: true,
|
|
44
|
-
children: name => name
|
|
45
|
-
}), ">"];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
54
|
+
const bases = [...(props.baseType ? [props.baseType] : []), ...(props.interfaceTypes || [])];
|
|
55
|
+
const base = bases.length > 0 ? [" : ", _$memo(() => join(bases, {
|
|
56
|
+
joiner: ", "
|
|
57
|
+
}))] : null;
|
|
58
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props), getClassModifiers(props)]);
|
|
49
59
|
return _$createComponent(core.Declaration, {
|
|
50
60
|
symbol: thisClassSymbol,
|
|
51
61
|
get children() {
|
|
52
|
-
return [_$
|
|
62
|
+
return [_$createComponent(DocWhen, {
|
|
63
|
+
get doc() {
|
|
64
|
+
return props.doc;
|
|
65
|
+
}
|
|
66
|
+
}), modifiers, "class ", _$createComponent(Name, {}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
|
|
67
|
+
get parameters() {
|
|
68
|
+
return props.typeParameters;
|
|
69
|
+
}
|
|
70
|
+
})), base, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
|
|
71
|
+
get parameters() {
|
|
72
|
+
return props.typeParameters;
|
|
73
|
+
}
|
|
74
|
+
})), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
|
|
53
75
|
newline: true,
|
|
54
76
|
get children() {
|
|
55
77
|
return _$createComponent(core.Scope, {
|
|
@@ -81,12 +103,7 @@ export function ClassConstructor(props) {
|
|
|
81
103
|
const ctorDeclScope = new CSharpMemberScope("constructor-decl", {
|
|
82
104
|
owner: ctorSymbol
|
|
83
105
|
});
|
|
84
|
-
const
|
|
85
|
-
const params = props.parameters ? _$createComponent(Parameters, {
|
|
86
|
-
get parameters() {
|
|
87
|
-
return props.parameters;
|
|
88
|
-
}
|
|
89
|
-
}) : "";
|
|
106
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
|
|
90
107
|
|
|
91
108
|
// note that scope wraps the ctor decl so that the params get the correct scope
|
|
92
109
|
return _$createComponent(core.Declaration, {
|
|
@@ -95,7 +112,11 @@ export function ClassConstructor(props) {
|
|
|
95
112
|
return _$createComponent(core.Scope, {
|
|
96
113
|
value: ctorDeclScope,
|
|
97
114
|
get children() {
|
|
98
|
-
return [
|
|
115
|
+
return [modifiers, _$createComponent(Name, {}), _$createComponent(Parameters, {
|
|
116
|
+
get parameters() {
|
|
117
|
+
return props.parameters;
|
|
118
|
+
}
|
|
119
|
+
}), _$createComponent(core.Block, {
|
|
99
120
|
newline: true,
|
|
100
121
|
get children() {
|
|
101
122
|
return props.children;
|
|
@@ -112,7 +133,7 @@ export function ClassConstructor(props) {
|
|
|
112
133
|
// a C# class member (i.e. a field within a class like "private int count")
|
|
113
134
|
export function ClassMember(props) {
|
|
114
135
|
let nameElement = "class-member-private";
|
|
115
|
-
if (props.
|
|
136
|
+
if (props.public) {
|
|
116
137
|
nameElement = "class-member-public";
|
|
117
138
|
}
|
|
118
139
|
const name = useCSharpNamePolicy().getName(props.name, nameElement);
|
|
@@ -124,10 +145,15 @@ export function ClassMember(props) {
|
|
|
124
145
|
scope,
|
|
125
146
|
refkeys: props.refkey ?? core.refkey(props.name)
|
|
126
147
|
});
|
|
148
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
|
|
127
149
|
return _$createComponent(core.Declaration, {
|
|
128
150
|
symbol: memberSymbol,
|
|
129
151
|
get children() {
|
|
130
|
-
return [_$
|
|
152
|
+
return [_$createComponent(DocWhen, {
|
|
153
|
+
get doc() {
|
|
154
|
+
return props.doc;
|
|
155
|
+
}
|
|
156
|
+
}), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
|
|
131
157
|
}
|
|
132
158
|
});
|
|
133
159
|
}
|
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
-
import {
|
|
3
|
-
import { ParameterProps } from "./
|
|
4
|
-
|
|
2
|
+
import { AccessModifiers } from "../modifiers.js";
|
|
3
|
+
import { ParameterProps } from "./parameters/parameters.jsx";
|
|
4
|
+
import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
|
|
5
|
+
/** Method modifiers. Can only be one. */
|
|
6
|
+
export interface ClassMethodModifiers {
|
|
7
|
+
readonly abstract?: boolean;
|
|
8
|
+
readonly sealed?: boolean;
|
|
9
|
+
readonly static?: boolean;
|
|
10
|
+
readonly virtual?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ClassMethodProps extends AccessModifiers, ClassMethodModifiers {
|
|
5
13
|
name: string;
|
|
6
14
|
refkey?: Refkey;
|
|
7
15
|
children?: Children;
|
|
8
|
-
accessModifier?: AccessModifier;
|
|
9
|
-
methodModifier?: MethodModifier;
|
|
10
16
|
parameters?: Array<ParameterProps>;
|
|
11
17
|
returns?: Children;
|
|
12
18
|
/**
|
|
13
19
|
* If true, the method will be declared as an async method.
|
|
14
20
|
*/
|
|
15
21
|
async?: boolean;
|
|
22
|
+
/** Doc comment */
|
|
23
|
+
doc?: Children;
|
|
24
|
+
/**
|
|
25
|
+
* Type parameters for the method
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <InterfaceMethod name="Test" typeParameters={["T"]} />
|
|
30
|
+
* ```
|
|
31
|
+
* This will produce:
|
|
32
|
+
* ```csharp
|
|
33
|
+
* public void Test<T>()
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
typeParameters?: (TypeParameterProps | string)[];
|
|
16
37
|
}
|
|
17
38
|
export declare function ClassMethod(props: ClassMethodProps): Children;
|
|
18
39
|
//# sourceMappingURL=ClassMethod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKhB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD,MAAM,WAAW,gBACf,SAAQ,eAAe,EACrB,oBAAoB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;CAClD;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YA0ClD"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { Block, MemberDeclaration, refkey, Scope } from "@alloy-js/core";
|
|
3
|
-
import { computeModifiersPrefix, getAccessModifier, getAsyncModifier,
|
|
3
|
+
import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, 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, useCSharpScope } from "../symbols/scopes.js";
|
|
7
|
-
import {
|
|
7
|
+
import { DocWhen } from "./doc/comment.js";
|
|
8
|
+
import { Parameters } from "./parameters/parameters.js";
|
|
9
|
+
import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
|
|
10
|
+
import { TypeParameters } from "./type-parameters/type-parameters.js";
|
|
11
|
+
|
|
12
|
+
/** Method modifiers. Can only be one. */
|
|
13
|
+
|
|
14
|
+
const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual"]);
|
|
8
15
|
|
|
9
16
|
// properties for creating a method
|
|
10
17
|
|
|
@@ -24,13 +31,8 @@ export function ClassMethod(props) {
|
|
|
24
31
|
const methodScope = new CSharpMemberScope("method-decl", {
|
|
25
32
|
owner: methodSymbol
|
|
26
33
|
});
|
|
27
|
-
const params = props.parameters ? _$createComponent(Parameters, {
|
|
28
|
-
get parameters() {
|
|
29
|
-
return props.parameters;
|
|
30
|
-
}
|
|
31
|
-
}) : "";
|
|
32
34
|
const returns = props.returns ?? (props.async ? "Task" : "void");
|
|
33
|
-
const modifiers = computeModifiersPrefix([getAccessModifier(props
|
|
35
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props), getAsyncModifier(props.async)]);
|
|
34
36
|
// note that scope wraps the method decl so that the params get the correct scope
|
|
35
37
|
return _$createComponent(MemberDeclaration, {
|
|
36
38
|
symbol: methodSymbol,
|
|
@@ -38,7 +40,23 @@ export function ClassMethod(props) {
|
|
|
38
40
|
return _$createComponent(Scope, {
|
|
39
41
|
value: methodScope,
|
|
40
42
|
get children() {
|
|
41
|
-
return [
|
|
43
|
+
return [_$createComponent(DocWhen, {
|
|
44
|
+
get doc() {
|
|
45
|
+
return props.doc;
|
|
46
|
+
}
|
|
47
|
+
}), modifiers, returns, " ", name, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
|
|
48
|
+
get parameters() {
|
|
49
|
+
return props.typeParameters;
|
|
50
|
+
}
|
|
51
|
+
})), _$createComponent(Parameters, {
|
|
52
|
+
get parameters() {
|
|
53
|
+
return props.parameters;
|
|
54
|
+
}
|
|
55
|
+
}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
|
|
56
|
+
get parameters() {
|
|
57
|
+
return props.typeParameters;
|
|
58
|
+
}
|
|
59
|
+
})), _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$createComponent(Block, {
|
|
42
60
|
newline: true,
|
|
43
61
|
get children() {
|
|
44
62
|
return props.children;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as core from "@alloy-js/core";
|
|
2
|
+
import { AccessModifiers } from "../modifiers.js";
|
|
3
|
+
export interface EnumDeclarationProps extends AccessModifiers {
|
|
4
|
+
name: string;
|
|
5
|
+
refkey?: core.Refkey;
|
|
6
|
+
children?: core.Children;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A C# enum declaration
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <EnumDeclaration public name="Color">
|
|
13
|
+
* <EnumMember name="Red" />
|
|
14
|
+
* <EnumMember name="Green" />
|
|
15
|
+
* <EnumMember name="Blue" />
|
|
16
|
+
* </EnumDeclaration>
|
|
17
|
+
* ```
|
|
18
|
+
* This will produce:
|
|
19
|
+
* ```csharp
|
|
20
|
+
* public enum Color
|
|
21
|
+
* {
|
|
22
|
+
* Red,
|
|
23
|
+
* Green,
|
|
24
|
+
* Blue
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function EnumDeclaration(props: EnumDeclarationProps): core.Children;
|
|
29
|
+
export interface EnumMemberProps {
|
|
30
|
+
name: string;
|
|
31
|
+
refkey?: core.Refkey;
|
|
32
|
+
}
|
|
33
|
+
export declare function EnumMember(props: EnumMemberProps): core.Children;
|
|
34
|
+
//# sourceMappingURL=EnumDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnumDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/EnumDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAOzB,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,iBAgC1D;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;CACtB;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAmBhD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as core from "@alloy-js/core";
|
|
3
|
-
import { getAccessModifier } from "../modifiers.js";
|
|
3
|
+
import { computeModifiersPrefix, getAccessModifier } 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, useCSharpScope } from "../symbols/scopes.js";
|
|
@@ -8,8 +8,27 @@ import { Name } from "./Name.js";
|
|
|
8
8
|
|
|
9
9
|
// properties for creating an enum
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A C# enum declaration
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <EnumDeclaration public name="Color">
|
|
16
|
+
* <EnumMember name="Red" />
|
|
17
|
+
* <EnumMember name="Green" />
|
|
18
|
+
* <EnumMember name="Blue" />
|
|
19
|
+
* </EnumDeclaration>
|
|
20
|
+
* ```
|
|
21
|
+
* This will produce:
|
|
22
|
+
* ```csharp
|
|
23
|
+
* public enum Color
|
|
24
|
+
* {
|
|
25
|
+
* Red,
|
|
26
|
+
* Green,
|
|
27
|
+
* Blue
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function EnumDeclaration(props) {
|
|
13
32
|
const name = useCSharpNamePolicy().getName(props.name, "enum");
|
|
14
33
|
const scope = useCSharpScope();
|
|
15
34
|
const thisEnumSymbol = new CSharpOutputSymbol(name, {
|
|
@@ -25,10 +44,11 @@ export function Enum(props) {
|
|
|
25
44
|
parent: scope,
|
|
26
45
|
owner: thisEnumSymbol
|
|
27
46
|
});
|
|
47
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
|
|
28
48
|
if (thisEnumScope.owner) return _$createComponent(core.Declaration, {
|
|
29
49
|
symbol: thisEnumSymbol,
|
|
30
50
|
get children() {
|
|
31
|
-
return [
|
|
51
|
+
return [modifiers, "enum ", _$createComponent(Name, {}), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Scope, {
|
|
32
52
|
value: thisEnumScope,
|
|
33
53
|
get children() {
|
|
34
54
|
return _$createComponent(core.Block, {
|
|
@@ -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":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,gBAAgB,CAAC;AAEhF,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,UAPsB,eAAe,WAON,CAAC;AACjD,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;AACD,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,WAEhD,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB;AACD,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,aACgB,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB;AACD,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,aACgB,CAAC;AAEtE,eAAO,MAAM,UAAU,UA/CgB,eAAe,aA+CA,CAAC;AACvD,eAAO,MAAM,UAAU,UAhDgB,eAAe,aAgDA,CAAC;AACvD,eAAO,MAAM,QAAQ,UAjDkB,eAAe,aAiDJ,CAAC;AACnD,eAAO,MAAM,aAAa,UAlDa,eAAe,aAkDM,CAAC;AAC7D,eAAO,MAAM,cAAc,UAnDY,eAAe,aAmDQ,CAAC;AAC/D,eAAO,MAAM,OAAO,UApDmB,eAAe,aAoDN,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AACD,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,aASxC,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AACD,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,aAQhD,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AACD,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB,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"}
|
|
@@ -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":""}
|