@dogsbay/format-starlight 0.2.0-beta.114 → 0.2.0-beta.116
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/adapter.d.ts +69 -1
- package/dist/adapters/cloudflare.d.ts +183 -1
- package/dist/adapters/cloudflare.js +1948 -57
- package/dist/cli.js +506 -15
- package/dist/fences.d.ts +16 -0
- package/dist/fences.js +49 -0
- package/dist/github-slug.d.ts +19 -0
- package/dist/github-slug.js +112 -0
- package/dist/js-literal.d.ts +12 -0
- package/dist/js-literal.js +249 -0
- package/dist/jsx-to-jinja.d.ts +62 -0
- package/dist/jsx-to-jinja.js +869 -0
- package/dist/parse-mdx.d.ts +38 -1
- package/dist/parse-mdx.js +433 -27
- package/dist/parse.js +7 -2
- package/dist/template-tokens.d.ts +63 -0
- package/dist/template-tokens.js +206 -0
- package/package.json +5 -3
package/dist/adapter.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export interface ComponentMapping {
|
|
|
17
17
|
container: boolean;
|
|
18
18
|
/** Strip the component entirely. If container=true, inner content is kept. */
|
|
19
19
|
strip?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A stripped non-container loses whatever it rendered, so it is REPORTED
|
|
22
|
+
* (onDrop) like an unmapped component. `silent` marks the few whose removal
|
|
23
|
+
* loses nothing (a widget replaced by structure built elsewhere).
|
|
24
|
+
*/
|
|
25
|
+
silent?: boolean;
|
|
20
26
|
}
|
|
21
27
|
export interface SiteAdapter {
|
|
22
28
|
/** Adapter name (e.g. "cloudflare") */
|
|
@@ -38,9 +44,71 @@ export interface SiteAdapter {
|
|
|
38
44
|
*
|
|
39
45
|
* @param source - MDX source text
|
|
40
46
|
* @param partialsDir - Base directory for partial files (auto-detected or CLI flag)
|
|
47
|
+
* @param options - `mode: "template"` emits template-page directives
|
|
48
|
+
* (`{% with %}{% include %}`) instead of inlining; see IncludeOptions
|
|
41
49
|
* @returns Source with include tags replaced by partial content
|
|
42
50
|
*/
|
|
43
|
-
|
|
51
|
+
/** `frontmatter`: the page's own (raw) front matter, for components that read it (`<ProductReleaseNotes>`). */
|
|
52
|
+
resolveIncludes?: (source: string, partialsDir?: string, options?: IncludeOptions, frontmatter?: Record<string, unknown>) => string;
|
|
44
53
|
/** Frontmatter field name that carries the redirect/external link URL */
|
|
45
54
|
redirectField?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Rewrite the finished tree — for structure a component mapping cannot
|
|
57
|
+
* express alone (sibling components that together form one group).
|
|
58
|
+
*/
|
|
59
|
+
transformTree?: (tree: TreeNode[]) => TreeNode[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* How `resolveIncludes` treats partials.
|
|
63
|
+
*
|
|
64
|
+
* - `inline` (default): splice each partial's content into the page, with
|
|
65
|
+
* its parameters substituted. Works for every output format.
|
|
66
|
+
* - `template`: emit `{% with k=v %}{% include "/_partials/<product>/<file>.md" %}{% endwith %}`
|
|
67
|
+
* and let the caller convert each partial into a TEMPLATE partial
|
|
68
|
+
* (plans/page-templates.md). Only a Dogsbay-MD output can carry it.
|
|
69
|
+
*/
|
|
70
|
+
import type { DirectiveTable } from "./template-tokens.js";
|
|
71
|
+
import type { TreeNode } from "@dogsbay/types";
|
|
72
|
+
/** What `<APIRequest>` takes from an OpenAPI operation. */
|
|
73
|
+
export interface ApiOperation {
|
|
74
|
+
summary?: string;
|
|
75
|
+
/** Security scheme names (`api_token`, `api_key`, …). */
|
|
76
|
+
security?: string[];
|
|
77
|
+
/** `x-api-token-group`: the token permissions that grant it. */
|
|
78
|
+
tokenGroups?: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface IncludeOptions {
|
|
81
|
+
mode?: "inline" | "template";
|
|
82
|
+
/** Directory of the page being converted: relative `?raw` imports resolve against it. */
|
|
83
|
+
pageDir?: string;
|
|
84
|
+
/** Product for a `<Render>` with no `product=` (the page's own). */
|
|
85
|
+
defaultProduct?: string;
|
|
86
|
+
/** Called for every partial reference emitted as a directive, with the parameter names it passes. */
|
|
87
|
+
onTemplateInclude?: (ref: {
|
|
88
|
+
product: string;
|
|
89
|
+
file: string;
|
|
90
|
+
params: string[];
|
|
91
|
+
}) => void;
|
|
92
|
+
/** Where emitted directives are registered, so they survive the MDX parse (template-tokens.ts). */
|
|
93
|
+
directives?: DirectiveTable;
|
|
94
|
+
/** `props.x` names read by param values (a partial forwarding its own parameters), for its `params:`. */
|
|
95
|
+
names?: Set<string>;
|
|
96
|
+
/** Called for every partial inlined in template mode because its params are outside the convertible subset. */
|
|
97
|
+
onInlined?: (ref: {
|
|
98
|
+
product: string;
|
|
99
|
+
file: string;
|
|
100
|
+
reason: string;
|
|
101
|
+
}) => void;
|
|
102
|
+
/** Called for every Cloudflare `<APIRequest>`: converted to a curl block, or left (and reported) when its props cannot be read. */
|
|
103
|
+
onApiRequest?: (converted: boolean) => void;
|
|
104
|
+
/**
|
|
105
|
+
* The Cloudflare API's operations (`--api-schema`), by `METHOD /path`:
|
|
106
|
+
* what `<APIRequest>` reads from the OpenAPI schema upstream.
|
|
107
|
+
*/
|
|
108
|
+
apiSchema?: Map<string, ApiOperation>;
|
|
109
|
+
/** An `<APIRequest>` whose operation the schema does not have. */
|
|
110
|
+
onApiMissing?: (key: string) => void;
|
|
111
|
+
/** Called for every component converted to a DECLARED lesser form (`<GitHubCode>` → a link to the source). */
|
|
112
|
+
/** `how`: what the lesser form is, shown in the report. */
|
|
113
|
+
onDegraded?: (tag: string, how: string) => void;
|
|
46
114
|
}
|
|
@@ -6,5 +6,187 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Source: https://github.com/cloudflare/cloudflare-docs/tree/production/src/components
|
|
8
8
|
*/
|
|
9
|
-
import type { SiteAdapter } from "../adapter.js";
|
|
9
|
+
import type { ApiOperation, SiteAdapter } from "../adapter.js";
|
|
10
|
+
import type { TreeNode } from "@dogsbay/types";
|
|
11
|
+
/**
|
|
12
|
+
* Page-level string constants: `export const x = "…";` (or a backtick
|
|
13
|
+
* template with no `${}`), used as `{x}`, `<Code code={x} lang="…" />` or
|
|
14
|
+
* `<Markdown text={x} />`. ESM is never rendered, but nothing read it: the
|
|
15
|
+
* statement showed as text, `{owaspCrsVersion}` literally, and a JSON-mode
|
|
16
|
+
* page's three code samples were missing (5 pages). Other values are left
|
|
17
|
+
* alone.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolvePageConstants(source: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* A `<LinkButton>` inside RAW HTML (a `<DashButton>` in an `<ol><li>`, which
|
|
22
|
+
* becomes a LinkButton above) is not a component there, it is a leaked tag.
|
|
23
|
+
* In HTML the button is a link: `<a href>label</a>`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function linkButtonsInHtml(tree: TreeNode[]): TreeNode[];
|
|
26
|
+
/** `<Render …/>` tags outside code, as [start, end) offsets; mid-line tags included. */
|
|
27
|
+
export declare function findRenderTags(src: string): Array<[number, number]>;
|
|
28
|
+
/**
|
|
29
|
+
* The indent a directive may keep where the tag stood. In MDX, whitespace
|
|
30
|
+
* before a JSX element means nothing — Cloudflare writes
|
|
31
|
+
* ` <Render …/>` inside a <TabItem> after unindented prose. In
|
|
32
|
+
* Markdown four spaces after a blank line open an INDENTED CODE BLOCK, and
|
|
33
|
+
* the include came out as a literal code sample. So the indent is capped at
|
|
34
|
+
* the content column of the previous non-blank line: a list item's text
|
|
35
|
+
* column (the directive stays in the item), otherwise that line's indent.
|
|
36
|
+
*/
|
|
37
|
+
export declare function markdownIndent(source: string, offset: number, indent: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Cloudflare's plan components, from `src/content/plans/index.json` at
|
|
40
|
+
* import, outside fenced and inline code. An unknown id leaves the tag, which
|
|
41
|
+
* is reported (both are lossy strips in the component map).
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolvePlans(source: string, partialsDir?: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* `<Plan type="…" />` → its label, `<Plan id="a.b.c" />` → that string from
|
|
46
|
+
* `plans/index.json` — in bold, as the component's emphasised line (a
|
|
47
|
+
* `<div>`: alone on its line it ends its paragraph). The old transform
|
|
48
|
+
* printed the raw type (`**ent-add-on plan**`) and never read `id=` (7
|
|
49
|
+
* reported). An unresolved tag is left to the parser: alone on a line it is
|
|
50
|
+
* dropped and reported as an unknown component; mid-line the leak scan
|
|
51
|
+
* reports it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolvePlanBadges(source: string, partialsDir?: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* `<AvailableNotifications product notificationFilter />` → a `<Details>`
|
|
56
|
+
* per notification (grouped under `##` product headings when unfiltered), as
|
|
57
|
+
* AvailableNotifications.astro renders, from `notifications/index.yaml`. The
|
|
58
|
+
* Details go through the normal component mapping.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveNotifications(source: string, partialsDir?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* `<PagesBuildPreset framework />` → its configuration table, and
|
|
63
|
+
* `<PagesBuildPresetsTable />` → every preset, as the components render them,
|
|
64
|
+
* from `pages-framework-presets/index.yaml`. An unknown framework leaves the
|
|
65
|
+
* tag, which is reported.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolvePagesPresets(source: string, partialsDir?: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* `<GitHubCode repo commit file lines tag lang />` fetches a file from GitHub
|
|
70
|
+
* at build time and shows it (or its `lines`, or a tagged region). An import
|
|
71
|
+
* does not reach the network, so it becomes a LINK to exactly that file at
|
|
72
|
+
* that commit (and those lines), and is counted as degraded — the reader
|
|
73
|
+
* can still get the code; the page no longer shows it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveGitHubCode(source: string, onDegraded?: (tag: string, how: string) => void): string;
|
|
76
|
+
/**
|
|
77
|
+
* `<AutoconfigDiagram framework configs={[…]}>` draws DATA — the framework,
|
|
78
|
+
* the configuration Wrangler generates, Workers — so it becomes that sentence
|
|
79
|
+
* and a File / Setting / Value table (nothing lost, not reported). Other
|
|
80
|
+
* diagrams are illustrations: the CLI's `describeComponent` keeps the
|
|
81
|
+
* description their component declares, reported as degraded.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveDiagrams(source: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* `<TypeScriptExample omitTabs>` inside a `<Tabs>` contributes its tabs to
|
|
86
|
+
* THAT group (upstream: JavaScript, generated from the TypeScript, then
|
|
87
|
+
* TypeScript). Stripped like the plain form, it left a bare code block as a
|
|
88
|
+
* direct child of the tab group, which broke the group. It becomes a
|
|
89
|
+
* TypeScript tab; the JavaScript variant is not generated by the import.
|
|
90
|
+
*/
|
|
91
|
+
export declare function resolveOmitTabsTypeScript(source: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Three small components over LOCAL data, read at import:
|
|
94
|
+
* - `<RSSButton href|changelog text?>` → a link (it renders one).
|
|
95
|
+
* - `<WARPReleases track>` → the latest release open and the rest in a
|
|
96
|
+
* collapsed history, from `src/content/warp-releases/<track>/*.yaml`.
|
|
97
|
+
* Upstream keeps the releases of the year before NOW; an import keeps the
|
|
98
|
+
* year before the LATEST release, so the output does not depend on the day
|
|
99
|
+
* it runs. The Linux distribution picker becomes one link per distribution.
|
|
100
|
+
* - `<CompatibilityFlags experimental?>` → each flag (`src/content/
|
|
101
|
+
* compatibility-flags/*.md`) as a heading, its dates and flags, and its
|
|
102
|
+
* body, newest first.
|
|
103
|
+
* Anything unreadable leaves the tag, which is reported.
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveLocalDataComponents(source: string, partialsDir?: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* The value of `const NAME = [ … ]` / `{ … }` in a component or TS source,
|
|
108
|
+
* read with the no-eval literal reader. Brackets are matched OUTSIDE strings
|
|
109
|
+
* and comments (a `]` in a description must not end the array).
|
|
110
|
+
*/
|
|
111
|
+
export declare function readConstLiteral(src: string, name: string): unknown;
|
|
112
|
+
/**
|
|
113
|
+
* The agent-setup pages (8): `<AgentHeader slug>`, `<OtherAgents currentSlug>`,
|
|
114
|
+
* `<ExamplePromptsList />`, `<RandomPrompt />` and `<PlatformAccess />`, from
|
|
115
|
+
* `components/agent-setup/{agents,prompts,definitions}.ts` and the section's
|
|
116
|
+
* own markup, read — never run. Upstream picks prompts at RANDOM per build;
|
|
117
|
+
* an import picks deterministically (the first ones). The skills and MCP
|
|
118
|
+
* server lists inside `<PlatformAccess>` are fetched at build time upstream,
|
|
119
|
+
* so they become links to where those lists live (reported as degraded).
|
|
120
|
+
*/
|
|
121
|
+
export declare function resolveAgentSetup(source: string, partialsDir?: string, onDegraded?: (tag: string, how: string) => void): string;
|
|
122
|
+
/**
|
|
123
|
+
* `<BuildAgentsCallout />` → its intro sentence and its cards, read from the
|
|
124
|
+
* component's own source (`const cards = [ … ]`, by the no-eval literal
|
|
125
|
+
* reader; the sentence is its first `<p>`). A component that cannot be read
|
|
126
|
+
* leaves the tag, which is reported.
|
|
127
|
+
*/
|
|
128
|
+
export declare function resolveBuildAgentsCallout(source: string, partialsDir?: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* `<Image src={x} alt="…" />` → ``, where `x` is an image the
|
|
131
|
+
* source IMPORTS (`import x from "~/assets/…png"`). A relative import is
|
|
132
|
+
* resolved against `file` and, under an `assets/` folder, rewritten to the `~/assets`
|
|
133
|
+
* alias (which becomes `/_assets` later). Unresolvable ones are left.
|
|
134
|
+
*/
|
|
135
|
+
export declare function resolveImageImports(source: string, file?: string): string;
|
|
136
|
+
/**
|
|
137
|
+
* `<ProductChangelog product="x" hideEntry publish_future_dated_entry numberOfEntries />`
|
|
138
|
+
* (or `area="Group"`, via the product directory's `entry.group`) → the
|
|
139
|
+
* product's changelog entries, newest first: `## date`, **title**, and the
|
|
140
|
+
* entry's MDX body spliced in, so its components are resolved like the
|
|
141
|
+
* page's own (this runs first in resolveIncludes). As upstream: hidden entries
|
|
142
|
+
* and future-dated ones are left out, `hideEntry` names one to skip. Not
|
|
143
|
+
* carried: the RSS button, per-entry product pills, WARP release entries.
|
|
144
|
+
*/
|
|
145
|
+
export declare function resolveProductChangelog(source: string, partialsDir?: string): string;
|
|
146
|
+
/**
|
|
147
|
+
* `<ProductReleaseNotes />` → the page's release notes (its front matter
|
|
148
|
+
* `release_notes_file_name`, from `release-notes/<name>.yaml`), newest date
|
|
149
|
+
* first, as ProductReleaseNotes.astro renders. An entry with its own page
|
|
150
|
+
* links to it: upstream EMBEDS that page's body, which would duplicate a page
|
|
151
|
+
* the site already has. `api-deprecations` is its own file, as upstream.
|
|
152
|
+
*/
|
|
153
|
+
export declare function resolveReleaseNotes(source: string, partialsDir?: string, frontmatter?: Record<string, unknown>): string;
|
|
154
|
+
/**
|
|
155
|
+
* Cloudflare's glossary components, from the glossary data at import:
|
|
156
|
+
* - `<GlossaryDefinition term prepend>` → the definition itself;
|
|
157
|
+
* - `<Glossary product>` → a table of terms (a Product column when unfiltered);
|
|
158
|
+
* - `<GlossaryTooltip term link>text</…>` → the text, linked when `link` is a
|
|
159
|
+
* string. The tooltip itself cannot travel to a static page.
|
|
160
|
+
* An unknown term leaves the tag as written, so it is REPORTED as unmapped
|
|
161
|
+
* rather than silently becoming nothing. Code is left alone.
|
|
162
|
+
*/
|
|
163
|
+
export declare function resolveGlossary(source: string, partialsDir?: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* `<APIRequest path method parameters json form />` → the curl command
|
|
166
|
+
* Cloudflare's component renders (APIRequest.astro + CURL.astro), built
|
|
167
|
+
* from the tag's own props. The component also fetches the OpenAPI schema
|
|
168
|
+
* over the network at build time, for two things we therefore do not
|
|
169
|
+
* produce: the "Required API token permissions" panel, and the block title
|
|
170
|
+
* (the operation summary). An import does not reach the network.
|
|
171
|
+
*
|
|
172
|
+
* Without the schema, a parameter is a PATH parameter when the path names it
|
|
173
|
+
* (`{zone_id}`) and a query parameter otherwise; unfilled path parameters
|
|
174
|
+
* become `$ZONE_ID`, as upstream writes them; auth is the API token (what
|
|
175
|
+
* nearly every operation takes). A tag whose props cannot be READ (a
|
|
176
|
+
* variable, a spread) is left as written and reported, never guessed.
|
|
177
|
+
*
|
|
178
|
+
* With the schema (`--api-schema <openapi.json>`, a local copy — the import
|
|
179
|
+
* still does not fetch): the operation summary titles the block, the auth
|
|
180
|
+
* headers follow the operation's security (email + key where it takes no
|
|
181
|
+
* token), and `roles` adds the "Required API token permissions" panel,
|
|
182
|
+
* filtered by a `roles="…"` string as upstream filters it.
|
|
183
|
+
*/
|
|
184
|
+
export declare function resolveApiRequest(source: string, onApiRequest?: (converted: boolean) => void, schema?: Map<string, ApiOperation>, onMissing?: (key: string) => void): string;
|
|
185
|
+
/**
|
|
186
|
+
* Each run of consecutive `rtk-snippet` siblings → one `tabs` group, synced
|
|
187
|
+
* on `realtimekit-sdk`, one tab per SDK. A snippet for several SDKs appears
|
|
188
|
+
* in each of their tabs, so picking an SDK in any group shows its code in
|
|
189
|
+
* every group. Recursive: snippets also sit in list items and steps.
|
|
190
|
+
*/
|
|
191
|
+
export declare function groupRtkSnippets(nodes: TreeNode[]): TreeNode[];
|
|
10
192
|
export declare const cloudflareAdapter: SiteAdapter;
|