fumadocs-typescript 5.0.0 → 5.1.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,114 @@
1
+ import { ExportedDeclarations, Project, Symbol, Type } from "ts-morph";
2
+
3
+ //#region src/create-project.d.ts
4
+ interface TypescriptConfig {
5
+ files?: string[];
6
+ tsconfigPath?: string;
7
+ /** A root directory to resolve relative path entries in the config file to. e.g. outDir */
8
+ basePath?: string;
9
+ }
10
+ declare function createProject(options?: TypescriptConfig): Project;
11
+ //#endregion
12
+ //#region src/lib/type-table.d.ts
13
+ interface BaseTypeTableProps {
14
+ /**
15
+ * The path to source TypeScript file.
16
+ */
17
+ path?: string;
18
+ /**
19
+ * Exported type name to generate from.
20
+ */
21
+ name?: string;
22
+ /**
23
+ * Set the type to generate from.
24
+ *
25
+ * When used with `name`, it generates the type with `name` as export name.
26
+ *
27
+ * ```ts
28
+ * export const myName = MyType;
29
+ * ```
30
+ *
31
+ * When `type` contains multiple lines, `export const` is not added.
32
+ * You need to export it manually, and specify the type name with `name`.
33
+ *
34
+ * ```tsx
35
+ * <AutoTypeTable
36
+ * path="./file.ts"
37
+ * type={`import { ReactNode } from "react"
38
+ * export const MyName = ReactNode`}
39
+ * name="MyName"
40
+ * />
41
+ * ```
42
+ */
43
+ type?: string;
44
+ }
45
+ interface GenerateTypeTableOptions extends GenerateOptions {
46
+ /**
47
+ * base path to resolve `path` prop
48
+ */
49
+ basePath?: string;
50
+ }
51
+ //#endregion
52
+ //#region src/cache/index.d.ts
53
+ interface Cache {
54
+ read: (key: string) => unknown | undefined | Promise<unknown | undefined>;
55
+ write: (key: string, value: unknown) => void | Promise<void>;
56
+ }
57
+ //#endregion
58
+ //#region src/lib/base.d.ts
59
+ interface GeneratedDoc {
60
+ name: string;
61
+ description: string;
62
+ entries: DocEntry[];
63
+ }
64
+ interface DocEntry {
65
+ name: string;
66
+ description: string;
67
+ type: string;
68
+ simplifiedType: string;
69
+ tags: RawTag[];
70
+ required: boolean;
71
+ deprecated: boolean;
72
+ }
73
+ interface RawTag {
74
+ name: string;
75
+ text: string;
76
+ }
77
+ interface EntryContext {
78
+ program: Project;
79
+ transform?: Transformer;
80
+ type: Type;
81
+ declaration: ExportedDeclarations;
82
+ }
83
+ type Transformer = (this: EntryContext, entry: DocEntry, propertyType: Type, propertySymbol: Symbol) => void;
84
+ interface GenerateOptions {
85
+ /**
86
+ * Allow fields with `@internal` tag
87
+ *
88
+ * @defaultValue false
89
+ */
90
+ allowInternal?: boolean;
91
+ /**
92
+ * Modify output property entry
93
+ */
94
+ transform?: Transformer;
95
+ }
96
+ type Generator = ReturnType<typeof createGenerator>;
97
+ interface GeneratorOptions extends TypescriptConfig {
98
+ /**
99
+ * cache results, note that some options are not marked as dependency.
100
+ *
101
+ * @defaultValue false
102
+ */
103
+ cache?: Cache | false;
104
+ project?: Project;
105
+ }
106
+ declare function createGenerator(config?: GeneratorOptions | Project): {
107
+ generateDocumentation(file: {
108
+ path: string;
109
+ content?: string;
110
+ }, name: string | undefined, options?: GenerateOptions): Promise<GeneratedDoc[]>;
111
+ generateTypeTable(props: BaseTypeTableProps, options?: GenerateTypeTableOptions): Promise<GeneratedDoc[]>;
112
+ };
113
+ //#endregion
114
+ export { GeneratorOptions as a, Cache as c, createProject as d, Generator as i, BaseTypeTableProps as l, GenerateOptions as n, RawTag as o, GeneratedDoc as r, createGenerator as s, DocEntry as t, GenerateTypeTableOptions as u };
package/dist/index.d.ts CHANGED
@@ -1,36 +1,43 @@
1
- import { G as GenerateTypeTableOptions, a as Generator, B as BaseTypeTableProps, C as Cache } from './base-C72MF-7Q.js';
2
- export { D as DocEntry, d as GenerateOptions, b as GeneratedDoc, e as GeneratorOptions, R as RawTag, f as createGenerator, c as createProject } from './base-C72MF-7Q.js';
3
- import { Nodes } from 'hast';
4
- import { Root } from 'mdast';
5
- import { Transformer } from 'unified';
6
- import 'ts-morph';
7
-
8
- declare function renderTypeToHast(type: string): Promise<Nodes>;
9
- declare function renderMarkdownToHast(md: string): Promise<Nodes>;
1
+ import { a as GeneratorOptions, c as Cache, d as createProject, i as Generator, l as BaseTypeTableProps, n as GenerateOptions, o as RawTag, r as GeneratedDoc, s as createGenerator, t as DocEntry, u as GenerateTypeTableOptions } from "./base-Dvhn4vZx.js";
2
+ import { ResolvedShikiConfig } from "fumadocs-core/highlight/config";
3
+ import { Nodes } from "hast";
4
+ import { Root } from "mdast";
5
+ import { Transformer } from "unified";
10
6
 
7
+ //#region src/markdown.d.ts
8
+ interface MarkdownRenderer {
9
+ renderTypeToHast: (type: string) => Nodes | Promise<Nodes>;
10
+ renderMarkdownToHast: (md: string) => Nodes | Promise<Nodes>;
11
+ }
12
+ //#endregion
13
+ //#region src/lib/remark-auto-type-table.d.ts
11
14
  interface RemarkAutoTypeTableOptions {
12
- /**
13
- * @defaultValue 'auto-type-table'
14
- */
15
- name?: string;
16
- /**
17
- * @defaultValue 'TypeTable'
18
- */
19
- outputName?: string;
20
- renderMarkdown?: typeof renderMarkdownToHast;
21
- renderType?: typeof renderTypeToHast;
22
- /**
23
- * Customise type table generation
24
- */
25
- options?: GenerateTypeTableOptions;
26
- /**
27
- * generate required `value` property for `remark-stringify`
28
- */
29
- remarkStringify?: boolean;
30
- generator?: Generator;
15
+ /**
16
+ * @defaultValue 'auto-type-table'
17
+ */
18
+ name?: string;
19
+ /**
20
+ * @defaultValue 'TypeTable'
21
+ */
22
+ outputName?: string;
23
+ /**
24
+ * config for Shiki when using default `renderMarkdown` & `renderType`.
25
+ */
26
+ shiki?: ResolvedShikiConfig;
27
+ renderMarkdown?: MarkdownRenderer['renderMarkdownToHast'];
28
+ renderType?: MarkdownRenderer['renderTypeToHast'];
29
+ /**
30
+ * Customise type table generation
31
+ */
32
+ options?: GenerateTypeTableOptions;
33
+ /**
34
+ * generate required `value` property for `remark-stringify`
35
+ */
36
+ remarkStringify?: boolean;
37
+ generator?: Generator;
31
38
  }
32
39
  interface TypeTableProps extends BaseTypeTableProps {
33
- cwd?: true;
40
+ cwd?: true;
34
41
  }
35
42
  /**
36
43
  * Compile `auto-type-table` into Fumadocs UI compatible TypeTable
@@ -38,7 +45,8 @@ interface TypeTableProps extends BaseTypeTableProps {
38
45
  * MDX is required to use this plugin.
39
46
  */
40
47
  declare function remarkAutoTypeTable(config?: RemarkAutoTypeTableOptions): Transformer<Root, Root>;
41
-
48
+ //#endregion
49
+ //#region src/cache/fs-cache.d.ts
42
50
  declare function createFileSystemGeneratorCache(dir: string): Cache;
43
-
44
- export { Cache, Generator, type RemarkAutoTypeTableOptions, type TypeTableProps, createFileSystemGeneratorCache, remarkAutoTypeTable, renderMarkdownToHast };
51
+ //#endregion
52
+ export { Cache, DocEntry, GenerateOptions, GeneratedDoc, Generator, GeneratorOptions, type MarkdownRenderer, RawTag, RemarkAutoTypeTableOptions, TypeTableProps, createFileSystemGeneratorCache, createGenerator, createProject, remarkAutoTypeTable };