@webpieces/docs-site 0.0.1
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.
- package/README.md +83 -0
- package/package.json +28 -0
- package/src/DocsSiteError.d.ts +24 -0
- package/src/DocsSiteError.js +33 -0
- package/src/DocsSiteError.js.map +1 -0
- package/src/assets/SiteScript.d.ts +11 -0
- package/src/assets/SiteScript.js +88 -0
- package/src/assets/SiteScript.js.map +1 -0
- package/src/assets/SiteStyles.d.ts +13 -0
- package/src/assets/SiteStyles.js +106 -0
- package/src/assets/SiteStyles.js.map +1 -0
- package/src/cli/DocsSiteCli.d.ts +37 -0
- package/src/cli/DocsSiteCli.js +116 -0
- package/src/cli/DocsSiteCli.js.map +1 -0
- package/src/cli/WpDocsSiteMain.d.ts +21 -0
- package/src/cli/WpDocsSiteMain.js +60 -0
- package/src/cli/WpDocsSiteMain.js.map +1 -0
- package/src/cli/wp-docs-site.d.ts +2 -0
- package/src/cli/wp-docs-site.js +22 -0
- package/src/cli/wp-docs-site.js.map +1 -0
- package/src/emit/SiteWriter.d.ts +13 -0
- package/src/emit/SiteWriter.js +34 -0
- package/src/emit/SiteWriter.js.map +1 -0
- package/src/index.d.ts +41 -0
- package/src/index.js +105 -0
- package/src/index.js.map +1 -0
- package/src/manifest/DocsManifest.d.ts +28 -0
- package/src/manifest/DocsManifest.js +44 -0
- package/src/manifest/DocsManifest.js.map +1 -0
- package/src/manifest/ProseLoader.d.ts +23 -0
- package/src/manifest/ProseLoader.js +81 -0
- package/src/manifest/ProseLoader.js.map +1 -0
- package/src/markdown/Markdown.d.ts +47 -0
- package/src/markdown/Markdown.js +178 -0
- package/src/markdown/Markdown.js.map +1 -0
- package/src/render/CardRenderer.d.ts +28 -0
- package/src/render/CardRenderer.js +70 -0
- package/src/render/CardRenderer.js.map +1 -0
- package/src/render/FieldTreeRenderer.d.ts +34 -0
- package/src/render/FieldTreeRenderer.js +91 -0
- package/src/render/FieldTreeRenderer.js.map +1 -0
- package/src/render/Html.d.ts +14 -0
- package/src/render/Html.js +28 -0
- package/src/render/Html.js.map +1 -0
- package/src/render/Layout.d.ts +21 -0
- package/src/render/Layout.js +74 -0
- package/src/render/Layout.js.map +1 -0
- package/src/render/NavModel.d.ts +47 -0
- package/src/render/NavModel.js +86 -0
- package/src/render/NavModel.js.map +1 -0
- package/src/render/OperationPageRenderer.d.ts +44 -0
- package/src/render/OperationPageRenderer.js +102 -0
- package/src/render/OperationPageRenderer.js.map +1 -0
- package/src/render/SitePage.d.ts +30 -0
- package/src/render/SitePage.js +46 -0
- package/src/render/SitePage.js.map +1 -0
- package/src/render/SiteRenderer.d.ts +34 -0
- package/src/render/SiteRenderer.js +121 -0
- package/src/render/SiteRenderer.js.map +1 -0
- package/src/render/SiteUrls.d.ts +24 -0
- package/src/render/SiteUrls.js +37 -0
- package/src/render/SiteUrls.js.map +1 -0
- package/src/samples/CodeSamples.d.ts +49 -0
- package/src/samples/CodeSamples.js +166 -0
- package/src/samples/CodeSamples.js.map +1 -0
- package/src/serve/DevServer.d.ts +35 -0
- package/src/serve/DevServer.js +109 -0
- package/src/serve/DevServer.js.map +1 -0
- package/src/spec/ApiSpec.d.ts +110 -0
- package/src/spec/ApiSpec.js +165 -0
- package/src/spec/ApiSpec.js.map +1 -0
- package/src/spec/ExampleBuilder.d.ts +32 -0
- package/src/spec/ExampleBuilder.js +119 -0
- package/src/spec/ExampleBuilder.js.map +1 -0
- package/src/spec/FieldTree.d.ts +75 -0
- package/src/spec/FieldTree.js +155 -0
- package/src/spec/FieldTree.js.map +1 -0
- package/src/spec/JsonNode.d.ts +53 -0
- package/src/spec/JsonNode.js +93 -0
- package/src/spec/JsonNode.js.map +1 -0
- package/src/spec/SchemaLens.d.ts +57 -0
- package/src/spec/SchemaLens.js +162 -0
- package/src/spec/SchemaLens.js.map +1 -0
- package/src/spec/SchemaShape.d.ts +22 -0
- package/src/spec/SchemaShape.js +61 -0
- package/src/spec/SchemaShape.js.map +1 -0
- package/src/spec/Slug.d.ts +16 -0
- package/src/spec/Slug.js +43 -0
- package/src/spec/Slug.js.map +1 -0
- package/src/spec/SpecLoader.d.ts +26 -0
- package/src/spec/SpecLoader.js +64 -0
- package/src/spec/SpecLoader.js.map +1 -0
- package/src/spec/SpecReader.d.ts +46 -0
- package/src/spec/SpecReader.js +174 -0
- package/src/spec/SpecReader.js.map +1 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WpDocsSiteMain = void 0;
|
|
4
|
+
const DocsSiteCli_1 = require("./DocsSiteCli");
|
|
5
|
+
const DevServer_1 = require("../serve/DevServer");
|
|
6
|
+
const DocsSiteError_1 = require("../DocsSiteError");
|
|
7
|
+
/**
|
|
8
|
+
* The body of the `wp-docs-site` bin: argument handling, the SINGLE top-level handler, and the exit
|
|
9
|
+
* code — with nothing that touches the process itself, so the suite runs the whole command.
|
|
10
|
+
*
|
|
11
|
+
* Everything below here THROWS {@link DocsSiteError} and prints nothing, so this is the only
|
|
12
|
+
* renderer of a failure and the only writer of an exit code (`.claude/review/error-output.md`). It
|
|
13
|
+
* renders from the error's FIELDS — the message, the location, the cure — rather than from a string
|
|
14
|
+
* somebody baked a cure into, so one audience's formatting never freezes into a thrower.
|
|
15
|
+
*/
|
|
16
|
+
class WpDocsSiteMain {
|
|
17
|
+
cli = new DocsSiteCli_1.DocsSiteCli();
|
|
18
|
+
/** @returns the process exit code. 0 on success, 1 on a stated failure. */
|
|
19
|
+
async run(argv, cwd, out) {
|
|
20
|
+
if (this.cli.wantsHelp(argv)) {
|
|
21
|
+
out.write(`${DocsSiteCli_1.USAGE}\n`);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- this IS the single top-level handler
|
|
25
|
+
try {
|
|
26
|
+
const result = this.cli.run(argv, cwd);
|
|
27
|
+
out.write(`wrote ${result.written.length} files to ${result.outDir}\n`);
|
|
28
|
+
await this.preview(result, out);
|
|
29
|
+
return 0;
|
|
30
|
+
// webpieces-disable no-any-unknown -- the catch binding, which TypeScript types for us
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
//const error = toError(err);
|
|
34
|
+
out.write(`${this.render(err)}\n`);
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* `--serve` starts the localhost preview and RESOLVES when it is listening, rather than blocking
|
|
40
|
+
* forever. The bin keeps the process alive because the socket is open, and the suite can start
|
|
41
|
+
* one, read a page and stop it — a run method that never returned would be untestable.
|
|
42
|
+
*/
|
|
43
|
+
async preview(result, out) {
|
|
44
|
+
if (!result.serve) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const server = new DevServer_1.DevServer(result.outDir);
|
|
48
|
+
await server.start(result.port);
|
|
49
|
+
out.write(`preview (not a host, loopback only) at ${server.url()}\n`);
|
|
50
|
+
}
|
|
51
|
+
// webpieces-disable no-any-unknown -- a caught value; this method is the audience-facing narrowing of it
|
|
52
|
+
render(err) {
|
|
53
|
+
if (!(err instanceof DocsSiteError_1.DocsSiteError)) {
|
|
54
|
+
return `wp-docs-site failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
55
|
+
}
|
|
56
|
+
return [`wp-docs-site refused: ${err.message}`, ` ${err.cure}`].join('\n');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.WpDocsSiteMain = WpDocsSiteMain;
|
|
60
|
+
//# sourceMappingURL=WpDocsSiteMain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WpDocsSiteMain.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/cli/WpDocsSiteMain.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,kDAA+C;AAC/C,oDAAiD;AAEjD;;;;;;;;GAQG;AACH,MAAa,cAAc;IACN,GAAG,GAAG,IAAI,yBAAW,EAAE,CAAC;IAEzC,2EAA2E;IAC3E,KAAK,CAAC,GAAG,CAAC,IAAuB,EAAE,GAAW,EAAE,GAA0B;QACtE,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,KAAK,CAAC,GAAG,mBAAK,IAAI,CAAC,CAAC;YACxB,OAAO,CAAC,CAAC;QACb,CAAC;QACD,sGAAsG;QACtG,IAAI,CAAC;YACD,MAAM,MAAM,GAAc,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAClD,GAAG,CAAC,KAAK,CAAC,SAAS,MAAM,CAAC,OAAO,CAAC,MAAM,aAAa,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;YACxE,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAChC,OAAO,CAAC,CAAC;YACT,uFAAuF;QAC3F,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,6BAA6B;YAC7B,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,OAAO,CAAC,MAAiB,EAAE,GAA0B;QAC/D,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO;QACX,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,qBAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,GAAG,CAAC,KAAK,CAAC,0CAA0C,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1E,CAAC;IAED,yGAAyG;IACjG,MAAM,CAAC,GAAY;QACvB,IAAI,CAAC,CAAC,GAAG,YAAY,6BAAa,CAAC,EAAE,CAAC;YAClC,OAAO,wBAAwB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QACtF,CAAC;QACD,OAAO,CAAC,yBAAyB,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,CAAC;CACJ;AA5CD,wCA4CC","sourcesContent":["import { CliResult, DocsSiteCli, USAGE } from './DocsSiteCli';\nimport { DevServer } from '../serve/DevServer';\nimport { DocsSiteError } from '../DocsSiteError';\n\n/**\n * The body of the `wp-docs-site` bin: argument handling, the SINGLE top-level handler, and the exit\n * code — with nothing that touches the process itself, so the suite runs the whole command.\n *\n * Everything below here THROWS {@link DocsSiteError} and prints nothing, so this is the only\n * renderer of a failure and the only writer of an exit code (`.claude/review/error-output.md`). It\n * renders from the error's FIELDS — the message, the location, the cure — rather than from a string\n * somebody baked a cure into, so one audience's formatting never freezes into a thrower.\n */\nexport class WpDocsSiteMain {\n private readonly cli = new DocsSiteCli();\n\n /** @returns the process exit code. 0 on success, 1 on a stated failure. */\n async run(argv: readonly string[], cwd: string, out: NodeJS.WritableStream): Promise<number> {\n if (this.cli.wantsHelp(argv)) {\n out.write(`${USAGE}\\n`);\n return 0;\n }\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- this IS the single top-level handler\n try {\n const result: CliResult = this.cli.run(argv, cwd);\n out.write(`wrote ${result.written.length} files to ${result.outDir}\\n`);\n await this.preview(result, out);\n return 0;\n // webpieces-disable no-any-unknown -- the catch binding, which TypeScript types for us\n } catch (err: unknown) {\n //const error = toError(err);\n out.write(`${this.render(err)}\\n`);\n return 1;\n }\n }\n\n /**\n * `--serve` starts the localhost preview and RESOLVES when it is listening, rather than blocking\n * forever. The bin keeps the process alive because the socket is open, and the suite can start\n * one, read a page and stop it — a run method that never returned would be untestable.\n */\n private async preview(result: CliResult, out: NodeJS.WritableStream): Promise<void> {\n if (!result.serve) {\n return;\n }\n const server = new DevServer(result.outDir);\n await server.start(result.port);\n out.write(`preview (not a host, loopback only) at ${server.url()}\\n`);\n }\n\n // webpieces-disable no-any-unknown -- a caught value; this method is the audience-facing narrowing of it\n private render(err: unknown): string {\n if (!(err instanceof DocsSiteError)) {\n return `wp-docs-site failed: ${err instanceof Error ? err.message : String(err)}`;\n }\n return [`wp-docs-site refused: ${err.message}`, ` ${err.cure}`].join('\\n');\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const WpDocsSiteMain_1 = require("./WpDocsSiteMain");
|
|
5
|
+
/**
|
|
6
|
+
* The `wp-docs-site` bin. It is a few lines because everything it does lives in
|
|
7
|
+
* {@link WpDocsSiteMain}, which the suite runs exactly as a user does — a bin whose body is only
|
|
8
|
+
* reachable by spawning a process is a bin nothing tests.
|
|
9
|
+
*
|
|
10
|
+
* The bin is declared in `publishConfig.bin`, never at the top level
|
|
11
|
+
* (`.claude/rules/packaging-and-bins.md`): pnpm chmods every `bin` target while linking a package
|
|
12
|
+
* from its SOURCE directory, where `src/` holds only `.ts` until tsc runs, so a top-level `bin`
|
|
13
|
+
* makes every `pnpm install` print an ENOENT warning. `scripts/publish-packages.sh` hoists it into
|
|
14
|
+
* the PUBLISHED manifest, and fails the release if it ever goes missing.
|
|
15
|
+
*/
|
|
16
|
+
// webpieces-disable no-process-exit-outside-main -- this IS main; WpDocsSiteMain never touches the process
|
|
17
|
+
void new WpDocsSiteMain_1.WpDocsSiteMain()
|
|
18
|
+
.run(process.argv.slice(2), process.cwd(), process.stdout)
|
|
19
|
+
.then((code) => {
|
|
20
|
+
process.exitCode = code;
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=wp-docs-site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wp-docs-site.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/cli/wp-docs-site.ts"],"names":[],"mappings":";;;AACA,qDAAkD;AAElD;;;;;;;;;;GAUG;AACH,2GAA2G;AAC3G,KAAK,IAAI,+BAAc,EAAE;KACpB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC;KACzD,IAAI,CAAC,CAAC,IAAY,EAAQ,EAAE;IACzB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC5B,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { WpDocsSiteMain } from './WpDocsSiteMain';\n\n/**\n * The `wp-docs-site` bin. It is a few lines because everything it does lives in\n * {@link WpDocsSiteMain}, which the suite runs exactly as a user does — a bin whose body is only\n * reachable by spawning a process is a bin nothing tests.\n *\n * The bin is declared in `publishConfig.bin`, never at the top level\n * (`.claude/rules/packaging-and-bins.md`): pnpm chmods every `bin` target while linking a package\n * from its SOURCE directory, where `src/` holds only `.ts` until tsc runs, so a top-level `bin`\n * makes every `pnpm install` print an ENOENT warning. `scripts/publish-packages.sh` hoists it into\n * the PUBLISHED manifest, and fails the release if it ever goes missing.\n */\n// webpieces-disable no-process-exit-outside-main -- this IS main; WpDocsSiteMain never touches the process\nvoid new WpDocsSiteMain()\n .run(process.argv.slice(2), process.cwd(), process.stdout)\n .then((code: number): void => {\n process.exitCode = code;\n });\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RenderedSite } from '../render/SitePage';
|
|
2
|
+
/**
|
|
3
|
+
* Writes a {@link RenderedSite} to a directory.
|
|
4
|
+
*
|
|
5
|
+
* The directory is created if it is not there, and files are overwritten in place. Nothing is
|
|
6
|
+
* DELETED: a renderer that cleans its output directory is one mistyped `--out` away from removing
|
|
7
|
+
* somebody's source tree, and the cost of the alternative is a stale page nobody links to.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SiteWriter {
|
|
10
|
+
/** @returns every absolute path written, in the order it was written. */
|
|
11
|
+
write(outDir: string, site: RenderedSite): readonly string[];
|
|
12
|
+
private writeOne;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SiteWriter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
7
|
+
/**
|
|
8
|
+
* Writes a {@link RenderedSite} to a directory.
|
|
9
|
+
*
|
|
10
|
+
* The directory is created if it is not there, and files are overwritten in place. Nothing is
|
|
11
|
+
* DELETED: a renderer that cleans its output directory is one mistyped `--out` away from removing
|
|
12
|
+
* somebody's source tree, and the cost of the alternative is a stale page nobody links to.
|
|
13
|
+
*/
|
|
14
|
+
class SiteWriter {
|
|
15
|
+
/** @returns every absolute path written, in the order it was written. */
|
|
16
|
+
write(outDir, site) {
|
|
17
|
+
const written = [];
|
|
18
|
+
for (const page of site.pages) {
|
|
19
|
+
written.push(this.writeOne(outDir, page.url, page.html));
|
|
20
|
+
}
|
|
21
|
+
for (const asset of site.assets) {
|
|
22
|
+
written.push(this.writeOne(outDir, asset.url, asset.contents));
|
|
23
|
+
}
|
|
24
|
+
return written;
|
|
25
|
+
}
|
|
26
|
+
writeOne(outDir, url, contents) {
|
|
27
|
+
const file = path.join(outDir, ...url.split('/'));
|
|
28
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
29
|
+
fs.writeFileSync(file, contents, 'utf8');
|
|
30
|
+
return file;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.SiteWriter = SiteWriter;
|
|
34
|
+
//# sourceMappingURL=SiteWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteWriter.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/emit/SiteWriter.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAGlC;;;;;;GAMG;AACH,MAAa,UAAU;IACnB,yEAAyE;IACzE,KAAK,CAAC,MAAc,EAAE,IAAkB;QACpC,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,QAAQ,CAAC,MAAc,EAAE,GAAW,EAAE,QAAgB;QAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAnBD,gCAmBC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { RenderedSite } from '../render/SitePage';\n\n/**\n * Writes a {@link RenderedSite} to a directory.\n *\n * The directory is created if it is not there, and files are overwritten in place. Nothing is\n * DELETED: a renderer that cleans its output directory is one mistyped `--out` away from removing\n * somebody's source tree, and the cost of the alternative is a stale page nobody links to.\n */\nexport class SiteWriter {\n /** @returns every absolute path written, in the order it was written. */\n write(outDir: string, site: RenderedSite): readonly string[] {\n const written: string[] = [];\n for (const page of site.pages) {\n written.push(this.writeOne(outDir, page.url, page.html));\n }\n for (const asset of site.assets) {\n written.push(this.writeOne(outDir, asset.url, asset.contents));\n }\n return written;\n }\n\n private writeOne(outDir: string, url: string, contents: string): string {\n const file = path.join(outDir, ...url.split('/'));\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(file, contents, 'utf8');\n return file;\n }\n}\n"]}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@webpieces/docs-site` — a static, three-pane API reference site from any OpenAPI 3.0-or-3.1
|
|
3
|
+
* document plus a directory of markdown prose.
|
|
4
|
+
*
|
|
5
|
+
* **Node builtins only.** No framework, no markdown library, no bundler, so adding docs to an
|
|
6
|
+
* upstream project never grows that project's dependency surface and this package's own build stays
|
|
7
|
+
* `tsc`. It also does NOT depend on `@webpieces/openapi-generator`, deliberately: the document is
|
|
8
|
+
* read structurally, so "generated by us" is not a precondition for "renderable by us".
|
|
9
|
+
*
|
|
10
|
+
* It ships the `wp-docs-site` bin.
|
|
11
|
+
*/
|
|
12
|
+
export { DocsSiteError } from './DocsSiteError';
|
|
13
|
+
export { JsonEntry, JsonNode } from './spec/JsonNode';
|
|
14
|
+
export type { JsonMap, JsonValue } from './spec/JsonNode';
|
|
15
|
+
export { ApiSpec, NamedSchema, OperationInfo, ResponseInfo, SecuritySchemeInfo, ServerInfo, TagSection, } from './spec/ApiSpec';
|
|
16
|
+
export { RefTarget, SchemaLens } from './spec/SchemaLens';
|
|
17
|
+
export { SchemaShape } from './spec/SchemaShape';
|
|
18
|
+
export { Slug } from './spec/Slug';
|
|
19
|
+
export { SpecLoader } from './spec/SpecLoader';
|
|
20
|
+
export { SpecReader, UNTAGGED_SECTION } from './spec/SpecReader';
|
|
21
|
+
export { FieldNode, FieldTreeBuilder, SchemaVariant } from './spec/FieldTree';
|
|
22
|
+
export { ExampleBuilder } from './spec/ExampleBuilder';
|
|
23
|
+
export { DocsManifest, ProsePage, ProsePageEntry } from './manifest/DocsManifest';
|
|
24
|
+
export { MANIFEST_FILE, ProseLoader } from './manifest/ProseLoader';
|
|
25
|
+
export { Markdown } from './markdown/Markdown';
|
|
26
|
+
export { CodeSample, CodeSampleBuilder, SampleHeader } from './samples/CodeSamples';
|
|
27
|
+
export { Html } from './render/Html';
|
|
28
|
+
export { GUIDES_GROUP, NavBuilder, NavGroup, NavLink, NavModel, SCHEMAS_GROUP, } from './render/NavModel';
|
|
29
|
+
export { SiteUrls } from './render/SiteUrls';
|
|
30
|
+
export { Layout } from './render/Layout';
|
|
31
|
+
export { COLLAPSE_ALL_LABEL, CardRenderer, REQUEST_LABEL } from './render/CardRenderer';
|
|
32
|
+
export { FieldTreeRenderer, POSSIBLE_VALUES } from './render/FieldTreeRenderer';
|
|
33
|
+
export { OperationPageRenderer, WEBHOOK_BADGE } from './render/OperationPageRenderer';
|
|
34
|
+
export { RenderedSite, SiteAsset, SitePage } from './render/SitePage';
|
|
35
|
+
export { OVERVIEW_TITLE, SiteRenderer } from './render/SiteRenderer';
|
|
36
|
+
export { SiteStyles } from './assets/SiteStyles';
|
|
37
|
+
export { SiteScript } from './assets/SiteScript';
|
|
38
|
+
export { SiteWriter } from './emit/SiteWriter';
|
|
39
|
+
export { DevServer, LOOPBACK } from './serve/DevServer';
|
|
40
|
+
export { CliResult, DocsSiteCli, USAGE } from './cli/DocsSiteCli';
|
|
41
|
+
export { WpDocsSiteMain } from './cli/WpDocsSiteMain';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OVERVIEW_TITLE = exports.SitePage = exports.SiteAsset = exports.RenderedSite = exports.WEBHOOK_BADGE = exports.OperationPageRenderer = exports.POSSIBLE_VALUES = exports.FieldTreeRenderer = exports.REQUEST_LABEL = exports.CardRenderer = exports.COLLAPSE_ALL_LABEL = exports.Layout = exports.SiteUrls = exports.SCHEMAS_GROUP = exports.NavModel = exports.NavLink = exports.NavGroup = exports.NavBuilder = exports.GUIDES_GROUP = exports.Html = exports.SampleHeader = exports.CodeSampleBuilder = exports.CodeSample = exports.Markdown = exports.ProseLoader = exports.MANIFEST_FILE = exports.ProsePageEntry = exports.ProsePage = exports.DocsManifest = exports.ExampleBuilder = exports.SchemaVariant = exports.FieldTreeBuilder = exports.FieldNode = exports.UNTAGGED_SECTION = exports.SpecReader = exports.SpecLoader = exports.Slug = exports.SchemaShape = exports.SchemaLens = exports.RefTarget = exports.TagSection = exports.ServerInfo = exports.SecuritySchemeInfo = exports.ResponseInfo = exports.OperationInfo = exports.NamedSchema = exports.ApiSpec = exports.JsonNode = exports.JsonEntry = exports.DocsSiteError = void 0;
|
|
4
|
+
exports.WpDocsSiteMain = exports.USAGE = exports.DocsSiteCli = exports.CliResult = exports.LOOPBACK = exports.DevServer = exports.SiteWriter = exports.SiteScript = exports.SiteStyles = exports.SiteRenderer = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* `@webpieces/docs-site` — a static, three-pane API reference site from any OpenAPI 3.0-or-3.1
|
|
7
|
+
* document plus a directory of markdown prose.
|
|
8
|
+
*
|
|
9
|
+
* **Node builtins only.** No framework, no markdown library, no bundler, so adding docs to an
|
|
10
|
+
* upstream project never grows that project's dependency surface and this package's own build stays
|
|
11
|
+
* `tsc`. It also does NOT depend on `@webpieces/openapi-generator`, deliberately: the document is
|
|
12
|
+
* read structurally, so "generated by us" is not a precondition for "renderable by us".
|
|
13
|
+
*
|
|
14
|
+
* It ships the `wp-docs-site` bin.
|
|
15
|
+
*/
|
|
16
|
+
var DocsSiteError_1 = require("./DocsSiteError");
|
|
17
|
+
Object.defineProperty(exports, "DocsSiteError", { enumerable: true, get: function () { return DocsSiteError_1.DocsSiteError; } });
|
|
18
|
+
var JsonNode_1 = require("./spec/JsonNode");
|
|
19
|
+
Object.defineProperty(exports, "JsonEntry", { enumerable: true, get: function () { return JsonNode_1.JsonEntry; } });
|
|
20
|
+
Object.defineProperty(exports, "JsonNode", { enumerable: true, get: function () { return JsonNode_1.JsonNode; } });
|
|
21
|
+
var ApiSpec_1 = require("./spec/ApiSpec");
|
|
22
|
+
Object.defineProperty(exports, "ApiSpec", { enumerable: true, get: function () { return ApiSpec_1.ApiSpec; } });
|
|
23
|
+
Object.defineProperty(exports, "NamedSchema", { enumerable: true, get: function () { return ApiSpec_1.NamedSchema; } });
|
|
24
|
+
Object.defineProperty(exports, "OperationInfo", { enumerable: true, get: function () { return ApiSpec_1.OperationInfo; } });
|
|
25
|
+
Object.defineProperty(exports, "ResponseInfo", { enumerable: true, get: function () { return ApiSpec_1.ResponseInfo; } });
|
|
26
|
+
Object.defineProperty(exports, "SecuritySchemeInfo", { enumerable: true, get: function () { return ApiSpec_1.SecuritySchemeInfo; } });
|
|
27
|
+
Object.defineProperty(exports, "ServerInfo", { enumerable: true, get: function () { return ApiSpec_1.ServerInfo; } });
|
|
28
|
+
Object.defineProperty(exports, "TagSection", { enumerable: true, get: function () { return ApiSpec_1.TagSection; } });
|
|
29
|
+
var SchemaLens_1 = require("./spec/SchemaLens");
|
|
30
|
+
Object.defineProperty(exports, "RefTarget", { enumerable: true, get: function () { return SchemaLens_1.RefTarget; } });
|
|
31
|
+
Object.defineProperty(exports, "SchemaLens", { enumerable: true, get: function () { return SchemaLens_1.SchemaLens; } });
|
|
32
|
+
var SchemaShape_1 = require("./spec/SchemaShape");
|
|
33
|
+
Object.defineProperty(exports, "SchemaShape", { enumerable: true, get: function () { return SchemaShape_1.SchemaShape; } });
|
|
34
|
+
var Slug_1 = require("./spec/Slug");
|
|
35
|
+
Object.defineProperty(exports, "Slug", { enumerable: true, get: function () { return Slug_1.Slug; } });
|
|
36
|
+
var SpecLoader_1 = require("./spec/SpecLoader");
|
|
37
|
+
Object.defineProperty(exports, "SpecLoader", { enumerable: true, get: function () { return SpecLoader_1.SpecLoader; } });
|
|
38
|
+
var SpecReader_1 = require("./spec/SpecReader");
|
|
39
|
+
Object.defineProperty(exports, "SpecReader", { enumerable: true, get: function () { return SpecReader_1.SpecReader; } });
|
|
40
|
+
Object.defineProperty(exports, "UNTAGGED_SECTION", { enumerable: true, get: function () { return SpecReader_1.UNTAGGED_SECTION; } });
|
|
41
|
+
var FieldTree_1 = require("./spec/FieldTree");
|
|
42
|
+
Object.defineProperty(exports, "FieldNode", { enumerable: true, get: function () { return FieldTree_1.FieldNode; } });
|
|
43
|
+
Object.defineProperty(exports, "FieldTreeBuilder", { enumerable: true, get: function () { return FieldTree_1.FieldTreeBuilder; } });
|
|
44
|
+
Object.defineProperty(exports, "SchemaVariant", { enumerable: true, get: function () { return FieldTree_1.SchemaVariant; } });
|
|
45
|
+
var ExampleBuilder_1 = require("./spec/ExampleBuilder");
|
|
46
|
+
Object.defineProperty(exports, "ExampleBuilder", { enumerable: true, get: function () { return ExampleBuilder_1.ExampleBuilder; } });
|
|
47
|
+
var DocsManifest_1 = require("./manifest/DocsManifest");
|
|
48
|
+
Object.defineProperty(exports, "DocsManifest", { enumerable: true, get: function () { return DocsManifest_1.DocsManifest; } });
|
|
49
|
+
Object.defineProperty(exports, "ProsePage", { enumerable: true, get: function () { return DocsManifest_1.ProsePage; } });
|
|
50
|
+
Object.defineProperty(exports, "ProsePageEntry", { enumerable: true, get: function () { return DocsManifest_1.ProsePageEntry; } });
|
|
51
|
+
var ProseLoader_1 = require("./manifest/ProseLoader");
|
|
52
|
+
Object.defineProperty(exports, "MANIFEST_FILE", { enumerable: true, get: function () { return ProseLoader_1.MANIFEST_FILE; } });
|
|
53
|
+
Object.defineProperty(exports, "ProseLoader", { enumerable: true, get: function () { return ProseLoader_1.ProseLoader; } });
|
|
54
|
+
var Markdown_1 = require("./markdown/Markdown");
|
|
55
|
+
Object.defineProperty(exports, "Markdown", { enumerable: true, get: function () { return Markdown_1.Markdown; } });
|
|
56
|
+
var CodeSamples_1 = require("./samples/CodeSamples");
|
|
57
|
+
Object.defineProperty(exports, "CodeSample", { enumerable: true, get: function () { return CodeSamples_1.CodeSample; } });
|
|
58
|
+
Object.defineProperty(exports, "CodeSampleBuilder", { enumerable: true, get: function () { return CodeSamples_1.CodeSampleBuilder; } });
|
|
59
|
+
Object.defineProperty(exports, "SampleHeader", { enumerable: true, get: function () { return CodeSamples_1.SampleHeader; } });
|
|
60
|
+
var Html_1 = require("./render/Html");
|
|
61
|
+
Object.defineProperty(exports, "Html", { enumerable: true, get: function () { return Html_1.Html; } });
|
|
62
|
+
var NavModel_1 = require("./render/NavModel");
|
|
63
|
+
Object.defineProperty(exports, "GUIDES_GROUP", { enumerable: true, get: function () { return NavModel_1.GUIDES_GROUP; } });
|
|
64
|
+
Object.defineProperty(exports, "NavBuilder", { enumerable: true, get: function () { return NavModel_1.NavBuilder; } });
|
|
65
|
+
Object.defineProperty(exports, "NavGroup", { enumerable: true, get: function () { return NavModel_1.NavGroup; } });
|
|
66
|
+
Object.defineProperty(exports, "NavLink", { enumerable: true, get: function () { return NavModel_1.NavLink; } });
|
|
67
|
+
Object.defineProperty(exports, "NavModel", { enumerable: true, get: function () { return NavModel_1.NavModel; } });
|
|
68
|
+
Object.defineProperty(exports, "SCHEMAS_GROUP", { enumerable: true, get: function () { return NavModel_1.SCHEMAS_GROUP; } });
|
|
69
|
+
var SiteUrls_1 = require("./render/SiteUrls");
|
|
70
|
+
Object.defineProperty(exports, "SiteUrls", { enumerable: true, get: function () { return SiteUrls_1.SiteUrls; } });
|
|
71
|
+
var Layout_1 = require("./render/Layout");
|
|
72
|
+
Object.defineProperty(exports, "Layout", { enumerable: true, get: function () { return Layout_1.Layout; } });
|
|
73
|
+
var CardRenderer_1 = require("./render/CardRenderer");
|
|
74
|
+
Object.defineProperty(exports, "COLLAPSE_ALL_LABEL", { enumerable: true, get: function () { return CardRenderer_1.COLLAPSE_ALL_LABEL; } });
|
|
75
|
+
Object.defineProperty(exports, "CardRenderer", { enumerable: true, get: function () { return CardRenderer_1.CardRenderer; } });
|
|
76
|
+
Object.defineProperty(exports, "REQUEST_LABEL", { enumerable: true, get: function () { return CardRenderer_1.REQUEST_LABEL; } });
|
|
77
|
+
var FieldTreeRenderer_1 = require("./render/FieldTreeRenderer");
|
|
78
|
+
Object.defineProperty(exports, "FieldTreeRenderer", { enumerable: true, get: function () { return FieldTreeRenderer_1.FieldTreeRenderer; } });
|
|
79
|
+
Object.defineProperty(exports, "POSSIBLE_VALUES", { enumerable: true, get: function () { return FieldTreeRenderer_1.POSSIBLE_VALUES; } });
|
|
80
|
+
var OperationPageRenderer_1 = require("./render/OperationPageRenderer");
|
|
81
|
+
Object.defineProperty(exports, "OperationPageRenderer", { enumerable: true, get: function () { return OperationPageRenderer_1.OperationPageRenderer; } });
|
|
82
|
+
Object.defineProperty(exports, "WEBHOOK_BADGE", { enumerable: true, get: function () { return OperationPageRenderer_1.WEBHOOK_BADGE; } });
|
|
83
|
+
var SitePage_1 = require("./render/SitePage");
|
|
84
|
+
Object.defineProperty(exports, "RenderedSite", { enumerable: true, get: function () { return SitePage_1.RenderedSite; } });
|
|
85
|
+
Object.defineProperty(exports, "SiteAsset", { enumerable: true, get: function () { return SitePage_1.SiteAsset; } });
|
|
86
|
+
Object.defineProperty(exports, "SitePage", { enumerable: true, get: function () { return SitePage_1.SitePage; } });
|
|
87
|
+
var SiteRenderer_1 = require("./render/SiteRenderer");
|
|
88
|
+
Object.defineProperty(exports, "OVERVIEW_TITLE", { enumerable: true, get: function () { return SiteRenderer_1.OVERVIEW_TITLE; } });
|
|
89
|
+
Object.defineProperty(exports, "SiteRenderer", { enumerable: true, get: function () { return SiteRenderer_1.SiteRenderer; } });
|
|
90
|
+
var SiteStyles_1 = require("./assets/SiteStyles");
|
|
91
|
+
Object.defineProperty(exports, "SiteStyles", { enumerable: true, get: function () { return SiteStyles_1.SiteStyles; } });
|
|
92
|
+
var SiteScript_1 = require("./assets/SiteScript");
|
|
93
|
+
Object.defineProperty(exports, "SiteScript", { enumerable: true, get: function () { return SiteScript_1.SiteScript; } });
|
|
94
|
+
var SiteWriter_1 = require("./emit/SiteWriter");
|
|
95
|
+
Object.defineProperty(exports, "SiteWriter", { enumerable: true, get: function () { return SiteWriter_1.SiteWriter; } });
|
|
96
|
+
var DevServer_1 = require("./serve/DevServer");
|
|
97
|
+
Object.defineProperty(exports, "DevServer", { enumerable: true, get: function () { return DevServer_1.DevServer; } });
|
|
98
|
+
Object.defineProperty(exports, "LOOPBACK", { enumerable: true, get: function () { return DevServer_1.LOOPBACK; } });
|
|
99
|
+
var DocsSiteCli_1 = require("./cli/DocsSiteCli");
|
|
100
|
+
Object.defineProperty(exports, "CliResult", { enumerable: true, get: function () { return DocsSiteCli_1.CliResult; } });
|
|
101
|
+
Object.defineProperty(exports, "DocsSiteCli", { enumerable: true, get: function () { return DocsSiteCli_1.DocsSiteCli; } });
|
|
102
|
+
Object.defineProperty(exports, "USAGE", { enumerable: true, get: function () { return DocsSiteCli_1.USAGE; } });
|
|
103
|
+
var WpDocsSiteMain_1 = require("./cli/WpDocsSiteMain");
|
|
104
|
+
Object.defineProperty(exports, "WpDocsSiteMain", { enumerable: true, get: function () { return WpDocsSiteMain_1.WpDocsSiteMain; } });
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/docs-site/src/index.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;GAUG;AACH,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,4CAAsD;AAA7C,qGAAA,SAAS,OAAA;AAAE,oGAAA,QAAQ,OAAA;AAE5B,0CAQwB;AAPpB,kGAAA,OAAO,OAAA;AACP,sGAAA,WAAW,OAAA;AACX,wGAAA,aAAa,OAAA;AACb,uGAAA,YAAY,OAAA;AACZ,6GAAA,kBAAkB,OAAA;AAClB,qGAAA,UAAU,OAAA;AACV,qGAAA,UAAU,OAAA;AAEd,gDAA0D;AAAjD,uGAAA,SAAS,OAAA;AAAE,wGAAA,UAAU,OAAA;AAC9B,kDAAiD;AAAxC,0GAAA,WAAW,OAAA;AACpB,oCAAmC;AAA1B,4FAAA,IAAI,OAAA;AACb,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,gDAAiE;AAAxD,wGAAA,UAAU,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACrC,8CAA8E;AAArE,sGAAA,SAAS,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAAE,0GAAA,aAAa,OAAA;AACnD,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,wDAAkF;AAAzE,4GAAA,YAAY,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,8GAAA,cAAc,OAAA;AAChD,sDAAoE;AAA3D,4GAAA,aAAa,OAAA;AAAE,0GAAA,WAAW,OAAA;AACnC,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,qDAAoF;AAA3E,yGAAA,UAAU,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAAE,2GAAA,YAAY,OAAA;AACpD,sCAAqC;AAA5B,4FAAA,IAAI,OAAA;AACb,8CAO2B;AANvB,wGAAA,YAAY,OAAA;AACZ,sGAAA,UAAU,OAAA;AACV,oGAAA,QAAQ,OAAA;AACR,mGAAA,OAAO,OAAA;AACP,oGAAA,QAAQ,OAAA;AACR,yGAAA,aAAa,OAAA;AAEjB,8CAA6C;AAApC,oGAAA,QAAQ,OAAA;AACjB,0CAAyC;AAAhC,gGAAA,MAAM,OAAA;AACf,sDAAwF;AAA/E,kHAAA,kBAAkB,OAAA;AAAE,4GAAA,YAAY,OAAA;AAAE,6GAAA,aAAa,OAAA;AACxD,gEAAgF;AAAvE,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAC3C,wEAAsF;AAA7E,8HAAA,qBAAqB,OAAA;AAAE,sHAAA,aAAa,OAAA;AAC7C,8CAAsE;AAA7D,wGAAA,YAAY,OAAA;AAAE,qGAAA,SAAS,OAAA;AAAE,oGAAA,QAAQ,OAAA;AAC1C,sDAAqE;AAA5D,8GAAA,cAAc,OAAA;AAAE,4GAAA,YAAY,OAAA;AACrC,kDAAiD;AAAxC,wGAAA,UAAU,OAAA;AACnB,kDAAiD;AAAxC,wGAAA,UAAU,OAAA;AACnB,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,+CAAwD;AAA/C,sGAAA,SAAS,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAC5B,iDAAkE;AAAzD,wGAAA,SAAS,OAAA;AAAE,0GAAA,WAAW,OAAA;AAAE,oGAAA,KAAK,OAAA;AACtC,uDAAsD;AAA7C,gHAAA,cAAc,OAAA","sourcesContent":["/**\n * `@webpieces/docs-site` — a static, three-pane API reference site from any OpenAPI 3.0-or-3.1\n * document plus a directory of markdown prose.\n *\n * **Node builtins only.** No framework, no markdown library, no bundler, so adding docs to an\n * upstream project never grows that project's dependency surface and this package's own build stays\n * `tsc`. It also does NOT depend on `@webpieces/openapi-generator`, deliberately: the document is\n * read structurally, so \"generated by us\" is not a precondition for \"renderable by us\".\n *\n * It ships the `wp-docs-site` bin.\n */\nexport { DocsSiteError } from './DocsSiteError';\nexport { JsonEntry, JsonNode } from './spec/JsonNode';\nexport type { JsonMap, JsonValue } from './spec/JsonNode';\nexport {\n ApiSpec,\n NamedSchema,\n OperationInfo,\n ResponseInfo,\n SecuritySchemeInfo,\n ServerInfo,\n TagSection,\n} from './spec/ApiSpec';\nexport { RefTarget, SchemaLens } from './spec/SchemaLens';\nexport { SchemaShape } from './spec/SchemaShape';\nexport { Slug } from './spec/Slug';\nexport { SpecLoader } from './spec/SpecLoader';\nexport { SpecReader, UNTAGGED_SECTION } from './spec/SpecReader';\nexport { FieldNode, FieldTreeBuilder, SchemaVariant } from './spec/FieldTree';\nexport { ExampleBuilder } from './spec/ExampleBuilder';\nexport { DocsManifest, ProsePage, ProsePageEntry } from './manifest/DocsManifest';\nexport { MANIFEST_FILE, ProseLoader } from './manifest/ProseLoader';\nexport { Markdown } from './markdown/Markdown';\nexport { CodeSample, CodeSampleBuilder, SampleHeader } from './samples/CodeSamples';\nexport { Html } from './render/Html';\nexport {\n GUIDES_GROUP,\n NavBuilder,\n NavGroup,\n NavLink,\n NavModel,\n SCHEMAS_GROUP,\n} from './render/NavModel';\nexport { SiteUrls } from './render/SiteUrls';\nexport { Layout } from './render/Layout';\nexport { COLLAPSE_ALL_LABEL, CardRenderer, REQUEST_LABEL } from './render/CardRenderer';\nexport { FieldTreeRenderer, POSSIBLE_VALUES } from './render/FieldTreeRenderer';\nexport { OperationPageRenderer, WEBHOOK_BADGE } from './render/OperationPageRenderer';\nexport { RenderedSite, SiteAsset, SitePage } from './render/SitePage';\nexport { OVERVIEW_TITLE, SiteRenderer } from './render/SiteRenderer';\nexport { SiteStyles } from './assets/SiteStyles';\nexport { SiteScript } from './assets/SiteScript';\nexport { SiteWriter } from './emit/SiteWriter';\nexport { DevServer, LOOPBACK } from './serve/DevServer';\nexport { CliResult, DocsSiteCli, USAGE } from './cli/DocsSiteCli';\nexport { WpDocsSiteMain } from './cli/WpDocsSiteMain';\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** One prose page named by `docs.manifest.json`, in the order the manifest names it. */
|
|
2
|
+
export declare class ProsePageEntry {
|
|
3
|
+
readonly file: string;
|
|
4
|
+
readonly title: string;
|
|
5
|
+
constructor(file: string, title: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `docs.manifest.json` — the ORDER of the prose pages, and nothing else.
|
|
9
|
+
*
|
|
10
|
+
* It exists for the same reason the OpenAPI document's `tags[]` does: the order is a teaching
|
|
11
|
+
* decision somebody made, and neither directory listing order nor alphabetical order is it.
|
|
12
|
+
* Alphabetising this array is not a cleanup — it reorders the pages a partner reads first.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DocsManifest {
|
|
15
|
+
/** Overrides the document's `info.title` in the site header. Empty means "use the document's". */
|
|
16
|
+
readonly title: string;
|
|
17
|
+
readonly pages: readonly ProsePageEntry[];
|
|
18
|
+
constructor(
|
|
19
|
+
/** Overrides the document's `info.title` in the site header. Empty means "use the document's". */
|
|
20
|
+
title: string, pages: readonly ProsePageEntry[]);
|
|
21
|
+
}
|
|
22
|
+
/** One prose page, loaded: its heading, its URL segment and its markdown source. */
|
|
23
|
+
export declare class ProsePage {
|
|
24
|
+
readonly title: string;
|
|
25
|
+
readonly slug: string;
|
|
26
|
+
readonly markdown: string;
|
|
27
|
+
constructor(title: string, slug: string, markdown: string);
|
|
28
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProsePage = exports.DocsManifest = exports.ProsePageEntry = void 0;
|
|
4
|
+
/** One prose page named by `docs.manifest.json`, in the order the manifest names it. */
|
|
5
|
+
class ProsePageEntry {
|
|
6
|
+
file;
|
|
7
|
+
title;
|
|
8
|
+
constructor(file, title) {
|
|
9
|
+
this.file = file;
|
|
10
|
+
this.title = title;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ProsePageEntry = ProsePageEntry;
|
|
14
|
+
/**
|
|
15
|
+
* `docs.manifest.json` — the ORDER of the prose pages, and nothing else.
|
|
16
|
+
*
|
|
17
|
+
* It exists for the same reason the OpenAPI document's `tags[]` does: the order is a teaching
|
|
18
|
+
* decision somebody made, and neither directory listing order nor alphabetical order is it.
|
|
19
|
+
* Alphabetising this array is not a cleanup — it reorders the pages a partner reads first.
|
|
20
|
+
*/
|
|
21
|
+
class DocsManifest {
|
|
22
|
+
title;
|
|
23
|
+
pages;
|
|
24
|
+
constructor(
|
|
25
|
+
/** Overrides the document's `info.title` in the site header. Empty means "use the document's". */
|
|
26
|
+
title, pages) {
|
|
27
|
+
this.title = title;
|
|
28
|
+
this.pages = pages;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.DocsManifest = DocsManifest;
|
|
32
|
+
/** One prose page, loaded: its heading, its URL segment and its markdown source. */
|
|
33
|
+
class ProsePage {
|
|
34
|
+
title;
|
|
35
|
+
slug;
|
|
36
|
+
markdown;
|
|
37
|
+
constructor(title, slug, markdown) {
|
|
38
|
+
this.title = title;
|
|
39
|
+
this.slug = slug;
|
|
40
|
+
this.markdown = markdown;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.ProsePage = ProsePage;
|
|
44
|
+
//# sourceMappingURL=DocsManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocsManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/manifest/DocsManifest.ts"],"names":[],"mappings":";;;AAAA,wFAAwF;AACxF,MAAa,cAAc;IAEV;IACA;IAFb,YACa,IAAY,EACZ,KAAa;QADb,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;IACvB,CAAC;CACP;AALD,wCAKC;AAED;;;;;;GAMG;AACH,MAAa,YAAY;IAGR;IACA;IAHb;IACI,kGAAkG;IACzF,KAAa,EACb,KAAgC;QADhC,UAAK,GAAL,KAAK,CAAQ;QACb,UAAK,GAAL,KAAK,CAA2B;IAC1C,CAAC;CACP;AAND,oCAMC;AAED,oFAAoF;AACpF,MAAa,SAAS;IAEL;IACA;IACA;IAHb,YACa,KAAa,EACb,IAAY,EACZ,QAAgB;QAFhB,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;IAC1B,CAAC;CACP;AAND,8BAMC","sourcesContent":["/** One prose page named by `docs.manifest.json`, in the order the manifest names it. */\nexport class ProsePageEntry {\n constructor(\n readonly file: string,\n readonly title: string,\n ) {}\n}\n\n/**\n * `docs.manifest.json` — the ORDER of the prose pages, and nothing else.\n *\n * It exists for the same reason the OpenAPI document's `tags[]` does: the order is a teaching\n * decision somebody made, and neither directory listing order nor alphabetical order is it.\n * Alphabetising this array is not a cleanup — it reorders the pages a partner reads first.\n */\nexport class DocsManifest {\n constructor(\n /** Overrides the document's `info.title` in the site header. Empty means \"use the document's\". */\n readonly title: string,\n readonly pages: readonly ProsePageEntry[],\n ) {}\n}\n\n/** One prose page, loaded: its heading, its URL segment and its markdown source. */\nexport class ProsePage {\n constructor(\n readonly title: string,\n readonly slug: string,\n readonly markdown: string,\n ) {}\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ProsePage } from './DocsManifest';
|
|
2
|
+
/** The one filename this package looks for inside a prose directory. */
|
|
3
|
+
export declare const MANIFEST_FILE = "docs.manifest.json";
|
|
4
|
+
/**
|
|
5
|
+
* Loads `docs.manifest.json` and the markdown it names.
|
|
6
|
+
*
|
|
7
|
+
* A page the manifest names but the directory does not hold is a HARD FAILURE, not a skipped entry.
|
|
8
|
+
* Skipping it would publish a site whose navigation silently lost a page somebody wrote, and the
|
|
9
|
+
* only way anybody notices is a partner asking where the guide went.
|
|
10
|
+
*
|
|
11
|
+
* A markdown file the manifest does NOT name is simply not published: the manifest is the published
|
|
12
|
+
* list, so adding a file to the directory is not the same act as publishing it.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ProseLoader {
|
|
15
|
+
/** @param directory the `--prose` directory, or `undefined` when the run has no prose at all. */
|
|
16
|
+
load(directory: string | undefined): readonly ProsePage[];
|
|
17
|
+
/** The manifest's own `title`, or the empty string when there is no manifest. */
|
|
18
|
+
titleOf(directory: string | undefined): string;
|
|
19
|
+
private manifestOf;
|
|
20
|
+
private pagesOf;
|
|
21
|
+
private read;
|
|
22
|
+
private parse;
|
|
23
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProseLoader = exports.MANIFEST_FILE = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
7
|
+
const DocsManifest_1 = require("./DocsManifest");
|
|
8
|
+
const DocsSiteError_1 = require("../DocsSiteError");
|
|
9
|
+
const JsonNode_1 = require("../spec/JsonNode");
|
|
10
|
+
const Slug_1 = require("../spec/Slug");
|
|
11
|
+
/** The one filename this package looks for inside a prose directory. */
|
|
12
|
+
exports.MANIFEST_FILE = 'docs.manifest.json';
|
|
13
|
+
/**
|
|
14
|
+
* Loads `docs.manifest.json` and the markdown it names.
|
|
15
|
+
*
|
|
16
|
+
* A page the manifest names but the directory does not hold is a HARD FAILURE, not a skipped entry.
|
|
17
|
+
* Skipping it would publish a site whose navigation silently lost a page somebody wrote, and the
|
|
18
|
+
* only way anybody notices is a partner asking where the guide went.
|
|
19
|
+
*
|
|
20
|
+
* A markdown file the manifest does NOT name is simply not published: the manifest is the published
|
|
21
|
+
* list, so adding a file to the directory is not the same act as publishing it.
|
|
22
|
+
*/
|
|
23
|
+
class ProseLoader {
|
|
24
|
+
/** @param directory the `--prose` directory, or `undefined` when the run has no prose at all. */
|
|
25
|
+
load(directory) {
|
|
26
|
+
if (directory === undefined) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return this.pagesOf(directory, this.manifestOf(directory));
|
|
30
|
+
}
|
|
31
|
+
/** The manifest's own `title`, or the empty string when there is no manifest. */
|
|
32
|
+
titleOf(directory) {
|
|
33
|
+
if (directory === undefined) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
return this.manifestOf(directory).title;
|
|
37
|
+
}
|
|
38
|
+
manifestOf(directory) {
|
|
39
|
+
const file = path.join(directory, exports.MANIFEST_FILE);
|
|
40
|
+
const root = new JsonNode_1.JsonNode(this.parse(file, this.read(file)));
|
|
41
|
+
const pages = [];
|
|
42
|
+
for (const entry of root.list('pages')) {
|
|
43
|
+
const name = entry.text('file');
|
|
44
|
+
if (name === undefined) {
|
|
45
|
+
throw new DocsSiteError_1.DocsSiteError(`a ${exports.MANIFEST_FILE} page entry has no "file"`, file, 'Give every entry of "pages" a "file" naming a markdown file in this directory.');
|
|
46
|
+
}
|
|
47
|
+
pages.push(new DocsManifest_1.ProsePageEntry(name, entry.text('title') ?? name));
|
|
48
|
+
}
|
|
49
|
+
return new DocsManifest_1.DocsManifest(root.text('title') ?? '', pages);
|
|
50
|
+
}
|
|
51
|
+
pagesOf(directory, manifest) {
|
|
52
|
+
const slugs = new Slug_1.Slug();
|
|
53
|
+
return manifest.pages.map((entry) => {
|
|
54
|
+
const file = path.join(directory, entry.file);
|
|
55
|
+
if (!fs.existsSync(file)) {
|
|
56
|
+
throw new DocsSiteError_1.DocsSiteError(`${exports.MANIFEST_FILE} names a page that is not there: ${entry.file}`, file, `Add ${entry.file} to ${directory}, or remove it from "pages" in ${exports.MANIFEST_FILE}.`);
|
|
57
|
+
}
|
|
58
|
+
return new DocsManifest_1.ProsePage(entry.title, slugs.unique(entry.title), this.read(file));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
read(file) {
|
|
62
|
+
if (!fs.existsSync(file)) {
|
|
63
|
+
throw new DocsSiteError_1.DocsSiteError(`no ${path.basename(file)} there`, file, `Point --prose at a directory holding ${exports.MANIFEST_FILE}, or leave --prose off to publish the reference alone.`);
|
|
64
|
+
}
|
|
65
|
+
return fs.readFileSync(file, 'utf8');
|
|
66
|
+
}
|
|
67
|
+
// webpieces-disable no-any-unknown -- JSON.parse returns a foreign value; JsonNode is the narrowing
|
|
68
|
+
parse(file, source) {
|
|
69
|
+
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- re-thrown below as a stated failure
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(source);
|
|
72
|
+
// webpieces-disable no-any-unknown -- the catch binding, which TypeScript types for us
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
//const error = toError(err);
|
|
76
|
+
throw new DocsSiteError_1.DocsSiteError(`${exports.MANIFEST_FILE} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`, file, 'Fix the JSON syntax and re-run.');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ProseLoader = ProseLoader;
|
|
81
|
+
//# sourceMappingURL=ProseLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProseLoader.js","sourceRoot":"","sources":["../../../../../../packages/docs/docs-site/src/manifest/ProseLoader.ts"],"names":[],"mappings":"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","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { DocsManifest, ProsePage, ProsePageEntry } from './DocsManifest';\nimport { DocsSiteError } from '../DocsSiteError';\nimport { JsonNode } from '../spec/JsonNode';\nimport { Slug } from '../spec/Slug';\n\n/** The one filename this package looks for inside a prose directory. */\nexport const MANIFEST_FILE = 'docs.manifest.json';\n\n/**\n * Loads `docs.manifest.json` and the markdown it names.\n *\n * A page the manifest names but the directory does not hold is a HARD FAILURE, not a skipped entry.\n * Skipping it would publish a site whose navigation silently lost a page somebody wrote, and the\n * only way anybody notices is a partner asking where the guide went.\n *\n * A markdown file the manifest does NOT name is simply not published: the manifest is the published\n * list, so adding a file to the directory is not the same act as publishing it.\n */\nexport class ProseLoader {\n /** @param directory the `--prose` directory, or `undefined` when the run has no prose at all. */\n load(directory: string | undefined): readonly ProsePage[] {\n if (directory === undefined) {\n return [];\n }\n return this.pagesOf(directory, this.manifestOf(directory));\n }\n\n /** The manifest's own `title`, or the empty string when there is no manifest. */\n titleOf(directory: string | undefined): string {\n if (directory === undefined) {\n return '';\n }\n return this.manifestOf(directory).title;\n }\n\n private manifestOf(directory: string): DocsManifest {\n const file = path.join(directory, MANIFEST_FILE);\n const root = new JsonNode(this.parse(file, this.read(file)));\n const pages: ProsePageEntry[] = [];\n for (const entry of root.list('pages')) {\n const name = entry.text('file');\n if (name === undefined) {\n throw new DocsSiteError(\n `a ${MANIFEST_FILE} page entry has no \"file\"`,\n file,\n 'Give every entry of \"pages\" a \"file\" naming a markdown file in this directory.',\n );\n }\n pages.push(new ProsePageEntry(name, entry.text('title') ?? name));\n }\n return new DocsManifest(root.text('title') ?? '', pages);\n }\n\n private pagesOf(directory: string, manifest: DocsManifest): readonly ProsePage[] {\n const slugs = new Slug();\n return manifest.pages.map((entry: ProsePageEntry): ProsePage => {\n const file = path.join(directory, entry.file);\n if (!fs.existsSync(file)) {\n throw new DocsSiteError(\n `${MANIFEST_FILE} names a page that is not there: ${entry.file}`,\n file,\n `Add ${entry.file} to ${directory}, or remove it from \"pages\" in ${MANIFEST_FILE}.`,\n );\n }\n return new ProsePage(entry.title, slugs.unique(entry.title), this.read(file));\n });\n }\n\n private read(file: string): string {\n if (!fs.existsSync(file)) {\n throw new DocsSiteError(\n `no ${path.basename(file)} there`,\n file,\n `Point --prose at a directory holding ${MANIFEST_FILE}, or leave --prose off to publish the reference alone.`,\n );\n }\n return fs.readFileSync(file, 'utf8');\n }\n\n // webpieces-disable no-any-unknown -- JSON.parse returns a foreign value; JsonNode is the narrowing\n private parse(file: string, source: string): unknown {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- re-thrown below as a stated failure\n try {\n return JSON.parse(source);\n // webpieces-disable no-any-unknown -- the catch binding, which TypeScript types for us\n } catch (err: unknown) {\n //const error = toError(err);\n throw new DocsSiteError(\n `${MANIFEST_FILE} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`,\n file,\n 'Fix the JSON syntax and re-run.',\n );\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A DOCUMENTED SUBSET of CommonMark, over trusted, PR-reviewed input — the JSDoc a developer wrote
|
|
3
|
+
* and the markdown files a manifest names. It is not a CommonMark implementation and does not try to
|
|
4
|
+
* be; #985 puts a full one explicitly out of scope, because the alternative to ~180 lines here is a
|
|
5
|
+
* dependency in every upstream project that wants an API reference.
|
|
6
|
+
*
|
|
7
|
+
* What it renders:
|
|
8
|
+
*
|
|
9
|
+
* | block | spelling |
|
|
10
|
+
* |---|---|
|
|
11
|
+
* | heading | `#` through `######` |
|
|
12
|
+
* | fenced code | ` ``` ` with an optional language word |
|
|
13
|
+
* | table | a `\|` row, then a `\|---\|` row, then rows |
|
|
14
|
+
* | list | `- ` / `* ` for bullets, `1. ` for numbers |
|
|
15
|
+
* | blockquote | `> ` |
|
|
16
|
+
* | rule | `---` on its own line |
|
|
17
|
+
* | paragraph | anything else, blank-line separated |
|
|
18
|
+
*
|
|
19
|
+
* and inline: `` `code` ``, `**bold**`, `*italic*`, `[text](url)`.
|
|
20
|
+
*
|
|
21
|
+
* **Everything is HTML-escaped first**, before any inline pattern runs, so a `<` in a JSDoc body is
|
|
22
|
+
* text rather than the start of a tag. That ordering is the whole safety argument: escape-then-mark
|
|
23
|
+
* cannot produce a tag the source did not ask for, while mark-then-escape would escape the tags this
|
|
24
|
+
* renderer just wrote.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Markdown {
|
|
27
|
+
private readonly html;
|
|
28
|
+
/** The rendered HTML for a markdown document. */
|
|
29
|
+
render(source: string): string;
|
|
30
|
+
/** Inline markdown only — for a place that is already one line, like a table cell. */
|
|
31
|
+
inline(source: string): string;
|
|
32
|
+
/** @returns the index of the first line AFTER the block this consumed. */
|
|
33
|
+
private block;
|
|
34
|
+
private fence;
|
|
35
|
+
private heading;
|
|
36
|
+
private table;
|
|
37
|
+
private list;
|
|
38
|
+
private quote;
|
|
39
|
+
private paragraph;
|
|
40
|
+
/** True when the line at `index` begins a block that a paragraph must not swallow. */
|
|
41
|
+
private startsBlock;
|
|
42
|
+
private isDivider;
|
|
43
|
+
private isBullet;
|
|
44
|
+
private isNumber;
|
|
45
|
+
private itemTextOf;
|
|
46
|
+
private cells;
|
|
47
|
+
}
|