Skip to content

Commit f75287d

Browse files
committed
Migrate remarkDynamicContent and remarkInstall to docs generator
1 parent cfe7e08 commit f75287d

40 files changed

+672
-337
lines changed

.changeset/mighty-books-occur.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
"fumadocs-core": major
3+
"fumadocs-typescript": major
4+
---
5+
6+
**Introduce `fumadocs-docgen` package.**
7+
8+
Offer a better authoring experience for advanced use cases.
9+
10+
- Move `remark-dynamic-content` and `remark-install` plugins to the new package `fumadocs-docgen`.
11+
- Support Typescript generator by default
12+
13+
**Usage**
14+
15+
Add the `remarkDocGen` plugin to your remark plugins.
16+
17+
```ts
18+
import { remarkDocGen, fileGenerator } from "fumadocs-docgen";
19+
20+
remark().use(remarkDocGen, { generators: [fileGenerator()] })
21+
```
22+
23+
Generate docs with code blocks.
24+
25+
````mdx
26+
```json doc-gen:<generator>
27+
{
28+
// options
29+
}
30+
```
31+
````
32+
33+
**Migrate**
34+
35+
For `remarkDynamicContent`, enable `fileGenerator` and use this syntax:
36+
37+
````mdx
38+
```json doc-gen:file
39+
{
40+
"file": "./path/to/my-file.txt"
41+
}
42+
```
43+
````
44+
45+
For `remarkInstall`, it remains the same:
46+
47+
```ts
48+
import { remarkInstall } from "fumadocs-docgen"
49+
```

.changeset/strange-pumas-sit.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

apps/docs/content/docs/ui/index.mdx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ Make sure to wrap your content in the [Page](/docs/ui/blocks/page) component, th
9797
<Accordions>
9898
<Accordion title="Example with Fumadocs MDX">
9999

100-
```tsx title="app/docs/[[...slug]]/page.tsx"
101-
|reference:../../examples/next-mdx/app/docs/[[...slug]]/page.tsx|
100+
```json doc-gen:file
101+
{
102+
"file": "../../examples/next-mdx/app/docs/[[...slug]]/page.tsx",
103+
"codeblock": {
104+
"meta": "title=\"app/docs/[[...slug]]/page.tsx\""
105+
}
106+
}
102107
```
103108

104109
</Accordion>
@@ -111,8 +116,13 @@ By default, it uses the built-in document search based on Flexsearch. [Learn to
111116
<Accordions>
112117
<Accordion title="Example with Fumadocs MDX">
113118

114-
```tsx title="app/api/search/route.ts"
115-
|reference:../../examples/next-mdx/app/api/search/route.ts|
119+
```json doc-gen:file
120+
{
121+
"file": "../../examples/next-mdx/app/api/search/route.ts",
122+
"codeblock": {
123+
"meta": "title=\"app/api/search/route.ts\""
124+
}
125+
}
116126
```
117127

118128
</Accordion>

apps/docs/next.config.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import createBundleAnalyzer from '@next/bundle-analyzer';
22
import createMDX from 'fumadocs-mdx/config';
3+
import { rehypeCodeDefaultOptions } from 'fumadocs-core/mdx-plugins';
34
import {
4-
remarkDynamicContent,
5-
remarkInstall,
6-
rehypeCodeDefaultOptions,
75
remarkDocGen,
8-
} from 'fumadocs-core/mdx-plugins';
6+
remarkInstall,
7+
fileGenerator,
8+
typescriptGenerator,
9+
} from 'fumadocs-docgen';
910
import { transformerTwoslash } from 'fumadocs-twoslash';
1011
import rehypeKatex from 'rehype-katex';
11-
import { typescriptGen } from 'fumadocs-typescript';
1212
import remarkMath from 'remark-math';
1313

1414
const withAnalyzer = createBundleAnalyzer({
@@ -63,9 +63,8 @@ const withMDX = createMDX({
6363
lastModifiedTime: 'git',
6464
remarkPlugins: [
6565
remarkMath,
66-
remarkDynamicContent,
6766
[remarkInstall, { Tabs: 'InstallTabs' }],
68-
[remarkDocGen, { generators: [typescriptGen()] }],
67+
[remarkDocGen, { generators: [typescriptGenerator(), fileGenerator()] }],
6968
],
7069
rehypePlugins: (v) => [rehypeKatex, ...v],
7170
},

apps/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"algoliasearch": "^4.23.3",
1717
"class-variance-authority": "^0.7.0",
1818
"fumadocs-core": "workspace:*",
19+
"fumadocs-docgen": "workspace:^",
1920
"fumadocs-mdx": "workspace:*",
2021
"fumadocs-twoslash": "workspace:^",
2122
"fumadocs-typescript": "workspace:^",

packages/core/src/mdx-plugins/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ export {
44
} from 'remark-gfm';
55
export * from './rehype-code';
66
export * from './remark-image';
7-
export * from './remark-dynamic-content';
87
export * from './remark-structure';
98
export * from './remark-heading';
10-
export * from './remark-install';
11-
export * from './remark-doc-gen';

packages/core/src/mdx-plugins/remark-doc-gen.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

packages/core/src/mdx-plugins/remark-dynamic-content.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

packages/core/test/fixtures/remark-dynamic-content.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/core/test/fixtures/remark-dynamic-content.output.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)