@reapi/docs-compile 0.1.0
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/dist/index.cjs +34039 -0
- package/dist/index.d.cts +70 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +34032 -0
- package/package.json +41 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Root } from 'mdast';
|
|
2
|
+
|
|
3
|
+
interface CompileIssue {
|
|
4
|
+
message: string;
|
|
5
|
+
line?: number;
|
|
6
|
+
column?: number;
|
|
7
|
+
}
|
|
8
|
+
interface TocEntry {
|
|
9
|
+
depth: number;
|
|
10
|
+
text: string;
|
|
11
|
+
id: string;
|
|
12
|
+
}
|
|
13
|
+
interface CompiledPage {
|
|
14
|
+
/** YAML frontmatter (title, description, openapi…), already parsed. */
|
|
15
|
+
frontmatter: Record<string, unknown>;
|
|
16
|
+
/** Sanitized mdast as plain JSON (positions stripped). */
|
|
17
|
+
ast: Root;
|
|
18
|
+
/** h2/h3 entries; heading ids are also stamped onto the ast nodes. */
|
|
19
|
+
toc: TocEntry[];
|
|
20
|
+
/** API slugs referenced by ApiOperation/ApiSchema embeds (+ frontmatter). */
|
|
21
|
+
embeds: string[];
|
|
22
|
+
errors: CompileIssue[];
|
|
23
|
+
}
|
|
24
|
+
interface OpenapiRef {
|
|
25
|
+
api: string;
|
|
26
|
+
method: string;
|
|
27
|
+
path: string;
|
|
28
|
+
}
|
|
29
|
+
/** `"<api-slug> <METHOD> <path>"` → parts, or null when malformed. */
|
|
30
|
+
declare function parseOpenapiRef(value: unknown): OpenapiRef | null;
|
|
31
|
+
declare function compileMdx(source: string): CompiledPage;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The preset component whitelist (portal.md §5). Anything else in JSX
|
|
35
|
+
* position is a publish-time error — the dialect has no user components,
|
|
36
|
+
* no expressions, no imports, so nothing the author writes ever executes.
|
|
37
|
+
*/
|
|
38
|
+
declare const PRESET_COMPONENTS: ReadonlySet<string>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `docs.json` at the docs root configures the site (Mintlify-style):
|
|
42
|
+
*
|
|
43
|
+
* {
|
|
44
|
+
* "name": "Acme Docs",
|
|
45
|
+
* "nav": [
|
|
46
|
+
* { "group": "Getting started", "pages": ["index", "quickstart"] },
|
|
47
|
+
* { "group": "Guides", "pages": ["guides/auth"] }
|
|
48
|
+
* ]
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* Page entries are repo-relative paths without extension; `index` is the
|
|
52
|
+
* site home. Theme keys are accepted but unused for now (Pro customization).
|
|
53
|
+
*/
|
|
54
|
+
interface DocsNavGroup {
|
|
55
|
+
group: string;
|
|
56
|
+
pages: string[];
|
|
57
|
+
}
|
|
58
|
+
interface DocsConfig {
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
nav: DocsNavGroup[];
|
|
62
|
+
}
|
|
63
|
+
/** Normalize a page path: strip ./, leading /, extension; index.* → index. */
|
|
64
|
+
declare function normalizePagePath(raw: string): string;
|
|
65
|
+
declare function parseDocsConfig(jsonText: string): {
|
|
66
|
+
config: DocsConfig | null;
|
|
67
|
+
errors: CompileIssue[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { type CompileIssue, type CompiledPage, type DocsConfig, type DocsNavGroup, type OpenapiRef, PRESET_COMPONENTS, type TocEntry, compileMdx, normalizePagePath, parseDocsConfig, parseOpenapiRef };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Root } from 'mdast';
|
|
2
|
+
|
|
3
|
+
interface CompileIssue {
|
|
4
|
+
message: string;
|
|
5
|
+
line?: number;
|
|
6
|
+
column?: number;
|
|
7
|
+
}
|
|
8
|
+
interface TocEntry {
|
|
9
|
+
depth: number;
|
|
10
|
+
text: string;
|
|
11
|
+
id: string;
|
|
12
|
+
}
|
|
13
|
+
interface CompiledPage {
|
|
14
|
+
/** YAML frontmatter (title, description, openapi…), already parsed. */
|
|
15
|
+
frontmatter: Record<string, unknown>;
|
|
16
|
+
/** Sanitized mdast as plain JSON (positions stripped). */
|
|
17
|
+
ast: Root;
|
|
18
|
+
/** h2/h3 entries; heading ids are also stamped onto the ast nodes. */
|
|
19
|
+
toc: TocEntry[];
|
|
20
|
+
/** API slugs referenced by ApiOperation/ApiSchema embeds (+ frontmatter). */
|
|
21
|
+
embeds: string[];
|
|
22
|
+
errors: CompileIssue[];
|
|
23
|
+
}
|
|
24
|
+
interface OpenapiRef {
|
|
25
|
+
api: string;
|
|
26
|
+
method: string;
|
|
27
|
+
path: string;
|
|
28
|
+
}
|
|
29
|
+
/** `"<api-slug> <METHOD> <path>"` → parts, or null when malformed. */
|
|
30
|
+
declare function parseOpenapiRef(value: unknown): OpenapiRef | null;
|
|
31
|
+
declare function compileMdx(source: string): CompiledPage;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The preset component whitelist (portal.md §5). Anything else in JSX
|
|
35
|
+
* position is a publish-time error — the dialect has no user components,
|
|
36
|
+
* no expressions, no imports, so nothing the author writes ever executes.
|
|
37
|
+
*/
|
|
38
|
+
declare const PRESET_COMPONENTS: ReadonlySet<string>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `docs.json` at the docs root configures the site (Mintlify-style):
|
|
42
|
+
*
|
|
43
|
+
* {
|
|
44
|
+
* "name": "Acme Docs",
|
|
45
|
+
* "nav": [
|
|
46
|
+
* { "group": "Getting started", "pages": ["index", "quickstart"] },
|
|
47
|
+
* { "group": "Guides", "pages": ["guides/auth"] }
|
|
48
|
+
* ]
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* Page entries are repo-relative paths without extension; `index` is the
|
|
52
|
+
* site home. Theme keys are accepted but unused for now (Pro customization).
|
|
53
|
+
*/
|
|
54
|
+
interface DocsNavGroup {
|
|
55
|
+
group: string;
|
|
56
|
+
pages: string[];
|
|
57
|
+
}
|
|
58
|
+
interface DocsConfig {
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
nav: DocsNavGroup[];
|
|
62
|
+
}
|
|
63
|
+
/** Normalize a page path: strip ./, leading /, extension; index.* → index. */
|
|
64
|
+
declare function normalizePagePath(raw: string): string;
|
|
65
|
+
declare function parseDocsConfig(jsonText: string): {
|
|
66
|
+
config: DocsConfig | null;
|
|
67
|
+
errors: CompileIssue[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { type CompileIssue, type CompiledPage, type DocsConfig, type DocsNavGroup, type OpenapiRef, PRESET_COMPONENTS, type TocEntry, compileMdx, normalizePagePath, parseDocsConfig, parseOpenapiRef };
|