Skip to content

Commit f6b77b8

Browse files
committed
feat(remark): remark restructure and improvements
1 parent 5d00946 commit f6b77b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2678
-4988
lines changed

.changeset/config.json

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"ignore": [
1414
"@devtools/*",
1515
"typedoc-plugin-frontmatter",
16-
"typedoc-plugin-remark",
1716
"typedoc-github-wiki-theme",
1817
"typedoc-gitlab-wiki-theme",
1918
"typedoc-vitepress-theme"

.changeset/fast-cases-film.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-remark': minor
3+
---
4+
5+
- Added support for conditional "remarkPlugins" configuration.

.changeset/three-rats-rule.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-remark': major
3+
---
4+
5+
- Removed "defaultRemarkPlugins" option - remark plugins are no longer added by default.

devtools/packages/prebuild-options/tasks/generate-models.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ ${name}?: ${getType(name, option, true)};`,
132132
${
133133
// this is a hack need to fix properly
134134
name === 'remarkPlugins'
135-
? 'export type RemarkPlugin = string | [string, Record<string, any>];'
135+
? `export type RemarkPlugin =
136+
| [string, Record<string, any>]
137+
| {
138+
applyTo: string[];
139+
plugins: [string, Record<string, any>][];
140+
};`
136141
: `export interface ${capitalize(name)} {
137142
${Object.entries(option.defaultValue as any)
138143
.map(

docs/app/layout.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { faMarkdown } from '@fortawesome/free-brands-svg-icons';
22
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3-
43
import { Footer, Layout, Navbar } from 'nextra-theme-docs';
54
import 'nextra-theme-docs/style.css';
65
import { Head } from 'nextra/components';

docs/content/docs/CHANGELOG.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## 4.6.2 (2025-04-09)
4+
5+
### Patch Changes
6+
7+
- Expose full declaration for returned union types ([#799](https://github.com/typedoc2md/typedoc-plugin-markdown/issues/799)).
8+
- Move isOptional flag inside backTicks ([#797](https://github.com/typedoc2md/typedoc-plugin-markdown/issues/797)) - thanks @LekoArts.
9+
- Added support for TypeDoc's v0.28.2 features `@group none`, `@category none` and `@disableGroups`.
10+
11+
## 4.6.1 (2025-04-02)
12+
13+
### Patch Changes
14+
15+
- Correctly render html table when interfacePropertiesFormat=htmlTable ([#794](https://github.com/typedoc2md/typedoc-plugin-markdown/issues/794)).
16+
- Correctly handle overloaded function display in list and table views ([#793](https://github.com/typedoc2md/typedoc-plugin-markdown/issues/793)).
17+
- Expose comments and signatures to index signature members.
18+
- Wrap default values in back ticks on table views to be consistent with list views.
19+
- Append semi colons to signature in code blocks.
20+
321
## 4.6.0 (2025-03-23)
422

523
This release continues the effort to further align to TypeDoc’s default theme, with improvements that make the plugin more consistent and predictable.
@@ -57,7 +75,7 @@ From a consumer perspective there should be no direct breaking change from the p
5775

5876
- As per TypeDoc model updates, Object literal Type Alias members are now rendered in groups ("Properties", "Methods") etc rather than under a single "Type Declaration" heading.
5977
- A new option "`typeAliasPropertiesFormat`" has been exposed to place properties rendered from the updated structure to a table format.
60-
- Type parameter list views have been updated to separate items with markdown headings for consistency and to improve readability when parameters have detailed explanations or complex properties. If type parameters are straightforward and few in number switching to `typeParametersFormat=table` might be preferable.
78+
- Type parameter list views have been updated to separate items with markdown headings for consistency and to improve readability when parameters have detailed explanations or complex properties. If type parameters are straightforward and few in number switching to `parametersFormat=table` might be preferable.
6179

6280
### Minor Changes
6381

docs/content/plugins/index.mdx

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Cards } from 'nextra/components';
2-
import Image from 'next/image';
3-
import { faFileLines, faBook } from '@fortawesome/free-solid-svg-icons';
1+
{/* prettier-ignore */}
2+
import { faBook, faFileLines } from '@fortawesome/free-solid-svg-icons';
43
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4+
import Image from 'next/image';
5+
import { Cards } from 'nextra/components';
56

67
# Utils & Themes
78

@@ -14,13 +15,22 @@ Utility plugins that can be used to provide metadata or adjust the output of the
1415
<Cards num={2}>
1516
<Cards.Card
1617
title="typedoc-plugin-frontmatter"
17-
icon={<FontAwesomeIcon icon={faBook} />}
18+
icon={
19+
<Image
20+
src="/logos/yaml-logo.png"
21+
alt="YAML Frontmatter"
22+
width={18}
23+
height={18}
24+
/>
25+
}
1826
arrow={true}
1927
href="plugins/frontmatter"
2028
/>
2129
<Cards.Card
2230
title="typedoc-plugin-remark"
23-
icon={<FontAwesomeIcon icon={faFileLines} />}
31+
icon={
32+
<Image src="/logos/remark-logo.png" alt="Remark" width={26} height={26} />
33+
}
2434
arrow={true}
2535
href="plugins/remark"
2636
/>

docs/content/plugins/remark/CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 2.0.0
4+
5+
This release includes fundamental architectural improvements and support for loading plugins conditionally based on page kind.
6+
7+
### Architectural Changes
8+
9+
- The plugin now constructs virtual files directly from TypeDoc's output before writing to disk rather than re-reading the corresponding file from the filesystem. This change improves performance and reliability by eliminating unnecessary disk I/O.
10+
- `remark-gfm`, `remark-frontmatter` and `remark-mdx` are no longer loaded by default.
11+
- `remark-frontmatter` is only loaded if a frontmatter YAML block is observed in the input document.
12+
- `remark-mdx` will need to be manually added if targetting MDX.
13+
- `remark-gfm` will need to be manually added if other plugins require it.
14+
- The plugin no longer adds a placeholder heading when `remark-toc` is added. Instead this logic has been decoupled in favour of the external plugin `remark-insert-headings`.
15+
316
## 1.3.0 (2025-03-16)
417

518
### Minor Changes

docs/content/plugins/remark/_meta.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export default {
22
'quick-start': '',
33
options: '',
4-
'useful-plugins': '',
4+
'remark-plugins-usage': '',
5+
'writing-a-plugin': '',
6+
CHANGELOG: '',
57
};

docs/content/plugins/remark/options.mdx

+37-30
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,55 @@ You can include any compatible [remark plugins](https://github.com/remarkjs/rema
1212

1313
Each plugin you wish to use must be installed individually.
1414

15-
Options can be provided as either an array of strings or an array of strings with associated options.
15+
You can apply plugins globally to all pages, or selectively to specific kinds of pages.
1616

17-
```json filename="typedoc.json"
17+
_Note: If a YAML frontmatter block is detected in the markdown, the [`remark-frontmatter`](https://github.com/remarkjs/remark-frontmatter) plugin will be automatically applied to parse it._
18+
19+
**Basic Usage (Global Plugins)**
20+
21+
To apply Remark plugins to all documentation pages:
22+
23+
Each item can be:
24+
25+
- A plugin name (string)
26+
- A tuple of [plugin, pluginOptions]
27+
28+
```json
1829
{
1930
"remarkPlugins": [
20-
"remark-github",
21-
[
22-
"remark-toc",
23-
{
24-
"maxDepth": 3
25-
}
26-
]
31+
"remark-mdx",
32+
["remark-github", { "repository": "myorg/myrepo" }]
2733
]
2834
}
2935
```
3036

31-
## defaultRemarkPlugins
37+
**Conditional Usage (Selective by Page Type)**
3238

33-
<Callout emoji="💡">
34-
A set of flags that control the enabling or disabling of remark plugins that
35-
are loaded by default.
36-
</Callout>
39+
To apply plugins only to specific page kinds, use grouped objects:
3740

38-
>
41+
```json
42+
{
43+
"remarkPlugins": [
44+
{
45+
"applyTo": "*",
46+
"plugins": ["remark-mdx"]
47+
},
48+
{
49+
"applyTo": ["Class", "Interface"],
50+
"plugins": ["remark-github", { "repository": "myorg/myrepo" }]
51+
}
52+
]
53+
}
54+
```
3955

40-
By default, the plugins [`remark-gfm`](https://github.com/remarkjs/remark-gfm), [`remark-frontmatter`](https://github.com/remarkjs/remark-frontmatter), and [`remark-mdx`](https://github.com/mdx-js/mdx/tree/main/packages/remark-mdx) are included, as these are considered the most common use cases.
56+
**Supported applyTo Values**
4157

42-
However, these plugins modify the default parsing behavior of remark, which may not be ideal for all scenarios.
58+
You can target specific pages using the `applyTo` field.
4359

44-
If you'd like to disable any of these default plugins, simply set the corresponding flag to `false`.
60+
The following applyTo values are supported:
4561

46-
```json filename="typedoc.json"
47-
{
48-
"defaultRemarkPlugins": {
49-
"gfm": true,
50-
"frontmatter": true,
51-
"mdx": true
52-
}
53-
}
54-
```
62+
- `"*"` applies to all pages
63+
- An array of on or more of the following page kinds: [`"Readme"`, `"Index"`, `"Module"`, `"Namespace"`, `"Document"`, `"Class"`, `"Interface"`, `"Enum"`, `"TypeAlias"`, `"Function"`, `"Variable"`].
5564

5665
## remarkStringifyOptions
5766

@@ -61,9 +70,7 @@ If you'd like to disable any of these default plugins, simply set the correspond
6170
6271
Under the hood, the [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) plugin is used to serialize the markdown into final output.
6372

64-
You can pass in options to the `remark-stringify` plugin using this option.
65-
66-
Please see https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options
73+
Please see https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options for available options to pass to the plugin.
6774

6875
```json filename="typedoc.json"
6976
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Remark Plugins Usage
2+
3+
## Useful Plugins
4+
5+
Here are a selection of remark plugins that might be useful. For a full list please visit the [remark plugins page](https://github.com/remarkjs/remark/blob/main/doc/plugins.md)
6+
7+
### remark-mdx
8+
9+
https://mdxjs.com/packages/remark-mdx
10+
11+
- If you are using MDX, this plugin is required to correctly parse to MDX.
12+
13+
```sh npm2yarn
14+
npm install remark-mdx --save-dev
15+
```
16+
17+
```json filename="typedoc.json"
18+
{
19+
"remarkPlugins": ["remark-mdx"]
20+
}
21+
```
22+
23+
### remark-github
24+
25+
https://github.com/remarkjs/remark-github
26+
27+
- Links references to commits, issues, and users in the same way that GitHub does in comments.
28+
29+
```sh npm2yarn
30+
npm install remark-github --save-dev
31+
```
32+
33+
```json filename="typedoc.json"
34+
{
35+
"remarkPlugins": ["remark-github", { "repository": "myorg/myrepo" }]
36+
}
37+
```
38+
39+
### remark-toc
40+
41+
https://github.com/remarkjs/remark-toc
42+
43+
- Adds inline table of contents to pages.
44+
45+
_Note: Also requires [`remark-insert-headings`](https://github.com/tgreyuk/remark-insert-headings) to add insert placeholder heading._
46+
47+
```sh npm2yarn
48+
npm install remark-insert-headings remark-toc --save-dev
49+
```
50+
51+
```json filename="typedoc.json"
52+
{
53+
"remarkPlugins": [
54+
["remark-insert-headings", { "text": "Contents" }],
55+
["remark-toc", { "maxDepth": 2 }]
56+
]
57+
}
58+
```
59+
60+
## Example Configuration
61+
62+
The following example shows how you might conditionally use the above plugins in your `typedoc.json`.
63+
64+
_This is for illustration purposes only, and you can use any combination of plugins you like._
65+
66+
```json filename="typedoc.json"
67+
{
68+
"plugin": ["typedoc-plugin-markdown", "typedoc-plugin-remark"],
69+
"remarkPlugins": [
70+
// Apply remark-mdx and remark-github to all files.
71+
{
72+
"applyTo": "*",
73+
"plugins": [
74+
"remark-mdx",
75+
["remark-github", { "repository": "myorg/myrepo" }]
76+
]
77+
},
78+
// Apply remark-toc to Readme page and members kinds of Document, Class and Interface only.
79+
{
80+
"applyTo": ["Readme", "Document", "Class", "Interface"],
81+
"plugins": [
82+
// remark-insert-headings is additionally required
83+
// (only display toc heading if there are more than two headings)
84+
[
85+
"remark-insert-headings",
86+
{
87+
"text": "Contents",
88+
"position": "start",
89+
"minHeadingCount": 2
90+
}
91+
],
92+
["remark-toc", { "maxDepth": 2 }]
93+
]
94+
}
95+
]
96+
}
97+
```

docs/content/plugins/remark/useful-plugins.mdx

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Writing A Plugin
2+
3+
It is straightforward to create a remark plugin locally if you would like to create your own functionality.
4+
5+
This example shows how to create a very simple plugin that adds a `meta` property to all code blocks in the documentation.
6+
7+
```js filename="my-custom-plugin.mjs"
8+
import { visit } from 'unist-util-visit';
9+
10+
export default function mySimpleRemarkPlugin() {
11+
return (tree) => {
12+
visit(tree, 'code', (node) => {
13+
node.meta = `playground`;
14+
});
15+
};
16+
}
17+
```
18+
19+
```json filename="typedoc.json"
20+
{
21+
"remarkPlugins": ["./my-custom-plugin.mjs"]
22+
}
23+
```

docs/public/logos/remark-logo.png

15.8 KB
Loading

docs/public/logos/yaml-logo.png

2.75 KB
Loading

0 commit comments

Comments
 (0)