Skip to content

Commit

Permalink
website: upgrade to Docusaurus 3
Browse files Browse the repository at this point in the history
Summary:
Docusaurus 3 has some breaking changes. Namely the "raw" HTML is no longer
supported. We have a plugin to use raw HTML to render generated colorful
output, although the coloring feature is not actually used. I disabled the
"coloring" feature to fix the MDX 3 compatibility for now. We can build our own
ANSI-to-MDX logic in the future if we want.

Reviewed By: sggutier

Differential Revision: D66508226

fbshipit-source-id: 15d5f8955924b7eb96970d9d3abc01058f2452d9
  • Loading branch information
quark-zju authored and facebook-github-bot committed Nov 26, 2024
1 parent 90eb13d commit 2dacd79
Show file tree
Hide file tree
Showing 5 changed files with 4,966 additions and 3,391 deletions.
20 changes: 10 additions & 10 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
"signsource": "node ./scripts/signsource.js"
},
"dependencies": {
"@docusaurus/core": "2.4.3",
"@docusaurus/preset-classic": "2.4.3",
"@mdx-js/react": "^1.6.22",
"@docusaurus/core": "3.6.3",
"@docusaurus/preset-classic": "3.6.3",
"@mdx-js/react": "^3.1.0",
"async-mutex": "^0.4.0",
"clsx": "^1.2.1",
"deep-equal": "^2.1.0",
"docusaurus-plugin-internaldocs-fb": "1.18.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-simple-code-editor": "^0.13.1",
"remark-github": "^10.1.0",
"docusaurus-plugin-internaldocs-fb": "1.19.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-simple-code-editor": "^0.14.1",
"remark-github": "^12.0.0",
"sapling-output-plugin": "file:src/plugins/sapling-output"
},
"devDependencies": {
"@babel/eslint-parser": "^7.18.2",
"@docusaurus/module-type-aliases": "2.4.3",
"@tsconfig/docusaurus": "^1.0.5",
"@docusaurus/module-type-aliases": "3.6.3",
"@tsconfig/docusaurus": "^2.0.3",
"eslint": "^8.19.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
Expand Down
1 change: 0 additions & 1 deletion website/src/plugins/sapling-output/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "dist/index.js",
"dependencies": {
"@types/unist": "^2.0.6",
"ansi-to-html": "^0.7.2",
"tmp-promise": "^3.0.3",
"typescript": "^4.7.4",
"unist-util-visit": "^4.1.1"
Expand Down
11 changes: 3 additions & 8 deletions website/src/plugins/sapling-output/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

// See project README.md for how to use this plugin in markdown.
const Convert = require('ansi-to-html');
const {execFile} = require('child_process');
const fs = require('fs');
const path = require('path');
Expand All @@ -20,7 +19,7 @@ const EXAMPLE_HEADER = String.raw`
# hide begin
$ cat >> "$HGRCPATH" << 'EOF'
> [ui]
> color=always
> # color=always
> [init]
> prefer-git=false
> [templatealias]
Expand Down Expand Up @@ -125,7 +124,7 @@ const COLORS = {
15: '#F2F2F2',
};

// Render `example` (in .t test format without " " prefix) into HTML.
// Render `example` (in .t test format without " " prefix) into text.
async function renderExample(example: string): Promise<string> {
// Prepare input.
const isDebug = process.env.MDX_SAPLING_OUTPUT_DEBUG != null;
Expand All @@ -149,16 +148,13 @@ async function renderExample(example: string): Promise<string> {
// Convert to HTML.
const rawOutput = await fs.promises.readFile(examplePath, {encoding: 'utf8'});
const output = processOutput(rawOutput);
const convert = new Convert({colors: COLORS});
const body = convert.toHtml(output);
const html = `<pre class="sapling-example">${body}</pre>`;

// Cleanup.
if (!isDebug) {
tmpDir.cleanup();
}

return html;
return output;
}

interface Node {
Expand Down Expand Up @@ -190,7 +186,6 @@ module.exports = function (options: any) {
// Process them.
await Promise.all(
nodes.map(async (node: Node) => {
node.type = 'html';
node.value = await renderExample(node.value);
}),
);
Expand Down
12 changes: 0 additions & 12 deletions website/src/plugins/sapling-output/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d"
integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==

ansi-to-html@^0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/ansi-to-html/-/ansi-to-html-0.7.2.tgz#a92c149e4184b571eb29a0135ca001a8e2d710cb"
integrity sha512-v6MqmEpNlxF+POuyhKkidusCHWWkaLcGRURzivcU3I9tv7k4JVhFcnukrM5Rlk2rUywdZuzYAZ+kbZqWCnfN3g==
dependencies:
entities "^2.2.0"

balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
Expand All @@ -32,11 +25,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==

entities@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55"
integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down
Loading

0 comments on commit 2dacd79

Please sign in to comment.