Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port "Language" section from reasonml.github.io #195

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { readFileSync } from "fs";
import { join } from "path";
import { defineConfig } from "vitepress";
import { bundledLanguages } from "shiki";

// Modify bundledLanguages so it no longer contains the bundled OCaml grammar. This is needed because vitepress config
// doesn't allow you to override bundled grammars, see
// https://github.com/vuejs/vitepress/blob/78c4d3dda085f31912578237dfbe7b1c62f48859/src/node/markdown/plugins/highlight.ts#L65
delete bundledLanguages['ocaml'];

const toggleSyntaxScript = readFileSync(join(__dirname, './toggleSyntax.js'), 'utf8');

Expand All @@ -9,16 +15,21 @@ const reasonGrammar = JSON.parse(
readFileSync(join(__dirname, "./reasonml.tmLanguage.json"), "utf8")
);

// https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/dune.json
// From https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/dune.json
const duneGrammar = JSON.parse(
readFileSync(join(__dirname, "./dune.tmLanguage.json"), "utf8")
);

// https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/opam.json
// From https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/opam.json
const opamGrammar = JSON.parse(
readFileSync(join(__dirname, "./opam.tmLanguage.json"), "utf8")
);

// From https://github.com/ocamllabs/vscode-ocaml-platform/blob/master/syntaxes/ocaml.json
const ocamlGrammar = JSON.parse(
readFileSync(join(__dirname, "./ocaml.tmLanguage.json"), "utf8")
);

const base = process.env.BASE || "unstable";

// https://vitepress.dev/reference/site-config
Expand All @@ -38,7 +49,7 @@ export default defineConfig({
hostname: `https://melange.re/${base}/`,
},
markdown: {
languages: [reasonGrammar, duneGrammar, opamGrammar],
languages: [duneGrammar, ocamlGrammar, opamGrammar, reasonGrammar],
},
themeConfig: {
outline: { level: [2, 3] },
Expand Down Expand Up @@ -112,6 +123,26 @@ export default defineConfig({
},
],
},
{
text: "Language Basics",
items: [
{ text: "Overview", link: "/overview" },
Copy link
Collaborator Author

@feihong feihong Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only added overview page so far

{ text: "Let bindings", link: "/let-bindings" },
{ text: "Primitives", link: "/primitives" },
{ text: "Basic structures", link: "/basic-structures" },
{ text: "Types", link: "/types" },
{ text: "Records", link: "/records" },
{ text: "Variants", link: "/variants" },
{ text: "Options and nullability", link: "/options" },
{ text: "Functions", link: "/functions" },
{ text: "Recursion", link: "/recursion" },
{ text: "Destructuring", link: "/destructuring" },
{ text: "Pattern matching", link: "/pattern-matching" },
{ text: "Mutable bindings", link: "/mutable-bindings" },
{ text: "Loops", link: "/loops" },
{ text: "Module", link: "/module" },
],
},
{
text: "Reference",
items: [{ text: "API", link: "/api" }],
Expand Down
Loading