@macroforge/mcp-server 0.1.33 → 0.1.35

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 (50) hide show
  1. package/README.md +68 -0
  2. package/dist/index.d.ts +32 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +46 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/tools/docs-loader.d.ts +133 -5
  7. package/dist/tools/docs-loader.d.ts.map +1 -1
  8. package/dist/tools/docs-loader.js +131 -15
  9. package/dist/tools/docs-loader.js.map +1 -1
  10. package/dist/tools/index.d.ts +48 -1
  11. package/dist/tools/index.d.ts.map +1 -1
  12. package/dist/tools/index.js +163 -14
  13. package/dist/tools/index.js.map +1 -1
  14. package/docs/api/api-overview.md +24 -46
  15. package/docs/api/expand-sync.md +24 -51
  16. package/docs/api/native-plugin.md +24 -56
  17. package/docs/api/position-mapper.md +34 -76
  18. package/docs/api/transform-sync.md +27 -59
  19. package/docs/builtin-macros/clone.md +45 -104
  20. package/docs/builtin-macros/debug.md +33 -104
  21. package/docs/builtin-macros/default.md +78 -114
  22. package/docs/builtin-macros/deserialize.md +93 -273
  23. package/docs/builtin-macros/hash.md +58 -100
  24. package/docs/builtin-macros/macros-overview.md +42 -103
  25. package/docs/builtin-macros/ord.md +65 -133
  26. package/docs/builtin-macros/partial-eq.md +53 -179
  27. package/docs/builtin-macros/partial-ord.md +67 -159
  28. package/docs/builtin-macros/serialize.md +64 -194
  29. package/docs/concepts/architecture.md +40 -99
  30. package/docs/concepts/derive-system.md +129 -125
  31. package/docs/concepts/how-macros-work.md +52 -84
  32. package/docs/custom-macros/custom-overview.md +17 -39
  33. package/docs/custom-macros/rust-setup.md +22 -55
  34. package/docs/custom-macros/ts-macro-derive.md +43 -107
  35. package/docs/custom-macros/ts-quote.md +177 -507
  36. package/docs/getting-started/first-macro.md +108 -33
  37. package/docs/getting-started/installation.md +32 -73
  38. package/docs/integration/cli.md +70 -156
  39. package/docs/integration/configuration.md +32 -75
  40. package/docs/integration/integration-overview.md +16 -55
  41. package/docs/integration/mcp-server.md +30 -69
  42. package/docs/integration/svelte-preprocessor.md +60 -83
  43. package/docs/integration/typescript-plugin.md +32 -74
  44. package/docs/integration/vite-plugin.md +30 -79
  45. package/docs/language-servers/ls-overview.md +22 -46
  46. package/docs/language-servers/svelte.md +30 -69
  47. package/docs/language-servers/zed.md +34 -72
  48. package/docs/roadmap/roadmap.md +54 -130
  49. package/docs/sections.json +3 -262
  50. package/package.json +2 -2
@@ -1,10 +1,7 @@
1
1
  # ts_macro_derive
2
-
3
- *The `#[ts_macro_derive]` attribute is a Rust procedural macro that registers your function as a Macroforge derive macro.*
4
-
5
- ## Basic Syntax
6
-
7
- ```rust
2
+ *The `#[ts_macro_derive]` attribute is a Rust procedural macro that registers your function as a Macroforge derive macro.*
3
+ ## Basic Syntax
4
+ ```
8
5
  use macroforge_ts::macros::ts_macro_derive;
9
6
  use macroforge_ts::ts_syn::{TsStream, MacroforgeError};
10
7
 
@@ -12,64 +9,39 @@ use macroforge_ts::ts_syn::{TsStream, MacroforgeError};
12
9
  pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
13
10
  // Macro implementation
14
11
  }
15
- ```
16
-
17
- ## Attribute Options
18
-
19
- ### Name (Required)
20
-
21
- The first argument is the macro name that users will reference in `@derive()`:
22
-
23
- ```rust
12
+ ``` ## Attribute Options
13
+ ### Name (Required)
14
+ The first argument is the macro name that users will reference in `@derive()`:
15
+ ```
24
16
  #[ts_macro_derive(JSON)] // Users write: @derive(JSON)
25
17
  pub fn derive_json(...)
26
- ```
27
-
28
- ### Description
29
-
30
- Provides documentation for the macro:
31
-
32
- ```rust
18
+ ``` ### Description
19
+ Provides documentation for the macro:
20
+ ```
33
21
  #[ts_macro_derive(
34
22
  JSON,
35
23
  description = "Generates toJSON() returning a plain object"
36
24
  )]
37
25
  pub fn derive_json(...)
38
- ```
39
-
40
- ### Attributes
41
-
42
- Declare which field-level decorators your macro accepts:
43
-
44
- ```rust
26
+ ``` ### Attributes
27
+ Declare which field-level decorators your macro accepts:
28
+ ```
45
29
  #[ts_macro_derive(
46
30
  Debug,
47
31
  description = "Generates toString()",
48
32
  attributes(debug) // Allows @debug({ ... }) on fields
49
33
  )]
50
34
  pub fn derive_debug(...)
51
- ```
52
-
53
- >
54
- > Declared attributes become available as `@attributeName(&#123; options &#125;)` decorators in TypeScript.
55
-
56
- ## Function Signature
57
-
58
- ```rust
35
+ ``` > **Note:** Declared attributes become available as @attributeName({ options }) decorators in TypeScript. ## Function Signature
36
+ ```
59
37
  pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError>
60
- ```
61
-
62
- | `input: TsStream`
63
- | Token stream containing the class/interface AST
64
-
65
- | `Result<TsStream, MacroforgeError>`
66
- | Returns generated code or an error with source location
67
-
68
- ## Parsing Input
69
-
70
- Use `parse_ts_macro_input!` to convert the token stream:
71
-
72
- ```rust
38
+ ``` | Parameter | Description |
39
+ | --- | --- |
40
+ | `input: TsStream` | Token stream containing the class/interface AST |
41
+ | `Result<TsStream, MacroforgeError>` | Returns generated code or an error with source location |
42
+ ## Parsing Input
43
+ Use `parse_ts_macro_input!` to convert the token stream:
44
+ ```
73
45
  use macroforge_ts::ts_syn::{Data, DeriveInput, parse_ts_macro_input};
74
46
 
75
47
  #[ts_macro_derive(MyMacro)]
@@ -91,11 +63,8 @@ pub fn my_macro(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
91
63
  }
92
64
  }
93
65
  }
94
- ```
95
-
96
- ## DeriveInput Structure
97
-
98
- ```rust
66
+ ``` ## DeriveInput Structure
67
+ ```
99
68
  struct DeriveInput {
100
69
  pub ident: Ident, // The type name
101
70
  pub span: SpanIR, // Span of the type definition
@@ -153,13 +122,9 @@ impl DataTypeAlias {
153
122
  fn as_union(&self) -> Option<&[TypeMember]>;
154
123
  fn as_object(&self) -> Option<&[InterfaceFieldIR]>;
155
124
  }
156
- ```
157
-
158
- ## Accessing Field Data
159
-
160
- ### Class Fields (FieldIR)
161
-
162
- ```rust
125
+ ``` ## Accessing Field Data
126
+ ### Class Fields (FieldIR)
127
+ ```
163
128
  struct FieldIR {
164
129
  pub name: String, // Field name
165
130
  pub span: SpanIR, // Field span
@@ -169,11 +134,8 @@ struct FieldIR {
169
134
  pub visibility: Visibility, // Public, Protected, Private
170
135
  pub decorators: Vec<DecoratorIR>, // Field decorators
171
136
  }
172
- ```
173
-
174
- ### Interface Fields (InterfaceFieldIR)
175
-
176
- ```rust
137
+ ``` ### Interface Fields (InterfaceFieldIR)
138
+ ```
177
139
  struct InterfaceFieldIR {
178
140
  pub name: String,
179
141
  pub span: SpanIR,
@@ -183,37 +145,24 @@ struct InterfaceFieldIR {
183
145
  pub decorators: Vec<DecoratorIR>,
184
146
  // Note: No visibility field (interfaces are always public)
185
147
  }
186
- ```
187
-
188
- ### Enum Variants (EnumVariantIR)
189
-
190
- ```rust
148
+ ``` ### Enum Variants (EnumVariantIR)
149
+ ```
191
150
  struct EnumVariantIR {
192
151
  pub name: String,
193
152
  pub span: SpanIR,
194
153
  pub value: EnumValue, // Auto, String(String), or Number(f64)
195
154
  pub decorators: Vec<DecoratorIR>,
196
155
  }
197
- ```
198
-
199
- ### Decorator Structure
200
-
201
- ```rust
156
+ ``` ### Decorator Structure
157
+ ```
202
158
  struct DecoratorIR {
203
159
  pub name: String, // e.g., "serde"
204
160
  pub args_src: String, // Raw args text, e.g., "skip, rename: 'id'"
205
161
  pub span: SpanIR,
206
162
  }
207
- ```
208
-
209
- >
210
- > To check for decorators, iterate through `field.decorators` and check `decorator.name`. For parsing options, you can write helper functions like the built-in macros do.
211
-
212
- ## Adding Imports
213
-
214
- If your macro generates code that requires imports, use the `add_import` method on `TsStream`:
215
-
216
- ```rust
163
+ ``` > **Note:** To check for decorators, iterate through field.decorators and check decorator.name. For parsing options, you can write helper functions like the built-in macros do. ## Adding Imports
164
+ If your macro generates code that requires imports, use the `add_import` method on `TsStream`:
165
+ ```
217
166
  // Add an import to be inserted at the top of the file
218
167
  let mut output = body! {
219
168
  validate(): ValidationResult {
@@ -226,16 +175,9 @@ output.add_import("validateFields", "my-validation-lib");
226
175
  output.add_import("ValidationResult", "my-validation-lib");
227
176
 
228
177
  Ok(output)
229
- ```
230
-
231
- >
232
- > Imports are automatically deduplicated. If the same import already exists in the file, it won't be added again.
233
-
234
- ## Returning Errors
235
-
236
- Use `MacroforgeError` to report errors with source locations:
237
-
238
- ```rust
178
+ ``` > **Note:** Imports are automatically deduplicated. If the same import already exists in the file, it won't be added again. ## Returning Errors
179
+ Use `MacroforgeError` to report errors with source locations:
180
+ ```
239
181
  #[ts_macro_derive(ClassOnly)]
240
182
  pub fn class_only(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
241
183
  let input = parse_ts_macro_input!(input as DeriveInput);
@@ -251,11 +193,8 @@ pub fn class_only(mut input: TsStream) -> Result<TsStream, MacroforgeError> {
251
193
  )),
252
194
  }
253
195
  }
254
- ```
255
-
256
- ## Complete Example
257
-
258
- ```rust
196
+ ``` ## Complete Example
197
+ ```
259
198
  use macroforge_ts::macros::{ts_macro_derive, body};
260
199
  use macroforge_ts::ts_syn::{
261
200
  Data, DeriveInput, FieldIR, MacroforgeError, TsStream, parse_ts_macro_input,
@@ -299,8 +238,5 @@ pub fn derive_validate(mut input: TsStream) -> Result<TsStream, MacroforgeError>
299
238
  )),
300
239
  }
301
240
  }
302
- ```
303
-
304
- ## Next Steps
305
-
306
- - [Learn the template syntax]({base}/docs/custom-macros/ts-quote)
241
+ ``` ## Next Steps
242
+ - [Learn the template syntax](../../docs/custom-macros/ts-quote)