Starlight Sites
plissken can write the API reference into an Astro Starlight
site. The template is starlight. It works with any Starlight site, and with the
Colliery theme starlight-aurora.
What plissken writes
Section titled “What plissken writes”| Output | Description |
|---|---|
One .md page for each module |
Python modules at the top of the output folder, Rust modules in rust/ |
index.md |
The index of the API reference: each module, with the first line of its docs |
_sidebar.mjs |
A Starlight sidebar group: the index (“Overview”), then the Python and Rust modules |
Each page has front matter:
---title: "mycrate::config"description: "The first line of the module docs."editUrl: falsesidebar: order: 3 hidden: true---- Starlight shows
titleas the page heading. editUrl: false: a generated page has no file to edit, so it has no “Edit page” link.sidebar.hiddenkeeps the pages out of anautogenerategroup. The pages are in the sidebar through_sidebar.mjs.- Each page ends with one newline, so
end-of-file-fixerpasses on the output.
plissken owns the output folder. When a module goes away, plissken render
deletes its page, and the folders left empty. It deletes only the pages that it
wrote (they hold its badges); other files in the folder stay.
The pages are .md, not .mdx. They contain Markdown and a small amount of HTML
(badges, anchors and <details> for source code).
Add the API reference to a starlight-aurora site
Section titled “Add the API reference to a starlight-aurora site”You need Node 22 or later, and a site made from the starlight-aurora starter
(template/ in the starlight-aurora repository).
-
In
plissken.toml, set the template and the output path:[output]format = "markdown"path = "docs/src/content/docs/reference/api"template = "starlight"The path must be a folder in
docs/src/content/docs/. For a new project,plissken init --template starlightwrites these values. -
Render the pages:
Terminal window plissken render -
In
docs/astro.config.mjs, import the sidebar group:import apiSidebar from './src/content/docs/reference/api/_sidebar.mjs'; -
Add the group to the sidebar. For example, put it in the Reference group of the starter:
sidebar: [// ...{ label: 'Reference', items: [{ autogenerate: { directory: 'reference' } }, apiSidebar] },// ...], -
Build the site:
Terminal window cd docs && npm run build
To show the group with a different label, use { ...apiSidebar, label: 'API' }.
Run plissken render again after each change to the code. Commit the generated
pages, or render them in the docs workflow before npm run build.
Links and anchors
Section titled “Links and anchors”-
Links between pages, and the links between Python and Rust items, are relative route links (for example
../../mypackage/#class.Task). They work at/and under a GitHub Pages base path such as/project/. -
Each class, struct, enum, function and method has a fixed anchor id:
Item Anchor Python class #class.NameRust struct #struct.NameRust enum #enum.NameRust trait #trait.NameRust constant #const.NAMERust type alias #type.NameFunction #fn.nameMethod #Type.method -
Intra-doc links in Rust doc comments (
[`Config`],[`Config`](crate::config::Config),[handler](super::handler), or a reference definition) point to the page and anchor of the item. A link that plissken cannot resolve (an item of another crate, or one that is not documented) shows as its text. -
Starlight skips a file whose name starts with
_. plissken writes such a module (for examplemypackage._core) asmypackage/_core/index.md. The route staysmypackage/_core/.
Colors and code
Section titled “Colors and code”- Badges use Starlight’s color variables: a fill (
--sl-color-<hue>-low) and text in the same hue (--sl-color-<hue>-high). starlight-aurora sets these from Aurora’s tokens, so the badges follow the light, dark and hyper themes. - Signatures, examples and source code are Markdown code fences. Starlight’s code highlighter draws them in each theme.
- Code fences from Rust doc comments with no language, or with only rustdoc
attributes such as
```ignoreor```rust,no_run, get the languagerust. The hidden lines of a doc test (# use mycrate::Thing;) are left out.
