@entifix/docs-engine 0.0.0-bootstrap.0 → 0.23.6
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/LICENSE +21 -0
- package/README.md +95 -1
- package/dist/directives.d.ts +25 -0
- package/dist/directives.d.ts.map +1 -0
- package/dist/directives.js +107 -0
- package/dist/directives.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/links.d.ts +19 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +17 -0
- package/dist/links.js.map +1 -0
- package/dist/markdown.d.ts +24 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +47 -0
- package/dist/markdown.js.map +1 -0
- package/dist/references.d.ts +20 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +16 -0
- package/dist/references.js.map +1 -0
- package/dist/site.d.ts +46 -0
- package/dist/site.d.ts.map +1 -0
- package/dist/site.js +90 -0
- package/dist/site.js.map +1 -0
- package/dist/sources.d.ts +65 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/sources.js +115 -0
- package/dist/sources.js.map +1 -0
- package/dist/spec-support.d.ts +6 -0
- package/dist/spec-support.d.ts.map +1 -0
- package/dist/spec-support.js +17 -0
- package/dist/spec-support.js.map +1 -0
- package/dist/ui/head.d.ts +16 -0
- package/dist/ui/head.d.ts.map +1 -0
- package/dist/ui/head.js +29 -0
- package/dist/ui/head.js.map +1 -0
- package/dist/ui/index.d.ts +13 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/layout.d.ts +15 -0
- package/dist/ui/layout.d.ts.map +1 -0
- package/dist/ui/layout.js +30 -0
- package/dist/ui/layout.js.map +1 -0
- package/dist/ui/page.d.ts +21 -0
- package/dist/ui/page.d.ts.map +1 -0
- package/dist/ui/page.js +70 -0
- package/dist/ui/page.js.map +1 -0
- package/dist/ui/pagefind.d.ts +37 -0
- package/dist/ui/pagefind.d.ts.map +1 -0
- package/dist/ui/pagefind.js +48 -0
- package/dist/ui/pagefind.js.map +1 -0
- package/dist/ui/root.d.ts +22 -0
- package/dist/ui/root.d.ts.map +1 -0
- package/dist/ui/root.js +85 -0
- package/dist/ui/root.js.map +1 -0
- package/dist/ui/scheme.d.ts +12 -0
- package/dist/ui/scheme.d.ts.map +1 -0
- package/dist/ui/scheme.js +17 -0
- package/dist/ui/scheme.js.map +1 -0
- package/dist/ui/search-dialog.d.ts +15 -0
- package/dist/ui/search-dialog.d.ts.map +1 -0
- package/dist/ui/search-dialog.js +60 -0
- package/dist/ui/search-dialog.js.map +1 -0
- package/dist/ui/skip-link.d.ts +7 -0
- package/dist/ui/skip-link.d.ts.map +1 -0
- package/dist/ui/skip-link.js +17 -0
- package/dist/ui/skip-link.js.map +1 -0
- package/dist/ui/translations.d.ts +12 -0
- package/dist/ui/translations.d.ts.map +1 -0
- package/dist/ui/translations.js +48 -0
- package/dist/ui/translations.js.map +1 -0
- package/package.json +87 -3
- package/src/ui/docs.css +154 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 r10c Technologies
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
1
|
# @entifix/docs-engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A documentation site from sources, exported as static files. A host hands it
|
|
4
|
+
its sections — decision records, Markdown guides, a reference it derives from
|
|
5
|
+
its own metadata — and a registry of the ids a guide may cite; the engine turns
|
|
6
|
+
them into one page tree, checks every page when the site is created, and renders
|
|
7
|
+
each with `fumadocs-ui` under entifix's tokens. Search is Pagefind over the
|
|
8
|
+
exported HTML. The decision is
|
|
9
|
+
[ADR 0031](../../../docs/adr/0031-entifix-docs-carries-the-records-and-a-docs-engine-reads-any-repositorys.md).
|
|
10
|
+
|
|
11
|
+
Two entry points, so a host that only wants the loader installs no UI:
|
|
12
|
+
|
|
13
|
+
| Import | Holds |
|
|
14
|
+
| ---------------------------------- | ---------------------------------------------------------------------------- |
|
|
15
|
+
| `@entifix/docs-engine` | the sources, the directive check, `createDocsSite` — `fumadocs-core` only |
|
|
16
|
+
| `@entifix/docs-engine/ui` | `DocsRoot`, `DocsHead`, `DocsLayout`, `DocsPage`, the Pagefind search dialog |
|
|
17
|
+
| `@entifix/docs-engine/ui/docs.css` | fumadocs' preset under entifix's tokens, and the conditions of ADR 0031 §4 |
|
|
18
|
+
|
|
19
|
+
`fumadocs-ui` is an optional peer, pinned exactly with `fumadocs-core`: both
|
|
20
|
+
move together, and only with the gate re-run.
|
|
21
|
+
|
|
22
|
+
## A site
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// site.ts — runs at build time, in Node
|
|
26
|
+
import { ENTIFIX_AREAS } from '@entifix/docs/reader';
|
|
27
|
+
import { createDocsSite, guidesSource, recordsSource, referenceKind } from '@entifix/docs-engine';
|
|
28
|
+
|
|
29
|
+
const records = recordsSource({
|
|
30
|
+
directory: 'node_modules/@entifix/docs/records',
|
|
31
|
+
areas: ENTIFIX_AREAS,
|
|
32
|
+
title: 'Decision records',
|
|
33
|
+
links: {
|
|
34
|
+
record: id => `/records/${id}/`,
|
|
35
|
+
file: path => `https://github.com/…/blob/main/docs/adr/${path}`,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const site = createDocsSite({
|
|
40
|
+
baseUrl: '/',
|
|
41
|
+
sources: [guidesSource({ directory: 'content/guides', title: 'Guides' }), records],
|
|
42
|
+
references: {
|
|
43
|
+
record: referenceKind(
|
|
44
|
+
records.pages.map(page => page.record?.id ?? ''),
|
|
45
|
+
id => `/records/${id}/`,
|
|
46
|
+
id => `ADR ${id}`,
|
|
47
|
+
),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
// app/[...slug]/page.tsx
|
|
54
|
+
export const dynamicParams = false;
|
|
55
|
+
export const generateStaticParams = () => site.params();
|
|
56
|
+
export default async function Page({ params }) {
|
|
57
|
+
return <DocsPage site={site} slugs={(await params).slug} />;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The layout renders `DocsHead` in `<head>`, then `DocsRoot` inside the host's
|
|
62
|
+
translator (`I18nProvider` from `@entifix/react-controls/i18next`), then
|
|
63
|
+
`DocsLayout`. `next.config` sets `output: 'export'` and `trailingSlash: true`,
|
|
64
|
+
and the build ends with `pagefind --site out --output-subdir pagefind`.
|
|
65
|
+
`examples/docs` is the whole of it, served under a `basePath`.
|
|
66
|
+
|
|
67
|
+
## Guides and their directives
|
|
68
|
+
|
|
69
|
+
A guide is Markdown with a `title` (and optionally `description` and `order`)
|
|
70
|
+
in its frontmatter. It cites what it describes:
|
|
71
|
+
|
|
72
|
+
| Directive | Becomes |
|
|
73
|
+
| --------------------------------- | --------------------------------------------------------- |
|
|
74
|
+
| `:<kind>[id]` | a link, for a kind the host registered and an id it holds |
|
|
75
|
+
| `:::note`, `:::tip`, `:::warning` | a callout |
|
|
76
|
+
|
|
77
|
+
⚠️ **Any other directive, and any id its kind does not hold, fails `next
|
|
78
|
+
build`** with the file and the line — every page is checked when the site is
|
|
79
|
+
created, not when it is first visited. An id may contain colons
|
|
80
|
+
(`:use-case[order:product-order:cancel]`). A bare `:word` glued to the word
|
|
81
|
+
before it is prose (`10:30`, `layer:base`) and stays as written.
|
|
82
|
+
|
|
83
|
+
## The theme
|
|
84
|
+
|
|
85
|
+
`data-theme` is the one owner of the palette, as everywhere in entifix.
|
|
86
|
+
fumadocs only knows light and dark, so a palette the host lists in
|
|
87
|
+
`darkPalettes` sets `data-scheme="dark"`, and fumadocs' `dark:` utilities and
|
|
88
|
+
the code blocks follow that. The first paint comes from `DocsHead` — an export
|
|
89
|
+
has no server to read the theme cookie.
|
|
90
|
+
|
|
91
|
+
## The gate
|
|
92
|
+
|
|
93
|
+
`examples/docs-e2e` runs on every change that reaches the engine, fumadocs or
|
|
94
|
+
the tokens: axe at WCAG 2.2 AA with `target-size`, entifix's keyboard walk, the
|
|
95
|
+
search dialog, a 3:1 control boundary, one focus indicator per control, and
|
|
96
|
+
forced colours — on two palettes at two widths. A fumadocs bump is not done
|
|
97
|
+
until it is green.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directives a page may use, resolved at build time.
|
|
3
|
+
*
|
|
4
|
+
* :<kind>[id] a citation of an id the host registered
|
|
5
|
+
* :::note / :::tip / :::warning a callout
|
|
6
|
+
*
|
|
7
|
+
* Any other directive, and any id its kind does not hold, stops the build with
|
|
8
|
+
* the file and the line: a typo is caught where it was made, not found later as
|
|
9
|
+
* text on the page. A bare text directive glued to the word before it is prose
|
|
10
|
+
* — a ratio, a time or a tag, `1:N`, `10:30`, `layer:base` — and is written
|
|
11
|
+
* back as the text it was.
|
|
12
|
+
*
|
|
13
|
+
* Graduated from myself-app's post directives (entifix ADR 0031 §5).
|
|
14
|
+
*/
|
|
15
|
+
import type { Root } from 'mdast';
|
|
16
|
+
import type { Plugin } from 'unified';
|
|
17
|
+
import type { ReferenceRegistry } from './references.js';
|
|
18
|
+
export declare const CALLOUTS: readonly ["note", "tip", "warning"];
|
|
19
|
+
export interface DirectiveOptions {
|
|
20
|
+
/** The page's file, for the error. */
|
|
21
|
+
readonly file: string;
|
|
22
|
+
readonly references: ReferenceRegistry;
|
|
23
|
+
}
|
|
24
|
+
export declare const remarkDocsDirectives: Plugin<[DirectiveOptions], Root>;
|
|
25
|
+
//# sourceMappingURL=directives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directives.d.ts","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,OAAO,CAAC;AAMxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,eAAO,MAAM,QAAQ,qCAAsC,CAAC;AAI5D,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;CACxC;AAqDD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAwC/D,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directives a page may use, resolved at build time.
|
|
3
|
+
*
|
|
4
|
+
* :<kind>[id] a citation of an id the host registered
|
|
5
|
+
* :::note / :::tip / :::warning a callout
|
|
6
|
+
*
|
|
7
|
+
* Any other directive, and any id its kind does not hold, stops the build with
|
|
8
|
+
* the file and the line: a typo is caught where it was made, not found later as
|
|
9
|
+
* text on the page. A bare text directive glued to the word before it is prose
|
|
10
|
+
* — a ratio, a time or a tag, `1:N`, `10:30`, `layer:base` — and is written
|
|
11
|
+
* back as the text it was.
|
|
12
|
+
*
|
|
13
|
+
* Graduated from myself-app's post directives (entifix ADR 0031 §5).
|
|
14
|
+
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
15
|
+
import { visit } from 'unist-util-visit';
|
|
16
|
+
import { DocsContentError } from './errors.js';
|
|
17
|
+
export const CALLOUTS = [
|
|
18
|
+
'note',
|
|
19
|
+
'tip',
|
|
20
|
+
'warning'
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* A citation's id, as written. An id with colons — `order:product-order:cancel`,
|
|
24
|
+
* a use case's shape — is parsed by remark-directive as text with nested text
|
|
25
|
+
* directives (`order` then `:product-order` then `:cancel`), so each one nested
|
|
26
|
+
* is read back as the colon and the name it was.
|
|
27
|
+
*/ const textOf = (node)=>node.children.map((child)=>{
|
|
28
|
+
if (child.type === 'textDirective') {
|
|
29
|
+
const nested = child;
|
|
30
|
+
const inner = textOf(nested);
|
|
31
|
+
return `:${nested.name}${inner === '' ? '' : `[${inner}]`}`;
|
|
32
|
+
}
|
|
33
|
+
return 'value' in child && child.value !== undefined ? String(child.value) : '';
|
|
34
|
+
}).join('').trim();
|
|
35
|
+
const fail = (file, node, detail)=>{
|
|
36
|
+
var _node_position;
|
|
37
|
+
throw new DocsContentError(file, detail, (_node_position = node.position) == null ? void 0 : _node_position.start.line);
|
|
38
|
+
};
|
|
39
|
+
const cite = (node, { file, references })=>{
|
|
40
|
+
var _ref;
|
|
41
|
+
const kind = references[node.name];
|
|
42
|
+
if (kind === undefined) {
|
|
43
|
+
fail(file, node, `holds an unknown directive ":${node.name}"`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const id = textOf(node);
|
|
47
|
+
if (!kind.ids.has(id)) {
|
|
48
|
+
fail(file, node, `cites an unknown ${node.name} "${id}"`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const label = {
|
|
52
|
+
type: 'text',
|
|
53
|
+
value: (_ref = kind.label == null ? void 0 : kind.label.call(kind, id)) != null ? _ref : id
|
|
54
|
+
};
|
|
55
|
+
node.data = {
|
|
56
|
+
hName: 'a',
|
|
57
|
+
hProperties: {
|
|
58
|
+
href: kind.href(id),
|
|
59
|
+
className: [
|
|
60
|
+
'docs-citation'
|
|
61
|
+
],
|
|
62
|
+
dataCitation: node.name
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
node.children = [
|
|
66
|
+
label
|
|
67
|
+
];
|
|
68
|
+
};
|
|
69
|
+
export const remarkDocsDirectives = (options)=>(tree)=>{
|
|
70
|
+
visit(tree, (node, index, parent)=>{
|
|
71
|
+
if (node.type === 'textDirective' && parent && index !== undefined) {
|
|
72
|
+
const before = parent.children[index - 1];
|
|
73
|
+
const glued = (before == null ? void 0 : before.type) === 'text' && /\S$/.test(before.value);
|
|
74
|
+
const bare = node.children.length === 0 && Object.keys(_extends({}, node.attributes)).length === 0;
|
|
75
|
+
if (glued && bare) {
|
|
76
|
+
parent.children.splice(index, 1, {
|
|
77
|
+
type: 'text',
|
|
78
|
+
value: `:${node.name}`
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
cite(node, options);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (node.type === 'containerDirective') {
|
|
86
|
+
if (CALLOUTS.includes(node.name)) {
|
|
87
|
+
node.data = {
|
|
88
|
+
hName: 'aside',
|
|
89
|
+
hProperties: {
|
|
90
|
+
role: 'note',
|
|
91
|
+
className: [
|
|
92
|
+
'docs-callout',
|
|
93
|
+
`docs-callout-${node.name}`
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
fail(options.file, node, `holds an unknown directive ":::${node.name}"`);
|
|
100
|
+
}
|
|
101
|
+
if (node.type === 'leafDirective') {
|
|
102
|
+
fail(options.file, node, `holds an unknown directive "::${node.name}"`);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=directives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/directives.ts"],"sourcesContent":["/**\n * The directives a page may use, resolved at build time.\n *\n * :<kind>[id] a citation of an id the host registered\n * :::note / :::tip / :::warning a callout\n *\n * Any other directive, and any id its kind does not hold, stops the build with\n * the file and the line: a typo is caught where it was made, not found later as\n * text on the page. A bare text directive glued to the word before it is prose\n * — a ratio, a time or a tag, `1:N`, `10:30`, `layer:base` — and is written\n * back as the text it was.\n *\n * Graduated from myself-app's post directives (entifix ADR 0031 §5).\n */\nimport type { Root, Text } from 'mdast';\nimport type {\n ContainerDirective,\n LeafDirective,\n TextDirective,\n} from 'mdast-util-directive';\nimport type { Plugin } from 'unified';\nimport { visit } from 'unist-util-visit';\n\nimport { DocsContentError } from './errors.js';\nimport type { ReferenceRegistry } from './references.js';\n\nexport const CALLOUTS = ['note', 'tip', 'warning'] as const;\n\ntype Directive = ContainerDirective | LeafDirective | TextDirective;\n\nexport interface DirectiveOptions {\n /** The page's file, for the error. */\n readonly file: string;\n readonly references: ReferenceRegistry;\n}\n\n/**\n * A citation's id, as written. An id with colons — `order:product-order:cancel`,\n * a use case's shape — is parsed by remark-directive as text with nested text\n * directives (`order` then `:product-order` then `:cancel`), so each one nested\n * is read back as the colon and the name it was.\n */\nconst textOf = (node: { readonly children: readonly unknown[] }): string =>\n (node.children as readonly (Directive | { type: string; value?: string })[])\n .map(child => {\n if (child.type === 'textDirective') {\n const nested = child as TextDirective;\n const inner = textOf(nested);\n return `:${nested.name}${inner === '' ? '' : `[${inner}]`}`;\n }\n return 'value' in child && child.value !== undefined\n ? String(child.value)\n : '';\n })\n .join('')\n .trim();\n\nconst fail = (file: string, node: Directive, detail: string): never => {\n throw new DocsContentError(file, detail, node.position?.start.line);\n};\n\nconst cite = (\n node: TextDirective,\n { file, references }: DirectiveOptions,\n): void => {\n const kind = references[node.name];\n if (kind === undefined) {\n fail(file, node, `holds an unknown directive \":${node.name}\"`);\n return;\n }\n const id = textOf(node);\n if (!kind.ids.has(id)) {\n fail(file, node, `cites an unknown ${node.name} \"${id}\"`);\n return;\n }\n const label: Text = { type: 'text', value: kind.label?.(id) ?? id };\n node.data = {\n hName: 'a',\n hProperties: {\n href: kind.href(id),\n className: ['docs-citation'],\n dataCitation: node.name,\n },\n };\n node.children = [label];\n};\n\nexport const remarkDocsDirectives: Plugin<[DirectiveOptions], Root> =\n options => tree => {\n visit(tree, (node, index, parent) => {\n if (node.type === 'textDirective' && parent && index !== undefined) {\n const before = parent.children[index - 1];\n const glued = before?.type === 'text' && /\\S$/.test(before.value);\n const bare =\n node.children.length === 0 &&\n Object.keys({ ...node.attributes }).length === 0;\n if (glued && bare) {\n parent.children.splice(index, 1, {\n type: 'text',\n value: `:${node.name}`,\n });\n return;\n }\n cite(node, options);\n return;\n }\n if (node.type === 'containerDirective') {\n if ((CALLOUTS as readonly string[]).includes(node.name)) {\n node.data = {\n hName: 'aside',\n hProperties: {\n role: 'note',\n className: ['docs-callout', `docs-callout-${node.name}`],\n },\n };\n return;\n }\n fail(\n options.file,\n node,\n `holds an unknown directive \":::${node.name}\"`,\n );\n }\n if (node.type === 'leafDirective') {\n fail(options.file, node, `holds an unknown directive \"::${node.name}\"`);\n }\n });\n };\n"],"names":["visit","DocsContentError","CALLOUTS","textOf","node","children","map","child","type","nested","inner","name","value","undefined","String","join","trim","fail","file","detail","position","start","line","cite","references","kind","id","ids","has","label","data","hName","hProperties","href","className","dataCitation","remarkDocsDirectives","options","tree","index","parent","before","glued","test","bare","length","Object","keys","attributes","splice","includes","role"],"mappings":"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"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A source the engine cannot turn into a page: an unknown directive, an id the
|
|
3
|
+
* host's registry does not hold, a record collection with problems. It names
|
|
4
|
+
* the file and, when it has one, the line — so a typo is caught where it was
|
|
5
|
+
* made, and `next build` stops on it rather than exporting a page with the
|
|
6
|
+
* mistake written into it.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DocsContentError extends Error {
|
|
9
|
+
readonly file: string;
|
|
10
|
+
readonly detail: string;
|
|
11
|
+
readonly line?: number | undefined;
|
|
12
|
+
readonly name = "DocsContentError";
|
|
13
|
+
constructor(file: string, detail: string, line?: number | undefined);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAIvC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;IALxB,SAAkB,IAAI,sBAAsB;gBAGjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAIzB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A source the engine cannot turn into a page: an unknown directive, an id the
|
|
3
|
+
* host's registry does not hold, a record collection with problems. It names
|
|
4
|
+
* the file and, when it has one, the line — so a typo is caught where it was
|
|
5
|
+
* made, and `next build` stops on it rather than exporting a page with the
|
|
6
|
+
* mistake written into it.
|
|
7
|
+
*/ export class DocsContentError extends Error {
|
|
8
|
+
constructor(file, detail, line){
|
|
9
|
+
super(`${file}${line === undefined ? '' : `:${line}`}: ${detail}`), this.file = file, this.detail = detail, this.line = line, this.name = 'DocsContentError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/**\n * A source the engine cannot turn into a page: an unknown directive, an id the\n * host's registry does not hold, a record collection with problems. It names\n * the file and, when it has one, the line — so a typo is caught where it was\n * made, and `next build` stops on it rather than exporting a page with the\n * mistake written into it.\n */\nexport class DocsContentError extends Error {\n override readonly name = 'DocsContentError';\n\n constructor(\n readonly file: string,\n readonly detail: string,\n readonly line?: number,\n ) {\n super(`${file}${line === undefined ? '' : `:${line}`}: ${detail}`);\n }\n}\n"],"names":["DocsContentError","Error","file","detail","line","undefined","name"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,yBAAyBC;IAGpC,YACE,AAASC,IAAY,EACrB,AAASC,MAAc,EACvB,AAASC,IAAa,CACtB;QACA,KAAK,CAAC,GAAGF,OAAOE,SAASC,YAAY,KAAK,CAAC,CAAC,EAAED,MAAM,CAAC,EAAE,EAAED,QAAQ,QAJxDD,OAAAA,WACAC,SAAAA,aACAC,OAAAA,WALOE,OAAO;IAQzB;AACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { DirectiveOptions } from './directives.js';
|
|
2
|
+
export { CALLOUTS, remarkDocsDirectives } from './directives.js';
|
|
3
|
+
export { DocsContentError } from './errors.js';
|
|
4
|
+
export type { LinkTargets } from './links.js';
|
|
5
|
+
export { rewriteLinks } from './links.js';
|
|
6
|
+
export type { RenderedMarkdown } from './markdown.js';
|
|
7
|
+
export { checkMarkdown, CODE_THEMES, renderMarkdown } from './markdown.js';
|
|
8
|
+
export type { ReferenceKind, ReferenceRegistry } from './references.js';
|
|
9
|
+
export { referenceKind } from './references.js';
|
|
10
|
+
export type { DocsPageData, DocsSite, DocsSiteOptions } from './site.js';
|
|
11
|
+
export { createDocsSite } from './site.js';
|
|
12
|
+
export type { DocsPageInput, DocsSource, GuidesSourceOptions, RecordsSourceOptions, ReferencePage, } from './sources.js';
|
|
13
|
+
export { guidesSource, recordsSource, referenceSource } from './sources.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EACV,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { CALLOUTS, remarkDocsDirectives } from './directives.js';
|
|
2
|
+
export { DocsContentError } from './errors.js';
|
|
3
|
+
export { rewriteLinks } from './links.js';
|
|
4
|
+
export { checkMarkdown, CODE_THEMES, renderMarkdown } from './markdown.js';
|
|
5
|
+
export { referenceKind } from './references.js';
|
|
6
|
+
export { createDocsSite } from './site.js';
|
|
7
|
+
export { guidesSource, recordsSource, referenceSource } from './sources.js';
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type { DirectiveOptions } from './directives.js';\nexport { CALLOUTS, remarkDocsDirectives } from './directives.js';\nexport { DocsContentError } from './errors.js';\nexport type { LinkTargets } from './links.js';\nexport { rewriteLinks } from './links.js';\nexport type { RenderedMarkdown } from './markdown.js';\nexport { checkMarkdown, CODE_THEMES, renderMarkdown } from './markdown.js';\nexport type { ReferenceKind, ReferenceRegistry } from './references.js';\nexport { referenceKind } from './references.js';\nexport type { DocsPageData, DocsSite, DocsSiteOptions } from './site.js';\nexport { createDocsSite } from './site.js';\nexport type {\n DocsPageInput,\n DocsSource,\n GuidesSourceOptions,\n RecordsSourceOptions,\n ReferencePage,\n} from './sources.js';\nexport { guidesSource, recordsSource, referenceSource } from './sources.js';\n"],"names":["CALLOUTS","remarkDocsDirectives","DocsContentError","rewriteLinks","checkMarkdown","CODE_THEMES","renderMarkdown","referenceKind","createDocsSite","guidesSource","recordsSource","referenceSource"],"mappings":"AACA,SAASA,QAAQ,EAAEC,oBAAoB,QAAQ,kBAAkB;AACjE,SAASC,gBAAgB,QAAQ,cAAc;AAE/C,SAASC,YAAY,QAAQ,aAAa;AAE1C,SAASC,aAAa,EAAEC,WAAW,EAAEC,cAAc,QAAQ,gBAAgB;AAE3E,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,SAASC,cAAc,QAAQ,YAAY;AAQ3C,SAASC,YAAY,EAAEC,aAAa,EAAEC,eAAe,QAAQ,eAAe"}
|
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface LinkTargets {
|
|
2
|
+
/** Where a link to another record of the same collection goes: its page. */
|
|
3
|
+
readonly record: (id: string, anchor: string | undefined) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Where any other relative link goes — a file of the repository the record
|
|
6
|
+
* was written in, usually on GitHub. `path` is relative to the collection.
|
|
7
|
+
*/
|
|
8
|
+
readonly file: (path: string, anchor: string | undefined) => string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A record's relative links, pointed at the site: a sibling record to its
|
|
12
|
+
* page, anything else to the file it names. An absolute URL, a root-relative
|
|
13
|
+
* path and an in-page anchor are left as they are.
|
|
14
|
+
*
|
|
15
|
+
* Graduated from myself-app's `sync-adrs.mjs` (entifix ADR 0031 §5); the page
|
|
16
|
+
* scheme is the host's, so both targets are functions it passes.
|
|
17
|
+
*/
|
|
18
|
+
export declare const rewriteLinks: (markdown: string, targets: LinkTargets) => string;
|
|
19
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,CAAC;IACpE;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,CAAC;CACrE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,SAAS,WAAW,KAAG,MAOlE,CAAC"}
|
package/dist/links.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const RECORD_FILE = /^(\d{4})-.*\.md$/;
|
|
2
|
+
/**
|
|
3
|
+
* A record's relative links, pointed at the site: a sibling record to its
|
|
4
|
+
* page, anything else to the file it names. An absolute URL, a root-relative
|
|
5
|
+
* path and an in-page anchor are left as they are.
|
|
6
|
+
*
|
|
7
|
+
* Graduated from myself-app's `sync-adrs.mjs` (entifix ADR 0031 §5); the page
|
|
8
|
+
* scheme is the host's, so both targets are functions it passes.
|
|
9
|
+
*/ export const rewriteLinks = (markdown, targets)=>markdown.replace(/\]\(([^)\s]+)\)/g, (whole, url)=>{
|
|
10
|
+
if (/^([a-z][a-z0-9+.-]*:|#|\/)/i.test(url)) return whole;
|
|
11
|
+
const [path = '', anchor] = url.split('#');
|
|
12
|
+
const record = RECORD_FILE.exec(path);
|
|
13
|
+
if (record) return `](${targets.record(record[1], anchor)})`;
|
|
14
|
+
return `](${targets.file(path, anchor)})`;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/links.ts"],"sourcesContent":["const RECORD_FILE = /^(\\d{4})-.*\\.md$/;\n\nexport interface LinkTargets {\n /** Where a link to another record of the same collection goes: its page. */\n readonly record: (id: string, anchor: string | undefined) => string;\n /**\n * Where any other relative link goes — a file of the repository the record\n * was written in, usually on GitHub. `path` is relative to the collection.\n */\n readonly file: (path: string, anchor: string | undefined) => string;\n}\n\n/**\n * A record's relative links, pointed at the site: a sibling record to its\n * page, anything else to the file it names. An absolute URL, a root-relative\n * path and an in-page anchor are left as they are.\n *\n * Graduated from myself-app's `sync-adrs.mjs` (entifix ADR 0031 §5); the page\n * scheme is the host's, so both targets are functions it passes.\n */\nexport const rewriteLinks = (markdown: string, targets: LinkTargets): string =>\n markdown.replace(/\\]\\(([^)\\s]+)\\)/g, (whole, url: string) => {\n if (/^([a-z][a-z0-9+.-]*:|#|\\/)/i.test(url)) return whole;\n const [path = '', anchor] = url.split('#');\n const record = RECORD_FILE.exec(path);\n if (record) return `](${targets.record(record[1] as string, anchor)})`;\n return `](${targets.file(path, anchor)})`;\n });\n"],"names":["RECORD_FILE","rewriteLinks","markdown","targets","replace","whole","url","test","path","anchor","split","record","exec","file"],"mappings":"AAAA,MAAMA,cAAc;AAYpB;;;;;;;CAOC,GACD,OAAO,MAAMC,eAAe,CAACC,UAAkBC,UAC7CD,SAASE,OAAO,CAAC,oBAAoB,CAACC,OAAOC;QAC3C,IAAI,8BAA8BC,IAAI,CAACD,MAAM,OAAOD;QACpD,MAAM,CAACG,OAAO,EAAE,EAAEC,OAAO,GAAGH,IAAII,KAAK,CAAC;QACtC,MAAMC,SAASX,YAAYY,IAAI,CAACJ;QAChC,IAAIG,QAAQ,OAAO,CAAC,EAAE,EAAER,QAAQQ,MAAM,CAACA,MAAM,CAAC,EAAE,EAAYF,QAAQ,CAAC,CAAC;QACtE,OAAO,CAAC,EAAE,EAAEN,QAAQU,IAAI,CAACL,MAAMC,QAAQ,CAAC,CAAC;IAC3C,GAAG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TOCItemType } from 'fumadocs-core/toc';
|
|
2
|
+
import type { Root as HastRoot } from 'hast';
|
|
3
|
+
import type { ReferenceRegistry } from './references.js';
|
|
4
|
+
/**
|
|
5
|
+
* Shiki's high-contrast pair. entifix has no syntax palette of its own, and
|
|
6
|
+
* the default GitHub themes measured 3.48:1 on white (spike, ADR 0031).
|
|
7
|
+
*/
|
|
8
|
+
export declare const CODE_THEMES: {
|
|
9
|
+
readonly light: "github-light-high-contrast";
|
|
10
|
+
readonly dark: "github-dark-high-contrast";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Parses and checks a page without rendering it: an unknown directive or id
|
|
14
|
+
* throws here. The site runs it over every page when it is created, so one bad
|
|
15
|
+
* citation fails the build however many pages are never visited.
|
|
16
|
+
*/
|
|
17
|
+
export declare const checkMarkdown: (markdown: string, file: string, references: ReferenceRegistry) => void;
|
|
18
|
+
export interface RenderedMarkdown {
|
|
19
|
+
readonly tree: HastRoot;
|
|
20
|
+
readonly toc: readonly TOCItemType[];
|
|
21
|
+
}
|
|
22
|
+
/** A page's body as HTML's tree, highlighted, with its table of contents. */
|
|
23
|
+
export declare const renderMarkdown: (markdown: string, file: string, references: ReferenceRegistry) => Promise<RenderedMarkdown>;
|
|
24
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAC;AAS7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,WAAW;;;CAGd,CAAC;AAYX;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,YAAY,iBAAiB,KAC5B,IAMF,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,SAAS,WAAW,EAAE,CAAC;CACtC;AAED,6EAA6E;AAC7E,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,YAAY,iBAAiB,KAC5B,OAAO,CAAC,gBAAgB,CAM1B,CAAC"}
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { rehypeCode, remarkGfm, remarkHeading } from 'fumadocs-core/mdx-plugins';
|
|
2
|
+
import remarkDirective from 'remark-directive';
|
|
3
|
+
import remarkParse from 'remark-parse';
|
|
4
|
+
import remarkRehype from 'remark-rehype';
|
|
5
|
+
import { unified } from 'unified';
|
|
6
|
+
import { VFile } from 'vfile';
|
|
7
|
+
import { remarkDocsDirectives } from './directives.js';
|
|
8
|
+
/**
|
|
9
|
+
* Shiki's high-contrast pair. entifix has no syntax palette of its own, and
|
|
10
|
+
* the default GitHub themes measured 3.48:1 on white (spike, ADR 0031).
|
|
11
|
+
*/ export const CODE_THEMES = {
|
|
12
|
+
light: 'github-light-high-contrast',
|
|
13
|
+
dark: 'github-dark-high-contrast'
|
|
14
|
+
};
|
|
15
|
+
const processor = (file, references)=>unified().use(remarkParse).use(remarkGfm).use(remarkDirective).use(remarkDocsDirectives, {
|
|
16
|
+
file,
|
|
17
|
+
references
|
|
18
|
+
}).use(remarkHeading).use(remarkRehype).use(rehypeCode, {
|
|
19
|
+
themes: CODE_THEMES,
|
|
20
|
+
lazy: true
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Parses and checks a page without rendering it: an unknown directive or id
|
|
24
|
+
* throws here. The site runs it over every page when it is created, so one bad
|
|
25
|
+
* citation fails the build however many pages are never visited.
|
|
26
|
+
*/ export const checkMarkdown = (markdown, file, references)=>{
|
|
27
|
+
const parser = unified().use(remarkParse).use(remarkDirective).use(remarkDocsDirectives, {
|
|
28
|
+
file,
|
|
29
|
+
references
|
|
30
|
+
});
|
|
31
|
+
parser.runSync(parser.parse(markdown));
|
|
32
|
+
};
|
|
33
|
+
/** A page's body as HTML's tree, highlighted, with its table of contents. */ export const renderMarkdown = async (markdown, file, references)=>{
|
|
34
|
+
const pipeline = processor(file, references);
|
|
35
|
+
const vfile = new VFile({
|
|
36
|
+
path: file,
|
|
37
|
+
value: markdown
|
|
38
|
+
});
|
|
39
|
+
const tree = await pipeline.run(pipeline.parse(vfile), vfile);
|
|
40
|
+
// remark-heading always writes the table of contents (`generateToc` is on).
|
|
41
|
+
return {
|
|
42
|
+
tree,
|
|
43
|
+
toc: vfile.data.toc
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/markdown.ts"],"sourcesContent":["import {\n rehypeCode,\n remarkGfm,\n remarkHeading,\n} from 'fumadocs-core/mdx-plugins';\nimport type { TOCItemType } from 'fumadocs-core/toc';\nimport type { Root as HastRoot } from 'hast';\nimport type { Root as MdastRoot } from 'mdast';\nimport remarkDirective from 'remark-directive';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { unified } from 'unified';\nimport { VFile } from 'vfile';\n\nimport { remarkDocsDirectives } from './directives.js';\nimport type { ReferenceRegistry } from './references.js';\n\n/**\n * Shiki's high-contrast pair. entifix has no syntax palette of its own, and\n * the default GitHub themes measured 3.48:1 on white (spike, ADR 0031).\n */\nexport const CODE_THEMES = {\n light: 'github-light-high-contrast',\n dark: 'github-dark-high-contrast',\n} as const;\n\nconst processor = (file: string, references: ReferenceRegistry) =>\n unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkDirective)\n .use(remarkDocsDirectives, { file, references })\n .use(remarkHeading)\n .use(remarkRehype)\n .use(rehypeCode, { themes: CODE_THEMES, lazy: true });\n\n/**\n * Parses and checks a page without rendering it: an unknown directive or id\n * throws here. The site runs it over every page when it is created, so one bad\n * citation fails the build however many pages are never visited.\n */\nexport const checkMarkdown = (\n markdown: string,\n file: string,\n references: ReferenceRegistry,\n): void => {\n const parser = unified()\n .use(remarkParse)\n .use(remarkDirective)\n .use(remarkDocsDirectives, { file, references });\n parser.runSync(parser.parse(markdown) as MdastRoot);\n};\n\nexport interface RenderedMarkdown {\n readonly tree: HastRoot;\n readonly toc: readonly TOCItemType[];\n}\n\n/** A page's body as HTML's tree, highlighted, with its table of contents. */\nexport const renderMarkdown = async (\n markdown: string,\n file: string,\n references: ReferenceRegistry,\n): Promise<RenderedMarkdown> => {\n const pipeline = processor(file, references);\n const vfile = new VFile({ path: file, value: markdown });\n const tree = (await pipeline.run(pipeline.parse(vfile), vfile)) as HastRoot;\n // remark-heading always writes the table of contents (`generateToc` is on).\n return { tree, toc: vfile.data.toc as readonly TOCItemType[] };\n};\n"],"names":["rehypeCode","remarkGfm","remarkHeading","remarkDirective","remarkParse","remarkRehype","unified","VFile","remarkDocsDirectives","CODE_THEMES","light","dark","processor","file","references","use","themes","lazy","checkMarkdown","markdown","parser","runSync","parse","renderMarkdown","pipeline","vfile","path","value","tree","run","toc","data"],"mappings":"AAAA,SACEA,UAAU,EACVC,SAAS,EACTC,aAAa,QACR,4BAA4B;AAInC,OAAOC,qBAAqB,mBAAmB;AAC/C,OAAOC,iBAAiB,eAAe;AACvC,OAAOC,kBAAkB,gBAAgB;AACzC,SAASC,OAAO,QAAQ,UAAU;AAClC,SAASC,KAAK,QAAQ,QAAQ;AAE9B,SAASC,oBAAoB,QAAQ,kBAAkB;AAGvD;;;CAGC,GACD,OAAO,MAAMC,cAAc;IACzBC,OAAO;IACPC,MAAM;AACR,EAAW;AAEX,MAAMC,YAAY,CAACC,MAAcC,aAC/BR,UACGS,GAAG,CAACX,aACJW,GAAG,CAACd,WACJc,GAAG,CAACZ,iBACJY,GAAG,CAACP,sBAAsB;QAAEK;QAAMC;IAAW,GAC7CC,GAAG,CAACb,eACJa,GAAG,CAACV,cACJU,GAAG,CAACf,YAAY;QAAEgB,QAAQP;QAAaQ,MAAM;IAAK;AAEvD;;;;CAIC,GACD,OAAO,MAAMC,gBAAgB,CAC3BC,UACAN,MACAC;IAEA,MAAMM,SAASd,UACZS,GAAG,CAACX,aACJW,GAAG,CAACZ,iBACJY,GAAG,CAACP,sBAAsB;QAAEK;QAAMC;IAAW;IAChDM,OAAOC,OAAO,CAACD,OAAOE,KAAK,CAACH;AAC9B,EAAE;AAOF,2EAA2E,GAC3E,OAAO,MAAMI,iBAAiB,OAC5BJ,UACAN,MACAC;IAEA,MAAMU,WAAWZ,UAAUC,MAAMC;IACjC,MAAMW,QAAQ,IAAIlB,MAAM;QAAEmB,MAAMb;QAAMc,OAAOR;IAAS;IACtD,MAAMS,OAAQ,MAAMJ,SAASK,GAAG,CAACL,SAASF,KAAK,CAACG,QAAQA;IACxD,4EAA4E;IAC5E,OAAO;QAAEG;QAAME,KAAKL,MAAMM,IAAI,CAACD,GAAG;IAA2B;AAC/D,EAAE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One kind of id a guide may cite, as `:<kind>[id]`: `:use-case[order-management:product-order:cancel]`.
|
|
3
|
+
*
|
|
4
|
+
* The engine knows no host's ids. A host passes one entry per directive name,
|
|
5
|
+
* built from whatever already holds them — a capability register, the entity
|
|
6
|
+
* metadata, the record index — so a guide can only cite what exists.
|
|
7
|
+
*/
|
|
8
|
+
export interface ReferenceKind {
|
|
9
|
+
/** Every id this kind may cite. */
|
|
10
|
+
readonly ids: ReadonlySet<string>;
|
|
11
|
+
/** Where a citation links. */
|
|
12
|
+
readonly href: (id: string) => string;
|
|
13
|
+
/** The words a citation shows; the id itself when absent. */
|
|
14
|
+
readonly label?: (id: string) => string;
|
|
15
|
+
}
|
|
16
|
+
/** Every directive name a guide may use, and what it resolves against. */
|
|
17
|
+
export type ReferenceRegistry = Readonly<Record<string, ReferenceKind>>;
|
|
18
|
+
/** A registry from plain id lists, for the common case. */
|
|
19
|
+
export declare const referenceKind: (ids: Iterable<string>, href: (id: string) => string, label?: (id: string) => string) => ReferenceKind;
|
|
20
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;CACzC;AAED,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AAExE,2DAA2D;AAC3D,eAAO,MAAM,aAAa,GACxB,KAAK,QAAQ,CAAC,MAAM,CAAC,EACrB,MAAM,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,EAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,KAC7B,aAGqC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One kind of id a guide may cite, as `:<kind>[id]`: `:use-case[order-management:product-order:cancel]`.
|
|
3
|
+
*
|
|
4
|
+
* The engine knows no host's ids. A host passes one entry per directive name,
|
|
5
|
+
* built from whatever already holds them — a capability register, the entity
|
|
6
|
+
* metadata, the record index — so a guide can only cite what exists.
|
|
7
|
+
*/ /** A registry from plain id lists, for the common case. */ export const referenceKind = (ids, href, label)=>label === undefined ? {
|
|
8
|
+
ids: new Set(ids),
|
|
9
|
+
href
|
|
10
|
+
} : {
|
|
11
|
+
ids: new Set(ids),
|
|
12
|
+
href,
|
|
13
|
+
label
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/references.ts"],"sourcesContent":["/**\n * One kind of id a guide may cite, as `:<kind>[id]`: `:use-case[order-management:product-order:cancel]`.\n *\n * The engine knows no host's ids. A host passes one entry per directive name,\n * built from whatever already holds them — a capability register, the entity\n * metadata, the record index — so a guide can only cite what exists.\n */\nexport interface ReferenceKind {\n /** Every id this kind may cite. */\n readonly ids: ReadonlySet<string>;\n /** Where a citation links. */\n readonly href: (id: string) => string;\n /** The words a citation shows; the id itself when absent. */\n readonly label?: (id: string) => string;\n}\n\n/** Every directive name a guide may use, and what it resolves against. */\nexport type ReferenceRegistry = Readonly<Record<string, ReferenceKind>>;\n\n/** A registry from plain id lists, for the common case. */\nexport const referenceKind = (\n ids: Iterable<string>,\n href: (id: string) => string,\n label?: (id: string) => string,\n): ReferenceKind =>\n label === undefined\n ? { ids: new Set(ids), href }\n : { ids: new Set(ids), href, label };\n"],"names":["referenceKind","ids","href","label","undefined","Set"],"mappings":"AAAA;;;;;;CAMC,GAaD,yDAAyD,GACzD,OAAO,MAAMA,gBAAgB,CAC3BC,KACAC,MACAC,QAEAA,UAAUC,YACN;QAAEH,KAAK,IAAII,IAAIJ;QAAMC;IAAK,IAC1B;QAAED,KAAK,IAAII,IAAIJ;QAAMC;QAAMC;IAAM,EAAE"}
|
package/dist/site.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type PageData } from 'fumadocs-core/source';
|
|
2
|
+
import type { ReferenceRegistry } from './references.js';
|
|
3
|
+
import type { DocsPageInput, DocsSource } from './sources.js';
|
|
4
|
+
export interface DocsSiteOptions {
|
|
5
|
+
/** Where the pages are served, below the app's `basePath`: `/docs`. */
|
|
6
|
+
readonly baseUrl: string;
|
|
7
|
+
/** The sections, in the order the sidebar shows them. */
|
|
8
|
+
readonly sources: readonly DocsSource[];
|
|
9
|
+
/** What each citation directive resolves against. */
|
|
10
|
+
readonly references?: ReferenceRegistry;
|
|
11
|
+
}
|
|
12
|
+
/** What a page carries into the loader, and what a route reads back. */
|
|
13
|
+
export interface DocsPageData {
|
|
14
|
+
readonly title: string;
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly input: DocsPageInput;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One site from its sources: a `fumadocs-core` page tree, the pages a route
|
|
20
|
+
* renders, and the parameters a static export enumerates.
|
|
21
|
+
*
|
|
22
|
+
* Every page is checked when the site is created — a duplicate address, an
|
|
23
|
+
* unknown directive, an id the registry does not hold — so `next build` stops
|
|
24
|
+
* on the first mistake with its file and line, whichever pages a reader would
|
|
25
|
+
* visit.
|
|
26
|
+
*/
|
|
27
|
+
export declare const createDocsSite: ({ baseUrl, sources, references, }: DocsSiteOptions) => {
|
|
28
|
+
source: import("fumadocs-core/source").LoaderOutput<{
|
|
29
|
+
meta: import("fumadocs-core/source").Meta<undefined, import("fumadocs-core/source").MetaData>;
|
|
30
|
+
page: import("fumadocs-core/source").Page<undefined, PageData>;
|
|
31
|
+
i18n: undefined;
|
|
32
|
+
}>;
|
|
33
|
+
/** The page tree the layout's sidebar renders. */
|
|
34
|
+
pageTree: import("fumadocs-core/page-tree").Root;
|
|
35
|
+
/** A page by its slugs, or `undefined` for an address nothing serves. */
|
|
36
|
+
page: (slugs: readonly string[] | undefined) => {
|
|
37
|
+
url: string;
|
|
38
|
+
data: DocsPageData;
|
|
39
|
+
} | undefined;
|
|
40
|
+
/** A page's body and table of contents. */
|
|
41
|
+
render: (data: DocsPageData) => Promise<import("./markdown.js").RenderedMarkdown>;
|
|
42
|
+
/** Every address, for `generateStaticParams`. */
|
|
43
|
+
params: () => (Record<"slug", string[]> & Record<"lang", string>)[];
|
|
44
|
+
};
|
|
45
|
+
export type DocsSite = ReturnType<typeof createDocsSite>;
|
|
46
|
+
//# sourceMappingURL=site.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,QAAQ,EAAoB,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,qDAAqD;IACrD,QAAQ,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;CAC/B;AA8CD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,mCAI5B,eAAe;;;;;;IAsBd,kDAAkD;;IAElD,yEAAyE;kBAC3D,SAAS,MAAM,EAAE,GAAG,SAAS;;cAIY,YAAY;;IAEnE,2CAA2C;mBAC5B,YAAY;IAE3B,iDAAiD;;CAGpD,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
|