fumadocs-typescript 4.0.14 → 5.0.1

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.
@@ -1,117 +0,0 @@
1
- import { Project, Type, ExportedDeclarations, Symbol } from 'ts-morph';
2
-
3
- interface TypescriptConfig {
4
- files?: string[];
5
- tsconfigPath?: string;
6
- /** A root directory to resolve relative path entries in the config file to. e.g. outDir */
7
- basePath?: string;
8
- }
9
- declare function createProject(options?: TypescriptConfig): Project;
10
-
11
- interface BaseTypeTableProps {
12
- /**
13
- * The path to source TypeScript file.
14
- */
15
- path?: string;
16
- /**
17
- * Exported type name to generate from.
18
- */
19
- name?: string;
20
- /**
21
- * Set the type to generate from.
22
- *
23
- * When used with `name`, it generates the type with `name` as export name.
24
- *
25
- * ```ts
26
- * export const myName = MyType;
27
- * ```
28
- *
29
- * When `type` contains multiple lines, `export const` is not added.
30
- * You need to export it manually, and specify the type name with `name`.
31
- *
32
- * ```tsx
33
- * <AutoTypeTable
34
- * path="./file.ts"
35
- * type={`import { ReactNode } from "react"
36
- * export const MyName = ReactNode`}
37
- * name="MyName"
38
- * />
39
- * ```
40
- */
41
- type?: string;
42
- }
43
- interface GenerateTypeTableOptions extends GenerateOptions {
44
- /**
45
- * base path to resolve `path` prop
46
- */
47
- basePath?: string;
48
- }
49
-
50
- interface GeneratedDoc {
51
- name: string;
52
- description: string;
53
- entries: DocEntry[];
54
- }
55
- interface DocEntry {
56
- name: string;
57
- description: string;
58
- type: string;
59
- simplifiedType: string;
60
- tags: RawTag[];
61
- required: boolean;
62
- deprecated: boolean;
63
- }
64
- interface RawTag {
65
- name: string;
66
- text: string;
67
- }
68
- interface EntryContext {
69
- program: Project;
70
- transform?: Transformer;
71
- type: Type;
72
- declaration: ExportedDeclarations;
73
- }
74
- type Transformer = (this: EntryContext, entry: DocEntry, propertyType: Type, propertySymbol: Symbol) => void;
75
- interface GenerateOptions {
76
- /**
77
- * Allow fields with `@internal` tag
78
- *
79
- * @defaultValue false
80
- */
81
- allowInternal?: boolean;
82
- /**
83
- * Modify output property entry
84
- */
85
- transform?: Transformer;
86
- }
87
- type Generator = ReturnType<typeof createGenerator>;
88
- interface GeneratorOptions extends TypescriptConfig {
89
- /**
90
- * cache results, note that some options are not marked as dependency.
91
- *
92
- * @defaultValue fs
93
- */
94
- cache?: 'fs' | false;
95
- project?: Project;
96
- }
97
- declare function createGenerator(config?: GeneratorOptions | Project): {
98
- generateDocumentation(file: {
99
- path: string;
100
- content?: string;
101
- }, name: string | undefined, options?: GenerateOptions): GeneratedDoc[];
102
- generateTypeTable(props: BaseTypeTableProps, options?: GenerateTypeTableOptions): Promise<GeneratedDoc[]>;
103
- };
104
- /**
105
- * Generate documentation for properties in an exported type/interface
106
- *
107
- * @deprecated use `createGenerator` instead
108
- */
109
- declare function generateDocumentation(file: string, name: string | undefined, content: string, options?: GenerateOptions & {
110
- /**
111
- * Typescript configurations
112
- */
113
- config?: TypescriptConfig;
114
- project?: Project;
115
- }): GeneratedDoc[];
116
-
117
- export { type BaseTypeTableProps as B, type DocEntry as D, type GenerateOptions as G, type RawTag as R, type GeneratedDoc as a, type Generator as b, type GenerateTypeTableOptions as c, createProject as d, type GeneratorOptions as e, createGenerator as f, generateDocumentation as g };
@@ -1,132 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
-
53
- // src/markdown.ts
54
- import { remark } from "remark";
55
- import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
56
- import {
57
- rehypeCode
58
- } from "fumadocs-core/mdx-plugins/rehype-code";
59
- import remarkRehype from "remark-rehype";
60
- import { highlightHast } from "fumadocs-core/highlight";
61
- var shikiOptions = {
62
- lazy: true,
63
- themes: {
64
- light: "github-light",
65
- dark: "github-dark"
66
- }
67
- };
68
- var processor = remark().use(remarkGfm).use(remarkRehype).use(rehypeCode, shikiOptions);
69
- function renderTypeToHast(type) {
70
- return __async(this, null, function* () {
71
- const nodes = yield highlightHast(type, __spreadProps(__spreadValues({}, shikiOptions), {
72
- lang: "ts",
73
- structure: "inline"
74
- }));
75
- return {
76
- type: "element",
77
- tagName: "span",
78
- properties: {
79
- class: "shiki"
80
- },
81
- children: [
82
- {
83
- type: "element",
84
- tagName: "code",
85
- properties: {},
86
- children: nodes.children
87
- }
88
- ]
89
- };
90
- });
91
- }
92
- function renderMarkdownToHast(md) {
93
- return __async(this, null, function* () {
94
- md = md.replace(new RegExp("{@link (?<link>[^}]*)}", "g"), "$1");
95
- return processor.run(processor.parse(md));
96
- });
97
- }
98
-
99
- // src/lib/parse-tags.ts
100
- function parseTags(tags) {
101
- var _a;
102
- const typed = {};
103
- for (const { name: key, text } of tags) {
104
- if (key === "default" || key === "defaultValue") {
105
- typed.default = text;
106
- continue;
107
- }
108
- if (key === "param") {
109
- const [param, description] = text.split("-", 2);
110
- (_a = typed.params) != null ? _a : typed.params = [];
111
- typed.params.push({
112
- name: param.trim(),
113
- description: description.trim()
114
- });
115
- continue;
116
- }
117
- if (key === "returns") {
118
- typed.returns = text;
119
- }
120
- }
121
- return typed;
122
- }
123
-
124
- export {
125
- __spreadValues,
126
- __spreadProps,
127
- __objRest,
128
- __async,
129
- renderTypeToHast,
130
- renderMarkdownToHast,
131
- parseTags
132
- };