@alloy-js/csharp 0.17.0 → 0.18.0-dev.10

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.
Files changed (109) hide show
  1. package/dist/src/components/ClassDeclaration.d.ts +57 -0
  2. package/dist/src/components/ClassDeclaration.d.ts.map +1 -0
  3. package/dist/src/components/{Class.js → ClassDeclaration.js} +42 -53
  4. package/dist/src/components/ClassMethod.d.ts +25 -0
  5. package/dist/src/components/ClassMethod.d.ts.map +1 -0
  6. package/dist/src/components/ClassMethod.js +60 -0
  7. package/dist/src/components/EnumDeclaration.d.ts +34 -0
  8. package/dist/src/components/EnumDeclaration.d.ts.map +1 -0
  9. package/dist/src/components/{Enum.js → EnumDeclaration.js} +25 -5
  10. package/dist/src/components/doc/comment.d.ts +70 -0
  11. package/dist/src/components/doc/comment.d.ts.map +1 -0
  12. package/dist/src/components/doc/comment.js +88 -0
  13. package/dist/src/components/doc/comment.test.d.ts +2 -0
  14. package/dist/src/components/doc/comment.test.d.ts.map +1 -0
  15. package/dist/src/components/doc/comment.test.js +348 -0
  16. package/dist/src/components/doc/from-markdown.d.ts +6 -0
  17. package/dist/src/components/doc/from-markdown.d.ts.map +1 -0
  18. package/dist/src/components/doc/from-markdown.js +58 -0
  19. package/dist/src/components/doc/from-markdown.test.d.ts +2 -0
  20. package/dist/src/components/doc/from-markdown.test.d.ts.map +1 -0
  21. package/dist/src/components/doc/from-markdown.test.js +83 -0
  22. package/dist/src/components/index.d.ts +7 -2
  23. package/dist/src/components/index.d.ts.map +1 -1
  24. package/dist/src/components/index.js +7 -2
  25. package/dist/src/components/interface/declaration.d.ts +34 -0
  26. package/dist/src/components/interface/declaration.d.ts.map +1 -0
  27. package/dist/src/components/interface/declaration.js +90 -0
  28. package/dist/src/components/interface/declaration.test.d.ts +2 -0
  29. package/dist/src/components/interface/declaration.test.d.ts.map +1 -0
  30. package/dist/src/components/interface/declaration.test.js +69 -0
  31. package/dist/src/components/interface/method.d.ts +18 -0
  32. package/dist/src/components/interface/method.d.ts.map +1 -0
  33. package/dist/src/components/interface/method.js +59 -0
  34. package/dist/src/components/interface/method.test.d.ts +2 -0
  35. package/dist/src/components/interface/method.test.d.ts.map +1 -0
  36. package/dist/src/components/interface/method.test.js +131 -0
  37. package/dist/src/components/interface/property.d.ts +21 -0
  38. package/dist/src/components/interface/property.d.ts.map +1 -0
  39. package/dist/src/components/interface/property.js +59 -0
  40. package/dist/src/components/interface/property.test.d.ts +2 -0
  41. package/dist/src/components/interface/property.test.d.ts.map +1 -0
  42. package/dist/src/components/interface/property.test.js +165 -0
  43. package/dist/src/components/stc/index.d.ts +2 -2
  44. package/dist/src/components/stc/index.d.ts.map +1 -1
  45. package/dist/src/components/stc/index.js +2 -2
  46. package/dist/src/modifiers.d.ts +13 -4
  47. package/dist/src/modifiers.d.ts.map +1 -1
  48. package/dist/src/modifiers.js +13 -27
  49. package/dist/src/name-policy.d.ts +1 -1
  50. package/dist/src/name-policy.d.ts.map +1 -1
  51. package/dist/src/name-policy.js +1 -0
  52. package/dist/test/class-declaration.test.d.ts +2 -0
  53. package/dist/test/class-declaration.test.d.ts.map +1 -0
  54. package/dist/test/{class.test.js → class-declaration.test.js} +123 -73
  55. package/dist/test/class-method.test.d.ts +2 -0
  56. package/dist/test/class-method.test.d.ts.map +1 -0
  57. package/dist/test/class-method.test.js +161 -0
  58. package/dist/test/enum.test.js +12 -12
  59. package/dist/test/namespace.test.js +8 -8
  60. package/dist/test/project-directory.test.d.ts +2 -0
  61. package/dist/test/project-directory.test.d.ts.map +1 -0
  62. package/dist/test/{projectdirectory.test.js → project-directory.test.js} +8 -8
  63. package/dist/test/sourcefile.test.js +4 -4
  64. package/dist/test/using.test.js +9 -9
  65. package/dist/test/utils.d.ts +3 -0
  66. package/dist/test/utils.d.ts.map +1 -1
  67. package/dist/test/utils.js +15 -0
  68. package/dist/test/vitest.setup.d.ts +2 -0
  69. package/dist/test/vitest.setup.d.ts.map +1 -0
  70. package/dist/test/vitest.setup.js +1 -0
  71. package/dist/tsconfig.tsbuildinfo +1 -1
  72. package/package.json +7 -6
  73. package/src/components/{Class.tsx → ClassDeclaration.tsx} +68 -66
  74. package/src/components/ClassMethod.tsx +94 -0
  75. package/src/components/{Enum.tsx → EnumDeclaration.tsx} +30 -6
  76. package/src/components/doc/comment.test.tsx +337 -0
  77. package/src/components/doc/comment.tsx +152 -0
  78. package/src/components/doc/from-markdown.test.tsx +103 -0
  79. package/src/components/doc/from-markdown.tsx +58 -0
  80. package/src/components/index.ts +7 -2
  81. package/src/components/interface/declaration.test.tsx +56 -0
  82. package/src/components/interface/declaration.tsx +109 -0
  83. package/src/components/interface/method.test.tsx +120 -0
  84. package/src/components/interface/method.tsx +82 -0
  85. package/src/components/interface/property.test.tsx +144 -0
  86. package/src/components/interface/property.tsx +90 -0
  87. package/src/components/stc/index.ts +2 -2
  88. package/src/modifiers.ts +32 -37
  89. package/src/name-policy.ts +2 -0
  90. package/temp/api.json +3275 -298
  91. package/test/{class.test.tsx → class-declaration.test.tsx} +103 -99
  92. package/test/class-method.test.tsx +147 -0
  93. package/test/enum.test.tsx +11 -11
  94. package/test/namespace.test.tsx +4 -4
  95. package/test/{projectdirectory.test.tsx → project-directory.test.tsx} +4 -4
  96. package/test/sourcefile.test.tsx +2 -2
  97. package/test/using.test.tsx +9 -9
  98. package/test/utils.tsx +9 -0
  99. package/test/vitest.setup.ts +1 -0
  100. package/tsconfig.json +2 -1
  101. package/vitest.config.ts +3 -0
  102. package/dist/src/components/Class.d.ts +0 -36
  103. package/dist/src/components/Class.d.ts.map +0 -1
  104. package/dist/src/components/Enum.d.ts +0 -15
  105. package/dist/src/components/Enum.d.ts.map +0 -1
  106. package/dist/test/class.test.d.ts +0 -2
  107. package/dist/test/class.test.d.ts.map +0 -1
  108. package/dist/test/projectdirectory.test.d.ts +0 -2
  109. package/dist/test/projectdirectory.test.d.ts.map +0 -1
@@ -0,0 +1,57 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifiers } from "../modifiers.js";
3
+ import { ParameterProps } from "./Parameters.jsx";
4
+ export interface ClassModifiers {
5
+ readonly abstract?: boolean;
6
+ readonly partial?: boolean;
7
+ readonly sealed?: boolean;
8
+ readonly static?: boolean;
9
+ }
10
+ export interface ClassDeclarationProps extends Omit<core.DeclarationProps, "nameKind">, AccessModifiers, ClassModifiers {
11
+ name: string;
12
+ /** Doc comment */
13
+ doc?: core.Children;
14
+ refkey?: core.Refkey;
15
+ typeParameters?: Record<string, core.Refkey>;
16
+ }
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 declare function ClassDeclaration(props: ClassDeclarationProps): core.Children;
42
+ export interface ClassConstructorProps extends AccessModifiers {
43
+ parameters?: Array<ParameterProps>;
44
+ refkey?: core.Refkey;
45
+ symbol?: core.OutputSymbol;
46
+ children?: core.Children;
47
+ }
48
+ export declare function ClassConstructor(props: ClassConstructorProps): core.Children;
49
+ export interface ClassMemberProps extends AccessModifiers {
50
+ name: string;
51
+ type: core.Children;
52
+ refkey?: core.Refkey;
53
+ /** Doc comment */
54
+ doc?: core.Children;
55
+ }
56
+ export declare function ClassMember(props: ClassMemberProps): core.Children;
57
+ //# 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,CA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CAAC;IACrB,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CACrB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,iBA0BlD"}
@@ -1,16 +1,41 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
2
  import * as core from "@alloy-js/core";
3
- import { getAccessModifier, getMethodModifier } from "../modifiers.js";
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, useCSharpScope } from "../symbols/scopes.js";
7
7
  import { Name } from "./Name.js";
8
8
  import { Parameters } from "./Parameters.js";
9
+ import { DocWhen } from "./doc/comment.js";
10
+ const getClassModifiers = makeModifiers(["abstract", "partial", "sealed", "static"]);
9
11
 
10
12
  // properties for creating a class
11
13
 
12
- // a C# class declaration
13
- export function Class(props) {
14
+ /**
15
+ * CSharp class declaration.
16
+ * @example
17
+ * ```tsx
18
+ * <ClassDeclaration public name="MyClass">
19
+ * <ClassMember public name="MyField" type="int" />
20
+ * <ClassConstructor>
21
+ * <Parameter name="value" type="int" />
22
+ * this.MyField = value;
23
+ * </ClassConstructor>
24
+ * </ClassDeclaration>
25
+ * ```
26
+ * This will produce:
27
+ * ```csharp
28
+ * public class MyClass
29
+ * {
30
+ * public int MyField;
31
+ * public MyClass(int value)
32
+ * {
33
+ * this.MyField = value;
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ export function ClassDeclaration(props) {
14
39
  const name = useCSharpNamePolicy().getName(props.name, "class");
15
40
  const thisClassSymbol = new CSharpOutputSymbol(name, {
16
41
  refkeys: props.refkey
@@ -46,10 +71,15 @@ export function Class(props) {
46
71
  }
47
72
  });
48
73
  }
74
+ const modifiers = computeModifiersPrefix([getAccessModifier(props), getClassModifiers(props)]);
49
75
  return _$createComponent(core.Declaration, {
50
76
  symbol: thisClassSymbol,
51
77
  get children() {
52
- return [_$memo(() => getAccessModifier(props.accessModifier)), "class ", _$createComponent(Name, {}), typeParams, _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
78
+ return [_$createComponent(DocWhen, {
79
+ get doc() {
80
+ return props.doc;
81
+ }
82
+ }), modifiers, "class ", _$createComponent(Name, {}), typeParams, _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
53
83
  newline: true,
54
84
  get children() {
55
85
  return _$createComponent(core.Scope, {
@@ -81,7 +111,7 @@ export function ClassConstructor(props) {
81
111
  const ctorDeclScope = new CSharpMemberScope("constructor-decl", {
82
112
  owner: ctorSymbol
83
113
  });
84
- const accessModifier = getAccessModifier(props.accessModifier);
114
+ const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
85
115
  const params = props.parameters ? _$createComponent(Parameters, {
86
116
  get parameters() {
87
117
  return props.parameters;
@@ -95,7 +125,7 @@ export function ClassConstructor(props) {
95
125
  return _$createComponent(core.Scope, {
96
126
  value: ctorDeclScope,
97
127
  get children() {
98
- return [accessModifier, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
128
+ return [modifiers, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
99
129
  newline: true,
100
130
  get children() {
101
131
  return props.children;
@@ -112,7 +142,7 @@ export function ClassConstructor(props) {
112
142
  // a C# class member (i.e. a field within a class like "private int count")
113
143
  export function ClassMember(props) {
114
144
  let nameElement = "class-member-private";
115
- if (props.accessModifier === "public") {
145
+ if (props.public) {
116
146
  nameElement = "class-member-public";
117
147
  }
118
148
  const name = useCSharpNamePolicy().getName(props.name, nameElement);
@@ -124,56 +154,15 @@ export function ClassMember(props) {
124
154
  scope,
125
155
  refkeys: props.refkey ?? core.refkey(props.name)
126
156
  });
157
+ const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
127
158
  return _$createComponent(core.Declaration, {
128
159
  symbol: memberSymbol,
129
160
  get children() {
130
- return [_$memo(() => getAccessModifier(props.accessModifier)), _$memo(() => props.type), " ", _$createComponent(Name, {})];
131
- }
132
- });
133
- }
134
-
135
- // properties for creating a method
136
-
137
- // a C# class method
138
- export function ClassMethod(props) {
139
- const name = useCSharpNamePolicy().getName(props.name, "class-method");
140
- const scope = useCSharpScope();
141
- if (scope.kind !== "member" || scope.name !== "class-decl") {
142
- throw new Error("can't define a class method outside of a class scope");
143
- }
144
- const methodSymbol = new CSharpOutputSymbol(name, {
145
- scope,
146
- refkeys: props.refkey ?? core.refkey(props.name)
147
- });
148
-
149
- // scope for method declaration
150
- const methodScope = new CSharpMemberScope("method-decl", {
151
- owner: methodSymbol
152
- });
153
- const accessModifier = getAccessModifier(props.accessModifier);
154
- const methodModifier = getMethodModifier(props.methodModifier);
155
- const params = props.parameters ? _$createComponent(Parameters, {
156
- get parameters() {
157
- return props.parameters;
158
- }
159
- }) : "";
160
- const returns = props.returns ?? "void";
161
-
162
- // note that scope wraps the method decl so that the params get the correct scope
163
- return _$createComponent(core.Declaration, {
164
- symbol: methodSymbol,
165
- get children() {
166
- return _$createComponent(core.Scope, {
167
- value: methodScope,
168
- get children() {
169
- return [accessModifier, methodModifier, returns, " ", _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
170
- newline: true,
171
- get children() {
172
- return props.children;
173
- }
174
- })];
161
+ return [_$createComponent(DocWhen, {
162
+ get doc() {
163
+ return props.doc;
175
164
  }
176
- });
165
+ }), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
177
166
  }
178
167
  });
179
168
  }
@@ -0,0 +1,25 @@
1
+ import { Children, Refkey } from "@alloy-js/core";
2
+ import { AccessModifiers } from "../modifiers.js";
3
+ import { ParameterProps } from "./Parameters.jsx";
4
+ /** Method modifiers. Can only be one. */
5
+ export interface ClassMethodModifiers {
6
+ readonly abstract?: boolean;
7
+ readonly sealed?: boolean;
8
+ readonly static?: boolean;
9
+ readonly virtual?: boolean;
10
+ }
11
+ export interface ClassMethodProps extends AccessModifiers, ClassMethodModifiers {
12
+ name: string;
13
+ refkey?: Refkey;
14
+ children?: Children;
15
+ parameters?: Array<ParameterProps>;
16
+ returns?: Children;
17
+ /**
18
+ * If true, the method will be declared as an async method.
19
+ */
20
+ async?: boolean;
21
+ /** Doc comment */
22
+ doc?: Children;
23
+ }
24
+ export declare function ClassMethod(props: ClassMethodProps): Children;
25
+ //# sourceMappingURL=ClassMethod.d.ts.map
@@ -0,0 +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,eAAe,EAKhB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAC;AAG9D,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;CAChB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAqClD"}
@@ -0,0 +1,60 @@
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { Block, MemberDeclaration, refkey, Scope } from "@alloy-js/core";
3
+ import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, makeModifiers } from "../modifiers.js";
4
+ import { useCSharpNamePolicy } from "../name-policy.js";
5
+ import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
6
+ import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
7
+ import { Parameters } from "./Parameters.js";
8
+ import { DocWhen } from "./doc/comment.js";
9
+
10
+ /** Method modifiers. Can only be one. */
11
+
12
+ const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual"]);
13
+
14
+ // properties for creating a method
15
+
16
+ // a C# class method
17
+ export function ClassMethod(props) {
18
+ const name = useCSharpNamePolicy().getName(props.name, "class-method");
19
+ const scope = useCSharpScope();
20
+ if (scope.kind !== "member" || scope.name !== "class-decl") {
21
+ throw new Error("can't define a class method outside of a class scope");
22
+ }
23
+ const methodSymbol = new CSharpOutputSymbol(name, {
24
+ scope,
25
+ refkeys: props.refkey ?? refkey(props.name)
26
+ });
27
+
28
+ // scope for method declaration
29
+ const methodScope = new CSharpMemberScope("method-decl", {
30
+ owner: methodSymbol
31
+ });
32
+ const params = props.parameters ? _$createComponent(Parameters, {
33
+ get parameters() {
34
+ return props.parameters;
35
+ }
36
+ }) : "";
37
+ const returns = props.returns ?? (props.async ? "Task" : "void");
38
+ const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props), getAsyncModifier(props.async)]);
39
+ // note that scope wraps the method decl so that the params get the correct scope
40
+ return _$createComponent(MemberDeclaration, {
41
+ symbol: methodSymbol,
42
+ get children() {
43
+ return _$createComponent(Scope, {
44
+ value: methodScope,
45
+ get children() {
46
+ return [_$createComponent(DocWhen, {
47
+ get doc() {
48
+ return props.doc;
49
+ }
50
+ }), modifiers, returns, " ", name, "(", params, ")", _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$createComponent(Block, {
51
+ newline: true,
52
+ get children() {
53
+ return props.children;
54
+ }
55
+ }))];
56
+ }
57
+ });
58
+ }
59
+ });
60
+ }
@@ -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 { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
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
- // a C# enum declaration
12
- export function Enum(props) {
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 [_$memo(() => getAccessModifier(props.accessModifier)), "enum ", _$createComponent(Name, {}), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Scope, {
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,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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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=comment.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment.test.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/comment.test.tsx"],"names":[],"mappings":""}