@serene-pub/docs 0.0.0-stage → 0.6.0-pr-2
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/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Serene Pub SDK
|
|
2
|
+
Copyright (c) 2025-2026 Jody Doolittle
|
|
3
|
+
|
|
4
|
+
This product includes software developed as part of the Serene Pub project
|
|
5
|
+
(https://github.com/doolijb/serene-pub).
|
|
6
|
+
|
|
7
|
+
The Serene Pub SDK is licensed under the Apache License, Version 2.0.
|
|
8
|
+
|
|
9
|
+
Note that the Serene Pub application itself is a separate work, licensed under
|
|
10
|
+
the GNU Affero General Public License v3.0. Building on this SDK does not place
|
|
11
|
+
your extension under the AGPL — that is the reason this SDK is licensed
|
|
12
|
+
permissively.
|
|
13
|
+
|
|
14
|
+
"Serene Pub" and the Serene Pub logo are trademarks of the project owner and are
|
|
15
|
+
not licensed by the Apache License (see Section 6). Their use is governed by the
|
|
16
|
+
project's trademark policy:
|
|
17
|
+
https://github.com/doolijb/serene-pub/blob/main/TRADEMARK.md
|
package/README.md
CHANGED
|
@@ -1,3 +1,287 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @serene-pub/docs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The docs compiler. It takes documentation from more than one place — the markdown a
|
|
4
|
+
human wrote in the app repo, and the pages `@serene-pub/cli`'s `renderAnnouncementDocs()`
|
|
5
|
+
renders straight out of a package's announcement — and emits **one reading order** over
|
|
6
|
+
all of it: an article body per page, a manifest that _is_ the nav, and a flat search index.
|
|
7
|
+
|
|
8
|
+
It refuses to emit any of it while a link, an anchor or an image is broken. That is the
|
|
9
|
+
point of the package: reference docs generated from declarations and prose written by
|
|
10
|
+
hand drift apart quietly, and a dead anchor is invisible until a reader clicks it.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { compileDocs } from '@serene-pub/docs'
|
|
14
|
+
import { renderAnnouncementDocs, typeSurfaces } from '@serene-pub/cli'
|
|
15
|
+
import { coreAnnouncement } from '@serene-pub/core-catalog'
|
|
16
|
+
|
|
17
|
+
const typeOf = await typeSurfaces()
|
|
18
|
+
const report = await compileDocs({
|
|
19
|
+
version: '0.6.0',
|
|
20
|
+
sources: [
|
|
21
|
+
{ id: 'app', group: 'Using Serene Pub', dir: 'docs' },
|
|
22
|
+
{
|
|
23
|
+
id: 'sdk',
|
|
24
|
+
group: 'SDK',
|
|
25
|
+
prefix: 'sdk',
|
|
26
|
+
pages: renderAnnouncementDocs(coreAnnouncement().document, typeOf),
|
|
27
|
+
banner: 'Plugin modding is only available in 0.7 previews.',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
out: 'static/docs',
|
|
31
|
+
assetsOut: 'static/docs/assets',
|
|
32
|
+
assetsBase: '/docs/assets',
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This package is **build-time only**. A consumer serves the output; it never imports the
|
|
37
|
+
compiler, and so never carries marked, shiki, jimp or the wasm webp encoder into a
|
|
38
|
+
runtime bundle. There are no native dependencies anywhere in that stack — decode and
|
|
39
|
+
resize are pure JS, the webp encoder is WASM.
|
|
40
|
+
|
|
41
|
+
## The dialect
|
|
42
|
+
|
|
43
|
+
CommonMark with GFM tables, plus eight things:
|
|
44
|
+
|
|
45
|
+
1. **Headings** get `id`s from **GitHub's slug rule** (`github-slugger`), one slugger per
|
|
46
|
+
page: the text is lowercased, the punctuation GitHub removes is removed — `_` and `-`
|
|
47
|
+
are not punctuation to it, and inline code and emphasis markers go while their
|
|
48
|
+
contents stay — and **each space becomes one `-`**, so an `&` removed from between two
|
|
49
|
+
spaces leaves two hyphens. A repeated heading gets `-1`, `-2`. So
|
|
50
|
+
``### `SERENE_PUB_DATA_DIR` is the one exception`` is
|
|
51
|
+
`#serene_pub_data_dir-is-the-one-exception`, `## Prompt Configs & Summarization Config`
|
|
52
|
+
is `#prompt-configs--summarization-config`, and `## Database won't open` is
|
|
53
|
+
`#database-wont-open`. This is not a preference: the guides lived on GitHub for a year
|
|
54
|
+
and link each other with these anchors, and TypeDoc's markdown emits the same shape
|
|
55
|
+
(`#slot_value`, `#band_order`). Readers have bookmarked them; they do not move.
|
|
56
|
+
2. **Links** to a relative `.md` file resolve against the current page's path inside its
|
|
57
|
+
source, then map to slug + `linkBase`. `./characters.md#creator-wizard` from an app
|
|
58
|
+
page becomes `/docs/characters#creator-wizard`; `pipelines/core_spec_respond.md` from
|
|
59
|
+
the `sdk` catalog index becomes `/docs/sdk/pipelines/core_spec_respond`. Offsite links
|
|
60
|
+
pass through untouched, and so does a bare `#anchor` — but a bare `#anchor` is still
|
|
61
|
+
**checked**, against the heading ids of the page that wrote it.
|
|
62
|
+
3. **Code fences** are highlighted by shiki with both themes baked into the same markup
|
|
63
|
+
as `--shiki-light` / `--shiki-dark` CSS variables, so the consumer keeps the
|
|
64
|
+
light/dark decision. An unknown language falls back to an escaped `<pre><code>`.
|
|
65
|
+
4. **Playground fences** — ` ```playground ` with an optional language after the word —
|
|
66
|
+
are a normal highlighted block wrapped in
|
|
67
|
+
`<div class="doc-playground" data-playground data-lang="ts">`, with the fence's own
|
|
68
|
+
text carried ahead of it as
|
|
69
|
+
`<script type="text/plain" class="doc-playground-source">`. The host reads
|
|
70
|
+
`textContent` off that element and **HTML-unescapes it** — the body is escaped, and a
|
|
71
|
+
literal `</script` in it is additionally written `<\/script` so a fence can never
|
|
72
|
+
close its own carrier. The highlighted markup is for reading; the carrier is what
|
|
73
|
+
gets run, because recovering source out of shiki's spans is right until the first
|
|
74
|
+
fence the highlighter styles in a way nobody predicted. Nothing on the page itself is
|
|
75
|
+
interactive: a host mounts `@serene-pub/playground` — a sandboxed iframe that
|
|
76
|
+
transpiles and runs what it is handed — against the wrapper.
|
|
77
|
+
5. **Admonitions** — a block from `:::note`, `:::tip` or `:::warning` (optional title
|
|
78
|
+
after the kind) to a closing `:::` — render as
|
|
79
|
+
`<aside class="doc-admonition doc-admonition-{kind}" role="note">` with a
|
|
80
|
+
`<p class="doc-admonition-title">`. The body is markdown.
|
|
81
|
+
6. **Images** — `` with an optional trailing `{w=800}` —
|
|
82
|
+
resolve against the source file, decode (PNG/JPEG/GIF first frame/WebP), downscale to
|
|
83
|
+
`maxWidth`, and encode to webp named by the sha256 of the output bytes. A standalone
|
|
84
|
+
image is a `<figure class="doc-figure">` with a `<figcaption>`; one sitting inside a
|
|
85
|
+
sentence is a bare `<img>`, because a `<figure>` inside a `<p>` is not HTML. `.svg`
|
|
86
|
+
is copied verbatim.
|
|
87
|
+
7. **Banners** — a source's `banner` is prepended to every one of its pages as
|
|
88
|
+
`<aside class="doc-banner" role="note">`.
|
|
89
|
+
8. **Pipeline fences** — ` ```pipeline core:spec/respond ` (the id is the info string
|
|
90
|
+
after the word; the body is ignored and is usually empty) — become an inline SVG of
|
|
91
|
+
that pipeline, laid out by [elkjs](https://github.com/kieler/elkjs)'s `layered`
|
|
92
|
+
algorithm with the same 220×58 cards and spacings the app's pipeline map uses, so the
|
|
93
|
+
drawing here and the drawing there read as the same picture. The compiler does not
|
|
94
|
+
know what a pipeline is: it asks `resolvers.pipeline`, below.
|
|
95
|
+
|
|
96
|
+
Nothing is sanitised. All of this is first-party content; everything the dialect itself
|
|
97
|
+
interpolates is escaped here.
|
|
98
|
+
|
|
99
|
+
## The output contract
|
|
100
|
+
|
|
101
|
+
````ts
|
|
102
|
+
export interface DocsSource {
|
|
103
|
+
/** 'app' | 'sdk' | any id. Recorded per page; drives banners. */
|
|
104
|
+
id: string
|
|
105
|
+
/** Nav group heading shown to readers. */
|
|
106
|
+
group: string
|
|
107
|
+
/** Either a directory of markdown files… */
|
|
108
|
+
dir?: string
|
|
109
|
+
/** …or pre-rendered markdown pages (e.g. from @serene-pub/cli renderAnnouncementDocs). `path` is like 'pipelines/core_spec_respond.md'. */
|
|
110
|
+
pages?: { path: string; markdown: string }[]
|
|
111
|
+
/** Slug prefix for every page of this source, e.g. 'sdk' → slug 'sdk/pipelines/core_spec_respond'. Omit for none. */
|
|
112
|
+
prefix?: string
|
|
113
|
+
/** Explicit reading order of slugs (without prefix). A page absent from it is appended alphabetically AND reported as a warning. */
|
|
114
|
+
order?: string[]
|
|
115
|
+
/** Prepended to every page of this source as <aside class="doc-banner" role="note">. */
|
|
116
|
+
banner?: string
|
|
117
|
+
/** Optional repo link and commit shown in the manifest for this source. */
|
|
118
|
+
repo?: { url: string; commit?: string }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface CompileDocsOptions {
|
|
122
|
+
version: string // product version recorded in the manifest
|
|
123
|
+
sources: DocsSource[]
|
|
124
|
+
/** Where pages/*.html, manifest.json, search.json go. Created/emptied. */
|
|
125
|
+
out: string
|
|
126
|
+
/** Where converted image assets go (a directory). Created/emptied. */
|
|
127
|
+
assetsOut: string
|
|
128
|
+
/** URL base the emitted <img src> uses, e.g. '/docs/assets'. */
|
|
129
|
+
assetsBase: string
|
|
130
|
+
/** URL base for page links, default '/docs'. rewriteDocHref('./x.md#a') → `${linkBase}/x#a`. */
|
|
131
|
+
linkBase?: string
|
|
132
|
+
/** Max image width in px (default 1200) and webp quality (default 80). */
|
|
133
|
+
image?: { maxWidth?: number; quality?: number }
|
|
134
|
+
/** Fails the compile if converted assets exceed this. Default 6 * 1024 * 1024. */
|
|
135
|
+
assetBudgetBytes?: number
|
|
136
|
+
/** Shiki languages to load. Default: ['ts','js','json','bash','yaml','html','css','svelte','markdown','liquid','sql']. */
|
|
137
|
+
languages?: string[]
|
|
138
|
+
/** Answers a ```pipeline <id> fence. null — or no resolver — fails the compile. */
|
|
139
|
+
resolvers?: { pipeline?: (id: string) => DocsGraph | null }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface DocsGraphNode {
|
|
143
|
+
key: string
|
|
144
|
+
kind: string // inlet | query | task | oracle | outlet | … — a CSS class suffix
|
|
145
|
+
label: string
|
|
146
|
+
sublabel?: string
|
|
147
|
+
}
|
|
148
|
+
export interface DocsGraphEdge {
|
|
149
|
+
from: string // a node `key`; an edge naming a key no node has is dropped
|
|
150
|
+
to: string
|
|
151
|
+
label?: string
|
|
152
|
+
}
|
|
153
|
+
export interface DocsGraph {
|
|
154
|
+
id: string // the fence's id; also slugged into every id the SVG defines
|
|
155
|
+
title?: string // the <figcaption> and the SVG's accessible name. Defaults to `id`
|
|
156
|
+
nodes: DocsGraphNode[]
|
|
157
|
+
edges: DocsGraphEdge[]
|
|
158
|
+
direction?: 'DOWN' | 'RIGHT' // ELK's layout direction, default 'DOWN'
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface DocsManifest {
|
|
162
|
+
version: string
|
|
163
|
+
generatedAt: string // ISO
|
|
164
|
+
linkBase: string
|
|
165
|
+
sources: Record<
|
|
166
|
+
string,
|
|
167
|
+
{ group: string; banner?: string; repo?: { url: string; commit?: string } }
|
|
168
|
+
>
|
|
169
|
+
nav: { group: string; source: string; pages: string[] }[] // slugs, in reading order
|
|
170
|
+
pages: Record<string, DocsPageMeta>
|
|
171
|
+
assets: { count: number; bytes: number; budgetBytes: number }
|
|
172
|
+
}
|
|
173
|
+
export interface DocsPageMeta {
|
|
174
|
+
slug: string // 'getting-started' or 'sdk/pipelines/core_spec_respond'
|
|
175
|
+
title: string // first H1, else slug
|
|
176
|
+
description: string // first paragraph after H1, inline markdown stripped, ≤200 chars
|
|
177
|
+
source: string
|
|
178
|
+
order: number // position within its source's nav
|
|
179
|
+
headings: { id: string; text: string; depth: number }[]
|
|
180
|
+
bytes: number // size of pages/<slug>.html
|
|
181
|
+
}
|
|
182
|
+
/** search.json: flat array, one entry per heading, mirroring the app's existing DocSection. */
|
|
183
|
+
export interface DocsSearchEntry {
|
|
184
|
+
slug: string
|
|
185
|
+
anchor: string
|
|
186
|
+
title: string
|
|
187
|
+
depth: number
|
|
188
|
+
preview: string
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface CompileDocsReport {
|
|
192
|
+
manifest: DocsManifest
|
|
193
|
+
warnings: string[] // e.g. slug missing from `order`
|
|
194
|
+
pagesWritten: number
|
|
195
|
+
assetsWritten: number
|
|
196
|
+
}
|
|
197
|
+
export function compileDocs(opts: CompileDocsOptions): Promise<CompileDocsReport>
|
|
198
|
+
````
|
|
199
|
+
|
|
200
|
+
Output files: `${out}/manifest.json`, `${out}/search.json`, `${out}/pages/<slug>.html`
|
|
201
|
+
(nested dirs for slugs with `/`; article body only, no `<html>`/`<body>`), and
|
|
202
|
+
`${assetsOut}/<contenthash>.webp` (and `.svg` copied verbatim).
|
|
203
|
+
|
|
204
|
+
**The compile fails**, with one error naming every offender, on: a link to a `.md` page
|
|
205
|
+
that is not in any source; a link whose anchor has no matching heading id on the page it
|
|
206
|
+
points at — including a bare `#anchor`, whose page is the one that wrote it; a referenced
|
|
207
|
+
image file that does not exist or cannot be decoded; a ` ```pipeline ` fence no resolver
|
|
208
|
+
answers; two pages that compile to the same slug; and converted assets over the budget. **Warnings**, which
|
|
209
|
+
do not stop it: a page missing from its source's `order`, and an `order` entry with no
|
|
210
|
+
page. Nothing is written until everything has been rendered and proved — a failed
|
|
211
|
+
compile leaves the previous output alone rather than a half-empty directory a server
|
|
212
|
+
would happily serve.
|
|
213
|
+
|
|
214
|
+
Also exported, because the app shares them: `slugifyHeading`, `stripInlineMarkdown`,
|
|
215
|
+
`rewriteDocHref` (the app's one-argument form, and a contextual two-argument one),
|
|
216
|
+
`resolveDocLink` and `renderMarkdown`.
|
|
217
|
+
|
|
218
|
+
And `loadMarkdownDir(dir, { prefix })`, which reads every `.md` under a directory
|
|
219
|
+
into `{ path, markdown }` pages with paths relative to `dir`. `DocsSource.dir`
|
|
220
|
+
already reads a directory, but it reads it as _the_ source; this is for markdown a
|
|
221
|
+
**generator** wrote — the TypeDoc API reference the SDK build leaves in
|
|
222
|
+
`docs/generated/api` — which has to be handed to a source that also carries a
|
|
223
|
+
prefix, a banner and a repo link. It does not swallow a missing directory: "the
|
|
224
|
+
generator never ran" and "it generated nothing" are different facts, and only the
|
|
225
|
+
caller knows which one is survivable.
|
|
226
|
+
|
|
227
|
+
## Pipeline graphs
|
|
228
|
+
|
|
229
|
+
`resolvers.pipeline` is the whole of the contract: given the fence's id, hand back a
|
|
230
|
+
`DocsGraph` or `null`. It is **synchronous and total** — the compiler has already
|
|
231
|
+
collected every fence on the page before it renders a line of it, and a `null` is not a
|
|
232
|
+
blank space but a named offender in the same error a broken link raises
|
|
233
|
+
(`` `sdk/pipelines/core_spec_respond` embeds pipeline `core:spec/nope` — no resolver /
|
|
234
|
+
unknown id. ``). That is deliberate: a generated catalog page that silently lost its map
|
|
235
|
+
looks finished.
|
|
236
|
+
|
|
237
|
+
`@serene-pub/cli` ships the resolver for a package's own announcement —
|
|
238
|
+
`pipelineResolver(announcement)` — and `specGraphOf(specDocument)` if you are assembling
|
|
239
|
+
one by hand.
|
|
240
|
+
|
|
241
|
+
Each fence becomes:
|
|
242
|
+
|
|
243
|
+
```html
|
|
244
|
+
<figure class="doc-graph">
|
|
245
|
+
<svg
|
|
246
|
+
role="img"
|
|
247
|
+
aria-labelledby="core-spec-respond-title"
|
|
248
|
+
viewBox="0 0 W H"
|
|
249
|
+
width="W"
|
|
250
|
+
height="H"
|
|
251
|
+
>
|
|
252
|
+
<title id="core-spec-respond-title">core:spec/respond</title>
|
|
253
|
+
<defs><marker id="core-spec-respond-arrow">…</marker></defs>
|
|
254
|
+
<path class="doc-graph-edge" d="…" marker-end="url(#core-spec-respond-arrow)" />
|
|
255
|
+
<text class="doc-graph-edge-label">…</text>
|
|
256
|
+
<g class="doc-graph-node doc-graph-node-query" transform="translate(x,y)">
|
|
257
|
+
<title>the full label, when the card's was cut</title>
|
|
258
|
+
<rect rx="8" />
|
|
259
|
+
<text>key</text>
|
|
260
|
+
<text class="doc-graph-sublabel">type id</text>
|
|
261
|
+
</g>
|
|
262
|
+
</svg>
|
|
263
|
+
<figcaption>core:spec/respond</figcaption>
|
|
264
|
+
</figure>
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Every id the SVG defines is prefixed with a slug of the graph's id, so two graphs on one
|
|
268
|
+
page never share a marker or an `aria-labelledby` target — which also means the **id is
|
|
269
|
+
what has to be unique on a page**, not merely present.
|
|
270
|
+
|
|
271
|
+
The `<svg>` carries a `viewBox` and matching `width`/`height`, so it is the host that
|
|
272
|
+
decides whether a wide graph scrolls or scales — `.doc-graph { overflow-x: auto }` or
|
|
273
|
+
`.doc-graph svg { max-width: 100%; height: auto }`. Core's `core:spec/respond` lays out
|
|
274
|
+
at about 2400×1360, so this is not a hypothetical: style it or it will overrun the
|
|
275
|
+
column, exactly as a wide `.doc-table` does.
|
|
276
|
+
|
|
277
|
+
**There are no colours in it.** Every stroke and fill is `currentColor` or `none`, set as
|
|
278
|
+
presentation attributes so any CSS rule beats them, because the app and the standalone
|
|
279
|
+
site theme these pages differently. The classes are the styling surface, and they are all
|
|
280
|
+
of it: `.doc-graph`, `.doc-graph-node`, `.doc-graph-node-{kind}` (`kind` slugged —
|
|
281
|
+
`inlet`, `query`, `task`, `oracle`, `outlet`, …), `.doc-graph-sublabel`,
|
|
282
|
+
`.doc-graph-edge`, `.doc-graph-edge-label`. Labels over 28 characters are cut with an `…`
|
|
283
|
+
and the full text goes in a `<title>` inside the node.
|
|
284
|
+
|
|
285
|
+
## Licence
|
|
286
|
+
|
|
287
|
+
Apache-2.0.
|