Skip to content

Commit 6d4da67

Browse files
committed
dev-call make-ast-diagram
1 parent c0d8cc3 commit 6d4da67

File tree

7 files changed

+2005
-1
lines changed

7 files changed

+2005
-1
lines changed

src/command/dev-call/cmd.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { commands } from "../command.ts";
44
import { buildJsCommand } from "./build-artifacts/cmd.ts";
55
import { validateYamlCommand } from "./validate-yaml/cmd.ts";
66
import { showAstTraceCommand } from "./show-ast-trace/cmd.ts";
7+
import { makeAstDiagramCommand } from "./make-ast-diagram/cmd.ts";
78

89
type CommandOptionInfo = {
910
name: string;
@@ -73,4 +74,5 @@ export const devCallCommand = new Command()
7374
.command("cli-info", generateCliInfoCommand)
7475
.command("validate-yaml", validateYamlCommand)
7576
.command("build-artifacts", buildJsCommand)
76-
.command("show-ast-trace", showAstTraceCommand);
77+
.command("show-ast-trace", showAstTraceCommand)
78+
.command("make-ast-diagram", makeAstDiagramCommand);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* cmd.ts
3+
*
4+
* Copyright (C) 2025 Posit Software, PBC
5+
*/
6+
7+
import { Command } from "cliffy/command/mod.ts";
8+
import { join } from "../../../deno_ral/path.ts";
9+
import { resourcePath } from "../../../core/resources.ts";
10+
import { execProcess } from "../../../core/process.ts";
11+
12+
export const makeAstDiagramCommand = new Command()
13+
.name("make-ast-diagram")
14+
.hidden()
15+
.arguments("<arguments...>")
16+
.description(
17+
"Creates a diagram of the Pandoc AST.\n\n",
18+
)
19+
.action(async (_options: unknown, ...args: string[]) => {
20+
const renderOpts = {
21+
cmd: Deno.execPath(),
22+
args: [
23+
"run",
24+
"--allow-read",
25+
"--allow-write",
26+
"--allow-run",
27+
resourcePath(join("tools", "ast-diagram", "main.ts")),
28+
...args,
29+
],
30+
};
31+
await execProcess(renderOpts);
32+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is currently copied over from https://github.com/cscheid/pandoc-ast-block-diagram
2+
3+
Ideally that becomes a whole set of NPM packages, and we then import from that directly.

0 commit comments

Comments
 (0)