sourcey 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -210
- package/dist/cli.js +18 -57
- package/dist/cli.js.map +1 -1
- package/dist/client/scroll-tracker.js +125 -40
- package/dist/client/search.js +27 -3
- package/dist/client/tabs.js +164 -24
- package/dist/components/App.d.ts +3 -2
- package/dist/components/App.d.ts.map +1 -1
- package/dist/components/App.js +3 -3
- package/dist/components/App.js.map +1 -1
- package/dist/components/layout/Head.d.ts.map +1 -1
- package/dist/components/layout/Head.js +30 -9
- package/dist/components/layout/Head.js.map +1 -1
- package/dist/components/layout/Header.d.ts +2 -7
- package/dist/components/layout/Header.d.ts.map +1 -1
- package/dist/components/layout/Header.js +12 -15
- package/dist/components/layout/Header.js.map +1 -1
- package/dist/components/layout/Page.d.ts.map +1 -1
- package/dist/components/layout/Page.js +54 -10
- package/dist/components/layout/Page.js.map +1 -1
- package/dist/components/layout/Sidebar.js +1 -1
- package/dist/components/layout/Sidebar.js.map +1 -1
- package/dist/components/layout/TableOfContents.d.ts.map +1 -1
- package/dist/components/layout/TableOfContents.js +1 -1
- package/dist/components/layout/TableOfContents.js.map +1 -1
- package/dist/components/openapi/CodeSamples.d.ts +4 -2
- package/dist/components/openapi/CodeSamples.d.ts.map +1 -1
- package/dist/components/openapi/CodeSamples.js +9 -5
- package/dist/components/openapi/CodeSamples.js.map +1 -1
- package/dist/components/openapi/Definition.js +1 -1
- package/dist/components/openapi/Definition.js.map +1 -1
- package/dist/components/openapi/EndpointBar.d.ts.map +1 -1
- package/dist/components/openapi/EndpointBar.js +3 -3
- package/dist/components/openapi/EndpointBar.js.map +1 -1
- package/dist/components/openapi/Introduction.d.ts.map +1 -1
- package/dist/components/openapi/Introduction.js +1 -1
- package/dist/components/openapi/Introduction.js.map +1 -1
- package/dist/components/openapi/Operation.d.ts.map +1 -1
- package/dist/components/openapi/Operation.js +5 -1
- package/dist/components/openapi/Operation.js.map +1 -1
- package/dist/components/openapi/Responses.d.ts +2 -1
- package/dist/components/openapi/Responses.d.ts.map +1 -1
- package/dist/components/openapi/Responses.js +17 -6
- package/dist/components/openapi/Responses.js.map +1 -1
- package/dist/components/openapi/Security.d.ts.map +1 -1
- package/dist/components/openapi/Security.js +3 -2
- package/dist/components/openapi/Security.js.map +1 -1
- package/dist/components/openapi/Tags.d.ts.map +1 -1
- package/dist/components/openapi/Tags.js +1 -1
- package/dist/components/openapi/Tags.js.map +1 -1
- package/dist/components/schema/ExampleView.d.ts +1 -1
- package/dist/components/schema/ExampleView.d.ts.map +1 -1
- package/dist/components/schema/ExampleView.js +3 -2
- package/dist/components/schema/ExampleView.js.map +1 -1
- package/dist/components/ui/CopyButton.d.ts +6 -0
- package/dist/components/ui/CopyButton.d.ts.map +1 -0
- package/dist/components/ui/CopyButton.js +10 -0
- package/dist/components/ui/CopyButton.js.map +1 -0
- package/dist/components/ui/Markdown.js +1 -1
- package/dist/components/ui/Markdown.js.map +1 -1
- package/dist/components/ui/SocialIcon.d.ts +5 -0
- package/dist/components/ui/SocialIcon.d.ts.map +1 -0
- package/dist/components/ui/SocialIcon.js +19 -0
- package/dist/components/ui/SocialIcon.js.map +1 -0
- package/dist/config.d.ts +133 -37
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +227 -73
- package/dist/config.js.map +1 -1
- package/dist/core/doxygen-loader.d.ts +9 -0
- package/dist/core/doxygen-loader.d.ts.map +1 -0
- package/dist/core/doxygen-loader.js +68 -0
- package/dist/core/doxygen-loader.js.map +1 -0
- package/dist/core/markdown-loader.d.ts +2 -5
- package/dist/core/markdown-loader.d.ts.map +1 -1
- package/dist/core/markdown-loader.js +218 -27
- package/dist/core/markdown-loader.js.map +1 -1
- package/dist/core/navigation.d.ts +2 -2
- package/dist/core/navigation.d.ts.map +1 -1
- package/dist/core/navigation.js +9 -10
- package/dist/core/navigation.js.map +1 -1
- package/dist/core/search-indexer.d.ts +1 -1
- package/dist/core/search-indexer.d.ts.map +1 -1
- package/dist/core/search-indexer.js +6 -5
- package/dist/core/search-indexer.js.map +1 -1
- package/dist/dev-server.d.ts +0 -12
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +101 -79
- package/dist/dev-server.js.map +1 -1
- package/dist/index.d.ts +2 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -70
- package/dist/index.js.map +1 -1
- package/dist/renderer/context.d.ts +29 -2
- package/dist/renderer/context.d.ts.map +1 -1
- package/dist/renderer/context.js +1 -1
- package/dist/renderer/context.js.map +1 -1
- package/dist/renderer/html-builder.d.ts +3 -16
- package/dist/renderer/html-builder.d.ts.map +1 -1
- package/dist/renderer/html-builder.js +6 -20
- package/dist/renderer/html-builder.js.map +1 -1
- package/dist/renderer/static-renderer.d.ts +2 -2
- package/dist/renderer/static-renderer.d.ts.map +1 -1
- package/dist/renderer/static-renderer.js +2 -2
- package/dist/renderer/static-renderer.js.map +1 -1
- package/dist/themes/default/main.css +13 -1
- package/dist/themes/default/sourcey.css +629 -41
- package/dist/utils/code-samples.d.ts +8 -3
- package/dist/utils/code-samples.d.ts.map +1 -1
- package/dist/utils/code-samples.js +188 -51
- package/dist/utils/code-samples.js.map +1 -1
- package/dist/utils/copy-svg.d.ts +9 -0
- package/dist/utils/copy-svg.d.ts.map +1 -0
- package/dist/utils/copy-svg.js +9 -0
- package/dist/utils/copy-svg.js.map +1 -0
- package/dist/utils/highlighter.d.ts.map +1 -1
- package/dist/utils/highlighter.js +18 -7
- package/dist/utils/highlighter.js.map +1 -1
- package/dist/utils/icons.d.ts +14 -0
- package/dist/utils/icons.d.ts.map +1 -0
- package/dist/utils/icons.js +59 -0
- package/dist/utils/icons.js.map +1 -0
- package/dist/utils/lang-icons.d.ts +17 -0
- package/dist/utils/lang-icons.d.ts.map +1 -0
- package/dist/utils/lang-icons.js +87 -0
- package/dist/utils/lang-icons.js.map +1 -0
- package/dist/utils/markdown.d.ts +17 -1
- package/dist/utils/markdown.d.ts.map +1 -1
- package/dist/utils/markdown.js +59 -2
- package/dist/utils/markdown.js.map +1 -1
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +4 -7
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +5 -4
package/dist/dev-server.js
CHANGED
|
@@ -1,50 +1,35 @@
|
|
|
1
1
|
import { createServer as createViteServer } from "vite";
|
|
2
|
-
import { resolve, dirname } from "node:path";
|
|
2
|
+
import { resolve, dirname, extname } from "node:path";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { loadConfig
|
|
5
|
+
import { loadConfig } from "./config.js";
|
|
5
6
|
import { loadSpec } from "./core/loader.js";
|
|
6
7
|
import { convertToOpenApi3 } from "./core/converter.js";
|
|
7
8
|
import { parseSpec } from "./core/parser.js";
|
|
8
9
|
import { normalizeSpec } from "./core/normalizer.js";
|
|
9
10
|
import { buildNavFromSpec, buildNavFromPages, buildSiteNavigation, withActivePage } from "./core/navigation.js";
|
|
10
11
|
import { loadMarkdownPage, slugFromPath } from "./core/markdown-loader.js";
|
|
12
|
+
import { loadDoxygenTab } from "./core/doxygen-loader.js";
|
|
11
13
|
import { buildSearchIndex } from "./core/search-indexer.js";
|
|
12
14
|
import { sourceyPlugin } from "./vite-plugin.js";
|
|
13
15
|
import tailwindcss from "@tailwindcss/vite";
|
|
14
16
|
import preact from "@preact/preset-vite";
|
|
15
17
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
/**
|
|
17
|
-
* Start a Vite-powered dev server for Sourcey.
|
|
18
|
-
*
|
|
19
|
-
* Uses Vite's ssrLoadModule() to render TSX components from source,
|
|
20
|
-
* so component changes are reflected instantly without a build step.
|
|
21
|
-
* CSS uses native Vite HMR. Spec/markdown changes trigger full reload.
|
|
22
|
-
*/
|
|
23
18
|
export async function startDevServer(options) {
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (specSource && !hasNavigation(config)) {
|
|
28
|
-
config = configFromSpec(specSource, { logo, favicon });
|
|
29
|
-
}
|
|
30
|
-
else if (!hasNavigation(config) && !specSource) {
|
|
31
|
-
console.error("\nError: No spec file provided and no sourcey.json with navigation found.\n");
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
if (logo)
|
|
35
|
-
config.logo = logo;
|
|
36
|
-
if (favicon)
|
|
37
|
-
config.favicon = favicon;
|
|
38
|
-
const tabs = config.navigation;
|
|
19
|
+
const { port } = options;
|
|
20
|
+
const config = await loadConfig();
|
|
21
|
+
const tabs = config.tabs;
|
|
39
22
|
// Collect watch paths
|
|
40
23
|
const watchPaths = [];
|
|
41
24
|
for (const tab of tabs) {
|
|
42
|
-
if (tab.
|
|
43
|
-
watchPaths.push(
|
|
25
|
+
if (tab.openapi)
|
|
26
|
+
watchPaths.push(tab.openapi);
|
|
27
|
+
if (tab.doxygen)
|
|
28
|
+
watchPaths.push(tab.doxygen.xml);
|
|
44
29
|
if (tab.groups) {
|
|
45
30
|
for (const group of tab.groups) {
|
|
46
31
|
for (const pagePath of group.pages) {
|
|
47
|
-
watchPaths.push(
|
|
32
|
+
watchPaths.push(pagePath);
|
|
48
33
|
}
|
|
49
34
|
}
|
|
50
35
|
}
|
|
@@ -54,19 +39,16 @@ export async function startDevServer(options) {
|
|
|
54
39
|
const tailwindCssPath = resolve(projectRoot, "src/themes/default/main.css");
|
|
55
40
|
const sourceyCssPath = resolve(projectRoot, "src/themes/default/sourcey.css");
|
|
56
41
|
const clientEntry = resolve(projectRoot, "src/client/index.ts");
|
|
57
|
-
// Path to the SSR entry point (source TSX, loaded via Vite)
|
|
58
42
|
const ssrRendererPath = resolve(projectRoot, "src/renderer/static-renderer.ts");
|
|
59
|
-
// We'll store the vite server reference so the render function can use ssrLoadModule
|
|
60
43
|
let vite;
|
|
61
|
-
// SSR render function: loads the renderer from source via Vite on every call
|
|
62
44
|
async function render(url) {
|
|
63
|
-
|
|
64
|
-
//
|
|
45
|
+
// Load render-path modules through Vite's SSR graph so invalidateAll() works.
|
|
46
|
+
// Static imports would survive invalidation and serve stale output.
|
|
65
47
|
const { renderPage } = await vite.ssrLoadModule(ssrRendererPath);
|
|
66
|
-
|
|
67
|
-
const { siteTabs, primarySpec, pageMap } = await loadSiteData(tabs,
|
|
48
|
+
const mdLoader = await vite.ssrLoadModule(resolve(projectRoot, "src/core/markdown-loader.ts"));
|
|
49
|
+
const { siteTabs, primarySpec, pageMap } = await loadSiteData(tabs, mdLoader.loadMarkdownPage);
|
|
68
50
|
const navigation = buildSiteNavigation(siteTabs);
|
|
69
|
-
|
|
51
|
+
const site = await buildSiteConfig(config);
|
|
70
52
|
let pagePath = url.replace(/^\//, "").replace(/\/$/, "");
|
|
71
53
|
if (!pagePath || pagePath === "index.html") {
|
|
72
54
|
const firstKey = pageMap.keys().next().value;
|
|
@@ -81,10 +63,10 @@ export async function startDevServer(options) {
|
|
|
81
63
|
if (!pageData)
|
|
82
64
|
return null;
|
|
83
65
|
const activeNav = withActivePage(navigation, pageData.tabSlug, pageData.pageSlug);
|
|
84
|
-
const renderOptions = { embeddable: false,
|
|
85
|
-
let html = renderPage(pageData.spec, renderOptions, activeNav, pageData.currentPage);
|
|
66
|
+
const renderOptions = { embeddable: false, assetBase: "/" };
|
|
67
|
+
let html = renderPage(pageData.spec, renderOptions, activeNav, pageData.currentPage, site);
|
|
86
68
|
// Rewrite asset paths for Vite HMR
|
|
87
|
-
html = html.replace(/<link rel="stylesheet" href="[^"]*sourcey\.css"[^>]*\/>/, `<link rel="stylesheet" href="/@fs${tailwindCssPath}" />\n<link rel="stylesheet" href="/@fs${sourceyCssPath}" />`);
|
|
69
|
+
html = html.replace(/<link rel="stylesheet" href="[^"]*sourcey\.css"[^>]*\/>/, `<link rel="stylesheet" href="/@fs${tailwindCssPath}" />\n<link rel="stylesheet" href="/@fs${sourceyCssPath}?direct" />`);
|
|
88
70
|
html = html.replace(/<script src="[^"]*sourcey\.js"[^>]*><\/script>/, `<script type="module" src="/@fs${clientEntry}"></script>`);
|
|
89
71
|
html = html.replace(/<script src="[^"]*sourcey\.js"[^>]*\/>/, `<script type="module" src="/@fs${clientEntry}"></script>`);
|
|
90
72
|
return html;
|
|
@@ -117,86 +99,126 @@ export async function startDevServer(options) {
|
|
|
117
99
|
console.log(` Watching: ${watchPaths.length} content file${watchPaths.length === 1 ? "" : "s"} + components + CSS (HMR)`);
|
|
118
100
|
console.log(` Press Ctrl+C to stop\n`);
|
|
119
101
|
}
|
|
120
|
-
async function loadSiteData(tabs,
|
|
102
|
+
async function loadSiteData(tabs, loadMarkdownPageFn = loadMarkdownPage) {
|
|
121
103
|
const specsBySlug = new Map();
|
|
122
104
|
const siteTabs = [];
|
|
123
105
|
const pageMap = new Map();
|
|
124
|
-
for (const
|
|
125
|
-
if (!
|
|
106
|
+
for (const tab of tabs) {
|
|
107
|
+
if (!tab.openapi)
|
|
126
108
|
continue;
|
|
127
|
-
const
|
|
128
|
-
const loaded = await loadSpec(specPath);
|
|
109
|
+
const loaded = await loadSpec(tab.openapi);
|
|
129
110
|
const parsed = await parseSpec(loaded);
|
|
130
111
|
const openapi3 = await convertToOpenApi3(parsed);
|
|
131
112
|
const spec = normalizeSpec(openapi3);
|
|
132
|
-
|
|
133
|
-
spec.info.logo = config.logo;
|
|
134
|
-
if (config.favicon)
|
|
135
|
-
spec.info.favicon = config.favicon;
|
|
136
|
-
specsBySlug.set(tabConfig.slug, spec);
|
|
113
|
+
specsBySlug.set(tab.slug, spec);
|
|
137
114
|
}
|
|
138
115
|
const primarySpec = specsBySlug.values().next().value ?? {
|
|
139
|
-
info: { title: "", version: "", description: ""
|
|
116
|
+
info: { title: "", version: "", description: "" },
|
|
140
117
|
servers: [], tags: [], operations: [], schemas: {}, securitySchemes: {}, webhooks: [],
|
|
141
118
|
};
|
|
142
|
-
for (const
|
|
143
|
-
if (
|
|
144
|
-
const spec = specsBySlug.get(
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
siteTabs.push(
|
|
148
|
-
pageMap.set(`${
|
|
119
|
+
for (const tab of tabs) {
|
|
120
|
+
if (tab.openapi) {
|
|
121
|
+
const spec = specsBySlug.get(tab.slug);
|
|
122
|
+
const navTab = buildNavFromSpec(spec, tab.slug);
|
|
123
|
+
navTab.label = tab.label;
|
|
124
|
+
siteTabs.push(navTab);
|
|
125
|
+
pageMap.set(`${tab.slug}/index.html`, {
|
|
149
126
|
spec,
|
|
150
127
|
currentPage: { kind: "spec", spec },
|
|
151
|
-
tabSlug:
|
|
128
|
+
tabSlug: tab.slug,
|
|
152
129
|
pageSlug: "introduction",
|
|
153
130
|
});
|
|
154
131
|
}
|
|
155
|
-
else if (
|
|
132
|
+
else if (tab.doxygen) {
|
|
133
|
+
const { pages, navTab } = await loadDoxygenTab(tab.doxygen, tab.slug, tab.label);
|
|
134
|
+
for (const [slug, page] of pages) {
|
|
135
|
+
pageMap.set(`${tab.slug}/${slug}.html`, {
|
|
136
|
+
spec: primarySpec,
|
|
137
|
+
currentPage: { kind: "markdown", markdown: page },
|
|
138
|
+
tabSlug: tab.slug,
|
|
139
|
+
pageSlug: slug,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
siteTabs.push(navTab);
|
|
143
|
+
}
|
|
144
|
+
else if (tab.groups) {
|
|
156
145
|
const pagesByPath = new Map();
|
|
157
|
-
for (const group of
|
|
146
|
+
for (const group of tab.groups) {
|
|
158
147
|
for (const pagePath of group.pages) {
|
|
159
|
-
const fullPath = resolve(configDir, pagePath);
|
|
160
148
|
const slug = slugFromPath(pagePath);
|
|
161
|
-
const page = await
|
|
149
|
+
const page = await loadMarkdownPageFn(pagePath, slug);
|
|
162
150
|
pagesByPath.set(pagePath, page);
|
|
163
|
-
pageMap.set(`${
|
|
151
|
+
pageMap.set(`${tab.slug}/${slug}.html`, {
|
|
164
152
|
spec: primarySpec,
|
|
165
153
|
currentPage: { kind: "markdown", markdown: page },
|
|
166
|
-
tabSlug:
|
|
154
|
+
tabSlug: tab.slug,
|
|
167
155
|
pageSlug: slug,
|
|
168
156
|
});
|
|
169
157
|
}
|
|
170
158
|
}
|
|
171
|
-
const
|
|
172
|
-
siteTabs.push(
|
|
159
|
+
const navTab = buildNavFromPages(tab, pagesByPath);
|
|
160
|
+
siteTabs.push(navTab);
|
|
173
161
|
}
|
|
174
162
|
}
|
|
175
|
-
return { siteTabs, primarySpec, pageMap };
|
|
163
|
+
return { siteTabs, primarySpec, pageMap, specsBySlug };
|
|
164
|
+
}
|
|
165
|
+
async function buildSiteConfig(config) {
|
|
166
|
+
const logo = config.logo
|
|
167
|
+
? {
|
|
168
|
+
light: await resolveAssetUrl(config.logo.light ?? ""),
|
|
169
|
+
dark: config.logo.dark ? await resolveAssetUrl(config.logo.dark) : undefined,
|
|
170
|
+
href: config.logo.href,
|
|
171
|
+
}
|
|
172
|
+
: undefined;
|
|
173
|
+
const customCSS = await loadCustomCSS(config.theme.css);
|
|
174
|
+
return {
|
|
175
|
+
name: config.name,
|
|
176
|
+
theme: config.theme,
|
|
177
|
+
logo: logo?.light ? logo : undefined,
|
|
178
|
+
favicon: config.favicon,
|
|
179
|
+
repo: config.repo,
|
|
180
|
+
codeSamples: config.codeSamples,
|
|
181
|
+
navbar: config.navbar,
|
|
182
|
+
footer: config.footer,
|
|
183
|
+
customCSS: customCSS || undefined,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async function loadCustomCSS(paths) {
|
|
187
|
+
const parts = [];
|
|
188
|
+
for (const p of paths) {
|
|
189
|
+
parts.push(await readFile(p, "utf-8"));
|
|
190
|
+
}
|
|
191
|
+
return parts.join("\n");
|
|
176
192
|
}
|
|
177
193
|
async function buildSearchIndexForDev(config) {
|
|
178
|
-
const
|
|
179
|
-
const configDir = process.cwd();
|
|
180
|
-
const { siteTabs, pageMap } = await loadSiteData(tabs, configDir, config);
|
|
194
|
+
const { siteTabs, pageMap, specsBySlug } = await loadSiteData(config.tabs);
|
|
181
195
|
const navigation = buildSiteNavigation(siteTabs);
|
|
182
|
-
const specsBySlug = new Map();
|
|
183
196
|
const markdownPagesByTab = new Map();
|
|
184
|
-
for (const
|
|
185
|
-
if (
|
|
186
|
-
specsBySlug.set(entry.tabSlug, entry.spec);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
for (const tabConfig of tabs) {
|
|
190
|
-
if (tabConfig.groups) {
|
|
197
|
+
for (const tab of config.tabs) {
|
|
198
|
+
if (tab.groups || tab.doxygen) {
|
|
191
199
|
const tabPages = [];
|
|
192
200
|
for (const [, entry] of pageMap) {
|
|
193
|
-
if (entry.tabSlug ===
|
|
201
|
+
if (entry.tabSlug === tab.slug && entry.currentPage.kind === "markdown") {
|
|
194
202
|
tabPages.push(entry.currentPage.markdown);
|
|
195
203
|
}
|
|
196
204
|
}
|
|
197
|
-
markdownPagesByTab.set(
|
|
205
|
+
markdownPagesByTab.set(tab.slug, tabPages);
|
|
198
206
|
}
|
|
199
207
|
}
|
|
200
208
|
return buildSearchIndex(specsBySlug, markdownPagesByTab, navigation);
|
|
201
209
|
}
|
|
210
|
+
const MIME_TYPES = {
|
|
211
|
+
".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
|
212
|
+
".gif": "image/gif", ".svg": "image/svg+xml", ".webp": "image/webp",
|
|
213
|
+
};
|
|
214
|
+
async function resolveAssetUrl(pathOrUrl) {
|
|
215
|
+
if (!pathOrUrl || pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://") || pathOrUrl.startsWith("data:")) {
|
|
216
|
+
return pathOrUrl;
|
|
217
|
+
}
|
|
218
|
+
const abs = resolve(pathOrUrl);
|
|
219
|
+
const ext = extname(abs).toLowerCase();
|
|
220
|
+
const mime = MIME_TYPES[ext] ?? "application/octet-stream";
|
|
221
|
+
const data = await readFile(abs);
|
|
222
|
+
return `data:${mime};base64,${data.toString("base64")}`;
|
|
223
|
+
}
|
|
202
224
|
//# sourceMappingURL=dev-server.js.map
|
package/dist/dev-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAyC,MAAM,MAAM,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAyC,MAAM,MAAM,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAIhH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC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S custom property overrides, e.g. { "--color-accent": "#e11d48" } */
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
}
|
|
2
|
+
import type { ResolvedConfig } from "./config.js";
|
|
7
3
|
export interface BuildOptions {
|
|
8
|
-
/** Path or URL to the OpenAPI/Swagger spec file */
|
|
9
4
|
specSource: string;
|
|
10
|
-
/** Output directory (default: "dist") */
|
|
11
5
|
outputDir?: string;
|
|
12
|
-
/** Path to a custom logo file */
|
|
13
|
-
logo?: string;
|
|
14
|
-
/** Path to a custom favicon */
|
|
15
|
-
favicon?: string;
|
|
16
|
-
/** Generate embeddable output (no <html>/<body> wrapper) */
|
|
17
6
|
embeddable?: boolean;
|
|
18
|
-
/** Skip writing files to disk (useful for validation) */
|
|
19
7
|
skipWrite?: boolean;
|
|
20
|
-
/** CSS custom property overrides for theming */
|
|
21
|
-
themeOverrides?: ThemeOverrides;
|
|
22
8
|
}
|
|
23
9
|
export interface BuildResult {
|
|
24
|
-
/** The normalized spec that was processed */
|
|
25
10
|
spec: NormalizedSpec;
|
|
26
|
-
/** Output directory where files were written */
|
|
27
11
|
outputDir: string;
|
|
28
|
-
/** Number of pages generated */
|
|
29
12
|
pageCount: number;
|
|
30
13
|
}
|
|
31
14
|
/**
|
|
@@ -34,29 +17,18 @@ export interface BuildResult {
|
|
|
34
17
|
*/
|
|
35
18
|
export declare function buildDocs(options: BuildOptions): Promise<BuildResult>;
|
|
36
19
|
export interface SiteBuildOptions {
|
|
37
|
-
/** Path to directory containing sourcey.json (default: cwd) */
|
|
38
20
|
configDir?: string;
|
|
39
|
-
/** Output directory (default: "dist") */
|
|
40
21
|
outputDir?: string;
|
|
41
|
-
|
|
42
|
-
config?: SourceyConfig;
|
|
43
|
-
/** Skip writing files to disk */
|
|
22
|
+
config?: ResolvedConfig;
|
|
44
23
|
skipWrite?: boolean;
|
|
45
|
-
/** Generate embeddable output (no <html>/<body> wrapper) */
|
|
46
24
|
embeddable?: boolean;
|
|
47
25
|
}
|
|
48
26
|
export interface SiteBuildResult {
|
|
49
|
-
/** Output directory where files were written */
|
|
50
27
|
outputDir: string;
|
|
51
|
-
/** Number of pages generated */
|
|
52
28
|
pageCount: number;
|
|
53
29
|
/** @internal specs by tab slug, for buildDocs compat */
|
|
54
30
|
_specs?: Map<string, NormalizedSpec>;
|
|
55
31
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Build a documentation site from a config.
|
|
58
|
-
* This is the single rendering path for all modes.
|
|
59
|
-
*/
|
|
60
32
|
export declare function buildSiteDocs(options?: SiteBuildOptions): Promise<SiteBuildResult>;
|
|
61
33
|
export type { NormalizedSpec, NormalizedOperation, NormalizedTag, NormalizedSchema, NormalizedParameter, NormalizedRequestBody, NormalizedResponse, } from "./core/types.js";
|
|
62
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;AAc/D,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAY3E;AAMD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACtC;AAED,wBAAsB,aAAa,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAqG5F;AAwED,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,9 @@ import { convertToOpenApi3 } from "./core/converter.js";
|
|
|
5
5
|
import { parseSpec } from "./core/parser.js";
|
|
6
6
|
import { normalizeSpec } from "./core/normalizer.js";
|
|
7
7
|
import { buildSite as buildSiteHtml } from "./renderer/html-builder.js";
|
|
8
|
-
import { loadConfig,
|
|
8
|
+
import { loadConfig, configFromSpec } from "./config.js";
|
|
9
9
|
import { loadMarkdownPage, slugFromPath } from "./core/markdown-loader.js";
|
|
10
|
+
import { loadDoxygenTab } from "./core/doxygen-loader.js";
|
|
10
11
|
import { buildNavFromSpec, buildNavFromPages, buildSiteNavigation } from "./core/navigation.js";
|
|
11
12
|
import { buildSearchIndex } from "./core/search-indexer.js";
|
|
12
13
|
/**
|
|
@@ -14,128 +15,111 @@ import { buildSearchIndex } from "./core/search-indexer.js";
|
|
|
14
15
|
* Wraps the spec in a single-tab site and renders through the modern layout.
|
|
15
16
|
*/
|
|
16
17
|
export async function buildDocs(options) {
|
|
17
|
-
const config = configFromSpec(options.specSource
|
|
18
|
-
logo: options.logo,
|
|
19
|
-
favicon: options.favicon,
|
|
20
|
-
});
|
|
21
|
-
config.theme = options.themeOverrides;
|
|
18
|
+
const config = configFromSpec(options.specSource);
|
|
22
19
|
const result = await buildSiteDocs({
|
|
23
20
|
config,
|
|
24
21
|
outputDir: options.outputDir,
|
|
25
22
|
skipWrite: options.skipWrite,
|
|
26
23
|
embeddable: options.embeddable,
|
|
27
24
|
});
|
|
28
|
-
|
|
29
|
-
const spec = result._specs?.values().next().value ?? createMinimalSpec(config);
|
|
25
|
+
const spec = result._specs?.values().next().value ?? createMinimalSpec();
|
|
30
26
|
return { spec, outputDir: result.outputDir, pageCount: result.pageCount };
|
|
31
27
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Build a documentation site from a config.
|
|
34
|
-
* This is the single rendering path for all modes.
|
|
35
|
-
*/
|
|
36
28
|
export async function buildSiteDocs(options = {}) {
|
|
37
|
-
const configDir = resolve(options.configDir ?? process.cwd());
|
|
38
29
|
const outputDir = resolve(options.outputDir ?? "dist");
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
if (!hasNavigation(config)) {
|
|
42
|
-
throw new Error("No navigation config found. Provide a sourcey.json with navigation, or pass a spec file.");
|
|
43
|
-
}
|
|
44
|
-
const tabs = config.navigation;
|
|
30
|
+
const config = options.config ?? await loadConfig(options.configDir);
|
|
31
|
+
const tabs = config.tabs;
|
|
45
32
|
const sitePages = [];
|
|
46
33
|
const siteTabs = [];
|
|
47
|
-
// Load all specs
|
|
48
34
|
const specsBySlug = new Map();
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
// Load all specs
|
|
36
|
+
for (const tab of tabs) {
|
|
37
|
+
if (!tab.openapi)
|
|
51
38
|
continue;
|
|
52
|
-
const
|
|
53
|
-
const loaded = await loadSpec(specPath);
|
|
39
|
+
const loaded = await loadSpec(tab.openapi);
|
|
54
40
|
const parsed = await parseSpec(loaded);
|
|
55
41
|
const openapi3 = await convertToOpenApi3(parsed);
|
|
56
42
|
const spec = normalizeSpec(openapi3);
|
|
57
|
-
|
|
58
|
-
spec.info.logo = await resolveAssetUrl(config.logo);
|
|
59
|
-
}
|
|
60
|
-
if (config.favicon) {
|
|
61
|
-
spec.info.favicon = config.favicon;
|
|
62
|
-
}
|
|
63
|
-
specsBySlug.set(tabConfig.slug, spec);
|
|
43
|
+
specsBySlug.set(tab.slug, spec);
|
|
64
44
|
}
|
|
65
45
|
// Primary spec for SpecContext on markdown pages
|
|
66
|
-
const primarySpec = specsBySlug.values().next().value
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
46
|
+
const primarySpec = specsBySlug.values().next().value ?? createMinimalSpec();
|
|
47
|
+
// Build SiteConfig from ResolvedConfig
|
|
48
|
+
const site = await buildSiteConfig(config);
|
|
49
|
+
// Process all tabs
|
|
50
|
+
for (const tab of tabs) {
|
|
51
|
+
if (tab.openapi) {
|
|
52
|
+
const spec = specsBySlug.get(tab.slug);
|
|
53
|
+
const navTab = buildNavFromSpec(spec, tab.slug);
|
|
54
|
+
navTab.label = tab.label;
|
|
55
|
+
siteTabs.push(navTab);
|
|
75
56
|
sitePages.push({
|
|
76
|
-
outputPath: `${
|
|
57
|
+
outputPath: `${tab.slug}/index.html`,
|
|
77
58
|
currentPage: { kind: "spec", spec },
|
|
78
59
|
spec,
|
|
79
|
-
tabSlug:
|
|
60
|
+
tabSlug: tab.slug,
|
|
80
61
|
pageSlug: "introduction",
|
|
81
62
|
});
|
|
82
63
|
}
|
|
83
|
-
else if (
|
|
64
|
+
else if (tab.doxygen) {
|
|
65
|
+
const { pages, navTab } = await loadDoxygenTab(tab.doxygen, tab.slug, tab.label);
|
|
66
|
+
for (const [slug, page] of pages) {
|
|
67
|
+
sitePages.push({
|
|
68
|
+
outputPath: `${tab.slug}/${slug}.html`,
|
|
69
|
+
currentPage: { kind: "markdown", markdown: page },
|
|
70
|
+
spec: primarySpec,
|
|
71
|
+
tabSlug: tab.slug,
|
|
72
|
+
pageSlug: slug,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
siteTabs.push(navTab);
|
|
76
|
+
}
|
|
77
|
+
else if (tab.groups) {
|
|
84
78
|
const pagesByPath = new Map();
|
|
85
|
-
for (const group of
|
|
79
|
+
for (const group of tab.groups) {
|
|
86
80
|
for (const pagePath of group.pages) {
|
|
87
|
-
const fullPath = resolve(configDir, pagePath);
|
|
88
81
|
const slug = slugFromPath(pagePath);
|
|
89
|
-
const page = await loadMarkdownPage(
|
|
82
|
+
const page = await loadMarkdownPage(pagePath, slug);
|
|
90
83
|
pagesByPath.set(pagePath, page);
|
|
91
84
|
sitePages.push({
|
|
92
|
-
outputPath: `${
|
|
85
|
+
outputPath: `${tab.slug}/${slug}.html`,
|
|
93
86
|
currentPage: { kind: "markdown", markdown: page },
|
|
94
87
|
spec: primarySpec,
|
|
95
|
-
tabSlug:
|
|
88
|
+
tabSlug: tab.slug,
|
|
96
89
|
pageSlug: slug,
|
|
97
90
|
});
|
|
98
91
|
}
|
|
99
92
|
}
|
|
100
|
-
const
|
|
101
|
-
siteTabs.push(
|
|
93
|
+
const navTab = buildNavFromPages(tab, pagesByPath);
|
|
94
|
+
siteTabs.push(navTab);
|
|
102
95
|
}
|
|
103
96
|
}
|
|
104
|
-
// Build navigation
|
|
105
97
|
const navigation = buildSiteNavigation(siteTabs);
|
|
106
98
|
// Build search index
|
|
107
99
|
const markdownPagesByTab = new Map();
|
|
108
|
-
for (const
|
|
109
|
-
if (
|
|
100
|
+
for (const tab of tabs) {
|
|
101
|
+
if (tab.groups || tab.doxygen) {
|
|
110
102
|
const tabPages = sitePages
|
|
111
|
-
.filter((p) => p.tabSlug ===
|
|
103
|
+
.filter((p) => p.tabSlug === tab.slug && p.currentPage.kind === "markdown")
|
|
112
104
|
.map((p) => p.currentPage.markdown);
|
|
113
|
-
markdownPagesByTab.set(
|
|
105
|
+
markdownPagesByTab.set(tab.slug, tabPages);
|
|
114
106
|
}
|
|
115
107
|
}
|
|
116
108
|
const searchIndex = buildSearchIndex(specsBySlug, markdownPagesByTab, navigation);
|
|
117
|
-
// Render all pages
|
|
118
109
|
if (!options.skipWrite) {
|
|
119
|
-
await buildSiteHtml(sitePages, navigation, outputDir, {
|
|
120
|
-
themeOverrides: config.theme,
|
|
110
|
+
await buildSiteHtml(sitePages, navigation, outputDir, site, {
|
|
121
111
|
searchIndex,
|
|
122
112
|
embeddable: options.embeddable,
|
|
123
113
|
});
|
|
124
114
|
}
|
|
125
115
|
return { outputDir, pageCount: sitePages.length, _specs: specsBySlug };
|
|
126
116
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
function createMinimalSpec(
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
// Helpers
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
function createMinimalSpec() {
|
|
131
121
|
return {
|
|
132
|
-
info: {
|
|
133
|
-
title: "",
|
|
134
|
-
version: "",
|
|
135
|
-
description: "",
|
|
136
|
-
logo: config.logo,
|
|
137
|
-
favicon: config.favicon,
|
|
138
|
-
},
|
|
122
|
+
info: { title: "", version: "", description: "" },
|
|
139
123
|
servers: [],
|
|
140
124
|
tags: [],
|
|
141
125
|
operations: [],
|
|
@@ -144,6 +128,34 @@ function createMinimalSpec(config) {
|
|
|
144
128
|
webhooks: [],
|
|
145
129
|
};
|
|
146
130
|
}
|
|
131
|
+
async function buildSiteConfig(config) {
|
|
132
|
+
const logo = config.logo
|
|
133
|
+
? {
|
|
134
|
+
light: await resolveAssetUrl(config.logo.light ?? ""),
|
|
135
|
+
dark: config.logo.dark ? await resolveAssetUrl(config.logo.dark) : undefined,
|
|
136
|
+
href: config.logo.href,
|
|
137
|
+
}
|
|
138
|
+
: undefined;
|
|
139
|
+
const customCSS = await loadCustomCSS(config.theme.css);
|
|
140
|
+
return {
|
|
141
|
+
name: config.name,
|
|
142
|
+
theme: config.theme,
|
|
143
|
+
logo: logo?.light ? logo : undefined,
|
|
144
|
+
favicon: config.favicon,
|
|
145
|
+
repo: config.repo,
|
|
146
|
+
codeSamples: config.codeSamples,
|
|
147
|
+
navbar: config.navbar,
|
|
148
|
+
footer: config.footer,
|
|
149
|
+
customCSS: customCSS || undefined,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async function loadCustomCSS(paths) {
|
|
153
|
+
const parts = [];
|
|
154
|
+
for (const p of paths) {
|
|
155
|
+
parts.push(await readFile(p, "utf-8"));
|
|
156
|
+
}
|
|
157
|
+
return parts.join("\n");
|
|
158
|
+
}
|
|
147
159
|
const MIME_TYPES = {
|
|
148
160
|
".png": "image/png",
|
|
149
161
|
".jpg": "image/jpeg",
|
|
@@ -154,7 +166,7 @@ const MIME_TYPES = {
|
|
|
154
166
|
".ico": "image/x-icon",
|
|
155
167
|
};
|
|
156
168
|
async function resolveAssetUrl(pathOrUrl) {
|
|
157
|
-
if (pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://") || pathOrUrl.startsWith("data:")) {
|
|
169
|
+
if (!pathOrUrl || pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://") || pathOrUrl.startsWith("data:")) {
|
|
158
170
|
return pathOrUrl;
|
|
159
171
|
}
|
|
160
172
|
const abs = resolve(pathOrUrl);
|