pmndrs/docs

Documentation generator for pmndrs/* projects.

Summary

A static MDX documentation generator, with a GitHub reusable workflow. It is primarily used for some pmndrs/* projects, but will work for anyone.

Gutenberg lithography

Those projects are known to be using this generator.

INSTALL

Nothing to install to use it: every command below runs through npx. What follows is for working on the generator itself.

Pre-requisites:

  • Install nvm, then:
    $ nvm install
    $ nvm use
    $ node -v # make sure your version satisfies package.json#engines.node
    
    nb: if you want this node version to be your default nvm's one: nvm alias default node
$ git clone https://github.com/pmndrs/docs.git
$ cd docs
$ pnpm install

Configuration

Important

Every flag falls back to the variable next to it, and every default is "" (think empty).

Those variables can be written down in a .env, in the folder the command runs from — a flag, or a variable already in the environment, wins over the file:

# .env
MDX=docs
NEXT_PUBLIC_LIBNAME=React Three Fiber
ICON=🇨🇭
flagvardescriptionexample
IN argument*MDXPath to *.mdx folder
NB: can be relative or absolute
docs or ~/code/myproject/documentation
--libname*NEXT_PUBLIC_LIBNAMELibrary nameReact Three Fiber
--libname-shortNEXT_PUBLIC_LIBNAME_SHORTLibrary short namer3f
--libname-dotsuffix-labelNEXT_PUBLIC_LIBNAME_DOTSUFFIX_LABELText for the ".docs" suffix link inside the headerdocs
--libname-dotsuffix-hrefNEXT_PUBLIC_LIBNAME_DOTSUFFIX_HREFHref for the ".docs" suffix link inside the headerhttps://docs.pmnd.rs
--base-pathBASE_PATHBase path for the final URL/react-three-fiber
--home-redirectHOME_REDIRECTWhere the home should redirect/getting-started/introduction
--mdx-baseurlMDX_BASEURLBase URL for inlining relative imageshttps://github.com/pmndrs/react-three-fiber/raw/master/docs
--sourcecode-baseurlSOURCECODE_BASEURLBase URL for sourcecode: code pathhttps://github.com/pmndrs/react-three-fiber/tree/main
--edit-baseurlEDIT_BASEURLBase URL for displaying "Edit this page" URLshttps://github.com/pmndrs/react-three-fiber/edit/master/docs
--urlNEXT_PUBLIC_URLFinal URL of the published websitehttps://pmndrs.github.io/react-three-fiber
--iconICONEmoji or image to use as (fav)icon (path local to MDX)🇨🇭 or /icon.png or /favicon.ico
--logoLOGOLogo src/path (either FQURL or local to MDX path)/logo.png or https://worldvectorlogo.com/r3f.png
--githubGITHUBGithub URLhttps://github.com/pmndrs/react-three-fiber
--discordDISCORDDiscord URLhttps://discord.com/channels/740090768164651008/740093168770613279
--theme-primaryTHEME_PRIMARYPrimary accent color#323e48
--theme-schemeTHEME_SCHEMETheme schemecontent or expressive or fidelity or monochrome or neutral or tonalSpot or vibrant
--theme-contrastTHEME_CONTRASTTheme contrast -- value between -1 and 10 or -1 or 1 or -.6
--theme-noteTHEME_NOTE"note" color#1f6feb
--theme-tipTHEME_TIP"tip" color#238636
--theme-importantTHEME_IMPORTANT"important" color#8957e5
--theme-warningTHEME_WARNING"warning" color#d29922
--theme-cautionTHEME_CAUTION"caution" color#da3633
CONTRIBUTORS_PATGitHub token for contributors API (see: https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators)ghp_1234567890

* Required

MDX_BASEURL

Given a advanced/introduction.mdx file in the MDX folder:

![](dog.png)

becomes (for a MDX_BASEURL=http://localhost:60141 value):

![](http://localhost:60141/advanced/dog.png)

http://localhost:60141 being the MDX folder served.

Tip

When deployed on GitHub Pages, MDX_BASEURL will typically value something like https://github.com/pmndrs/uikit/raw/main/docs, thanks to build.yml rule.

THEME_*

We implement m3 design system, using material-theme-builder.

color scheme

Note
  • Material Color for more information
  • We currently don't have secondary/tertiary colors (maybe some day).

Usage

dev

$ npx -y @pmndrs/docs@latest dev docs \
  --libname "React Three Fiber" \
  --libname-short "r3f" \
  --home-redirect /getting-started/introduction \
  --icon 🇨🇭 \
  --github https://github.com/pmndrs/react-three-fiber

Then go to: http://localhost:3000

Pages are read on every request — edit one, reload. The MDX folder is served alongside, so relative images resolve as you write them, and --port moves the server.

Tip

If --home-redirect is left empty, / will not redirect, and instead displays an index of libraries.

With the options in a .env, there is nothing left to pass:

$ npx -y @pmndrs/docs@latest dev

build

$ npx -y @pmndrs/docs@latest build docs out --format website \
  --libname "React Three Fiber" \
  --icon 🇨🇭
$ npx -y serve out

--format website statically exports the whole site into out — what build.yml publishes to GitHub Pages. --format fragment (the default) compiles one .html per .mdx instead: the compiled MDX and nothing else, no layout, no stylesheet, no script.

Agents

llms.txt dumps and the pmndrs MCP server moved to their own page: Agents.