Skip to content

Commit ae356cf

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

File tree

90 files changed

+1792
-1440
lines changed

Some content is hidden

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

90 files changed

+1792
-1440
lines changed

.changeset/bumpy-dolls-teach.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'docusaurus-plugin-typedoc': minor
3+
'typedoc-docusaurus-theme': minor
4+
---
5+
6+
- Decoupled TypeDoc logic into seperate TypeDoc plugin "typedoc-docusaurus-theme" ("docusaurus-plugin-typedoc" and "typedoc-docusaurus-theme" will be published and versioned together as linked packages).
7+
- Unquoted object keys in generated sidebar.

.changeset/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{ "repo": "typedoc2md/typedoc-plugin-markdown" }
66
],
77
"commit": false,
8-
"fixed": [],
8+
"fixed": [["docusaurus-plugin-typedoc", "typedoc-docusaurus-theme"]],
99
"linked": [],
1010
"access": "public",
1111
"baseBranch": "main",

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ 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
39-
run: npm run build --workspace typedoc-plugin-markdown --workspace docusaurus-plugin-typedoc
39+
run: npm run build --workspace typedoc-plugin-markdown --workspace typedoc-docusaurus-theme --workspace docusaurus-plugin-typedoc
4040
- name: Test
4141
run: npm run test --workspace docusaurus-plugin-typedoc
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/*'],
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/*'],
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export interface SomeInterfaceA {
2+
propa: string;
3+
propb: string;
4+
}
5+
6+
export interface SomeInterfaceB {
7+
propa: string;
8+
propb: string;
9+
}
10+
11+
export enum SomeEnumA {
12+
Member,
13+
MemberB,
14+
}
15+
16+
export enum SomeEnumB {
17+
Member,
18+
MemberB,
19+
}
20+
21+
export class SomeClassA {}
22+
23+
export class SomeClassB {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface SomeInterface<T> {
2+
propa: string;
3+
propb: T;
4+
}
5+
6+
export enum SomeEnum {
7+
Member,
8+
MemberB,
9+
}
10+
11+
export class SomeClass {}

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/packages/prebuild-options/tasks/generate-docs.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ ${presetsJson}
146146
: '',
147147
];
148148
const optionLevel =
149-
categories.length === 1 && !docsConfig.presets ? '##' : '##';
149+
categories.length === 1 && !docsConfig.presets ? '##' : '###';
150150
if (categories.length > 1) {
151151
out.push(`# ${getDocsTitle(categoryName)}`);
152152
if (Object.keys(categoryDescriptions)?.length) {
@@ -232,7 +232,7 @@ ${JSON.stringify(exampleJson, null, 2)}
232232
if (categories.length > 1) {
233233
outputPage.push(optionsTable.join('\n'));
234234
const catDocPath = path.join(
235-
getPagesPath(docsConfig.optionsPath),
235+
getPagesPath(docsConfig.optionsPath as string),
236236
'options',
237237
`${categoryName.toLowerCase()}-options.mdx`,
238238
);
@@ -262,7 +262,7 @@ ${JSON.stringify(exampleJson, null, 2)}
262262
);
263263

264264
const metaJsPath = path.join(
265-
getPagesPath(docsConfig.optionsPath),
265+
getPagesPath(docsConfig.optionsPath as string),
266266
'options',
267267
'_meta.js',
268268
);
@@ -271,7 +271,7 @@ ${JSON.stringify(exampleJson, null, 2)}
271271
}
272272

273273
const optionDocPath = path.join(
274-
getPagesPath(docsConfig.optionsPath),
274+
getPagesPath(docsConfig.optionsPath as string),
275275
docsConfig.optionsFile || 'options.mdx',
276276
);
277277

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
};

0 commit comments

Comments
 (0)