Build the Documentation
The published Megatron Core documentation is a Fern
site. Fern compiles Markdown/MDX content and YAML configuration into a hosted static site.
The content lives in docs/, and the Fern configuration lives in fern/.
- Prerequisites
- Install the Fern CLI
- Project Layout
- Add or Edit a Page
- Validate the Documentation
- Preview Locally
- Share a Preview
- Publish
Prerequisites
- Node.js 22
- The Fern CLI at the version pinned in
fern/fern.config.json. Using the pinned version keeps local results consistent with CI.
Install the Fern CLI
From the repository root, install the pinned version of the CLI:
Do not run
fern initin this repository. Thefern/folder already exists and is configured. Runfern upgradeonly when intentionally bumping the CLI pin infern/fern.config.json.
Project Layout
The site has two versions: Nightly (the default, built from docs/) and Archives.
Publishing tags select a Git revision.
Add or Edit a Page
-
Create or edit a Markdown file under
docs/. Start a new page with front matter: -
Register the page in
docs/index.ymlso it appears in the navigation. Paths are relative todocs/index.yml:
Fern supports GitHub flavored Markdown within MDX files. Pages are parsed as MDX, so escape or put
in code spans any bare <, >, or { characters in prose.
If you rename or move a page, add a rule to fern/redirects.yml for the old URL.
Validate the Documentation
Run the same checks as CI from the fern/ folder:
fern checkvalidates the Fern configuration.fern docs md checkvalidates the MDX content.fern docs broken-links --strictfails on broken internal links.
Preview Locally
Run the local development server with hot reloading. The site updates as you edit Markdown and YAML files:
Open the URL printed in the terminal (by default, http://localhost:3000) to view the site.
If you use a remote machine, forward the port to your local machine.
fern docs dev cannot test redirects. Verify them on a shared preview deployment.
Share a Preview
You do not need to create previews manually for pull requests. Once a non-draft PR is synchronized to
pull-request/<number>, CI validates the documentation and, after a reviewer approves the
fern-preview deployment, posts a preview link on the PR. See fern/README.md for details.
To generate a shareable preview link manually, log in with fern login (or set FERN_TOKEN) and run:
Publish
Publishing is handled by CI and requires approval. Do not publish from a local machine.
- Pushes to
mainthat change docs update the sharedmegatron-lm-stagingpreview. - Pushing a
docs/v*tag, or manually running thefern-docs-publish.ymlworkflow, publishes production after validation and approval of thefern-publishenvironment. - When a final
core_vX.Y.Zrelease is cut, a draft PR adds the release tofern/versions/archives.mdx.