Back to Slint

Slint Documentation

docs/astro/README.md

1.16.12.7 KB
Original Source
<!-- cSpell: ignore docsnapper -->

Slint Documentation

Prerequisites

  • Rust
  • Node.js
  • pnpm

πŸš€ Project Structure

The documentation site is built with Astro Starlight and reuses its project structure.

docs/
β”œβ”€β”€ public/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ content/
β”‚   β”‚   β”œβ”€β”€ docs/
β”‚   β”‚   └── config.ts
β”‚   └── env.d.ts
β”œβ”€β”€ tests/
β”œβ”€β”€ astro.config.mjs
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└──

Starlight looks for .md or .mdx files in the src/content/docs/ directory. Each file is exposed as a route based on its file name.

Images can be added to src/assets/ and embedded in Markdown with a relative link. They will be optimized for download size and also their width and height will be extracted so the framework can render them without ugly content shifts.

Static assets, like favicons, can be placed in the public/ directory. Note that images in this folder will not be processed and optimized by Starlight.

Building the docs

The docs use a lot of autogenerated content. First create all the screenshots which will be placed at src/assets/generated/.

bash
cargo run -p slint-docsnapper -- docs/astro/src/content --overwrite

Then generate the slint auto generated content.

bash
cargo xtask slintdocs

This xtask also installs the npm dependencies and builds the docs. The equivalent of:

bash
pnpm i
pnpm run build

This will build the site and place it in dist/.

Live edit the docs

To run the live hot reloading dev server run in the astro directory:

bash
cd docs/astro/
pnpm start

This will start the dev server at localhost:4321/docs/.

🧞 Commands

All commands are run from the root of the project, from a terminal:

CommandAction
pnpm iInstalls dependencies
pnpm startStarts local dev server at localhost:4321
pnpm buildBuild your production site to ./dist/
pnpm previewPreview your build locally, before deploying
pnpm run astro ...Run CLI commands like astro add, astro check
npm run astro -- --helpGet help using the Astro CLI

πŸ‘€ Want to learn more about Astro and Starlight?

Check out Starlight’s docs, read the Astro documentation, or jump into the Astro Discord server.