docs: Add highlighting for devicetree and kconfig

Added syntax highlighting for devicetree and kconfig files.

The PrismJS project is not accepting contributions right now as they
work on a version 2 of the library, so the new language files are added
directly here.

Also enabled syntax highlighting for various languages that are used in
the docs but aren't enabled in Docusaurus by default.
This commit is contained in:
Joel Spadin
2023-10-06 22:02:23 -05:00
committed by Cem Aksoylar
parent 6af22424f1
commit 4a339093ce
6 changed files with 269 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import siteConfig from "@generated/docusaurus.config";
export default function prismIncludeLanguages(PrismObject) {
const {
themeConfig: { prism },
} = siteConfig;
const { additionalLanguages } = prism;
// Prism components work on the Prism instance on the window, while prism-
// react-renderer uses its own Prism instance. We temporarily mount the
// instance onto window, import components to enhance it, then remove it to
// avoid polluting global namespace.
// You can mutate PrismObject: registering plugins, deleting languages... As
// long as you don't re-assign it
globalThis.Prism = PrismObject;
additionalLanguages.forEach((lang) => {
// eslint-disable-next-line global-require
require(`prismjs/components/prism-${lang}`);
});
require("./prism/components/prism-devicetree.js");
require("./prism/components/prism-kconfig.js");
delete globalThis.Prism;
}