sveld 0.32.8 → 0.34.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 +250 -3
- package/lib/ComponentParser.d.ts +91 -12
- package/lib/bundle.d.ts +156 -0
- package/lib/check.d.ts +37 -0
- package/lib/cli.d.ts +17 -1
- package/lib/dependency-graph.d.ts +20 -0
- package/lib/diagnostics.d.ts +30 -0
- package/lib/example-check.d.ts +22 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +715 -684
- package/lib/load-config.d.ts +44 -0
- package/lib/parse-cache.d.ts +28 -0
- package/lib/parse-entry-exports.d.ts +30 -0
- package/lib/plugin.d.ts +37 -43
- package/lib/resolve-types.d.ts +52 -0
- package/lib/sveld.d.ts +13 -1
- package/lib/watch.d.ts +34 -0
- package/lib/writer/built-in-writers.d.ts +1 -0
- package/lib/writer/document-model.d.ts +34 -0
- package/lib/writer/markdown-format-utils.d.ts +30 -1
- package/lib/writer/markdown-render-utils.d.ts +2 -1
- package/lib/writer/registry.d.ts +17 -0
- package/lib/writer/writer-json.d.ts +3 -0
- package/lib/writer/writer-markdown.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PluginSveldOptions } from "./plugin";
|
|
2
|
+
/**
|
|
3
|
+
* Public shape of a `sveld.config.{js,ts,mjs}` file. Identical to the options
|
|
4
|
+
* accepted by the Vite/Rollup plugin and the CLI.
|
|
5
|
+
*/
|
|
6
|
+
export type SveldConfig = PluginSveldOptions;
|
|
7
|
+
/** Config file names probed at the project root. First existing file wins. */
|
|
8
|
+
export declare const CONFIG_FILE_NAMES: readonly ["sveld.config.js", "sveld.config.mjs", "sveld.config.ts"];
|
|
9
|
+
/**
|
|
10
|
+
* Identity helper that fully types a `sveld` config object.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // sveld.config.js
|
|
15
|
+
* import { defineConfig } from "sveld";
|
|
16
|
+
*
|
|
17
|
+
* export default defineConfig({
|
|
18
|
+
* glob: true,
|
|
19
|
+
* json: true,
|
|
20
|
+
* markdown: true,
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function defineConfig(config: SveldConfig): SveldConfig;
|
|
25
|
+
/** Locate a `sveld.config.{js,mjs,ts}` file in `cwd`, or `null` if none exists. */
|
|
26
|
+
export declare function resolveConfigPath(cwd?: string): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Load and validate a `sveld` config file by absolute path.
|
|
29
|
+
*
|
|
30
|
+
* The package is ESM-only, so the file is loaded via dynamic `import()`. A
|
|
31
|
+
* cache-busting query is appended so repeated loads (e.g. across tests or
|
|
32
|
+
* watch runs) reflect the latest contents.
|
|
33
|
+
*
|
|
34
|
+
* @throws if the module cannot be imported (e.g. a syntax error or a config
|
|
35
|
+
* that throws at evaluation time) or if it does not default-export an object.
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadConfigFrom(configPath: string): Promise<SveldConfig>;
|
|
38
|
+
/**
|
|
39
|
+
* Discover and load a `sveld.config.{js,mjs,ts}` file from `cwd`.
|
|
40
|
+
* Returns an empty object when no config file is present.
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadConfig(cwd?: string): Promise<SveldConfig>;
|
|
43
|
+
/** Shallow-merge option sources. Later sources override earlier ones. */
|
|
44
|
+
export declare function mergeConfig<T extends PluginSveldOptions = PluginSveldOptions>(...sources: Array<Partial<T> | undefined>): Partial<T>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ParsedComponent } from "./ComponentParser";
|
|
2
|
+
/** Default on-disk location for the persistent parse cache, relative to the project root. */
|
|
3
|
+
export declare const DEFAULT_CACHE_FILE: string;
|
|
4
|
+
/** Resolves the effective cache file path for `cache: true | string`. */
|
|
5
|
+
export declare function resolveCacheFilePath(rootDir: string, cache: boolean | string): string;
|
|
6
|
+
export declare function hashSource(source: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Cross-run parse cache. Entries match on file path and sha256 of source.
|
|
9
|
+
* Symbol-keyed TypeScript metadata is stored separately because JSON drops symbols.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ParseCache {
|
|
12
|
+
private readonly cacheFilePath;
|
|
13
|
+
private readonly file;
|
|
14
|
+
private readonly next;
|
|
15
|
+
/** Paths forced to miss this run (e.g. dependents of a changed `@extends` target). */
|
|
16
|
+
private readonly blocked;
|
|
17
|
+
constructor(cacheFilePath: string);
|
|
18
|
+
/** True when `get()` would return a hit for `resolvedPath` and `hash`. */
|
|
19
|
+
has(resolvedPath: string, hash: string): boolean;
|
|
20
|
+
/** Returns the cached parse for `resolvedPath` when its content hash still matches. */
|
|
21
|
+
get(resolvedPath: string, hash: string): ParsedComponent | null;
|
|
22
|
+
/** Records a freshly parsed component so it can be reused on a future run. */
|
|
23
|
+
set(resolvedPath: string, hash: string, parsed: ParsedComponent): void;
|
|
24
|
+
/** Skip cache for `resolvedPath` this run (e.g. an @extends dependent). */
|
|
25
|
+
invalidate(resolvedPath: string): void;
|
|
26
|
+
/** Persists this run's cache entries back to disk. */
|
|
27
|
+
save(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** One named export from the entry barrel (not a `.svelte` component). */
|
|
2
|
+
export interface EntryExport {
|
|
3
|
+
name: string;
|
|
4
|
+
kind: "const" | "let" | "var" | "function" | "class" | "type" | "interface" | "enum";
|
|
5
|
+
/** Type text from the source, when present. */
|
|
6
|
+
type?: string;
|
|
7
|
+
/** Initializer text for simple constants. */
|
|
8
|
+
value?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Declaring module, relative to the entry file. */
|
|
11
|
+
source?: string;
|
|
12
|
+
isTypeOnly: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type EntryExports = EntryExport[];
|
|
15
|
+
/**
|
|
16
|
+
* List consts, functions, and types exported from an entry barrel.
|
|
17
|
+
*
|
|
18
|
+
* Follows re-exports with AST-only traversal. Skips `.svelte` files.
|
|
19
|
+
*
|
|
20
|
+
* @param entryFile - Absolute path to the entry module.
|
|
21
|
+
* @returns Exports deduplicated by name, sorted alphabetically.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* // entry: export { VERSION } from "./constants"; export type { Theme } from "./types";
|
|
26
|
+
* parseEntryExports("/abs/src/index.ts");
|
|
27
|
+
* // [{ name: "Theme", kind: "type", isTypeOnly: true, ... }, { name: "VERSION", kind: "const", ... }]
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseEntryExports(entryFile: string): EntryExports;
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,67 +1,62 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export
|
|
1
|
+
import { type GenerateBundleOptions, type GenerateBundleResult } from "./bundle";
|
|
2
|
+
import "./writer/built-in-writers";
|
|
3
|
+
import type { WriteJsonOptions } from "./writer/writer-json";
|
|
4
|
+
import type { WriteMarkdownOptions } from "./writer/writer-markdown";
|
|
5
|
+
import type { WriteTsDefinitionsOptions } from "./writer/writer-ts-definitions";
|
|
6
|
+
export type { CollectedComponents, ComponentDocApi, ComponentDocs, ComponentParseError, GenerateBundleOptions, GenerateBundleResult, ResolveComponentFilePath, } from "./bundle";
|
|
7
|
+
export { collectComponents, collectSvelteFilePaths, generateBundle, processComponent, readFileMap, reportParseErrors, toGenerateBundleOptions, } from "./bundle";
|
|
8
|
+
export interface PluginSveldOptions extends Pick<GenerateBundleOptions, "resolveTypes" | "cache" | "checkExamples"> {
|
|
8
9
|
/**
|
|
9
10
|
* Specify the entry point to uncompiled Svelte source.
|
|
10
11
|
* If not provided, sveld will use the "svelte" field from package.json.
|
|
11
12
|
*/
|
|
12
13
|
entry?: string;
|
|
13
14
|
glob?: boolean;
|
|
15
|
+
/** Record consts, functions, and types from the entry barrel. Off by default. */
|
|
16
|
+
documentExports?: boolean;
|
|
14
17
|
types?: boolean;
|
|
15
18
|
typesOptions?: Partial<Omit<WriteTsDefinitionsOptions, "inputDir">>;
|
|
16
19
|
json?: boolean;
|
|
17
20
|
jsonOptions?: Partial<Omit<WriteJsonOptions, "inputDir">>;
|
|
18
21
|
markdown?: boolean;
|
|
19
22
|
markdownOptions?: Partial<WriteMarkdownOptions>;
|
|
23
|
+
/**
|
|
24
|
+
* Run additional, userland-registered writers (via `registerWriter` from
|
|
25
|
+
* "sveld") beyond the built-in `json`/`markdown`/`types` outputs. Keyed by
|
|
26
|
+
* the writer's registered `name`, valued by that writer's options.
|
|
27
|
+
*/
|
|
28
|
+
additionalWriters?: Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Abort the entire run when a single component fails to parse.
|
|
31
|
+
* When `false` (the default), parse failures are collected as diagnostics
|
|
32
|
+
* and the remaining components still emit their output.
|
|
33
|
+
*/
|
|
34
|
+
failFast?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Regenerate output incrementally when `.svelte` source changes during
|
|
37
|
+
* `vite dev` / `vite build --watch`. Only the changed component and the
|
|
38
|
+
* components that depend on it via `@extendProps` / `@extends` are re-parsed.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
watch?: boolean;
|
|
20
42
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
/** Subset of Vite/Rollup's HMR context that the watch hook relies on. */
|
|
44
|
+
interface HotUpdateContext {
|
|
45
|
+
file: string;
|
|
24
46
|
}
|
|
25
|
-
export type ComponentDocs = Map<string, ComponentDocApi>;
|
|
26
47
|
interface SveldPlugin {
|
|
27
48
|
name: string;
|
|
28
49
|
apply?: "build" | "serve";
|
|
29
50
|
enforce?: "pre" | "post";
|
|
30
|
-
buildStart(): void
|
|
51
|
+
buildStart(): void | Promise<void>;
|
|
31
52
|
generateBundle(): Promise<void>;
|
|
32
53
|
writeBundle(): void;
|
|
54
|
+
/** Vite dev-server HMR hook (serve mode). */
|
|
55
|
+
handleHotUpdate?(ctx: HotUpdateContext): void;
|
|
56
|
+
/** Rollup/Vite watch hook (build `--watch`). */
|
|
57
|
+
watchChange?(id: string): void;
|
|
33
58
|
}
|
|
34
59
|
export default function pluginSveld(opts?: PluginSveldOptions): SveldPlugin;
|
|
35
|
-
interface GenerateBundleResult {
|
|
36
|
-
exports: ParsedExports;
|
|
37
|
-
components: ComponentDocs;
|
|
38
|
-
allComponentsForTypes: ComponentDocs;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Generates component documentation bundle from Svelte source files.
|
|
42
|
-
*
|
|
43
|
-
* Parses exports, discovers components (optionally via glob), and processes
|
|
44
|
-
* all Svelte files to extract component metadata. Returns both exported
|
|
45
|
-
* components (for JSON/Markdown) and all components (for TypeScript definitions).
|
|
46
|
-
*
|
|
47
|
-
* @param input - Entry point file or directory containing Svelte components
|
|
48
|
-
* @param glob - Whether to glob for all .svelte files in the directory
|
|
49
|
-
* @returns Bundle result containing exports, components, and allComponentsForTypes
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* // Generate from single file:
|
|
54
|
-
* const result = await generateBundle("./src/App.svelte", false);
|
|
55
|
-
*
|
|
56
|
-
* // Generate from directory with glob:
|
|
57
|
-
* const result = await generateBundle("./src", true);
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function generateBundle(input: string, glob: boolean): Promise<{
|
|
61
|
-
exports: ParsedExports;
|
|
62
|
-
components: ComponentDocs;
|
|
63
|
-
allComponentsForTypes: ComponentDocs;
|
|
64
|
-
}>;
|
|
65
60
|
/**
|
|
66
61
|
* Writes output files based on plugin options.
|
|
67
62
|
*
|
|
@@ -84,4 +79,3 @@ export declare function generateBundle(input: string, glob: boolean): Promise<{
|
|
|
84
79
|
* ```
|
|
85
80
|
*/
|
|
86
81
|
export declare function writeOutput(result: GenerateBundleResult, opts: PluginSveldOptions, input: string): void;
|
|
87
|
-
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ParsedComponentTypeScriptMetadata, ResolvedComponentProp } from "./ComponentParser";
|
|
2
|
+
import type { ExampleCheckSource } from "./example-check";
|
|
3
|
+
export interface ResolveTarget {
|
|
4
|
+
moduleName: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
metadata: ParsedComponentTypeScriptMetadata;
|
|
7
|
+
}
|
|
8
|
+
export interface ExampleCheckTarget {
|
|
9
|
+
moduleName: string;
|
|
10
|
+
filePath: string;
|
|
11
|
+
sources: ExampleCheckSource[];
|
|
12
|
+
}
|
|
13
|
+
/** One `@example` block that failed to type-check. */
|
|
14
|
+
export interface ExampleCheckDiagnostic {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Expands opaque imported `$props()` types using the project's TypeScript program.
|
|
21
|
+
* Loaded only when `resolveTypes` is enabled.
|
|
22
|
+
*/
|
|
23
|
+
export declare class TypeResolver {
|
|
24
|
+
private readonly api;
|
|
25
|
+
private readonly symbolFlags;
|
|
26
|
+
private readonly tsconfigPath;
|
|
27
|
+
private readonly overlay;
|
|
28
|
+
private constructor();
|
|
29
|
+
/**
|
|
30
|
+
* Loads `typescript` and the nearest `tsconfig.json`.
|
|
31
|
+
* Returns `null` when either is missing.
|
|
32
|
+
*/
|
|
33
|
+
static create(cwd?: string): Promise<TypeResolver | null>;
|
|
34
|
+
/** Resolves every target in one program snapshot. */
|
|
35
|
+
expandAll(targets: ResolveTarget[]): Promise<Map<string, ResolvedComponentProp[]>>;
|
|
36
|
+
/**
|
|
37
|
+
* Type-checks every `@example` block in one program snapshot.
|
|
38
|
+
*
|
|
39
|
+
* Each example gets its own virtual file: a `declare`-style binding for the
|
|
40
|
+
* documented symbol (typed as `any` end-to-end, so types sveld can't see
|
|
41
|
+
* never cause a false positive), then the example body. Catches renamed
|
|
42
|
+
* or removed symbols and wrong arity. Not full type checking; it does not
|
|
43
|
+
* depend on the rest of the component's types.
|
|
44
|
+
*/
|
|
45
|
+
checkExamples(targets: ExampleCheckTarget[]): Promise<Map<string, ExampleCheckDiagnostic[]>>;
|
|
46
|
+
/** Closes the TypeScript server process. */
|
|
47
|
+
dispose(): Promise<void>;
|
|
48
|
+
private resolveFile;
|
|
49
|
+
private createFileSystem;
|
|
50
|
+
private virtualFileName;
|
|
51
|
+
private exampleFileName;
|
|
52
|
+
}
|
package/lib/sveld.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SveldDiagnostic } from "./diagnostics";
|
|
1
2
|
import { type PluginSveldOptions } from "./plugin";
|
|
2
3
|
interface SveldOptions extends Omit<PluginSveldOptions, "entry"> {
|
|
3
4
|
/**
|
|
@@ -6,6 +7,17 @@ interface SveldOptions extends Omit<PluginSveldOptions, "entry"> {
|
|
|
6
7
|
* the entry point from the `package.json#svelte` field.
|
|
7
8
|
*/
|
|
8
9
|
input?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Exit with code 1 when diagnostics are present. Default `false`.
|
|
12
|
+
*/
|
|
13
|
+
strict?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Result of a programmatic `sveld` run.
|
|
17
|
+
*/
|
|
18
|
+
interface SveldResult {
|
|
19
|
+
/** Diagnostics from this run. */
|
|
20
|
+
diagnostics: SveldDiagnostic[];
|
|
9
21
|
}
|
|
10
22
|
/**
|
|
11
23
|
* Programmatic entry point for sveld.
|
|
@@ -21,5 +33,5 @@ interface SveldOptions extends Omit<PluginSveldOptions, "entry"> {
|
|
|
21
33
|
* });
|
|
22
34
|
* ```
|
|
23
35
|
*/
|
|
24
|
-
export declare function sveld(opts?: SveldOptions): Promise<
|
|
36
|
+
export declare function sveld(opts?: SveldOptions): Promise<SveldResult>;
|
|
25
37
|
export {};
|
package/lib/watch.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type GenerateBundleResult } from "./bundle";
|
|
2
|
+
/** Result of an incremental update. */
|
|
3
|
+
export interface SveldBundleUpdate {
|
|
4
|
+
/** The full, updated bundle result (all components, with the affected ones re-parsed). */
|
|
5
|
+
result: GenerateBundleResult;
|
|
6
|
+
/**
|
|
7
|
+
* Absolute paths of the components that were re-parsed: the changed files
|
|
8
|
+
* plus their transitive `@extendProps` / `@extends` dependents. Other
|
|
9
|
+
* components are reused from the previous parse.
|
|
10
|
+
*/
|
|
11
|
+
reparsed: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A long-lived bundle that supports scoped, incremental re-parsing.
|
|
15
|
+
*
|
|
16
|
+
* `createSveldBundle` performs the initial full parse. `update` then re-parses
|
|
17
|
+
* only the components affected by a set of changed files, leaving every other
|
|
18
|
+
* component's previously-parsed output untouched. This is the core of the
|
|
19
|
+
* plugin's watch mode.
|
|
20
|
+
*/
|
|
21
|
+
export interface SveldBundle {
|
|
22
|
+
readonly result: GenerateBundleResult;
|
|
23
|
+
/** Re-parse the changed files plus their dependents and return the updated bundle. */
|
|
24
|
+
update(changedFilePaths: string[]): Promise<SveldBundleUpdate>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a watch-mode bundle for the given entry point, performing the initial
|
|
28
|
+
* full parse up front.
|
|
29
|
+
*
|
|
30
|
+
* @param input - Entry point file or directory containing Svelte components
|
|
31
|
+
* @param glob - Whether to glob for all `.svelte` files in the directory
|
|
32
|
+
* @param documentExports - Record consts, functions, and types from the entry barrel
|
|
33
|
+
*/
|
|
34
|
+
export declare function createSveldBundle(input: string, glob: boolean, documentExports?: boolean): Promise<SveldBundle>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EntryExports } from "../parse-entry-exports";
|
|
2
|
+
import type { ComponentDocApi, ComponentDocs } from "../plugin";
|
|
3
|
+
export declare const COMPONENT_API_SCHEMA_VERSION = 1;
|
|
4
|
+
/**
|
|
5
|
+
* Canonical, renderer-agnostic representation of a component collection.
|
|
6
|
+
*
|
|
7
|
+
* Every writer (JSON, Markdown, TypeScript definitions) builds this document
|
|
8
|
+
* via `buildComponentApiDocument` instead of independently sorting/filtering
|
|
9
|
+
* the raw `ComponentDocs` map, so sort order and field stripping can't drift
|
|
10
|
+
* between output formats.
|
|
11
|
+
*/
|
|
12
|
+
export interface ComponentApiDocument {
|
|
13
|
+
schemaVersion: 1;
|
|
14
|
+
generator: {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
svelteVersion: string;
|
|
18
|
+
};
|
|
19
|
+
total: number;
|
|
20
|
+
components: ComponentDocApi[];
|
|
21
|
+
/** Only when `documentExports` is on. */
|
|
22
|
+
totalExports?: number;
|
|
23
|
+
exports?: EntryExports;
|
|
24
|
+
}
|
|
25
|
+
export interface BuildComponentApiDocumentOptions {
|
|
26
|
+
/** Entry-barrel exports when `documentExports` is on. */
|
|
27
|
+
entryExports?: EntryExports;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Builds the canonical document for a component collection: components
|
|
31
|
+
* sorted alphabetically by `moduleName`, with the Node-only `diagnostics`
|
|
32
|
+
* field stripped.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildComponentApiDocument(components: ComponentDocs, options?: BuildComponentApiDocumentOptions): ComponentApiDocument;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { DeprecatedValue } from "../ComponentParser";
|
|
1
2
|
export declare const BACKTICK_REGEX: RegExp;
|
|
2
3
|
export declare const WHITESPACE_REGEX: RegExp;
|
|
3
4
|
export declare const MD_TYPE_UNDEFINED = "--";
|
|
4
5
|
export declare const PROP_TABLE_HEADER = "| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |\n| :- | :- | :- | :- | :- | :- | :- | :- |\n";
|
|
5
|
-
export declare const SLOT_TABLE_HEADER = "| Slot name | Default | Props | Fallback |\n| :- | :- | :- | :- |\n";
|
|
6
|
+
export declare const SLOT_TABLE_HEADER = "| Slot name | Default | Props | Fallback | Description |\n| :- | :- | :- | :- | :- |\n";
|
|
6
7
|
export declare const EVENT_TABLE_HEADER = "| Event name | Type | Detail | Description |\n| :- | :- | :- | :- |\n";
|
|
8
|
+
export declare const EXPORT_TABLE_HEADER = "| Name | Kind | Type | Description |\n| :- | :- | :- | :- |\n";
|
|
7
9
|
/**
|
|
8
10
|
* Escape `|` and wrap a prop type for markdown table cells.
|
|
9
11
|
*
|
|
@@ -33,6 +35,16 @@ export declare function escapeHtml(text: string): string;
|
|
|
33
35
|
* ```
|
|
34
36
|
*/
|
|
35
37
|
export declare function formatPropValue(value: string | undefined): string;
|
|
38
|
+
/**
|
|
39
|
+
* Strike through deprecated prop, slot, and event names in markdown tables.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* formatNameWithDeprecation("size", "use width")
|
|
44
|
+
* // Returns: "<s>size</s><br />**Deprecated**: use width"
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatNameWithDeprecation(name: string, deprecated: DeprecatedValue | undefined): string;
|
|
36
48
|
/**
|
|
37
49
|
* Format a prop description; newlines become `<br />`.
|
|
38
50
|
*
|
|
@@ -63,6 +75,23 @@ export declare function formatSlotProps(props?: string): string;
|
|
|
63
75
|
* ```
|
|
64
76
|
*/
|
|
65
77
|
export declare function formatSlotFallback(fallback?: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Format a slot/snippet description plus pass-through JSDoc tags for markdown
|
|
80
|
+
* table cells. Newlines become `<br />` and `<`, `>`, `|` are escaped so the
|
|
81
|
+
* content stays inside a single table cell.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* formatSlotDescription("Header content.", [{ name: "since", body: "1.0.0" }])
|
|
86
|
+
* // Returns: "Header content.<br />@since 1.0.0"
|
|
87
|
+
* formatSlotDescription(undefined, [])
|
|
88
|
+
* // Returns: "--"
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function formatSlotDescription(description?: string, tags?: Array<{
|
|
92
|
+
name: string;
|
|
93
|
+
body: string;
|
|
94
|
+
}>): string;
|
|
66
95
|
/**
|
|
67
96
|
* Format event detail types for markdown table cells.
|
|
68
97
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EntryExports } from "../parse-entry-exports";
|
|
1
2
|
import type { ComponentDocs } from "../plugin";
|
|
2
3
|
import type { AppendType } from "./MarkdownWriterBase";
|
|
3
4
|
/** Minimal markdown writer surface used by JSON and browser renderers. */
|
|
@@ -5,5 +6,5 @@ interface MarkdownDocument {
|
|
|
5
6
|
append(type: AppendType, raw?: string): MarkdownDocument;
|
|
6
7
|
tableOfContents(): MarkdownDocument;
|
|
7
8
|
}
|
|
8
|
-
export declare function renderComponentsToMarkdown(document: MarkdownDocument, components: ComponentDocs): void;
|
|
9
|
+
export declare function renderComponentsToMarkdown(document: MarkdownDocument, components: ComponentDocs, entryExports?: EntryExports): void;
|
|
9
10
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentDocs } from "../plugin";
|
|
2
|
+
/** Which component set a writer expects: exported-only, or every discovered component. */
|
|
3
|
+
export type WriterComponentSet = "exported" | "all";
|
|
4
|
+
/**
|
|
5
|
+
* A pluggable output format. Built-in writers (`json`, `markdown`, `types`)
|
|
6
|
+
* register themselves under these names; third parties can `registerWriter`
|
|
7
|
+
* their own to add new output formats without a core PR.
|
|
8
|
+
*/
|
|
9
|
+
export interface OutputWriter<TOptions = unknown> {
|
|
10
|
+
name: string;
|
|
11
|
+
/** Which component set this writer expects. @default "exported" */
|
|
12
|
+
componentSet?: WriterComponentSet;
|
|
13
|
+
write(components: ComponentDocs, options: TOptions): Promise<unknown> | unknown;
|
|
14
|
+
}
|
|
15
|
+
export declare function registerWriter<TOptions = unknown>(writer: OutputWriter<TOptions>): void;
|
|
16
|
+
export declare function getWriter(name: string): OutputWriter<unknown> | undefined;
|
|
17
|
+
export declare function listWriters(): OutputWriter<unknown>[];
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { EntryExports } from "../parse-entry-exports";
|
|
1
2
|
import type { ComponentDocs } from "../plugin";
|
|
2
3
|
export interface WriteJsonOptions {
|
|
3
4
|
input: string;
|
|
4
5
|
inputDir: string;
|
|
5
6
|
outFile: string;
|
|
6
7
|
outDir?: string;
|
|
8
|
+
/** Entry-barrel exports when `documentExports` is on. */
|
|
9
|
+
entryExports?: EntryExports;
|
|
7
10
|
}
|
|
8
11
|
/**
|
|
9
12
|
* Writes component documentation to JSON format.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { EntryExports } from "../parse-entry-exports";
|
|
1
2
|
import type { ComponentDocs } from "../plugin";
|
|
2
3
|
import WriterMarkdown, { type AppendType } from "./WriterMarkdown";
|
|
3
4
|
export interface WriteMarkdownOptions {
|
|
4
5
|
write?: boolean;
|
|
5
6
|
outFile: string;
|
|
7
|
+
/** Entry-barrel exports when `documentExports` is on. */
|
|
8
|
+
entryExports?: EntryExports;
|
|
6
9
|
onAppend?: (type: AppendType, document: WriterMarkdown, components: ComponentDocs) => void;
|
|
7
10
|
}
|
|
8
11
|
/**
|