fumadocs-typescript 1.0.0 → 1.0.2
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.
|
@@ -5,6 +5,10 @@ interface TypescriptConfig {
|
|
|
5
5
|
tsconfigPath?: string;
|
|
6
6
|
/** A root directory to resolve relative path entries in the config file to. e.g. outDir */
|
|
7
7
|
basePath?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Default lib directory, use `./node_modules/typescript/lib` if not specified
|
|
10
|
+
*/
|
|
11
|
+
getDefaultLibLocation?: (() => string) | 'default';
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
interface GeneratedDoc {
|
|
@@ -21,15 +25,22 @@ interface DocEntry {
|
|
|
21
25
|
interface EntryContext {
|
|
22
26
|
program: ts.Program;
|
|
23
27
|
checker: ts.TypeChecker;
|
|
24
|
-
|
|
28
|
+
transform?: Transformer;
|
|
25
29
|
type: ts.Type;
|
|
26
30
|
symbol: ts.Symbol;
|
|
27
31
|
}
|
|
32
|
+
type Transformer = (this: EntryContext, entry: DocEntry, propertyType: ts.Type, propertySymbol: ts.Symbol) => void;
|
|
28
33
|
interface GenerateOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Allow fields with `@internal` tag
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue false
|
|
38
|
+
*/
|
|
39
|
+
allowInternal?: boolean;
|
|
29
40
|
/**
|
|
30
41
|
* Modify output property entry
|
|
31
42
|
*/
|
|
32
|
-
transform?:
|
|
43
|
+
transform?: Transformer;
|
|
33
44
|
}
|
|
34
45
|
interface GenerateDocumentationOptions extends GenerateOptions {
|
|
35
46
|
/**
|
|
@@ -41,6 +52,6 @@ interface GenerateDocumentationOptions extends GenerateOptions {
|
|
|
41
52
|
* Generate documentation for properties in an exported type/interface
|
|
42
53
|
*/
|
|
43
54
|
declare function generateDocumentation(file: string, name: string, options?: GenerateDocumentationOptions): GeneratedDoc | undefined;
|
|
44
|
-
declare function generate(program: ts.Program, symbol: ts.Symbol,
|
|
55
|
+
declare function generate(program: ts.Program, symbol: ts.Symbol, { allowInternal, transform }: GenerateOptions): GeneratedDoc;
|
|
45
56
|
|
|
46
57
|
export { type DocEntry as D, type GenerateOptions as G, type TypescriptConfig as T, type GeneratedDoc as a, type GenerateDocumentationOptions as b, generate as c, generateDocumentation as g };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
14
|
}
|
|
17
15
|
return a;
|
|
18
16
|
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
17
|
var __objRest = (source, exclude) => {
|
|
21
18
|
var target = {};
|
|
22
19
|
for (var prop in source)
|
|
@@ -30,7 +27,7 @@ var __objRest = (source, exclude) => {
|
|
|
30
27
|
return target;
|
|
31
28
|
};
|
|
32
29
|
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((
|
|
30
|
+
return new Promise((resolve2, reject) => {
|
|
34
31
|
var fulfilled = (value) => {
|
|
35
32
|
try {
|
|
36
33
|
step(generator.next(value));
|
|
@@ -45,7 +42,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
45
42
|
reject(e);
|
|
46
43
|
}
|
|
47
44
|
};
|
|
48
|
-
var step = (x) => x.done ?
|
|
45
|
+
var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
46
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
47
|
});
|
|
51
48
|
};
|
|
@@ -54,6 +51,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
54
51
|
import ts2 from "typescript";
|
|
55
52
|
|
|
56
53
|
// src/program.ts
|
|
54
|
+
import * as path from "path";
|
|
57
55
|
import ts from "typescript";
|
|
58
56
|
var cache = /* @__PURE__ */ new Map();
|
|
59
57
|
function getFileSymbol(file, program) {
|
|
@@ -64,25 +62,31 @@ function getFileSymbol(file, program) {
|
|
|
64
62
|
return checker.getSymbolAtLocation(sourceFile);
|
|
65
63
|
}
|
|
66
64
|
function getProgram(options = {}) {
|
|
67
|
-
var _a, _b, _c;
|
|
65
|
+
var _a, _b, _c, _d;
|
|
68
66
|
const key = JSON.stringify(options);
|
|
69
67
|
const cached = cache.get(key);
|
|
70
68
|
if (cached)
|
|
71
69
|
return cached;
|
|
72
70
|
const configFile = ts.readJsonConfigFile(
|
|
73
71
|
(_a = options.tsconfigPath) != null ? _a : "./tsconfig.json",
|
|
74
|
-
(
|
|
72
|
+
(p) => ts.sys.readFile(p)
|
|
75
73
|
);
|
|
76
74
|
const parsed = ts.parseJsonSourceFileConfigFileContent(
|
|
77
75
|
configFile,
|
|
78
76
|
ts.sys,
|
|
79
77
|
(_b = options.basePath) != null ? _b : "./"
|
|
80
78
|
);
|
|
79
|
+
parsed.options.incremental = false;
|
|
80
|
+
const host = ts.createCompilerHost(parsed.options);
|
|
81
|
+
if (options.getDefaultLibLocation !== "default") {
|
|
82
|
+
host.getDefaultLibLocation = (_c = options.getDefaultLibLocation) != null ? _c : () => path.resolve("./node_modules/typescript/lib");
|
|
83
|
+
}
|
|
81
84
|
const program = ts.createProgram({
|
|
82
|
-
rootNames: (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
rootNames: (_d = options.files) != null ? _d : parsed.fileNames,
|
|
86
|
+
host,
|
|
87
|
+
options: parsed.options,
|
|
88
|
+
configFileParsingDiagnostics: parsed.errors,
|
|
89
|
+
projectReferences: parsed.projectReferences
|
|
86
90
|
});
|
|
87
91
|
cache.set(key, program);
|
|
88
92
|
return program;
|
|
@@ -99,12 +103,12 @@ function generateDocumentation(file, name, options = {}) {
|
|
|
99
103
|
return;
|
|
100
104
|
return generate(program, symbol, options);
|
|
101
105
|
}
|
|
102
|
-
function generate(program, symbol,
|
|
106
|
+
function generate(program, symbol, { allowInternal = false, transform }) {
|
|
103
107
|
const checker = program.getTypeChecker();
|
|
104
108
|
const type = checker.getDeclaredTypeOfSymbol(symbol);
|
|
105
109
|
const entryContext = {
|
|
106
110
|
checker,
|
|
107
|
-
|
|
111
|
+
transform,
|
|
108
112
|
program,
|
|
109
113
|
type,
|
|
110
114
|
symbol
|
|
@@ -114,12 +118,12 @@ function generate(program, symbol, options) {
|
|
|
114
118
|
description: ts2.displayPartsToString(
|
|
115
119
|
symbol.getDocumentationComment(checker)
|
|
116
120
|
),
|
|
117
|
-
entries: type.getProperties().map((prop) => getDocEntry(prop, entryContext))
|
|
121
|
+
entries: type.getProperties().map((prop) => getDocEntry(prop, entryContext)).filter((entry) => allowInternal || !("internal" in entry.tags))
|
|
118
122
|
};
|
|
119
123
|
}
|
|
120
124
|
function getDocEntry(prop, context) {
|
|
121
|
-
var _a, _b
|
|
122
|
-
const { checker,
|
|
125
|
+
var _a, _b;
|
|
126
|
+
const { checker, transform } = context;
|
|
123
127
|
const subType = checker.getTypeOfSymbol(prop);
|
|
124
128
|
const tags = Object.fromEntries(
|
|
125
129
|
prop.getJsDocTags().map((tag) => [tag.name, ts2.displayPartsToString(tag.text)])
|
|
@@ -141,7 +145,7 @@ function getDocEntry(prop, context) {
|
|
|
141
145
|
tags,
|
|
142
146
|
type: typeName
|
|
143
147
|
};
|
|
144
|
-
|
|
148
|
+
transform == null ? void 0 : transform.call(context, entry, subType, prop);
|
|
145
149
|
return entry;
|
|
146
150
|
}
|
|
147
151
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GenerateOptions, T as TypescriptConfig, a as GeneratedDoc, D as DocEntry } from './base-
|
|
2
|
-
export { b as GenerateDocumentationOptions, c as generate, g as generateDocumentation } from './base-
|
|
1
|
+
import { G as GenerateOptions, T as TypescriptConfig, a as GeneratedDoc, D as DocEntry } from './base-3iGxlbJG.js';
|
|
2
|
+
export { b as GenerateDocumentationOptions, c as generate, g as generateDocumentation } from './base-3iGxlbJG.js';
|
|
3
3
|
import fg from 'fast-glob';
|
|
4
4
|
import 'typescript';
|
|
5
5
|
|
package/dist/index.js
CHANGED
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GenerateOptions } from '../base-
|
|
1
|
+
import { G as GenerateOptions } from '../base-3iGxlbJG.js';
|
|
2
2
|
import 'typescript';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -10,6 +10,6 @@ declare function AutoTypeTable({ path, name, options, }: {
|
|
|
10
10
|
path: string;
|
|
11
11
|
name: string;
|
|
12
12
|
options?: GenerateOptions;
|
|
13
|
-
}):
|
|
13
|
+
}): React.ReactElement;
|
|
14
14
|
|
|
15
15
|
export { AutoTypeTable };
|
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateDocumentation
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-KXYVJC2E.js";
|
|
4
4
|
|
|
5
5
|
// src/ui/auto-type-table.tsx
|
|
6
6
|
import { TypeTable } from "fumadocs-ui/components/type-table";
|
|
@@ -9,9 +9,7 @@ import { TypeTable } from "fumadocs-ui/components/type-table";
|
|
|
9
9
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
10
10
|
import { gfmFromMarkdown } from "mdast-util-gfm";
|
|
11
11
|
import { toHast } from "mdast-util-to-hast";
|
|
12
|
-
import {
|
|
13
|
-
toJsxRuntime
|
|
14
|
-
} from "hast-util-to-jsx-runtime";
|
|
12
|
+
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
15
13
|
import * as runtime from "react/jsx-runtime";
|
|
16
14
|
function renderMarkdown(md) {
|
|
17
15
|
const mdast = fromMarkdown(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-typescript",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Typescript Integration for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/hast": "^3.0.4",
|
|
46
46
|
"@types/mdast": "^4.0.3",
|
|
47
|
-
"@types/react": "18.2.
|
|
48
|
-
"@types/react-dom": "18.2.
|
|
47
|
+
"@types/react": "18.2.67",
|
|
48
|
+
"@types/react-dom": "18.2.22",
|
|
49
49
|
"eslint-config-custom": "0.0.0",
|
|
50
|
-
"fumadocs-ui": "10.
|
|
50
|
+
"fumadocs-ui": "10.1.0",
|
|
51
51
|
"tsconfig": "0.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|