@serene-pub/docs 0.0.0-stage → 0.6.0-pr-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/LICENSE +202 -0
- package/NOTICE +17 -0
- package/README.md +286 -2
- package/dist/compile.d.ts +3 -0
- package/dist/compile.js +329 -0
- package/dist/dialect.d.ts +139 -0
- package/dist/dialect.js +465 -0
- package/dist/escape.d.ts +14 -0
- package/dist/escape.js +21 -0
- package/dist/graph.d.ts +31 -0
- package/dist/graph.js +132 -0
- package/dist/highlight.d.ts +7 -0
- package/dist/highlight.js +40 -0
- package/dist/images.d.ts +22 -0
- package/dist/images.js +137 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/manifest.d.ts +44 -0
- package/dist/manifest.js +72 -0
- package/dist/sources.d.ts +15 -0
- package/dist/sources.js +52 -0
- package/dist/specGraph.d.ts +34 -0
- package/dist/specGraph.js +0 -0
- package/dist/types.d.ts +208 -0
- package/dist/types.js +19 -0
- package/package.json +67 -5
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@serene-pub/docs` — the contract.
|
|
3
|
+
*
|
|
4
|
+
* The compiler takes documentation from more than one place — a directory of
|
|
5
|
+
* markdown a human wrote, and pages `@serene-pub/cli` rendered out of an
|
|
6
|
+
* announcement — and emits ONE reading order over all of it. Keeping the
|
|
7
|
+
* contract in its own module is what lets the consumer pin against these
|
|
8
|
+
* shapes without importing the compiler (and the marked/shiki/jimp weight
|
|
9
|
+
* behind it).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* This package does not import `@serene-pub/cli`, and cannot: the CLI now
|
|
13
|
+
* imports `DocsGraph` from here (it renders the ` ```pipeline ` fence the
|
|
14
|
+
* compiler resolves), and two packages whose emitted `.d.ts` files reference
|
|
15
|
+
* each other cannot both be built — whichever goes second reads the other's
|
|
16
|
+
* declarations, which read its own, and `tsc` refuses to overwrite an input.
|
|
17
|
+
* So the arrow points one way, docs → cli is gone, and `DocsSource.pages`
|
|
18
|
+
* states the shape it accepts structurally.
|
|
19
|
+
*
|
|
20
|
+
* The claim that shape IS what `renderAnnouncementDocs()` returns has not
|
|
21
|
+
* gone anywhere — it moved to `sdk-tests/docsSource.assert.ts`, which sees
|
|
22
|
+
* both packages' SOURCE and so proves it against the CLI as written rather
|
|
23
|
+
* than against the CLI as last built.
|
|
24
|
+
*/
|
|
25
|
+
export interface DocsSource {
|
|
26
|
+
/** 'app' | 'sdk' | any id. Recorded per page; drives banners. */
|
|
27
|
+
id: string;
|
|
28
|
+
/**
|
|
29
|
+
* Nav group heading shown to readers — the source's ONE group when `order`
|
|
30
|
+
* is flat, and the heading of the trailing group that catches pages a
|
|
31
|
+
* grouped `order` does not list.
|
|
32
|
+
*/
|
|
33
|
+
group: string;
|
|
34
|
+
/** Either a directory of markdown files… */
|
|
35
|
+
dir?: string;
|
|
36
|
+
/** …or pre-rendered markdown pages (e.g. from @serene-pub/cli renderAnnouncementDocs). `path` is like 'pipelines/core_spec_respond.md'. */
|
|
37
|
+
pages?: {
|
|
38
|
+
path: string;
|
|
39
|
+
markdown: string;
|
|
40
|
+
}[];
|
|
41
|
+
/** Slug prefix for every page of this source, e.g. 'sdk' → slug 'sdk/pipelines/core_spec_respond'. Omit for none. */
|
|
42
|
+
prefix?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Explicit reading order of slugs (without prefix). A page absent from it is
|
|
45
|
+
* appended alphabetically AND reported as a warning.
|
|
46
|
+
*
|
|
47
|
+
* Either flat — one nav group, headed `group` — or a list of **order
|
|
48
|
+
* groups**, each its own nav group headed by its own name, so one source
|
|
49
|
+
* can fill several sections of the nav without its files moving. A grouped
|
|
50
|
+
* order's unlisted pages land in a trailing group headed `group` (merged
|
|
51
|
+
* into a declared group of that name, if there is one).
|
|
52
|
+
*/
|
|
53
|
+
order?: string[] | DocsOrderGroup[];
|
|
54
|
+
/** Prepended to every page of this source as <aside class="doc-banner" role="note">. */
|
|
55
|
+
banner?: string;
|
|
56
|
+
/** Optional repo link and commit shown in the manifest for this source. */
|
|
57
|
+
repo?: {
|
|
58
|
+
url: string;
|
|
59
|
+
commit?: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One **order group**: a named run of a source's reading order, which becomes
|
|
64
|
+
* one nav group of its own. Names are unique within a source; a slug belongs
|
|
65
|
+
* to at most one group.
|
|
66
|
+
*/
|
|
67
|
+
export interface DocsOrderGroup {
|
|
68
|
+
/** Nav group heading shown to readers. */
|
|
69
|
+
group: string;
|
|
70
|
+
/** Slugs (without prefix), in reading order. */
|
|
71
|
+
pages: string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One box in a drawing the compiler lays out but does not understand.
|
|
75
|
+
*
|
|
76
|
+
* `kind` is an opaque token — `inlet`, `query`, `task`, `oracle`, `outlet`,
|
|
77
|
+
* whatever the resolver calls it — that reaches the page as the class suffix
|
|
78
|
+
* `doc-graph-node-{kind}` and nothing more. Knowing a query from an oracle is
|
|
79
|
+
* the resolver's job, which is what keeps this package free of a dependency
|
|
80
|
+
* on `@serene-pub/sdk`.
|
|
81
|
+
*/
|
|
82
|
+
export interface DocsGraphNode {
|
|
83
|
+
key: string;
|
|
84
|
+
/** inlet | query | task | oracle | outlet | … */
|
|
85
|
+
kind: string;
|
|
86
|
+
label: string;
|
|
87
|
+
sublabel?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface DocsGraphEdge {
|
|
90
|
+
/** A node `key`. An edge naming a key no node has is dropped. */
|
|
91
|
+
from: string;
|
|
92
|
+
to: string;
|
|
93
|
+
label?: string;
|
|
94
|
+
}
|
|
95
|
+
/** What a ` ```pipeline <id> ` fence resolves to. */
|
|
96
|
+
export interface DocsGraph {
|
|
97
|
+
/** The fence's id. Also slugged into every id the emitted SVG defines. */
|
|
98
|
+
id: string;
|
|
99
|
+
/** The `<figcaption>` and the SVG's accessible name. Defaults to `id`. */
|
|
100
|
+
title?: string;
|
|
101
|
+
nodes: DocsGraphNode[];
|
|
102
|
+
edges: DocsGraphEdge[];
|
|
103
|
+
/** ELK's layout direction. Default 'DOWN'. */
|
|
104
|
+
direction?: 'DOWN' | 'RIGHT';
|
|
105
|
+
}
|
|
106
|
+
export interface CompileDocsOptions {
|
|
107
|
+
/** Product version recorded in the manifest. */
|
|
108
|
+
version: string;
|
|
109
|
+
sources: DocsSource[];
|
|
110
|
+
/** Where pages/*.html, manifest.json, search.json go. Created/emptied. */
|
|
111
|
+
out: string;
|
|
112
|
+
/** Where converted image assets go (a directory). Created/emptied. */
|
|
113
|
+
assetsOut: string;
|
|
114
|
+
/** URL base the emitted <img src> uses, e.g. '/docs/assets'. */
|
|
115
|
+
assetsBase: string;
|
|
116
|
+
/** URL base for page links, default '/docs'. rewriteDocHref('./x.md#a') → `${linkBase}/x#a`. */
|
|
117
|
+
linkBase?: string;
|
|
118
|
+
/** Max image width in px (default 1200) and webp quality (default 80). */
|
|
119
|
+
image?: {
|
|
120
|
+
maxWidth?: number;
|
|
121
|
+
quality?: number;
|
|
122
|
+
};
|
|
123
|
+
/** Fails the compile if converted assets exceed this. Default 6 * 1024 * 1024. */
|
|
124
|
+
assetBudgetBytes?: number;
|
|
125
|
+
/** Shiki languages to load. Default: ['ts','js','json','bash','yaml','html','css','svelte','markdown','liquid','sql']. */
|
|
126
|
+
languages?: string[];
|
|
127
|
+
/**
|
|
128
|
+
* Content the compiler renders but cannot know: `pipeline` answers a
|
|
129
|
+
* ` ```pipeline <id> ` fence with the graph to draw. Returning null — or
|
|
130
|
+
* not supplying the resolver at all — fails the compile, naming the page
|
|
131
|
+
* and the id, in the same offender listing as a broken link.
|
|
132
|
+
*/
|
|
133
|
+
resolvers?: {
|
|
134
|
+
pipeline?: (id: string) => DocsGraph | null;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export interface DocsManifest {
|
|
138
|
+
version: string;
|
|
139
|
+
/** ISO. */
|
|
140
|
+
generatedAt: string;
|
|
141
|
+
linkBase: string;
|
|
142
|
+
sources: Record<string, {
|
|
143
|
+
group: string;
|
|
144
|
+
banner?: string;
|
|
145
|
+
repo?: {
|
|
146
|
+
url: string;
|
|
147
|
+
commit?: string;
|
|
148
|
+
};
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Nav groups, in reading order; slugs within each, in reading order. A
|
|
152
|
+
* source with a grouped `order` contributes several consecutive groups,
|
|
153
|
+
* so `source` is NOT unique here — key a group by `source` + `group`.
|
|
154
|
+
*/
|
|
155
|
+
nav: {
|
|
156
|
+
group: string;
|
|
157
|
+
source: string;
|
|
158
|
+
pages: string[];
|
|
159
|
+
}[];
|
|
160
|
+
pages: Record<string, DocsPageMeta>;
|
|
161
|
+
assets: {
|
|
162
|
+
count: number;
|
|
163
|
+
bytes: number;
|
|
164
|
+
budgetBytes: number;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export interface DocsPageMeta {
|
|
168
|
+
/** 'getting-started' or 'sdk/pipelines/core_spec_respond'. */
|
|
169
|
+
slug: string;
|
|
170
|
+
/** First H1, else slug. */
|
|
171
|
+
title: string;
|
|
172
|
+
/** First paragraph after H1, inline markdown stripped, ≤200 chars. */
|
|
173
|
+
description: string;
|
|
174
|
+
source: string;
|
|
175
|
+
/** Position within its source's nav. */
|
|
176
|
+
order: number;
|
|
177
|
+
headings: {
|
|
178
|
+
id: string;
|
|
179
|
+
text: string;
|
|
180
|
+
depth: number;
|
|
181
|
+
}[];
|
|
182
|
+
/** Size of pages/<slug>.html. */
|
|
183
|
+
bytes: number;
|
|
184
|
+
}
|
|
185
|
+
/** search.json: flat array, one entry per heading, mirroring the app's existing DocSection. */
|
|
186
|
+
export interface DocsSearchEntry {
|
|
187
|
+
slug: string;
|
|
188
|
+
anchor: string;
|
|
189
|
+
title: string;
|
|
190
|
+
depth: number;
|
|
191
|
+
preview: string;
|
|
192
|
+
/** The section's body as plain text, ≤1200 chars — searched, never shown. */
|
|
193
|
+
text: string;
|
|
194
|
+
}
|
|
195
|
+
export interface CompileDocsReport {
|
|
196
|
+
manifest: DocsManifest;
|
|
197
|
+
/** e.g. slug missing from `order`. */
|
|
198
|
+
warnings: string[];
|
|
199
|
+
pagesWritten: number;
|
|
200
|
+
assetsWritten: number;
|
|
201
|
+
}
|
|
202
|
+
/** Shiki grammars loaded when `languages` is not given. */
|
|
203
|
+
export declare const DEFAULT_DOC_LANGUAGES: string[];
|
|
204
|
+
export declare const DEFAULT_LINK_BASE = "/docs";
|
|
205
|
+
export declare const DEFAULT_MAX_WIDTH = 1200;
|
|
206
|
+
export declare const DEFAULT_QUALITY = 80;
|
|
207
|
+
export declare const DEFAULT_ASSET_BUDGET_BYTES: number;
|
|
208
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Shiki grammars loaded when `languages` is not given. */
|
|
2
|
+
export const DEFAULT_DOC_LANGUAGES = [
|
|
3
|
+
'ts',
|
|
4
|
+
'js',
|
|
5
|
+
'json',
|
|
6
|
+
'bash',
|
|
7
|
+
'yaml',
|
|
8
|
+
'html',
|
|
9
|
+
'css',
|
|
10
|
+
'svelte',
|
|
11
|
+
'markdown',
|
|
12
|
+
'liquid',
|
|
13
|
+
'sql',
|
|
14
|
+
];
|
|
15
|
+
export const DEFAULT_LINK_BASE = '/docs';
|
|
16
|
+
export const DEFAULT_MAX_WIDTH = 1200;
|
|
17
|
+
export const DEFAULT_QUALITY = 80;
|
|
18
|
+
export const DEFAULT_ASSET_BUDGET_BYTES = 6 * 1024 * 1024;
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@serene-pub/docs",
|
|
3
|
+
"version": "0.6.0-pr-1",
|
|
4
|
+
"description": "Serene Pub's docs compiler: markdown sources plus rendered announcement pages in, a manifest, a search index and one HTML file per page out.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://github.com/SerenePub/serene-pub-sdk/tree/main/docs#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/SerenePub/serene-pub-sdk/issues"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/SerenePub/serene-pub-sdk.git",
|
|
13
|
+
"directory": "docs"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=24"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"!dist/**/*.map",
|
|
22
|
+
"README.md",
|
|
23
|
+
"NOTICE"
|
|
24
|
+
],
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./graph": {
|
|
33
|
+
"types": "./dist/graph.d.ts",
|
|
34
|
+
"import": "./dist/graph.js"
|
|
35
|
+
},
|
|
36
|
+
"./spec-graph": {
|
|
37
|
+
"types": "./dist/specGraph.d.ts",
|
|
38
|
+
"import": "./dist/specGraph.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.build.json"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@jsquash/webp": "^1.5.0",
|
|
47
|
+
"elkjs": "^0.12.0",
|
|
48
|
+
"github-slugger": "^2.0.0",
|
|
49
|
+
"jimp": "^1.6.1",
|
|
50
|
+
"marked": "^15.0.12",
|
|
51
|
+
"shiki": "^4.4.3"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@serene-pub/sdk": "^0.6.0-pr-1"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@serene-pub/sdk": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@serene-pub/sdk": "0.6.0-pr-1"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
66
|
+
"tag": "next"
|
|
67
|
+
}
|
|
68
|
+
}
|