yaakdoc 0.1.0 → 0.2.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.
@@ -0,0 +1,133 @@
1
+ import { ResolvedConfig, YaakdocConfig } from "@yaakdoc/config";
2
+ import { ThemeDefinition } from "@yaakdoc/react/theme";
3
+ import { PreparedDocument, YaakDocument } from "@yaakdoc/core";
4
+ import { Assets, PageData, SiteData } from "@yaakdoc/react";
5
+ //#region src/node/theme.d.ts
6
+ type ResolvedTheme = {
7
+ name: string;
8
+ definition: ThemeDefinition;
9
+ /** Directory of the theme manifest. */
10
+ root: string;
11
+ manifest: string;
12
+ /** Absolute paths. */
13
+ entry: string;
14
+ client: string | null;
15
+ styles: string[];
16
+ /** Validated theme options. */
17
+ options: Record<string, unknown>;
18
+ /** Package name, when the theme comes from npm. */
19
+ packageName: string | null;
20
+ /** Files (importers) used as fallbacks when a theme dependency is not installed locally. */
21
+ fallbackImporters: string[];
22
+ highlight: {
23
+ light: string;
24
+ dark: string;
25
+ };
26
+ };
27
+ declare class ThemeError extends Error {
28
+ name: string;
29
+ }
30
+ /** Candidate package names for a theme spec: `kiseki` → `@yaakdoc/theme-kiseki`, `yaakdoc-theme-kiseki`. */
31
+ declare function themePackageCandidates(spec: string): string[];
32
+ /** Loads and validates a theme from a short name, package name or local path. */
33
+ declare function resolveTheme(spec: string, options: {
34
+ root: string;
35
+ themeOptions: Record<string, unknown>;
36
+ }): Promise<ResolvedTheme>;
37
+ /**
38
+ * Validates the options of an already loaded theme definition. `resolveTheme` loads the definition
39
+ * from a manifest; bundled engines (the Yaak plugin) pass a definition they import themselves.
40
+ */
41
+ declare function themeFromDefinition(definition: ThemeDefinition, options: {
42
+ /** Path of the theme manifest; `entry`, `client` and `styles` are resolved against it. */
43
+ manifest: string;
44
+ packageName?: string | null;
45
+ themeOptions: Record<string, unknown>;
46
+ fallbackImporters?: string[];
47
+ }): ResolvedTheme;
48
+ //#endregion
49
+ //#region src/node/context.d.ts
50
+ type YaakdocOptions = {
51
+ /** Project directory (default: `process.cwd()`). */
52
+ cwd?: string;
53
+ /** Explicit config file. */
54
+ configFile?: string;
55
+ /** Config overrides (e.g. from CLI flags). Takes precedence over the config file. */
56
+ overrides?: YaakdocConfig;
57
+ /** The Yaak export itself, instead of reading it from `export` or auto-detecting it. */
58
+ exportData?: unknown;
59
+ /** Replaces theme loading, e.g. for an engine that bundles its theme (the Yaak plugin). */
60
+ resolveTheme?: (spec: string, options: {
61
+ root: string;
62
+ themeOptions: Record<string, unknown>;
63
+ }) => ResolvedTheme | Promise<ResolvedTheme>;
64
+ };
65
+ type Route = {
66
+ /** URL path including the base, e.g. `/docs/products/`. */
67
+ path: string;
68
+ /** Output file relative to outDir, e.g. `products/index.html`. */
69
+ file: string;
70
+ page: PageData;
71
+ };
72
+ type Context = {
73
+ cwd: string;
74
+ root: string;
75
+ configFile: string | null;
76
+ config: ResolvedConfig;
77
+ /** Path of the export, or null when it was passed as `exportData`. */
78
+ exportPath: string | null;
79
+ source: YaakDocument;
80
+ theme: ResolvedTheme;
81
+ document: PreparedDocument;
82
+ site: SiteData;
83
+ routes: Route[];
84
+ notFound: Route;
85
+ /** Markdown/text outputs keyed by URL path (e.g. `/products.md`, `/llms.txt`). */
86
+ textFiles: Map<string, string>;
87
+ /** Local branding assets keyed by URL path → absolute file path. */
88
+ assets: Map<string, string>;
89
+ /** Files that trigger a full rebuild of the context when changed. */
90
+ watchFiles: string[];
91
+ };
92
+ /** Loads config, export and theme, and prepares everything needed to render the site. */
93
+ declare function resolveContext(options?: YaakdocOptions): Promise<Context>;
94
+ /**
95
+ * Maps a local asset (logo, favicon) to a public URL under `<base>_yaakdoc/`, registering it in
96
+ * `assets` so it's copied into the site. URLs and site-root paths that don't exist on disk (e.g.
97
+ * `/logo.svg` served from `public/`) are kept as is.
98
+ */
99
+ declare function publicAsset(path: string | undefined, base: string, assets: Map<string, string>): string | null;
100
+ /** Finds the route for a URL path (ignoring query/hash; `/x` matches `/x/`). */
101
+ declare function matchRoute(context: Context, pathname: string): Route | null;
102
+ //#endregion
103
+ //#region src/node/site.d.ts
104
+ /** What the SSR entry exports, in dev and in builds. */
105
+ type RenderEntry = {
106
+ render: (input: {
107
+ document: Context["document"];
108
+ site: Context["site"];
109
+ page: Route["page"];
110
+ assets: Assets;
111
+ }) => Promise<string>;
112
+ };
113
+ /** Prefixes the client asset paths (relative to the output directory) with the site's base. */
114
+ declare function withBase(assets: Assets, base: string): Assets;
115
+ /** Refuses to empty the project directory (or a parent of it). */
116
+ declare function assertSafeOutDir(outDir: string, root: string): void;
117
+ /** Empties (or creates) the output directory, after checking that it's safe to. */
118
+ declare function emptyOutDir(outDir: string, root: string): Promise<void>;
119
+ /**
120
+ * Writes the site into `context.config.outDir`, next to the client assets that are already there:
121
+ * every route prerendered with `render`, the Markdown twins and llms.txt, branding assets and the
122
+ * sitemap. Returns the written files, relative to the output directory.
123
+ */
124
+ declare function writeSite(context: Context, { render, assets }: {
125
+ render: RenderEntry["render"];
126
+ assets: Assets;
127
+ }): Promise<string[]>;
128
+ //#endregion
129
+ //#region src/node/version.d.ts
130
+ /** The yaakdoc version: inlined by the build, read from package.json when running from source. */
131
+ declare const VERSION: string;
132
+ //#endregion
133
+ export { themePackageCandidates as _, withBase as a, Route as c, publicAsset as d, resolveContext as f, themeFromDefinition as g, resolveTheme as h, emptyOutDir as i, YaakdocOptions as l, ThemeError as m, RenderEntry as n, writeSite as o, ResolvedTheme as p, assertSafeOutDir as r, Context as s, VERSION as t, matchRoute as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaakdoc",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Static, themable, and LLM-friendly API documentation generated from Yaak exports.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,6 +14,11 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
16
  },
17
+ "./static": {
18
+ "@yaakdoc/source": "./src/static.ts",
19
+ "types": "./dist/static.d.ts",
20
+ "default": "./dist/static.js"
21
+ },
17
22
  "./config.schema.json": "./config.schema.json",
18
23
  "./package.json": "./package.json"
19
24
  },
@@ -55,12 +60,12 @@
55
60
  "dependencies": {
56
61
  "@clack/prompts": "^1.8.1",
57
62
  "@shikijs/rehype": "^4.5.0",
58
- "@yaakdoc/config": "^0.1.0",
59
- "@yaakdoc/core": "^0.1.0",
60
- "@yaakdoc/markdown": "^0.1.0",
61
- "@yaakdoc/react": "^0.1.0",
62
- "@yaakdoc/snippets": "^0.1.0",
63
- "@yaakdoc/theme-kiseki": "^0.1.0",
63
+ "@yaakdoc/config": "^0.2.0",
64
+ "@yaakdoc/core": "^0.2.0",
65
+ "@yaakdoc/markdown": "^0.2.0",
66
+ "@yaakdoc/react": "^0.2.0",
67
+ "@yaakdoc/snippets": "^0.2.0",
68
+ "@yaakdoc/theme-kiseki": "^0.2.0",
64
69
  "citty": "^0.2.2",
65
70
  "consola": "^3.4.2",
66
71
  "jiti": "^2.7.0",