Docs.rs (formerly cratesfyi) hosts documentation for crates published on crates.io. It builds documentation with rustdoc and the nightly Rust toolchain.
This README contains the commands needed to develop and test docs.rs. See the docs.rs about page for user-facing documentation and the developer guide for architecture, infrastructure, operations, and design documentation.
The recommended setup runs the Rust binaries on the host and external services with Docker Compose. This provides fast incremental Rust builds without requiring PostgreSQL or S3-compatible storage on the host.
Building crates still requires Docker because docs.rs uses rustwide to run
crate builds in isolated containers.
Install:
- Rust and Cargo;
- Docker with the Compose plugin;
- Git;
- GCC and G++;
pkg-config;- Make and CMake;
- zlib development files; and
- OpenSSL development files, such as
libssl-devon Ubuntu.
The initial setup downloads roughly 10 GB of data.
$ git clone https://github.com/rust-lang/docs.rs.git docs.rs
$ cd docs.rs
$ cp .env.sample .env
$ mkdir -p ignored/cratesfyi-prefix/crates.io-index
$ SQLX_OFFLINE=1 cargo buildStart PostgreSQL and the local S3 service, then initialize the database:
$ just compose-up-resources
$ just sqlx-migrate-runMost recipes start these resources automatically; use
just compose-up-resources when running application commands directly. The
cli, builder, watcher, and Compose application recipes also apply pending
migrations before starting.
The just recipes load .env and start PostgreSQL and S3 when needed. Commands
run directly with Cargo need the same environment variables; source .env or
use a dotenv integration for your shell before running them.
Large local files should go in ignored/, which is excluded from both Git and
Docker build contexts.
$ just webThe site is available at http://localhost:3000. To restart it automatically when web, template, asset, shared-library, or workspace configuration files change, run:
$ just web-watchThe watch command runs from the repository root and ignores changes confined to other application binaries, such as the builder and registry watcher.
Set up or update the docs.rs nightly toolchain, then build a release:
$ just builder build update-toolchain
$ just builder build crate regex 1.3.1The builder recipe uses DOCSRS_BUILDER_CLI_MODE: it defaults to local on
amd64 Linux and docker on other platforms. Set the variable explicitly to
override that choice.
The cli and watcher recipes similarly use DOCSRS_CLI_MODE, but default to
local on every platform. Set either mode variable to docker to keep using
the same high-level recipe through its corresponding Compose service.
To test a local package instead:
$ just builder build crate --local /path/to/packageSome workspace packages must first be packaged with Cargo. See Building workspace packages.
If you only need an existing release in your local environment, import it instead of running the builder:
$ just import-release regex latestIf running the Rust binaries on the host is impractical, the just recipes can
keep the same interface while running them through Docker Compose. Add these
settings to .env:
DOCSRS_CLI_MODE=docker
DOCSRS_BUILDER_CLI_MODE=dockerThen use the normal recipes:
$ just cli-db-migrate
$ just compose-up-webAdditional services can be started as needed:
$ just compose-up-builder
$ just compose-up-watcherCommon one-off commands include:
$ just builder build update-toolchain
$ just builder build crate regex 1.3.1
$ just cli queue add regex 1.3.1Use just --list to see all available recipes. The Rust test suite still runs
on the host; the GUI suite has a container integration mode described below. The
lower-level docker-run recipe is available when a specific Compose service
must be selected explicitly, but is not needed for normal development.
To stop the services while retaining their data, or to remove their local data:
$ just compose-down
$ just compose-down-and-wipeThe second command removes this Compose project's containers, images, volumes, and other local artifacts.
Run the complete Rust workspace test suite with:
$ just run-testsThis starts PostgreSQL and S3, builds tests for every workspace member, and runs
cargo test --workspace --locked --no-fail-fast with the required test
environment. Plain cargo test only tests the workspace's default members.
Run the ignored builder tests separately with:
$ just run-builder-testsTest database migrations through both SQLx CLI and docs_rs_admin with:
$ just test-database-migrationsAfter changing queries or migrations, apply migrations and regenerate the committed SQLx offline metadata with:
$ just sqlx-updateRun the complete lint suite with:
$ just lintLinting GitHub Actions workflows requires
actionlint.
If it is not installed, that check is skipped with a warning.
Run all formatters with:
$ just formatIf files are not formatted correctly, this command rewrites them and exits with an error so that you can review the changes.
Prepare the GUI fixture crates once with:
$ just prepare-gui-testsThe builder follows DOCSRS_BUILDER_CLI_MODE, so it normally runs on the host
on amd64 Linux and through the packaged builder image elsewhere. The generated
fixture data remains in PostgreSQL and S3.
Run the GUI tests against a temporary host web server with:
$ just run-gui-testsThis reuses the existing fixtures, so changes limited to templates, CSS,
JavaScript, or web behavior do not require another preparation step. Fixture
data remains available after just compose-down, while
just compose-down-and-wipe removes it.
To reproduce the container integration setup used in CI, run:
$ DOCSRS_CLI_MODE=docker DOCSRS_BUILDER_CLI_MODE=docker \
just prepare-gui-tests run-gui-tests-e2eThis applies migrations through the packaged admin image, builds fixtures through the packaged builder image, and serves them with the packaged web image. The Node/Puppeteer browser runner remains on the host.
These tests use browser-ui-test; its script documentation describes the test format. To run only the browser assertions against a web server already listening on port 3000, use:
$ just run-gui-browser-testsThe test suite needs at least 4096 open file descriptors. If tests fail or time out because the limit is too low, raise it in the current shell:
$ ulimit -n 4096The developer guide covers the components and workflows beyond this basic setup, including:
- binaries and services;
- development notes;
- infrastructure;
- production operations; and
- design documentation.
Build and open the guide locally with:
$ just book-openTest its examples and links with:
$ just book-testDocs.rs and rustwide use the
crates-build-env Docker images
as the crate build environment. Add missing system dependencies there.
Docs.rs is run and maintained by the docs.rs team. You can find us in #t-docs-rs on Zulip. Development problems and bugs can also be reported in the issue tracker.