@theholocron/astro-config 8.9.0-alpha.2 → 8.9.0-alpha.4
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 +29 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +29 -3
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -61,9 +61,37 @@ export default defineConfig({
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
### API reference from TSDoc
|
|
65
|
+
|
|
66
|
+
`apiReference()` generates a package's API reference from its TSDoc comments each time the docs are built or served (nothing generated is committed). It returns a Starlight plugin and a sidebar group:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { apiReference, defineConfig } from "@theholocron/astro-config";
|
|
70
|
+
import { createStarlightTypeDocPlugin } from "starlight-typedoc";
|
|
71
|
+
|
|
72
|
+
const arrayUtils = apiReference({
|
|
73
|
+
createPlugin: createStarlightTypeDocPlugin,
|
|
74
|
+
root: new URL("./", import.meta.url),
|
|
75
|
+
package: "utils/array-utils",
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export default defineConfig({
|
|
79
|
+
docs: {
|
|
80
|
+
name: "Utils",
|
|
81
|
+
github: "utils",
|
|
82
|
+
sidebar: [{ label: "array-utils", items: [{ label: "Overview", slug: "array-utils" }, arrayUtils.group] }],
|
|
83
|
+
},
|
|
84
|
+
plugins: [arrayUtils.plugin],
|
|
85
|
+
starlight,
|
|
86
|
+
docsTheme,
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`entryPoints` (default `["src/index.ts"]`, relative to the package) and `label` (default "API reference") are optional. `starlight-typedoc` ships TypeScript source, so, like `starlight` and `docsTheme`, you import it in your own config and pass it in; install `starlight-typedoc`, `typedoc` and `typedoc-plugin-markdown` in the site.
|
|
91
|
+
|
|
64
92
|
## What it generates
|
|
65
93
|
|
|
66
|
-
- `site` — `https://theholocron.
|
|
94
|
+
- `site` — only when you pass it (for example `https://docs.theholocron.dev`); without it Starlight cannot generate a sitemap
|
|
67
95
|
- `base` — `/${docs.slug}`
|
|
68
96
|
- Starlight integration with the `@theholocron/docs-theme` plugin
|
|
69
97
|
- GitHub social link to `https://github.com/theholocron/${docs.slug}`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { defineConfig as defineConfig$1 } from "astro/config";
|
|
2
2
|
import starlight from "@astrojs/starlight";
|
|
3
3
|
import { docsTheme } from "@theholocron/docs-theme";
|
|
4
|
+
import { createStarlightTypeDocPlugin } from "starlight-typedoc";
|
|
4
5
|
type StarlightSidebar = NonNullable<Parameters<typeof starlight>[0]["sidebar"]>;
|
|
6
|
+
type StarlightPlugins = NonNullable<Parameters<typeof starlight>[0]["plugins"]>;
|
|
5
7
|
export interface DocsConfig {
|
|
6
8
|
name: string;
|
|
7
9
|
github: string;
|
|
@@ -11,10 +13,41 @@ export interface DocsConfigInput {
|
|
|
11
13
|
docs: DocsConfig;
|
|
12
14
|
starlight: typeof starlight;
|
|
13
15
|
docsTheme: typeof docsTheme;
|
|
16
|
+
/** Further Starlight plugins, added after the docs theme (for example the ones `apiReference()` returns). */
|
|
17
|
+
plugins?: StarlightPlugins;
|
|
14
18
|
srcDir?: string;
|
|
15
19
|
outDir?: string;
|
|
16
20
|
publicDir?: string;
|
|
17
21
|
base?: string;
|
|
22
|
+
/** The site's absolute origin (for example `https://docs.theholocron.dev`). Starlight needs it to generate a sitemap. */
|
|
23
|
+
site?: string;
|
|
18
24
|
}
|
|
19
|
-
export declare function defineConfig({ docs, starlight, docsTheme, srcDir, outDir, publicDir, base }: DocsConfigInput): ReturnType<typeof defineConfig$1>;
|
|
25
|
+
export declare function defineConfig({ docs, starlight, docsTheme, plugins, srcDir, outDir, publicDir, base, site }: DocsConfigInput): ReturnType<typeof defineConfig$1>;
|
|
26
|
+
export interface ApiReferenceInput {
|
|
27
|
+
/** `createStarlightTypeDocPlugin` from your own `starlight-typedoc` import, as with `starlight` and `docsTheme`. */
|
|
28
|
+
createPlugin: typeof createStarlightTypeDocPlugin;
|
|
29
|
+
/** The repo root, as a URL or path: `new URL("./", import.meta.url)` from a config at the root. */
|
|
30
|
+
root: URL | string;
|
|
31
|
+
/** The package's folder from the repo root (`utils/array-utils`). */
|
|
32
|
+
package: string;
|
|
33
|
+
/** Entry points, relative to the package. Defaults to `src/index.ts`. */
|
|
34
|
+
entryPoints?: string[];
|
|
35
|
+
/** The sidebar group's label. Defaults to "API reference". */
|
|
36
|
+
label?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ApiReference {
|
|
39
|
+
/** Add to `defineConfig({ plugins })`. */
|
|
40
|
+
plugin: StarlightPlugins[number];
|
|
41
|
+
/** Put in the sidebar where the reference should appear. */
|
|
42
|
+
group: StarlightSidebar[number];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The generated API reference of one package: its TSDoc comments, run through TypeDoc each time the docs are built
|
|
46
|
+
* or served, as pages under `<package>/api` and a collapsed sidebar group. Nothing generated is committed.
|
|
47
|
+
*
|
|
48
|
+
* `starlight-typedoc` ships TypeScript source, so, like `starlight` and `docsTheme`, it is imported by the site's
|
|
49
|
+
* own config and passed in, which keeps Astro's loader in charge of it. Install `starlight-typedoc`, `typedoc` and
|
|
50
|
+
* `typedoc-plugin-markdown` in the site.
|
|
51
|
+
*/
|
|
52
|
+
export declare function apiReference({ createPlugin, root, package: dir, entryPoints, label }: ApiReferenceInput): ApiReference;
|
|
20
53
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import react from "@astrojs/react";
|
|
2
3
|
import { defineConfig as defineConfig$1 } from "astro/config";
|
|
3
4
|
// index.ts
|
|
4
|
-
function defineConfig({ docs, starlight, docsTheme, srcDir, outDir, publicDir, base }) {
|
|
5
|
+
function defineConfig({ docs, starlight, docsTheme, plugins, srcDir, outDir, publicDir, base, site }) {
|
|
5
6
|
return defineConfig$1({
|
|
7
|
+
...site && { site },
|
|
6
8
|
base: base ?? `/${docs.github}`,
|
|
7
9
|
...srcDir && { srcDir },
|
|
8
10
|
...outDir && { outDir },
|
|
@@ -10,7 +12,7 @@ function defineConfig({ docs, starlight, docsTheme, srcDir, outDir, publicDir, b
|
|
|
10
12
|
vite: { resolve: { alias: { "@": new URL(srcDir ?? "src", `file://${process.cwd()}/`).pathname } } },
|
|
11
13
|
integrations: [starlight({
|
|
12
14
|
title: docs.name,
|
|
13
|
-
plugins: [docsTheme()],
|
|
15
|
+
plugins: [docsTheme(), ...plugins ?? []],
|
|
14
16
|
social: [{
|
|
15
17
|
icon: "github",
|
|
16
18
|
label: "GitHub",
|
|
@@ -20,4 +22,28 @@ function defineConfig({ docs, starlight, docsTheme, srcDir, outDir, publicDir, b
|
|
|
20
22
|
}), react()]
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The generated API reference of one package: its TSDoc comments, run through TypeDoc each time the docs are built
|
|
27
|
+
* or served, as pages under `<package>/api` and a collapsed sidebar group. Nothing generated is committed.
|
|
28
|
+
*
|
|
29
|
+
* `starlight-typedoc` ships TypeScript source, so, like `starlight` and `docsTheme`, it is imported by the site's
|
|
30
|
+
* own config and passed in, which keeps Astro's loader in charge of it. Install `starlight-typedoc`, `typedoc` and
|
|
31
|
+
* `typedoc-plugin-markdown` in the site.
|
|
32
|
+
*/
|
|
33
|
+
function apiReference({ createPlugin, root, package: dir, entryPoints = ["src/index.ts"], label = "API reference" }) {
|
|
34
|
+
const [plugin, group] = createPlugin();
|
|
35
|
+
const inPackage = (path) => fileURLToPath(new URL(`${dir}/${path}`, root));
|
|
36
|
+
return {
|
|
37
|
+
group,
|
|
38
|
+
plugin: plugin({
|
|
39
|
+
entryPoints: entryPoints.map(inPackage),
|
|
40
|
+
tsconfig: inPackage("tsconfig.json"),
|
|
41
|
+
output: `${dir}/api`,
|
|
42
|
+
sidebar: {
|
|
43
|
+
label,
|
|
44
|
+
collapsed: true
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export { apiReference, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/astro-config",
|
|
3
|
-
"version": "8.9.0-alpha.
|
|
3
|
+
"version": "8.9.0-alpha.4",
|
|
4
4
|
"description": "Astro configuration factory for theholocron docs sites.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -32,17 +32,20 @@
|
|
|
32
32
|
"dist/"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@astrojs/react": "^6.0.
|
|
35
|
+
"@astrojs/react": "^6.0.6",
|
|
36
36
|
"@astrojs/starlight": "^0.41.7",
|
|
37
|
-
"@theholocron/docs-theme": "^1.3.5",
|
|
38
37
|
"@vitest/coverage-v8": "^5.0.5",
|
|
39
|
-
"astro": "^7.
|
|
38
|
+
"astro": "^7.3.3",
|
|
40
39
|
"react": "^19.0.0",
|
|
41
40
|
"react-dom": "^19.0.0",
|
|
41
|
+
"starlight-typedoc": "^0.23.1",
|
|
42
42
|
"tsdown": "^0.23.3",
|
|
43
|
+
"typedoc": "^0.28.20",
|
|
44
|
+
"typedoc-plugin-markdown": "^4.14.1",
|
|
43
45
|
"typescript": "^5.9.3",
|
|
44
46
|
"vitest": "^5.0.5",
|
|
45
|
-
"@theholocron/
|
|
47
|
+
"@theholocron/docs-theme": "^1.10.5-alpha.1",
|
|
48
|
+
"@theholocron/tsconfig": "8.9.0-alpha.4"
|
|
46
49
|
},
|
|
47
50
|
"peerDependencies": {
|
|
48
51
|
"@astrojs/react": ">=6.0.0",
|