Skip to content

Commit f87a225

Browse files
committed
Add support for macro doc comments
1 parent b4e1f96 commit f87a225

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ vscode-hex-casting now supports Hex Casting 0.11.2 for Minecraft 1.20.1! This is
3535
"hex-casting.disabledModIds": ["hexal", "moreiotas"]
3636
}
3737
```
38+
- Added support for setting the description of macros. Any lines starting with `///` immediately after the macro definition will be included as Markdown. For example:
39+
```
40+
#define My Macro (EAST aqweds) = int -> str
41+
/// **Description line 1.**
42+
/// More text on description line 1.
43+
///
44+
/// Description line 2.
45+
```
3846

3947
### Changes
4048

src/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,18 @@ async function refreshDirectivesAndDiagnostics(
962962
return;
963963
}
964964

965+
let descriptionLines = [];
966+
for (let i = lineIndex + 1; i < document.lineCount; i++) {
967+
const line = document.lineAt(i).text.trim();
968+
if (!line.startsWith("///")) break;
969+
descriptionLines.push(line.slice(3).trimStart());
970+
}
971+
965972
newMacroRegistryWithImports[translation] = newMacroRegistry[translation] = new MacroPatternInfo({
966973
translation,
967974
direction,
968975
signature,
976+
description: descriptionLines.join("\n") || undefined,
969977
inputs,
970978
outputs,
971979
});

src/patterns/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ export class MacroPatternInfo {
8989
translation,
9090
direction,
9191
signature,
92+
description,
9293
inputs,
9394
outputs,
9495
}: {
9596
translation: string;
9697
direction?: Direction;
9798
signature?: string;
99+
description?: string;
98100
inputs?: string;
99101
outputs?: string;
100102
}) {
@@ -103,7 +105,7 @@ export class MacroPatternInfo {
103105
this.signature = signature ?? null;
104106
this.operators = [
105107
{
106-
description: null,
108+
description: description ?? null,
107109
inputs: inputs ?? null,
108110
outputs: outputs ?? null,
109111
book_url: null,

test.hexpattern

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Imported
77
#define Foo's Reflection = int ->[str]*/
88
#define (e) = int->[str]
99
#define Foo's Reflection (northeast aqweds) = int->[str] //
10+
/// **Description line 1.**
11+
/// More text on description line 1.
12+
///
13+
/// Description line 2.
1014
#define Foo's Reflection1 (nse aaa) = int ->[str]
1115
#define Foo's Reflection2 (w) = int -> [str]
1216
#define Foo's Reflection3 (se d) = int ->
@@ -24,6 +28,8 @@ Imported
2428
#define Foo's Purification3 (e)
2529
#define Foo's Purification4 (e) =
2630
#define Foo's Reflection12
31+
/// description line 1
32+
/// description line 2
2733
#define Foo's Reflection13 = int -> int
2834
#define Foo =
2935
define Foo

0 commit comments

Comments
 (0)