sourcey 3.6.0 → 3.6.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/README.md +5 -2
- package/dist/adapters/index.d.ts +3 -2
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +35 -3
- package/dist/adapters/types.d.ts +8 -2
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/cli.js +28 -34
- package/dist/client/search.js +181 -119
- package/dist/client/tabs.js +23 -0
- package/dist/components/layout/Head.d.ts.map +1 -1
- package/dist/components/layout/Head.js +7 -6
- package/dist/components/openapi/Introduction.d.ts.map +1 -1
- package/dist/components/openapi/Introduction.js +16 -1
- package/dist/components/openapi/Security.d.ts.map +1 -1
- package/dist/components/openapi/Security.js +18 -2
- package/dist/config.d.ts +70 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -7
- package/dist/core/api-rendering.d.ts +47 -0
- package/dist/core/api-rendering.d.ts.map +1 -0
- package/dist/core/api-rendering.js +76 -0
- package/dist/core/doxygen-loader.d.ts +1 -1
- package/dist/core/doxygen-loader.d.ts.map +1 -1
- package/dist/core/doxygen-loader.js +37 -19
- package/dist/core/godoc-loader.d.ts.map +1 -1
- package/dist/core/godoc-loader.js +17 -6
- package/dist/core/markdown-loader.d.ts.map +1 -1
- package/dist/core/markdown-loader.js +8 -5
- package/dist/core/mcp-normalizer.d.ts.map +1 -1
- package/dist/core/mcp-normalizer.js +48 -34
- package/dist/core/parser.d.ts.map +1 -1
- package/dist/core/parser.js +75 -4
- package/dist/core/rustdoc-introspector.d.ts +29 -0
- package/dist/core/rustdoc-introspector.d.ts.map +1 -0
- package/dist/core/rustdoc-introspector.js +236 -0
- package/dist/core/rustdoc-loader.d.ts +25 -0
- package/dist/core/rustdoc-loader.d.ts.map +1 -0
- package/dist/core/rustdoc-loader.js +472 -0
- package/dist/core/rustdoc-render.d.ts +82 -0
- package/dist/core/rustdoc-render.d.ts.map +1 -0
- package/dist/core/rustdoc-render.js +808 -0
- package/dist/core/rustdoc-types.d.ts +314 -0
- package/dist/core/rustdoc-types.d.ts.map +1 -0
- package/dist/core/rustdoc-types.js +18 -0
- package/dist/core/search-indexer.js +1 -1
- package/dist/core/sourcey-rustdoc/Cargo.lock +705 -0
- package/dist/core/sourcey-rustdoc/Cargo.toml +38 -0
- package/dist/core/sourcey-rustdoc/README.md +59 -0
- package/dist/core/sourcey-rustdoc/src/diagnostics.rs +42 -0
- package/dist/core/sourcey-rustdoc/src/doctest.rs +268 -0
- package/dist/core/sourcey-rustdoc/src/extract.rs +492 -0
- package/dist/core/sourcey-rustdoc/src/lib.rs +58 -0
- package/dist/core/sourcey-rustdoc/src/links.rs +126 -0
- package/dist/core/sourcey-rustdoc/src/main.rs +256 -0
- package/dist/core/sourcey-rustdoc/src/signature.rs +415 -0
- package/dist/core/sourcey-rustdoc/src/spec.rs +390 -0
- package/dist/core/sourcey-rustdoc/tests/format_version.rs +45 -0
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +50 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -13
- package/dist/init.js +2 -2
- package/dist/renderer/changelog-feed.d.ts.map +1 -1
- package/dist/renderer/changelog-feed.js +27 -19
- package/dist/renderer/context.d.ts +1 -0
- package/dist/renderer/context.d.ts.map +1 -1
- package/dist/renderer/html-builder.d.ts.map +1 -1
- package/dist/renderer/html-builder.js +4 -3
- package/dist/renderer/llms.js +57 -2
- package/dist/site-assembly.d.ts +5 -0
- package/dist/site-assembly.d.ts.map +1 -1
- package/dist/site-assembly.js +57 -2
- package/dist/themes/default/sourcey.css +300 -0
- package/dist/utils/code-samples.d.ts +1 -0
- package/dist/utils/code-samples.d.ts.map +1 -1
- package/dist/utils/code-samples.js +30 -22
- package/dist/utils/html.d.ts +10 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +152 -0
- package/dist/utils/http.d.ts +0 -2
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/http.js +19 -34
- package/dist/utils/markdown.d.ts.map +1 -1
- package/dist/utils/markdown.js +102 -37
- package/package.json +10 -5
package/dist/config.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ export interface ChangelogConfig {
|
|
|
36
36
|
}
|
|
37
37
|
export interface SourceyConfig {
|
|
38
38
|
name?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Separator inserted between the page title and the site name in `<title>`/OG
|
|
41
|
+
* metadata, and between fields in generated API search snippets.
|
|
42
|
+
* @default " - "
|
|
43
|
+
*/
|
|
44
|
+
titleSeparator?: string;
|
|
39
45
|
/** Public site origin for absolute feeds, OG metadata, and canonical URLs (e.g. "https://docs.example.com"). */
|
|
40
46
|
siteUrl?: string;
|
|
41
47
|
/** Public path prefix when the docs are served from a subpath (e.g. "/reference"). */
|
|
@@ -136,6 +142,63 @@ export interface GodocGoEnv {
|
|
|
136
142
|
GOARCH?: string;
|
|
137
143
|
tags?: string[];
|
|
138
144
|
}
|
|
145
|
+
export type RustdocMode = "auto" | "live" | "snapshot";
|
|
146
|
+
export interface RustdocFeatures {
|
|
147
|
+
/** Use the crate's default features. Defaults to `true`. */
|
|
148
|
+
default?: boolean;
|
|
149
|
+
/** Extra features to enable. */
|
|
150
|
+
list?: string[];
|
|
151
|
+
/** Enable every feature. Overrides `default` and `list`. */
|
|
152
|
+
all?: boolean;
|
|
153
|
+
}
|
|
154
|
+
export interface RustdocConfig {
|
|
155
|
+
/** Cargo manifest path. Either a Cargo.toml or a directory that contains one. */
|
|
156
|
+
manifest?: string;
|
|
157
|
+
/** Crates to document. Defaults to the manifest's own package. */
|
|
158
|
+
crates?: string[];
|
|
159
|
+
/** Optional path to a committed v1 RustdocSpec snapshot (rustdoc.json). */
|
|
160
|
+
snapshot?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Source mode.
|
|
163
|
+
* - "live": invoke the bundled Rust helper at build time (requires nightly).
|
|
164
|
+
* - "snapshot": read the committed snapshot file; no Rust toolchain required.
|
|
165
|
+
* - "auto" (default): prefer live when nightly is available; fall back to snapshot.
|
|
166
|
+
*/
|
|
167
|
+
mode?: RustdocMode;
|
|
168
|
+
/** Feature selection. Defaults to `{ default: true }`. */
|
|
169
|
+
features?: RustdocFeatures;
|
|
170
|
+
/** Include `pub(crate)` and private items (default: false). */
|
|
171
|
+
includePrivate?: boolean;
|
|
172
|
+
/** Include items marked `#[doc(hidden)]` (default: false). */
|
|
173
|
+
includeHidden?: boolean;
|
|
174
|
+
/** Target triple to build docs for. */
|
|
175
|
+
target?: string;
|
|
176
|
+
/** rustup toolchain name. Defaults to `nightly`. */
|
|
177
|
+
toolchain?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Repository-relative base path for source links. Leave empty when the
|
|
180
|
+
* configured manifest is at the repository root.
|
|
181
|
+
*/
|
|
182
|
+
sourceBasePath?: string;
|
|
183
|
+
/** Render a dedicated doctests index page. Defaults to `true`. */
|
|
184
|
+
doctestsIndex?: boolean;
|
|
185
|
+
}
|
|
186
|
+
export interface ResolvedRustdocConfig {
|
|
187
|
+
/** Absolute path to the Cargo manifest file. */
|
|
188
|
+
manifest: string;
|
|
189
|
+
/** Crates to document. Always at least one entry. */
|
|
190
|
+
crates: string[];
|
|
191
|
+
/** Absolute path to a snapshot file when configured. */
|
|
192
|
+
snapshot?: string;
|
|
193
|
+
mode: RustdocMode;
|
|
194
|
+
features: Required<RustdocFeatures>;
|
|
195
|
+
includePrivate: boolean;
|
|
196
|
+
includeHidden: boolean;
|
|
197
|
+
target?: string;
|
|
198
|
+
toolchain: string;
|
|
199
|
+
sourceBasePath: string;
|
|
200
|
+
doctestsIndex: boolean;
|
|
201
|
+
}
|
|
139
202
|
export interface GodocConfig {
|
|
140
203
|
/** Module root (directory containing go.mod). Defaults to the directory containing sourcey.config.ts. */
|
|
141
204
|
module?: string;
|
|
@@ -187,6 +250,11 @@ export interface TabConfig {
|
|
|
187
250
|
* `{ module: <value>, packages: ["./..."], mode: "auto", includeTests: true }`.
|
|
188
251
|
*/
|
|
189
252
|
godoc?: GodocConfig | string;
|
|
253
|
+
/**
|
|
254
|
+
* Native Rust API documentation. String shorthand expands to
|
|
255
|
+
* `{ manifest: <value>, mode: "auto", doctestsIndex: true }`.
|
|
256
|
+
*/
|
|
257
|
+
rustdoc?: RustdocConfig | string;
|
|
190
258
|
}
|
|
191
259
|
export interface GroupConfig {
|
|
192
260
|
group: string;
|
|
@@ -229,6 +297,7 @@ export interface ResolvedChangelogConfig {
|
|
|
229
297
|
}
|
|
230
298
|
export interface ResolvedConfig {
|
|
231
299
|
name: string;
|
|
300
|
+
titleSeparator: string;
|
|
232
301
|
siteUrl?: string;
|
|
233
302
|
baseUrl: string;
|
|
234
303
|
prettyUrls: PrettyUrls;
|
|
@@ -293,6 +362,7 @@ export interface ResolvedTab {
|
|
|
293
362
|
doxygen?: ResolvedDoxygenConfig;
|
|
294
363
|
mcp?: string;
|
|
295
364
|
godoc?: ResolvedGodocConfig;
|
|
365
|
+
rustdoc?: ResolvedRustdocConfig;
|
|
296
366
|
}
|
|
297
367
|
export interface ResolvedPage {
|
|
298
368
|
/** Original config slug (e.g. "run/index") */
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAUhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG5E,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAMhD,MAAM,MAAM,WAA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ACb,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAwBD,wBAAsB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAgC9E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAiC/D;AAMD,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CAuCzB;AAwJD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK5C;AAED,wEAAwE;AACxE,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI7D;AAED,4DAA4D;AAC5D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CAIlF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CAQ5F;AAQD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO5C"}
|
package/dist/config.js
CHANGED
|
@@ -2,7 +2,8 @@ import { access } from "node:fs/promises";
|
|
|
2
2
|
import { resolve, dirname } from "node:path";
|
|
3
3
|
import { createJiti } from "jiti";
|
|
4
4
|
import { normalizeBaseUrl, normalizeSiteUrl } from "./site-url.js";
|
|
5
|
-
import { doxygen as doxygenSource, godoc as godocSource, markdown as markdownSource, mcp as mcpSource, mkdocs as mkdocsSource, openapi as openapiSource, } from "./adapters/index.js";
|
|
5
|
+
import { doxygen as doxygenSource, godoc as godocSource, markdown as markdownSource, mcp as mcpSource, mkdocs as mkdocsSource, openapi as openapiSource, rustdoc as rustdocSource, } from "./adapters/index.js";
|
|
6
|
+
import { DEFAULT_CODE_SAMPLE_LANGS, SUPPORTED_CODE_SAMPLE_LANGS } from "./utils/code-samples.js";
|
|
6
7
|
export function defineConfig(config) {
|
|
7
8
|
return config;
|
|
8
9
|
}
|
|
@@ -55,6 +56,7 @@ export function configFromSpec(specPath) {
|
|
|
55
56
|
const absSpec = resolve(specPath);
|
|
56
57
|
return {
|
|
57
58
|
name: "API Reference",
|
|
59
|
+
titleSeparator: " - ",
|
|
58
60
|
siteUrl: undefined,
|
|
59
61
|
baseUrl: "",
|
|
60
62
|
prettyUrls: false,
|
|
@@ -94,6 +96,7 @@ export async function resolveConfigFromRaw(raw, configDir) {
|
|
|
94
96
|
const changelog = resolveChangelog(raw.changelog);
|
|
95
97
|
return {
|
|
96
98
|
name: raw.name ?? "",
|
|
99
|
+
titleSeparator: raw.titleSeparator ?? " - ",
|
|
97
100
|
siteUrl: normalizeSiteUrl(raw.siteUrl),
|
|
98
101
|
baseUrl: normalizeBaseUrl(raw.baseUrl),
|
|
99
102
|
prettyUrls: resolvePrettyUrls(raw.prettyUrls),
|
|
@@ -108,7 +111,7 @@ export async function resolveConfigFromRaw(raw, configDir) {
|
|
|
108
111
|
repo: raw.repo,
|
|
109
112
|
editBranch: raw.editBranch,
|
|
110
113
|
editBasePath: raw.editBasePath,
|
|
111
|
-
codeSamples: raw.codeSamples
|
|
114
|
+
codeSamples: resolveCodeSamples(raw.codeSamples),
|
|
112
115
|
tabs,
|
|
113
116
|
navbar: {
|
|
114
117
|
links: raw.navbar?.links ?? [],
|
|
@@ -188,16 +191,17 @@ async function resolveTabs(tabs, configDir) {
|
|
|
188
191
|
tab.source,
|
|
189
192
|
tab.openapi,
|
|
190
193
|
tab.mkdocs,
|
|
191
|
-
tab.groups,
|
|
194
|
+
tab.groups?.length ? tab.groups : undefined,
|
|
192
195
|
tab.doxygen,
|
|
193
196
|
tab.mcp,
|
|
194
197
|
tab.godoc,
|
|
198
|
+
tab.rustdoc,
|
|
195
199
|
].filter(Boolean).length;
|
|
196
200
|
if (sources > 1) {
|
|
197
|
-
throw new Error(`Tab "${tab.tab}" has multiple sources; use only one of "source", "openapi", "mkdocs", "groups", "doxygen", "mcp", or "
|
|
201
|
+
throw new Error(`Tab "${tab.tab}" has multiple sources; use only one of "source", "openapi", "mkdocs", "groups", "doxygen", "mcp", "godoc", or "rustdoc"`);
|
|
198
202
|
}
|
|
199
203
|
if (sources === 0) {
|
|
200
|
-
throw new Error(`Tab "${tab.tab}" needs one of "source", "openapi", "mkdocs", "groups", "doxygen", "mcp", or "
|
|
204
|
+
throw new Error(`Tab "${tab.tab}" needs one of "source", "openapi", "mkdocs", "groups", "doxygen", "mcp", "godoc", or "rustdoc"`);
|
|
201
205
|
}
|
|
202
206
|
const adapter = tab.source ?? legacySourceAdapter(tab);
|
|
203
207
|
const source = await adapter.resolve({
|
|
@@ -223,6 +227,8 @@ function legacySourceAdapter(tab) {
|
|
|
223
227
|
return doxygenSource(tab.doxygen);
|
|
224
228
|
if (tab.godoc)
|
|
225
229
|
return godocSource(tab.godoc);
|
|
230
|
+
if (tab.rustdoc)
|
|
231
|
+
return rustdocSource(tab.rustdoc);
|
|
226
232
|
return markdownSource({ groups: tab.groups });
|
|
227
233
|
}
|
|
228
234
|
function resolvedTabFromSource(label, slug, source) {
|
|
@@ -242,6 +248,8 @@ function resolvedTabFromSource(label, slug, source) {
|
|
|
242
248
|
return { ...base, doxygen: source.config };
|
|
243
249
|
case "godoc":
|
|
244
250
|
return { ...base, godoc: source.config };
|
|
251
|
+
case "rustdoc":
|
|
252
|
+
return { ...base, rustdoc: source.config };
|
|
245
253
|
}
|
|
246
254
|
}
|
|
247
255
|
// ---------------------------------------------------------------------------
|
|
@@ -291,14 +299,22 @@ function resolvePrettyUrls(value) {
|
|
|
291
299
|
throw new Error(`Invalid prettyUrls "${String(value)}". Expected false, "slash", or "strip".`);
|
|
292
300
|
}
|
|
293
301
|
export function hexToRgb(hex) {
|
|
294
|
-
const h = hex.replace(
|
|
295
|
-
if (h
|
|
302
|
+
const h = hex.replace(/^#/, "");
|
|
303
|
+
if (!/^[0-9a-fA-F]{6}$/.test(h))
|
|
296
304
|
throw new Error(`Invalid hex color: "${hex}"`);
|
|
297
305
|
const r = parseInt(h.slice(0, 2), 16);
|
|
298
306
|
const g = parseInt(h.slice(2, 4), 16);
|
|
299
307
|
const b = parseInt(h.slice(4, 6), 16);
|
|
300
308
|
return `${r} ${g} ${b}`;
|
|
301
309
|
}
|
|
310
|
+
function resolveCodeSamples(value) {
|
|
311
|
+
const langs = value ?? DEFAULT_CODE_SAMPLE_LANGS;
|
|
312
|
+
const unsupported = langs.filter((lang) => !SUPPORTED_CODE_SAMPLE_LANGS.includes(lang));
|
|
313
|
+
if (unsupported.length) {
|
|
314
|
+
throw new Error(`Invalid codeSamples value "${unsupported[0]}". Must be one of: ${SUPPORTED_CODE_SAMPLE_LANGS.join(", ")}`);
|
|
315
|
+
}
|
|
316
|
+
return [...langs];
|
|
317
|
+
}
|
|
302
318
|
async function assertExists(filePath, label) {
|
|
303
319
|
try {
|
|
304
320
|
await access(filePath);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared API-documentation rendering primitives.
|
|
3
|
+
*
|
|
4
|
+
* Introduced by the rustdoc adapter and designed to be reusable by the godoc
|
|
5
|
+
* and doxygen adapters in a follow-on retrofit. Class names mirror rustdoc's
|
|
6
|
+
* DOM so deep-links from a rustdoc URL line up with sourcey output.
|
|
7
|
+
*/
|
|
8
|
+
export interface ApiStabilityCalloutInput {
|
|
9
|
+
kind: "unstable" | "deprecated" | "portability" | "non_exhaustive" | "must_use";
|
|
10
|
+
since?: string | null;
|
|
11
|
+
reason?: string | null;
|
|
12
|
+
featureName?: string | null;
|
|
13
|
+
issueId?: number | null;
|
|
14
|
+
/** Tracking-issue URL prefix; defaults to rust-lang issues. */
|
|
15
|
+
issueBaseUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function apiStabilityCallout(input: ApiStabilityCalloutInput): string;
|
|
18
|
+
export interface ApiItemInfoRowInput {
|
|
19
|
+
since?: string | null;
|
|
20
|
+
sourceHref?: string | null;
|
|
21
|
+
sourceLabel?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function apiItemInfoRow(input: ApiItemInfoRowInput): string;
|
|
24
|
+
export interface ApiSymbolLinkInput {
|
|
25
|
+
kind: string;
|
|
26
|
+
href: string;
|
|
27
|
+
text: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function apiSymbolLink(input: ApiSymbolLinkInput): string;
|
|
31
|
+
export interface ApiToggleInput {
|
|
32
|
+
open?: boolean;
|
|
33
|
+
summary: string;
|
|
34
|
+
body: string;
|
|
35
|
+
cssClass: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function apiImplToggle(input: Omit<ApiToggleInput, "cssClass">): string;
|
|
38
|
+
export interface ApiSectionAnchorInput {
|
|
39
|
+
level: 2 | 3 | 4 | 5;
|
|
40
|
+
id: string;
|
|
41
|
+
text: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function apiSectionAnchor(input: ApiSectionAnchorInput): string;
|
|
45
|
+
export declare function escapeHtml(value: string): string;
|
|
46
|
+
export declare function escapeAttr(value: string): string;
|
|
47
|
+
//# sourceMappingURL=api-rendering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-rendering.d.ts","sourceRoot":"","sources":["../../src/core/api-rendering.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,UAAU,GA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CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAQrE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared API-documentation rendering primitives.
|
|
3
|
+
*
|
|
4
|
+
* Introduced by the rustdoc adapter and designed to be reusable by the godoc
|
|
5
|
+
* and doxygen adapters in a follow-on retrofit. Class names mirror rustdoc's
|
|
6
|
+
* DOM so deep-links from a rustdoc URL line up with sourcey output.
|
|
7
|
+
*/
|
|
8
|
+
import { escapeAttr as sharedEscapeAttr, escapeHtml as sharedEscapeHtml } from "../utils/html.js";
|
|
9
|
+
export function apiStabilityCallout(input) {
|
|
10
|
+
switch (input.kind) {
|
|
11
|
+
case "unstable": {
|
|
12
|
+
const issue = input.issueId
|
|
13
|
+
? ` (<a href="${escapeAttr((input.issueBaseUrl ?? "https://github.com/rust-lang/rust/issues/") +
|
|
14
|
+
String(input.issueId))}">#${input.issueId}</a>)`
|
|
15
|
+
: "";
|
|
16
|
+
const feature = input.featureName ? ` <code>${escapeHtml(input.featureName)}</code>` : "";
|
|
17
|
+
return `<div class="stab unstable api-stab api-stab-unstable">🔬 This is a nightly-only experimental API.${feature}${issue}</div>`;
|
|
18
|
+
}
|
|
19
|
+
case "deprecated": {
|
|
20
|
+
const since = input.since ? ` since ${escapeHtml(input.since)}` : "";
|
|
21
|
+
const reason = input.reason ? `: ${escapeHtml(input.reason)}` : "";
|
|
22
|
+
return `<div class="stab deprecated api-stab api-stab-deprecated">👎 Deprecated${since}${reason}</div>`;
|
|
23
|
+
}
|
|
24
|
+
case "portability": {
|
|
25
|
+
const feature = input.featureName
|
|
26
|
+
? ` crate feature <code>${escapeHtml(input.featureName)}</code>`
|
|
27
|
+
: "";
|
|
28
|
+
return `<div class="stab portability api-stab api-stab-portability">Available on${feature} only.</div>`;
|
|
29
|
+
}
|
|
30
|
+
case "non_exhaustive":
|
|
31
|
+
return `<div class="stab api-stab api-stab-non-exhaustive">This is marked <code>#[non_exhaustive]</code>; new variants or fields may be added in future versions.</div>`;
|
|
32
|
+
case "must_use": {
|
|
33
|
+
const reason = input.reason ? `: ${escapeHtml(input.reason)}` : "";
|
|
34
|
+
return `<div class="stab api-stab api-stab-must-use"><code>#[must_use]</code>${reason}</div>`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function apiItemInfoRow(input) {
|
|
39
|
+
const parts = [];
|
|
40
|
+
if (input.since) {
|
|
41
|
+
parts.push(`<span class="since api-since">${escapeHtml(input.since)}</span>`);
|
|
42
|
+
}
|
|
43
|
+
if (input.sourceHref) {
|
|
44
|
+
parts.push(`<a class="srclink api-srclink" href="${escapeAttr(input.sourceHref)}">${escapeHtml(input.sourceLabel ?? "Source")}</a>`);
|
|
45
|
+
}
|
|
46
|
+
if (parts.length === 0)
|
|
47
|
+
return "";
|
|
48
|
+
return `<div class="rightside api-rightside">${parts.join(" · ")}</div>`;
|
|
49
|
+
}
|
|
50
|
+
export function apiSymbolLink(input) {
|
|
51
|
+
const title = input.title ? ` title="${escapeAttr(input.title)}"` : "";
|
|
52
|
+
return `<a class="${escapeAttr(input.kind)} api-symbol-link"${title} href="${escapeAttr(input.href)}">${escapeHtml(input.text)}</a>`;
|
|
53
|
+
}
|
|
54
|
+
export function apiImplToggle(input) {
|
|
55
|
+
return apiToggle({
|
|
56
|
+
...input,
|
|
57
|
+
cssClass: "api-toggle api-impl-toggle",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function apiToggle(input) {
|
|
61
|
+
const openAttr = input.open === false ? "" : " open";
|
|
62
|
+
return `<details class="${escapeAttr(input.cssClass)}"${openAttr}><summary class="api-toggle-summary">${input.summary}</summary><div class="api-toggle-body">${input.body}</div></details>`;
|
|
63
|
+
}
|
|
64
|
+
export function apiSectionAnchor(input) {
|
|
65
|
+
const cls = input.className ? ` ${input.className}` : "";
|
|
66
|
+
return (`<h${input.level} id="${escapeAttr(input.id)}" class="section-header api-section-header${cls}">` +
|
|
67
|
+
`${escapeHtml(input.text)}` +
|
|
68
|
+
` <a class="anchor api-anchor" href="#${escapeAttr(input.id)}">§</a>` +
|
|
69
|
+
`</h${input.level}>`);
|
|
70
|
+
}
|
|
71
|
+
export function escapeHtml(value) {
|
|
72
|
+
return sharedEscapeHtml(value);
|
|
73
|
+
}
|
|
74
|
+
export function escapeAttr(value) {
|
|
75
|
+
return sharedEscapeAttr(value);
|
|
76
|
+
}
|
|
@@ -10,5 +10,5 @@ export declare function rewriteGeneratedDoxygenIncludePath(includePath: string):
|
|
|
10
10
|
export declare function rewriteGeneratedDoxygenMarkdown(markdown: string): string;
|
|
11
11
|
export declare function rewriteGeneratedDoxygenHref(href: string): string;
|
|
12
12
|
export declare function rewriteGeneratedDoxygenHtmlLinks(html: string): string;
|
|
13
|
-
export declare function loadDoxygenTab(config: ResolvedDoxygenConfig, tabSlug: string, tabLabel: string): Promise<DoxygenResult>;
|
|
13
|
+
export declare function loadDoxygenTab(config: ResolvedDoxygenConfig, tabSlug: string, tabLabel: string, titleSeparator: string): Promise<DoxygenResult>;
|
|
14
14
|
//# sourceMappingURL=doxygen-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doxygen-loader.d.ts","sourceRoot":"","sources":["../../src/core/doxygen-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,qBAAqB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"doxygen-loader.d.ts","sourceRoot":"","sources":["../../src/core/doxygen-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAO7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAA6B,MAAM,iBAAiB,CAAC;AAM1E,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMzF;AAED,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAoB9E;AAED,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOxE;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOhE;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBrE;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,aAAa,CAAC,CA6GxB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generate } from "moxygen";
|
|
2
|
-
import { renderMarkdown, extractHeadings, extractFirstParagraph, stripMarkdownLinks } from "../utils/markdown.js";
|
|
2
|
+
import { renderMarkdown, extractHeadings, extractFirstParagraph, stripMarkdownLinks, } from "../utils/markdown.js";
|
|
3
3
|
export function normalizeDoxygenDescription(description, markdown) {
|
|
4
4
|
if (!description)
|
|
5
5
|
return "";
|
|
@@ -35,9 +35,7 @@ export function rewriteGeneratedDoxygenHref(href) {
|
|
|
35
35
|
const [path, hash] = href.split("#", 2);
|
|
36
36
|
if (!path.startsWith("api_") || !path.endsWith(".md"))
|
|
37
37
|
return href;
|
|
38
|
-
const slug = path
|
|
39
|
-
.slice("api_".length, -".md".length)
|
|
40
|
-
.replace(/--/g, "-");
|
|
38
|
+
const slug = path.slice("api_".length, -".md".length).replace(/--/g, "-");
|
|
41
39
|
return `${slug}.html${hash ? `#${hash}` : ""}`;
|
|
42
40
|
}
|
|
43
41
|
export function rewriteGeneratedDoxygenHtmlLinks(html) {
|
|
@@ -55,13 +53,21 @@ export function rewriteGeneratedDoxygenHtmlLinks(html) {
|
|
|
55
53
|
return `<code>${label}</code>`;
|
|
56
54
|
});
|
|
57
55
|
}
|
|
58
|
-
export async function loadDoxygenTab(config, tabSlug, tabLabel) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
export async function loadDoxygenTab(config, tabSlug, tabLabel, titleSeparator) {
|
|
57
|
+
let generated;
|
|
58
|
+
try {
|
|
59
|
+
generated = await generate({
|
|
60
|
+
directory: config.xml,
|
|
61
|
+
language: config.language,
|
|
62
|
+
sourceUrl: config.sourceUrl,
|
|
63
|
+
titleSeparator,
|
|
64
|
+
quiet: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
+
throw new Error(`Failed to load Doxygen XML from ${config.xml}: ${message}`);
|
|
70
|
+
}
|
|
65
71
|
const pages = new Map();
|
|
66
72
|
const groupMap = new Map();
|
|
67
73
|
for (const page of generated) {
|
|
@@ -200,7 +206,9 @@ function buildRichIndex(groupMap, pages) {
|
|
|
200
206
|
cards.push(`<a href="${href}" class="card-item">` +
|
|
201
207
|
`<div class="card-item-inner">` +
|
|
202
208
|
`<h3 class="card-item-title">${escHtml(page.title)}</h3>` +
|
|
203
|
-
(desc
|
|
209
|
+
(desc
|
|
210
|
+
? `<div class="card-item-content"><p>${escHtml(desc)}</p>${meta}</div>`
|
|
211
|
+
: `<div class="card-item-content">${meta}</div>`) +
|
|
204
212
|
`</div></a>`);
|
|
205
213
|
}
|
|
206
214
|
// Also include groups without a group page (orphan namespaces)
|
|
@@ -280,15 +288,25 @@ function lastSegment(name) {
|
|
|
280
288
|
return parts[parts.length - 1] || name;
|
|
281
289
|
}
|
|
282
290
|
function escHtml(s) {
|
|
283
|
-
return s
|
|
291
|
+
return s
|
|
292
|
+
.replace(/&/g, "&")
|
|
293
|
+
.replace(/</g, "<")
|
|
294
|
+
.replace(/>/g, ">")
|
|
295
|
+
.replace(/"/g, """);
|
|
284
296
|
}
|
|
285
297
|
function kindLabel(kind) {
|
|
286
298
|
switch (kind) {
|
|
287
|
-
case "class":
|
|
288
|
-
|
|
289
|
-
case "
|
|
290
|
-
|
|
291
|
-
case "
|
|
292
|
-
|
|
299
|
+
case "class":
|
|
300
|
+
return "Classes";
|
|
301
|
+
case "struct":
|
|
302
|
+
return "Structs";
|
|
303
|
+
case "enum":
|
|
304
|
+
return "Enums";
|
|
305
|
+
case "union":
|
|
306
|
+
return "Unions";
|
|
307
|
+
case "typedef":
|
|
308
|
+
return "Type Aliases";
|
|
309
|
+
default:
|
|
310
|
+
return kind.charAt(0).toUpperCase() + kind.slice(1) + "s";
|
|
293
311
|
}
|
|
294
312
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"godoc-loader.d.ts","sourceRoot":"","sources":["../../src/core/godoc-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"godoc-loader.d.ts","sourceRoot":"","sources":["../../src/core/godoc-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAaxD,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAA6B,MAAM,iBAAiB,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,qBAAqB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,sBAA2B,GACvC,OAAO,CAAC,iBAAiB,CAAC,CAG5B"}
|
|
@@ -2,7 +2,7 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import { GODOC_SCHEMA_VERSION } from "./godoc-types.js";
|
|
4
4
|
import { runIntrospector, GodocIntrospectorError } from "./godoc-introspector.js";
|
|
5
|
-
import { renderCodeBlock, renderMarkdown
|
|
5
|
+
import { renderCodeBlock, renderMarkdown } from "../utils/markdown.js";
|
|
6
6
|
/**
|
|
7
7
|
* Resolve a configured godoc tab into pre-rendered Sourcey pages plus a
|
|
8
8
|
* navigation tab. Honours `mode: "live" | "snapshot" | "auto"`:
|
|
@@ -32,7 +32,18 @@ async function loadSpec(config) {
|
|
|
32
32
|
return runIntrospector({ config });
|
|
33
33
|
}
|
|
34
34
|
if (config.snapshot) {
|
|
35
|
-
|
|
35
|
+
const spec = await loadSnapshot(config.snapshot, config.module);
|
|
36
|
+
return {
|
|
37
|
+
...spec,
|
|
38
|
+
diagnostics: [
|
|
39
|
+
{
|
|
40
|
+
severity: "info",
|
|
41
|
+
code: "GODOC_AUTO_FELL_BACK_TO_SNAPSHOT",
|
|
42
|
+
message: "godoc auto mode did not find Go on PATH and used the configured snapshot.",
|
|
43
|
+
},
|
|
44
|
+
...spec.diagnostics,
|
|
45
|
+
],
|
|
46
|
+
};
|
|
36
47
|
}
|
|
37
48
|
throw new GodocIntrospectorError("GO_NOT_FOUND", "godoc mode is 'auto' and Go is not on PATH. Install Go or set " +
|
|
38
49
|
"mode: 'snapshot' with a committed godoc.json.");
|
|
@@ -455,7 +466,9 @@ function sourceURL(position, sourceLinks) {
|
|
|
455
466
|
if (!position || !sourceLinks.repo || !sourceLinks.editBranch)
|
|
456
467
|
return undefined;
|
|
457
468
|
const repoBase = sourceLinks.repo.replace(/\/$/, "");
|
|
458
|
-
const basePath = sourceLinks.editBasePath
|
|
469
|
+
const basePath = sourceLinks.editBasePath
|
|
470
|
+
? `${sourceLinks.editBasePath.replace(/^\/|\/$/g, "")}/`
|
|
471
|
+
: "";
|
|
459
472
|
return `${repoBase}/blob/${sourceLinks.editBranch}/${basePath}${position.file}#L${position.line}`;
|
|
460
473
|
}
|
|
461
474
|
function renderExample(ex) {
|
|
@@ -472,9 +485,7 @@ function renderExample(ex) {
|
|
|
472
485
|
return parts.join("\n");
|
|
473
486
|
}
|
|
474
487
|
function humaniseSuffix(suffix) {
|
|
475
|
-
return suffix
|
|
476
|
-
.replace(/_/g, " ")
|
|
477
|
-
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
488
|
+
return suffix.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
478
489
|
}
|
|
479
490
|
function renderDoc(input) {
|
|
480
491
|
return renderMarkdown(input).trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-loader.d.ts","sourceRoot":"","sources":["../../src/core/markdown-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-loader.d.ts","sourceRoot":"","sources":["../../src/core/markdown-loader.ts"],"names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AM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUxD,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,KAAK,MAAM,CAAC;AAonChG;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAK5F;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,QAAQ,CAAC,CAgCnB;AA+DD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOrD"}
|
|
@@ -3,6 +3,7 @@ import { basename, extname, relative } from "node:path";
|
|
|
3
3
|
import { load as parseYaml } from "js-yaml";
|
|
4
4
|
import { normalizeChangelog } from "./changelog-normalizer.js";
|
|
5
5
|
import { htmlId } from "../utils/html-id.js";
|
|
6
|
+
import { escapeAttr, safeUrl } from "../utils/html.js";
|
|
6
7
|
import { renderIcon } from "../utils/icons.js";
|
|
7
8
|
import { renderCodeBlock, renderMarkdown, renderMarkdownInline, extractHeadings, extractFirstParagraph, stripMarkdownLinks, } from "../utils/markdown.js";
|
|
8
9
|
// ---------------------------------------------------------------------------
|
|
@@ -453,8 +454,9 @@ ${body}
|
|
|
453
454
|
const cols = node.attrs.cols || "2";
|
|
454
455
|
const cardHtml = cards
|
|
455
456
|
.map((card) => {
|
|
456
|
-
const
|
|
457
|
-
const
|
|
457
|
+
const safeHref = card.attrs.href ? safeUrl(card.attrs.href) : null;
|
|
458
|
+
const tag = safeHref ? "a" : "div";
|
|
459
|
+
const href = safeHref ? ` href="${escapeHtmlAttr(safeHref)}"` : "";
|
|
458
460
|
const iconHtml = renderIcon(card.attrs.icon || "");
|
|
459
461
|
const title = renderMarkdownInline(card.attrs.title || "").trim();
|
|
460
462
|
const body = renderComponentChildrenToHtml(card.children);
|
|
@@ -565,7 +567,7 @@ function escapeRegExp(value) {
|
|
|
565
567
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
566
568
|
}
|
|
567
569
|
function escapeHtmlAttr(value) {
|
|
568
|
-
return value
|
|
570
|
+
return escapeAttr(value);
|
|
569
571
|
}
|
|
570
572
|
function stripDirectiveIndent(line) {
|
|
571
573
|
return line.replace(/^ {0,3}/, "");
|
|
@@ -824,8 +826,9 @@ ${body}
|
|
|
824
826
|
if (type === "card-group") {
|
|
825
827
|
const cols = parseAttrs(meta.match(/^\{([^}]*)\}$/)?.[1] ?? "").cols || "2";
|
|
826
828
|
const cards = splitChildren(content, "card").map((child) => {
|
|
827
|
-
const
|
|
828
|
-
const
|
|
829
|
+
const safeHref = child.attrs.href ? safeUrl(child.attrs.href) : null;
|
|
830
|
+
const tag = safeHref ? "a" : "div";
|
|
831
|
+
const href = safeHref ? ` href="${escapeHtmlAttr(safeHref)}"` : "";
|
|
829
832
|
const iconHtml = renderIcon(child.attrs.icon || "");
|
|
830
833
|
const title = renderMarkdownInline(child.attrs.title || "").trim();
|
|
831
834
|
const body = renderDirectiveMarkdown(child.body);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-normalizer.d.ts","sourceRoot":"","sources":["../../src/core/mcp-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mcp-normalizer.d.ts","sourceRoot":"","sources":["../../src/core/mcp-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,cAAc,EASf,MAAM,YAAY,CAAC;AAKpB,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CAwD9D"}
|