Skip to content

Commit adba3b9

Browse files
Upgrade to docusaurus 3.0 (microsoft#2628)
Docusaurus 3.0 was just released, this new version brings up - react 18 which allows us to not use an outdated version here - config can use typescript - some perf improvement(however we already were proactive so its not very noticable) https://docusaurus.io/blog/releases/3.0 Typespec azure PR https://github.com/Azure/typespec-azure/pull/3823
1 parent af875c3 commit adba3b9

File tree

28 files changed

+1846
-1943
lines changed

28 files changed

+1846
-1943
lines changed

common/config/rush/common-versions.json

-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,5 @@
4040
// "typescript": [
4141
// "~2.4.0"
4242
// ]
43-
"react": ["^17.0.2"],
44-
"react-dom": ["^17.0.2"]
4543
}
4644
}

common/config/rush/pnpm-config.json

-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@
8989
* PNPM documentation: https://pnpm.io/package_json#pnpmoverrides
9090
*/
9191
"globalOverrides": {
92-
"trim@0.0.1": "0.0.3",
93-
"update-notifier@^5.1.0": "^6.0.2",
9492
"node-fetch@3.2.8": "^3.3.2"
9593
// "example1": "^1.0.0",
9694
// "example2": "npm:@company/example2@^1.0.0"

common/config/rush/pnpm-lock.yaml

+1,804-1,837
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/extending-typespec/basics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ This will create `tsconfig.json`. But we need to make a couple changes to this.
8787

8888
Open `./src/lib.ts` and create your library definition that registers your library with the TypeSpec compiler and defines any diagnostics your library will emit. Make sure to export the library definition as `$lib`.
8989

90-
:::warn
90+
:::warning
9191
If `$lib` is not accessible from your library package (`import {$lib} from "my-library";`) some functionality will be unavailable like validation of emitter options, linter rules, etc.
9292
:::
9393

docs/introduction/reproducibility.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The command `npm ci` can also be used in the CI to ensure that the `package.json
2222

2323
TypeSpec provides a library `@typespec/versioning` that can be used to describe changes to a service or library over time. Using this will ensure that a service can evolve while keeping track of the changes and allowing emitters to see the service representation at different versions.
2424

25-
[See versioning docs](../standard-library/versioning/reference/index.md)
25+
[See versioning docs](../standard-library/versioning/reference/index.mdx)
2626

2727
## 3. Change to the TypeSpec spec
2828

@@ -32,5 +32,5 @@ Using version control and pinning to a specific commit SHA will ensure that the
3232
## Summary
3333

3434
1. Use `package-lock.json`
35-
2. Use [versioning library](../standard-library/versioning/reference/index.md)
35+
2. Use [versioning library](../standard-library/versioning/reference/index.mdx)
3636
3. Keep track of commit IDs

packages/tspd/src/ref-doc/emitters/docusaurus.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { MarkdownRenderer, groupByNamespace } from "./markdown.js";
2121
export function renderToDocusaurusMarkdown(refDoc: TypeSpecRefDoc): Record<string, string> {
2222
const renderer = new DocusaurusRenderer();
2323
const files: Record<string, string> = {
24-
"index.md": renderIndexFile(renderer, refDoc),
24+
"index.mdx": renderIndexFile(renderer, refDoc),
2525
};
2626

2727
const decoratorFile = renderDecoratorFile(renderer, refDoc);

packages/website/docusaurus.config.js packages/website/docusaurus.config.ts

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// @ts-check
22
// Note: type annotations allow type checking and IDEs autocompletion
33

4-
// const lightCodeTheme = require("prism-react-renderer/themes/github");
5-
const lightCodeTheme = require("./themes/prism/atom-one-light.js");
6-
const { themes } = require("prism-react-renderer");
4+
import type { VersionOptions } from "@docusaurus/plugin-content-docs";
5+
import type { Config } from "@docusaurus/types";
6+
import { themes } from "prism-react-renderer";
77
const { resolve } = require("path");
88

9-
function getMajorMinorVersion(pkgJsonPath) {
9+
function getMajorMinorVersion(pkgJsonPath): string {
1010
const version = require(pkgJsonPath).version;
1111
const [major, minor] = version.split(".");
1212
return `${major}.${minor}.x`;
@@ -16,9 +16,8 @@ function getLatestVersion() {
1616
return `Latest (${getMajorMinorVersion("../compiler/package.json")})`;
1717
}
1818

19-
/** @returns {Record<string, import('@docusaurus/plugin-content-docs').VersionOptions>} */
20-
function getVersionLabels() {
21-
const labels = {
19+
function getVersionLabels(): Record<string, VersionOptions> {
20+
const labels: Record<string, VersionOptions> = {
2221
current: {
2322
label: `Next 🚧`,
2423
},
@@ -34,8 +33,7 @@ function getVersionLabels() {
3433
return labels;
3534
}
3635

37-
/** @type {import('@docusaurus/types').Config} */
38-
const config = {
36+
const config: Config = {
3937
title: "TypeSpec",
4038
tagline: "API first with TypeSpec for Azure services",
4139
url: "https://microsoft.github.io",
@@ -60,13 +58,14 @@ const config = {
6058

6159
markdown: {
6260
mermaid: true,
61+
format: "detect",
6362
},
6463
themes: ["@docusaurus/theme-mermaid"],
6564
presets: [
6665
[
6766
"classic",
6867
/** @type {import('@docusaurus/preset-classic').Options} */
69-
({
68+
{
7069
docs: {
7170
routeBasePath: "/",
7271
sidebarPath: require.resolve("./sidebars.js"),
@@ -80,7 +79,7 @@ const config = {
8079
theme: {
8180
customCss: require.resolve("./src/css/custom.css"),
8281
},
83-
}),
82+
},
8483
],
8584
],
8685
staticDirectories: [resolve(__dirname, "./node_modules/@typespec/spec/dist")],
@@ -109,7 +108,7 @@ const config = {
109108
},
110109
themeConfig:
111110
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
112-
({
111+
{
113112
navbar: {
114113
title: "TypeSpec",
115114
items: [
@@ -170,7 +169,7 @@ const config = {
170169
copyright: `Copyright © ${new Date().getFullYear()} Microsoft Corp.`,
171170
},
172171
prism: {
173-
theme: lightCodeTheme,
172+
theme: themes.oneLight,
174173
darkTheme: themes.dracula,
175174
additionalLanguages: [],
176175
},
@@ -181,7 +180,7 @@ const config = {
181180
apiKey: "bae16ae67ddbe24e700ac20d192ad20f",
182181
indexName: "typespec",
183182
},
184-
}),
183+
},
185184
};
186185

187-
module.exports = config;
186+
export default config;

packages/website/package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
"author": "",
2424
"license": "ISC",
2525
"dependencies": {
26-
"@docusaurus/core": "^2.2.0",
27-
"@docusaurus/preset-classic": "^2.2.0",
28-
"@docusaurus/theme-mermaid": "^2.2.0",
29-
"@mdx-js/react": "^1.6.22",
30-
"prism-react-renderer": "^2.0.6",
31-
"react": "^17.0.2",
32-
"react-dom": "^17.0.2"
26+
"@docusaurus/core": "^3.0.0",
27+
"@docusaurus/preset-classic": "^3.0.0",
28+
"@docusaurus/theme-mermaid": "^3.0.0",
29+
"@docusaurus/plugin-content-docs": "~3.0.0",
30+
"@mdx-js/react": "^3.0.0",
31+
"prism-react-renderer": "^2.1.0",
32+
"react": "~18.2.0",
33+
"react-dom": "~18.2.0"
3334
},
3435
"devDependencies": {
3536
"@swc/core": "^1.3.62",
@@ -43,15 +44,14 @@
4344
"@typespec/protobuf": "workspace:~0.49.0",
4445
"@typespec/versioning": "workspace:~0.49.0",
4546
"@typespec/json-schema": "workspace:~0.49.0",
46-
"@docusaurus/module-type-aliases": "^2.4.3",
47-
"@docusaurus/types": "^2.4.3",
48-
"@tsconfig/docusaurus": "^2.0.1",
47+
"@docusaurus/module-type-aliases": "^3.0.0",
48+
"@docusaurus/types": "^3.0.0",
49+
"@docusaurus/tsconfig": "^3.0.0",
4950
"typescript": "~5.2.2",
5051
"@types/node": "~18.11.9",
5152
"prism-themes": "~1.9.0",
5253
"playwright": "^1.39.0",
5354
"mermaid": "~10.4.0",
54-
"mdx-mermaid": "2.0.0",
5555
"@typespec/eslint-config-typespec": "workspace:~0.49.0",
5656
"eslint": "^8.49.0",
5757
"rimraf": "~5.0.1",

packages/website/sidebars.js packages/website/sidebars.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// @ts-check
1+
import { SidebarsConfig } from "@docusaurus/plugin-content-docs";
2+
import { SidebarItemConfig } from "@docusaurus/plugin-content-docs/src/sidebars/types.js";
23

3-
/**
4-
*
5-
* @param {string} libName
6-
* @param {any[]} [extra]
7-
* @returns {any}
8-
*/
9-
function createLibraryReferenceStructure(libName, labelName, extra) {
4+
function createLibraryReferenceStructure(
5+
libName: string,
6+
labelName: string,
7+
extra: SidebarItemConfig[]
8+
): SidebarItemConfig {
109
return {
1110
type: "category",
1211
label: labelName,
@@ -24,8 +23,7 @@ function createLibraryReferenceStructure(libName, labelName, extra) {
2423
};
2524
}
2625

27-
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
28-
const sidebars = {
26+
const sidebars: SidebarsConfig = {
2927
docsSidebar: [
3028
{
3129
type: "category",
@@ -153,4 +151,4 @@ const sidebars = {
153151
],
154152
};
155153

156-
module.exports = sidebars;
154+
export default sidebars;

packages/website/themes/prism/atom-one-light.js

-57
This file was deleted.

packages/website/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "@tsconfig/docusaurus/tsconfig.json",
2+
"extends": "@docusaurus/tsconfig",
33
"compilerOptions": {
44
"baseUrl": ".",
55
"jsx": "react-jsx"

packages/website/versioned_docs/version-latest/extending-typespec/basics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ This will create `tsconfig.json`. But we need to make a couple changes to this.
8787

8888
Open `./src/lib.ts` and create your library definition that registers your library with the TypeSpec compiler and defines any diagnostics your library will emit. Make sure to export the library definition as `$lib`.
8989

90-
:::warn
90+
:::warning
9191
If `$lib` is not accessible from your library package (`import {$lib} from "my-library";`) some functionality will be unavailable like validation of emitter options, linter rules, etc.
9292
:::
9393

packages/website/versioned_docs/version-latest/introduction/reproducibility.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The command `npm ci` can also be used in the CI to ensure that the `package.json
2222

2323
TypeSpec provides a library `@typespec/versioning` that can be used to describe changes to a service or library over time. Using this will ensure that a service can evolve while keeping track of the changes and allowing emitters to see the service representation at different versions.
2424

25-
[See versioning docs](../standard-library/versioning/reference/index.md)
25+
[See versioning docs](../standard-library/versioning/reference/index.mdx)
2626

2727
## 3. Change to the TypeSpec spec
2828

@@ -32,5 +32,5 @@ Using version control and pinning to a specific commit SHA will ensure that the
3232
## Summary
3333

3434
1. Use `package-lock.json`
35-
2. Use [versioning library](../standard-library/versioning/reference/index.md)
35+
2. Use [versioning library](../standard-library/versioning/reference/index.mdx)
3636
3. Keep track of commit IDs

0 commit comments

Comments
 (0)