Skip to content

Commit 4fc65b4

Browse files
committed
feat: this adds support for rendering with generateDocs
1 parent e1d5e73 commit 4fc65b4

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

bun.lock

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@docusaurus/utils": "3.9.2",
3838
"@docusaurus/utils-common": "3.9.2",
3939
"@docusaurus/utils-validation": "3.9.2",
40+
"@open-rpc/markdown-generator": "workspace:*",
4041
"@open-rpc/meta-schema": "^1.14.9",
4142
"@open-rpc/schema-utils-js": "^2.1.2",
4243
},
@@ -91,10 +92,11 @@
9192
},
9293
},
9394
"packages/markdown-generator": {
94-
"name": "markdown-gen",
95+
"name": "@open-rpc/markdown-generator",
9596
"version": "0.0.0-development",
9697
"dependencies": {
9798
"@open-rpc/json-schema-renderer": "workspace:*",
99+
"@open-rpc/schema-utils-js": "^2.1.2",
98100
"@types/mdast": "^4.0.4",
99101
},
100102
"devDependencies": {
@@ -601,6 +603,8 @@
601603

602604
"@open-rpc/json-schema-renderer": ["@open-rpc/json-schema-renderer@workspace:packages/json-schema-renderer"],
603605

606+
"@open-rpc/markdown-generator": ["@open-rpc/markdown-generator@workspace:packages/markdown-generator"],
607+
604608
"@open-rpc/meta-schema": ["@open-rpc/[email protected]", "", {}, "sha512-2/CbDzOVpcaSnMs28TsRv8MKJwJi0TTYFlQ6q6qobAH26oIuhYgcZooKf4l71emgntU6MMcFQCA0h4mJ4dBCdA=="],
605609

606610
"@open-rpc/schema-utils-js": ["@open-rpc/[email protected]", "", { "dependencies": { "@json-schema-tools/dereferencer": "^1.6.3", "@json-schema-tools/meta-schema": "^1.7.5", "@json-schema-tools/reference-resolver": "^1.2.6", "@open-rpc/meta-schema": "^1.14.9", "@open-rpc/specification-extension-spec": "^1.0.2", "ajv": "^6.10.0", "detect-node": "^2.0.4", "fast-safe-stringify": "^2.0.7", "fs-extra": "^10.1.0", "is-url": "^1.2.4", "isomorphic-fetch": "^3.0.0" } }, "sha512-GQT+UQSBg/xoPW3NMr7a9YV9iype0DlSYUocCb1qe4IvgJk9HX6KPfXwSVCNr0S7o4fJpc6A80azqODqfkJXMQ=="],
@@ -1549,8 +1553,6 @@
15491553

15501554
"markdown-extensions": ["[email protected]", "", {}, "sha512-o5vL7aDWatOTX8LzaS1WMoaoxIiLRQJuIKKe2wAw6IeULDHaqbiqiggmx+pKvZDb1Sj+pE46Sn1T7lCqfFtg1Q=="],
15511555

1552-
"markdown-gen": ["markdown-gen@workspace:packages/markdown-generator"],
1553-
15541556
"markdown-table": ["[email protected]", "", {}, "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw=="],
15551557

15561558
"marked": ["[email protected]", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-TI3V8YYWvkVf3KJe1dRkpnjs68JUPyEa5vjKrp1XEEJUAOaQc+Qj+L1qWbPd0SJuAdQkFU0h73sXXqwDYxsiDA=="],

packages/docusaurus-plugin/src/lib.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import {
66
MethodObjectParams,
77
} from "@open-rpc/meta-schema";
88

9+
import type { Edits, SchemaEdits } from "@open-rpc/markdown-generator";
10+
import {
11+
identityEdits,
12+
identitySchemaEdits,
13+
renderMethodsToMarkdown,
14+
} from "@open-rpc/markdown-generator";
15+
916
import { promises as fs } from "fs";
1017

1118
import * as path from "path";
@@ -63,6 +70,12 @@ export async function generateDocs(inputPath: string, outputPath: string) {
6370
raw,
6471
)) as DereffedOpenrpcDocument;
6572

73+
const methods = await renderMethodsToMarkdown(
74+
doc,
75+
identityEdits,
76+
identitySchemaEdits,
77+
);
78+
6679
const outDir = outputPath;
6780
const methodsDir = path.join(outDir, "methods");
6881
const schemasDir = path.join(outDir, "schemas");
@@ -73,10 +86,10 @@ export async function generateDocs(inputPath: string, outputPath: string) {
7386

7487
await fs.writeFile(path.join(outDir, "index.md"), renderIndex(doc), "utf8");
7588

76-
for (const m of doc.methods) {
89+
for (const m of methods) {
7790
await fs.writeFile(
78-
path.join(methodsDir, `${m.name}.mdx`),
79-
renderMethod(m),
91+
path.join(methodsDir, `${m.methodName}.mdx`),
92+
m.markdown,
8093
"utf8",
8194
);
8295
}

0 commit comments

Comments
 (0)