Development Guide
This guide walks you through setting up your environment, building the project, running tests, and generating documentation for typstyle .
Prerequisites
Rust (stable toolchain) with cargo .
Node.js and yarn (for web assets, if modifying web/
)
Initial Setup
To build Typstyle CLI:
git clone https://github.com/Enter-tainer/typstyle.git
cd typstyle
# Debug
cargo build
# Release
cargo build --release
To run tests, you need to install cargo-nextest and cargo-insta .
Workspace Layout
crates/typstyle/
— formatter CLI
crates/typstyle-core/
— core formatting logic
crates/typstyle-consistency/
— framework for consistency tests
tests/
— code and fixtures for testing core library features
web/
— frontend demo
Running Tests
When you change the core library or fixtures, you need to update snapshots with insta.
When you change the CLI, you need to add or update tests in typstyle/tests .
Specially, when you add a style arg, you need to write a testcase in test_style_args.rs to ensure it works.
cargo nextest list --workspace
Run all tests and review snapshots:
cargo nextest run --workspace --no-fail-fast
cargo insta review
cargo nextest run --workspace -E 'test([snapshot])' --no-fail-fast --no-default-features
cargo insta review
Run tests excluding end-to-end (e2e):
cargo nextest run --workspace -E '!test([e2e])' --no-fail-fast
cargo nextest run -p typstyle --no-fail-fast
Snapshot Review
When snapshot tests change, review and accept updates:
cargo insta review
# or simply
cargo insta accept
Running Benchmarks
Benchmarks use Criterion.rs .
cargo bench --workspace -- --list
You can check target/criterion/report
to see the reports.