fumadocs-core 8.0.0 → 8.1.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.
- package/dist/mdx-plugins/index.d.ts +2 -2
- package/dist/mdx-plugins/index.js +3 -3
- package/dist/server/index.d.ts +1 -1
- package/dist/typescript.d.ts +37 -0
- package/dist/typescript.js +90 -0
- package/package.json +12 -6
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { Options as RemarkGfmOptions, default as remarkGfm } from 'remark-gfm';
|
|
2
2
|
import { Root } from 'hast';
|
|
3
|
-
import {
|
|
3
|
+
import { RehypeShikiOptions } from '@shikijs/rehype';
|
|
4
4
|
import { Processor, Transformer } from 'unified';
|
|
5
5
|
import { Root as Root$1 } from 'mdast';
|
|
6
6
|
export { S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-RwYPDA6M.js';
|
|
7
7
|
|
|
8
8
|
declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
|
|
9
|
-
type RehypeCodeOptions =
|
|
9
|
+
type RehypeCodeOptions = RehypeShikiOptions & {
|
|
10
10
|
/**
|
|
11
11
|
* Filter meta string before processing
|
|
12
12
|
*/
|
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
} from "remark-gfm";
|
|
18
18
|
|
|
19
19
|
// src/mdx-plugins/rehype-code.ts
|
|
20
|
-
import
|
|
20
|
+
import rehypeShiki from "@shikijs/rehype";
|
|
21
21
|
import {
|
|
22
22
|
transformerNotationHighlight,
|
|
23
23
|
transformerNotationWordHighlight
|
|
24
|
-
} from "
|
|
24
|
+
} from "@shikijs/transformers";
|
|
25
25
|
|
|
26
26
|
// src/mdx-plugins/hast-utils.ts
|
|
27
27
|
function visit2(node, tagNames, handler) {
|
|
@@ -94,7 +94,7 @@ function rehypeCode(options = {}) {
|
|
|
94
94
|
...codeOptions.transformers
|
|
95
95
|
];
|
|
96
96
|
const prefix = "language-";
|
|
97
|
-
const transformer =
|
|
97
|
+
const transformer = rehypeShiki.call(this, codeOptions);
|
|
98
98
|
return (root, vfile) => __async(this, null, function* () {
|
|
99
99
|
visit2(root, ["pre"], (element) => {
|
|
100
100
|
var _a;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
|
|
3
|
+
interface DocEntry {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
type: string;
|
|
7
|
+
default?: string;
|
|
8
|
+
}
|
|
9
|
+
interface Context {
|
|
10
|
+
program: ts.Program;
|
|
11
|
+
checker: ts.TypeChecker;
|
|
12
|
+
options: Options;
|
|
13
|
+
}
|
|
14
|
+
interface EntryContext extends Context {
|
|
15
|
+
type: ts.Type;
|
|
16
|
+
symbol: ts.Symbol;
|
|
17
|
+
}
|
|
18
|
+
interface Options {
|
|
19
|
+
file: string;
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* Modify output property entry
|
|
23
|
+
*/
|
|
24
|
+
transform?: (this: EntryContext, entry: DocEntry, propertyType: ts.Type, propertySymbol: ts.Symbol) => void;
|
|
25
|
+
options?: Partial<{
|
|
26
|
+
files: string[];
|
|
27
|
+
tsconfigPath: string;
|
|
28
|
+
/** A root directory to resolve relative path entries in the config file to. e.g. outDir */
|
|
29
|
+
basePath: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Generate documentation for properties in an exported type/interface
|
|
34
|
+
*/
|
|
35
|
+
declare function generateDocumentation(options: Options): DocEntry[];
|
|
36
|
+
|
|
37
|
+
export { type DocEntry, type Options, generateDocumentation };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
5
|
+
|
|
6
|
+
// src/typescript.ts
|
|
7
|
+
import * as ts from "typescript";
|
|
8
|
+
var cache = /* @__PURE__ */ new Map();
|
|
9
|
+
function getProgram(options = {}) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const key = JSON.stringify(options);
|
|
12
|
+
const cached = cache.get(key);
|
|
13
|
+
if (cached)
|
|
14
|
+
return cached;
|
|
15
|
+
const configFile = ts.readJsonConfigFile(
|
|
16
|
+
(_a = options.tsconfigPath) != null ? _a : "./tsconfig.json",
|
|
17
|
+
(path) => ts.sys.readFile(path)
|
|
18
|
+
);
|
|
19
|
+
const parsed = ts.parseJsonSourceFileConfigFileContent(
|
|
20
|
+
configFile,
|
|
21
|
+
ts.sys,
|
|
22
|
+
(_b = options.basePath) != null ? _b : "./"
|
|
23
|
+
);
|
|
24
|
+
const program = ts.createProgram({
|
|
25
|
+
rootNames: (_c = options.files) != null ? _c : parsed.fileNames,
|
|
26
|
+
options: __spreadProps(__spreadValues({}, parsed.options), {
|
|
27
|
+
incremental: false
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
cache.set(key, program);
|
|
31
|
+
return program;
|
|
32
|
+
}
|
|
33
|
+
function getExportedSymbol({
|
|
34
|
+
options: { file, name },
|
|
35
|
+
checker,
|
|
36
|
+
program
|
|
37
|
+
}) {
|
|
38
|
+
const sourceFile = program.getSourceFile(file);
|
|
39
|
+
if (!sourceFile)
|
|
40
|
+
return;
|
|
41
|
+
const fileSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
42
|
+
if (!fileSymbol)
|
|
43
|
+
return;
|
|
44
|
+
const exports = checker.getExportsOfModule(fileSymbol);
|
|
45
|
+
return exports.find((e) => e.getEscapedName().toString() === name);
|
|
46
|
+
}
|
|
47
|
+
function generateDocumentation(options) {
|
|
48
|
+
const program = getProgram(options.options);
|
|
49
|
+
const checker = program.getTypeChecker();
|
|
50
|
+
const ctx = {
|
|
51
|
+
checker,
|
|
52
|
+
program,
|
|
53
|
+
options
|
|
54
|
+
};
|
|
55
|
+
const symbol = getExportedSymbol(ctx);
|
|
56
|
+
if (!symbol)
|
|
57
|
+
return [];
|
|
58
|
+
const type = checker.getDeclaredTypeOfSymbol(symbol);
|
|
59
|
+
const entryContext = __spreadProps(__spreadValues({}, ctx), {
|
|
60
|
+
type,
|
|
61
|
+
symbol
|
|
62
|
+
});
|
|
63
|
+
return type.getProperties().map(getDocEntry.bind(entryContext));
|
|
64
|
+
}
|
|
65
|
+
function getDocEntry(prop) {
|
|
66
|
+
var _a;
|
|
67
|
+
const subType = this.checker.getTypeOfSymbol(prop);
|
|
68
|
+
const defaultJsDocTag = prop.getJsDocTags().find((info) => ["default", "defaultValue"].includes(info.name));
|
|
69
|
+
let typeName = this.checker.typeToString(
|
|
70
|
+
subType.getNonNullableType(),
|
|
71
|
+
void 0,
|
|
72
|
+
ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
|
|
73
|
+
);
|
|
74
|
+
if (subType.aliasSymbol && !subType.aliasTypeArguments) {
|
|
75
|
+
typeName = subType.aliasSymbol.escapedName.toString();
|
|
76
|
+
}
|
|
77
|
+
const entry = {
|
|
78
|
+
name: prop.getName(),
|
|
79
|
+
description: ts.displayPartsToString(
|
|
80
|
+
prop.getDocumentationComment(this.checker)
|
|
81
|
+
),
|
|
82
|
+
default: (defaultJsDocTag == null ? void 0 : defaultJsDocTag.text) ? ts.displayPartsToString(defaultJsDocTag.text) : void 0,
|
|
83
|
+
type: typeName
|
|
84
|
+
};
|
|
85
|
+
(_a = this.options.transform) == null ? void 0 : _a.call(this, entry, subType, prop);
|
|
86
|
+
return entry;
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
generateDocumentation
|
|
90
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.1",
|
|
4
4
|
"description": "The library for building a documentation website in Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
7
7
|
"Docs"
|
|
8
8
|
],
|
|
9
9
|
"homepage": "https://fumadocs.vercel.app",
|
|
10
|
-
"repository": "github:fuma-nama/
|
|
10
|
+
"repository": "github:fuma-nama/fumadocs",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Fuma Nama",
|
|
13
13
|
"type": "module",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"import": "./dist/link.js",
|
|
45
45
|
"types": "./dist/link.d.ts"
|
|
46
46
|
},
|
|
47
|
+
"./typescript": {
|
|
48
|
+
"import": "./dist/typescript.js",
|
|
49
|
+
"types": "./dist/typescript.d.ts"
|
|
50
|
+
},
|
|
47
51
|
"./middleware": {
|
|
48
52
|
"import": "./dist/middleware.js",
|
|
49
53
|
"types": "./dist/middleware.d.ts"
|
|
@@ -72,6 +76,9 @@
|
|
|
72
76
|
"toc": [
|
|
73
77
|
"./dist/toc.d.ts"
|
|
74
78
|
],
|
|
79
|
+
"typescript": [
|
|
80
|
+
"./dist/typescript.d.ts"
|
|
81
|
+
],
|
|
75
82
|
"search/client": [
|
|
76
83
|
"./dist/search/client.d.ts"
|
|
77
84
|
],
|
|
@@ -109,17 +116,17 @@
|
|
|
109
116
|
],
|
|
110
117
|
"dependencies": {
|
|
111
118
|
"@formatjs/intl-localematcher": "^0.5.0",
|
|
119
|
+
"@shikijs/rehype": "^1.0.0-beta.0",
|
|
120
|
+
"@shikijs/transformers": "^1.0.0-beta.0",
|
|
112
121
|
"flexsearch": "0.7.21",
|
|
113
122
|
"github-slugger": "^2.0.0",
|
|
114
123
|
"negotiator": "^0.6.3",
|
|
115
124
|
"react-remove-scroll": "^2.5.6",
|
|
116
|
-
"rehype-shikiji": "^0.10.0",
|
|
117
125
|
"remark": "^15.0.0",
|
|
118
126
|
"remark-gfm": "^4.0.0",
|
|
119
127
|
"remark-mdx": "^3.0.0",
|
|
120
128
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
121
|
-
"
|
|
122
|
-
"shikiji-transformers": "^0.10.0",
|
|
129
|
+
"shiki": "^1.0.0-beta.0",
|
|
123
130
|
"swr": "^2.2.2",
|
|
124
131
|
"unist-util-visit": "^5.0.0"
|
|
125
132
|
},
|
|
@@ -152,7 +159,6 @@
|
|
|
152
159
|
"clean": "rimraf dist",
|
|
153
160
|
"dev": "tsup --watch",
|
|
154
161
|
"lint": "eslint .",
|
|
155
|
-
"test": "vitest",
|
|
156
162
|
"types:check": "tsc --noEmit"
|
|
157
163
|
}
|
|
158
164
|
}
|