Skip to content

Commit 896d636

Browse files
committed
feat(docusaurus): decouple typedoc logic into dedicated "typedoc-docusaurus-theme" plugin
1 parent 05f3b32 commit 896d636

File tree

80 files changed

+1162
-941
lines changed

Some content is hidden

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

80 files changed

+1162
-941
lines changed

.github/workflows/ci.docusaurus-plugin-typedoc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
node-version: ${{ matrix.node }}
3333
cache: 'npm'
3434
- name: Install
35-
run: HUSKY=0 npm install
35+
run: HUSKY=0 npm ci
3636
- name: Lint
3737
run: npm run lint --workspace docusaurus-plugin-typedoc
3838
- name: Build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI [typedoc-docusaurus-theme]
2+
on:
3+
push:
4+
paths:
5+
- 'packages/typedoc-docusaurus-theme/**'
6+
- '!packages/typedoc-docusaurus-theme/README.md'
7+
- '!packages/typedoc-docusaurus-theme/CHANGELOG.md'
8+
- '!packages/typedoc-docusaurus-theme/package.json'
9+
branches:
10+
- main
11+
- release
12+
- beta
13+
pull_request:
14+
paths:
15+
- 'packages/typedoc-docusaurus-theme/**'
16+
- '!packages/typedoc-docusaurus-theme/README.md'
17+
- '!packages/typedoc-docusaurus-theme/CHANGELOG.md'
18+
- '!packages/typedoc-docusaurus-theme/package.json'
19+
jobs:
20+
lint-and-test:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
node: ['18']
25+
name: Node ${{ matrix.node }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v3
29+
- name: Set up Node
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: ${{ matrix.node }}
33+
cache: 'npm'
34+
- name: Install
35+
run: HUSKY=0 npm ci
36+
- name: Lint
37+
run: npm run lint --workspace typedoc-docusaurus-theme
38+
- name: Build
39+
run: npm run build --workspace typedoc-plugin-markdown --workspace typedoc-docusaurus-theme
40+
- name: Test
41+
run: npm run test --workspace typedoc-docusaurus-theme

.github/workflows/ci.typedoc-github-wiki-theme.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
node-version: ${{ matrix.node }}
3333
cache: 'npm'
3434
- name: Install
35-
run: HUSKY=0 npm install
35+
run: HUSKY=0 npm ci
3636
- name: Lint
3737
run: npm run lint --workspace typedoc-github-wiki-theme
3838
- name: Build

.github/workflows/ci.typedoc-gitlab-wiki-theme.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
node-version: ${{ matrix.node }}
3333
cache: 'npm'
3434
- name: Install
35-
run: HUSKY=0 npm install
35+
run: HUSKY=0 npm ci
3636
- name: Lint
3737
run: npm run lint --workspace typedoc-github-wiki-theme
3838
- name: Build

.github/workflows/ci.typedoc-plugin-frontmatter.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
node-version: ${{ matrix.node }}
3333
cache: 'npm'
3434
- name: Install
35-
run: HUSKY=0 npm install
35+
run: HUSKY=0 npm ci
3636
- name: Lint
3737
run: npm run lint --workspace typedoc-plugin-frontmatter
3838
- name: Build

.github/workflows/ci.typedoc-plugin-remark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
node-version: ${{ matrix.node }}
3333
cache: 'npm'
3434
- name: Install
35-
run: HUSKY=0 npm install
35+
run: HUSKY=0 npm ci
3636
- name: Lint
3737
run: npm run lint --workspace typedoc-plugin-remark
3838
- name: Build

.github/workflows/ci.typedoc-vitepress-theme.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
node-version: ${{ matrix.node }}
3333
cache: 'npm'
3434
- name: Install
35-
run: HUSKY=0 npm install
35+
run: HUSKY=0 npm ci
3636
- name: Lint
3737
run: npm run lint --workspace typedoc-vitepress-theme
3838
- name: Build

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Please see [typedoc-plugin-markdown.org](https://typedoc-plugin-markdown.org).
1616
[typedoc-github-wiki-theme](./packages/typedoc-github-wiki-theme#readme) | [![npm](https://img.shields.io/npm/v/typedoc-github-wiki-theme.svg?logo=npm)](https://www.npmjs.com/package/typedoc-github-wiki-theme) | ![Downloads](https://img.shields.io/npm/dw/typedoc-github-wiki-theme?label=↓) | [Changelog](./packages/typedoc-github-wiki-theme/CHANGELOG.md) |
1717
[typedoc-gitlab-wiki-theme](./packages/typedoc-gitlab-wiki-theme#readme) | [![npm](https://img.shields.io/npm/v/typedoc-gitlab-wiki-theme.svg?logo=npm)](https://www.npmjs.com/package/typedoc-gitlab-wiki-theme) | ![Downloads](https://img.shields.io/npm/dw/typedoc-gitlab-wiki-theme?label=↓) | [Changelog](./packages/typedoc-gitlab-wiki-theme/CHANGELOG.md) |
1818
[typedoc-vitepress-theme](./packages/typedoc-vitepress-theme#readme) | [![npm](https://img.shields.io/npm/v/typedoc-vitepress-theme.svg?logo=npm)](https://www.npmjs.com/package/typedoc-vitepress-theme) | ![Downloads](https://img.shields.io/npm/dw/typedoc-vitepress-theme?label=↓) | [Changelog](./packages/typedoc-vitepress-theme/CHANGELOG.md) |
19+
[typedoc-docusaurus-theme](./packages/typedoc-docusaurus-theme#readme) | [![npm](https://img.shields.io/npm/v/typedoc-docusaurus-theme.svg?logo=npm)](https://www.npmjs.com/package/typedoc-docusaurus-theme) | ![Downloads](https://img.shields.io/npm/dw/typedoc-docusaurus-theme?label=↓) | [Changelog](./packages/typedoc-docusaurus-theme/CHANGELOG.md) |
1920
[docusaurus-plugin-typedoc](./packages/docusaurus-plugin-typedoc#readme) | [![npm](https://img.shields.io/npm/v/docusaurus-plugin-typedoc.svg?logo=npm)](https://www.npmjs.com/package/docusaurus-plugin-typedoc) | ![Downloads](https://img.shields.io/npm/dw/docusaurus-plugin-typedoc?label=↓) | [Changelog](./packages/docusaurus-plugin-typedoc/CHANGELOG.md) |
2021

2122
## Contributing

devtools/examples/docusaurus-ts/docusaurus.config.ts

+24-13
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,28 @@ const config: Config = {
4545
[
4646
docusaurusPlugin,
4747
{
48-
...require(
49-
path.join(
50-
__dirname,
51-
'../../../packages/typedoc-plugin-markdown/test/fixtures/typedoc.cjs',
52-
),
53-
),
54-
tsconfig: path.join(
55-
__dirname,
56-
'../../../packages/typedoc-plugin-markdown/test/fixtures/tsconfig.json',
57-
),
58-
entryPoints: [
59-
'../../../packages/typedoc-plugin-markdown/test/fixtures/src/reflections/index.ts',
60-
],
48+
tsconfig: './stubs/tsconfig.json',
49+
entryPoints: ['./stubs/src/index.ts'],
50+
readme: 'none',
51+
cleanOutputDir: true,
52+
logLevel: 'Warn',
53+
},
54+
],
55+
[
56+
docusaurusPlugin,
57+
{
58+
id: 'api-2',
59+
tsconfig: './stubs/tsconfig.json',
60+
entryPoints: ['./stubs/src/index.ts'],
61+
out: './docs/api-2',
62+
readme: 'none',
6163
sidebar: {
6264
typescript: true,
6365
pretty: true,
66+
deprecatedItemClassName: 'is-deprecated',
6467
},
68+
logLevel: 'Warn',
69+
plugin: ['./stubs/custom-plugin.mjs'],
6570
},
6671
],
6772
],
@@ -114,6 +119,12 @@ const config: Config = {
114119
label: 'API 1',
115120
position: 'left',
116121
},
122+
{
123+
to: 'docs/api-2',
124+
activeBasePath: 'docs',
125+
label: 'API 2',
126+
position: 'left',
127+
},
117128
],
118129
},
119130
footer: {

devtools/examples/docusaurus-ts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"docusaurus": "docusaurus",
77
"prestart": "rm -rf ./docs && cd ../../../packages/docusaurus-plugin-typedoc && npm run build",
8+
"generate": "npm run prestart && docusaurus generate-typedoc",
89
"start": "docusaurus start",
910
"build": "docusaurus build",
1011
"swizzle": "docusaurus swizzle",

devtools/examples/docusaurus-ts/sidebars.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { SidebarsConfig } from '@docusaurus/plugin-content-docs';
2-
import typedocSidebar from './docs/api/typedoc-sidebar';
1+
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';
2+
import typedocSidebar from './docs/api-2/typedoc-sidebar';
33

44
const sidebars: SidebarsConfig = {
55
typedocSidebar: [
@@ -8,7 +8,7 @@ const sidebars: SidebarsConfig = {
88
label: 'Typedoc API',
99
link: {
1010
type: 'doc',
11-
id: 'api/index',
11+
id: 'api-2/index',
1212
},
1313
items: typedocSidebar.items,
1414
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @ts-check
2+
import * as fs from 'fs';
3+
import { MarkdownRendererEvent } from 'typedoc-plugin-markdown';
4+
5+
export function load(app) {
6+
app.renderer.on(MarkdownRendererEvent.END, (renderer) => {
7+
fs.writeFileSync(
8+
`${renderer.outputDirectory}/custom-plugin.txt`,
9+
'custom-plugin',
10+
);
11+
});
12+
}

packages/docusaurus-plugin-typedoc/test/stubs/tsconfig.json renamed to devtools/examples/docusaurus-ts/stubs/tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"strict": true,
99
"noUnusedLocals": false,
1010
"noUnusedParameters": false,
11-
"target": "es2022"
11+
"target": "es2022",
12+
"jsx": "react",
13+
"types": ["node", "react"]
1214
},
1315
"include": ["./src/*.ts"]
1416
}

devtools/packages/helpers/constants.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@ export const DOCS_CONFIG: Record<string, DocsConfig> = {
5151
declarations: true,
5252
presets: true,
5353
},
54-
['docusaurus-plugin-typedoc']: {
54+
['typedoc-docusaurus-theme']: {
5555
declarationsPath: `${process.cwd()}/src/options/declarations.ts`,
5656
presetsPath: `${process.cwd()}/src/options/presets.ts`,
57-
optionsPath: '/plugins/docusaurus',
57+
optionsPath: 'plugins/docusaurus',
5858
docsPath: '/plugins/docusaurus',
5959
declarations: true,
6060
presets: true,
6161
},
62+
['docusaurus-plugin-typedoc']: {
63+
docsPath: '/plugins/docusaurus',
64+
},
6265
};

devtools/packages/helpers/models.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ export interface DocsConfig {
22
declarationsPath?: string;
33
translatablePath?: string;
44
presetsPath?: string;
5-
optionsPath: string;
5+
optionsPath?: string;
66
optionsFile?: string;
77
docsPath: string;
8-
declarations: boolean;
9-
presets: boolean;
8+
declarations?: boolean;
9+
presets?: boolean;
1010
categories?: Record<string, string>;
1111
}
1212

devtools/scripts/generate-readmes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ async function main() {
1212
'typedoc-github-wiki-theme',
1313
'typedoc-gitlab-wiki-theme',
1414
'typedoc-vitepress-theme',
15+
'typedoc-docusaurus-theme',
1516
'docusaurus-plugin-typedoc',
1617
].map(async (packageName) => {
1718
const packageJson = await import(

docs/content/docs/quick-start.mdx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Callout, Steps } from 'nextra/components';
2-
31
# Quick Start
42

53
## Installation
@@ -31,6 +29,6 @@ Or:
3129
}
3230
```
3331

34-
```shell filename="CLI"
32+
```bash filename="CLI"
3533
npm run docs
3634
```

docs/content/plugins/_meta.js

-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,5 @@ export default {
1313
'github-wiki': 'Github Wiki',
1414
'gitlab-wiki': 'Gitlab Wiki',
1515
vitepress: 'VitePress',
16-
'-- Integrations': {
17-
type: 'separator',
18-
title: 'Integrations',
19-
},
2016
docusaurus: 'Docusaurus',
2117
};

docs/content/plugins/docusaurus/index.mdx

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
asIndexPage: true
33
---
44

5-
import { Cards } from 'nextra/components';
6-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5+
{/* prettier-ignore */}
76
import { faGithub } from '@fortawesome/free-brands-svg-icons';
87
import { faGlobe } from '@fortawesome/free-solid-svg-icons';
8+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9+
import { Cards } from 'nextra/components';
910

10-
# docusaurus-plugin-typedoc
11+
# typedoc-docusaurus-theme
1112

12-
<PackageVersion name={'docusaurus-plugin-typedoc'} />
13+
<PackageVersion name={'typedoc-docusaurus-theme'} />
1314

1415
## Overview
1516

@@ -20,8 +21,8 @@ It is a Docusaurus plugin (not a TypeDoc plugin) and is designed to work within
2021
## Features
2122

2223
- Presets relevant options of typedoc-plugin-markdown.
23-
- Bootstraps TypeDoc from the Docusaurus CLI.
24-
- Generates a sidebar file with configurable structure.
24+
- Generates a configurable docusaurus sidebar.
25+
- Use a Docusaurus plugin to bootstraps TypeDoc from the Docusaurus CLI.
2526

2627
## Example
2728

docs/content/plugins/docusaurus/options.mdx

+41-13
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ The following are preset typedoc-plugin-markdown options:
1313

1414
```json"
1515
{
16-
"out": "./docs/api",
1716
"hideBreadcrumbs": true,
1817
"hidePageHeader": true,
19-
"entryFileName": "index.md"
18+
"entryFileName": "index.md",
19+
"out": "docs/api"
2020
}
2121
```
2222

@@ -26,7 +26,7 @@ The following options are exposed by this plugin:
2626

2727
## sidebar
2828

29-
<Callout emoji="💡">Configures the autogenerated Docusaurus sidebar.</Callout>
29+
<Callout emoji="💡">Configures the autogenerated sidebar.</Callout>
3030

3131
> Accepts a key/value object.
3232
@@ -48,20 +48,48 @@ The class name to apply to deprecated items in the sidebar. Defaults to `"typedo
4848

4949
Please see the [sidebar guide](/plugins/docusaurus/guides/sidebar) for additional information on sidebar setup.
5050

51-
```js filename="docusaurus.config.js"
51+
````js filename="docusaurus.config.js"
5252
{
5353
plugins: [
5454
[
5555
'docusaurus-plugin-typedoc',
5656
{
57-
sidebar: {
58-
autoConfiguration: true,
59-
pretty: false,
60-
typescript: false,
61-
deprecatedItemClassName: 'typedoc-sidebar-item-deprecated',
62-
},
63-
},
64-
],
65-
];
57+
"sidebar": {
58+
"autoConfiguration": true,
59+
"pretty": false,
60+
"typescript": false,
61+
"deprecatedItemClassName": "typedoc-sidebar-item-deprecated"
62+
}
63+
}
64+
]
65+
]
66+
}
67+
68+
## docsPath
69+
70+
<Callout emoji="💡">The path to docsPath.</Callout>
71+
72+
> Defaults to `"./docs"`.
73+
74+
This is the docs path for the generated docs.
75+
76+
77+
```json filename="typedoc.json"
78+
{
79+
"docsPath": "./docs"
80+
}
81+
````
82+
83+
## numberPrefixParser
84+
85+
<Callout emoji="💡">The numberPrefixParser.</Callout>
86+
87+
> Accepts a boolean value. Defaults to `false`.
88+
89+
The equivalent number prefix parser.
90+
91+
```json filename="typedoc.json"
92+
{
93+
"numberPrefixParser": false
6694
}
6795
```

0 commit comments

Comments
 (0)