Skip to content

Commit 0054749

Browse files
jyn514Joshua Nelson
authored and
Joshua Nelson
committed
Update README
- Point users to the /about page - Recommend `cargo run` over `docker-compose up` - Document native dependencies - Suggest `--registry-watcher disabled` for the daemon
1 parent 818e365 commit 0054749

File tree

1 file changed

+56
-69
lines changed

1 file changed

+56
-69
lines changed

README.md

Lines changed: 56 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,33 @@ of crates for the Rust Programming Language.
99
Docs.rs automatically builds crates' documentation released on crates.io using
1010
the nightly release of the Rust compiler.
1111

12-
The README of a crate is taken from the readme field defined in Cargo.toml.
13-
If a crate doesn't have this field, no README will be displayed.
12+
This readme is for developing docs.rs. See [the about page](https://docs.rs/about) for user-facing documentation.
1413

15-
### Redirections
14+
## Changing the build environment
1615

17-
Docs.rs is using semver to parse URLs. You can use this feature to access
18-
crates' documentation easily. Example of URL redirections for `clap` crate:
19-
20-
| URL | Redirects to documentation of |
21-
|-----------------------------------------------|--------------------------------------------------|
22-
| <https://docs.rs/clap> | Latest version of clap |
23-
| <https://docs.rs/clap/~2> | 2.* version |
24-
| <https://docs.rs/clap/~2.9> | 2.9.* version |
25-
| <https://docs.rs/clap/2.9.3> | 2.9.3 version (you don't need = unlike semver) |
26-
| <https://docs.rs/clap/*/clap/struct.App.html> | Latest version of this page (if it still exists).|
27-
28-
### Badges
16+
To make a change to [the build environment](https://github.com/rust-lang/crates-build-env)
17+
and test that it works on docs.rs, see [the wiki](https://forge.rust-lang.org/docs-rs/add-dependencies.html).
2918

30-
You can use badges to show state of your documentation to your users.
31-
The default badge will be pointed at the latest version of a crate.
32-
You can use `version` parameter to show status of documentation for
33-
any version you want.
19+
## Development
3420

35-
Badge will display in blue if docs.rs is successfully hosting your crate
36-
documentation, and red if building documentation failing.
21+
The recommended way to develop docs.rs is a combination of `cargo run` for
22+
the main binary and [docker-compose](https://docs.docker.com/compose/) for the external services.
23+
This gives you reasonable incremental build times without having to add new users and packages to your host machine.
3724

38-
Example badges for `mio` crate:
25+
### Dependencies
3926

40-
| URL | Badge |
41-
|-------|-------|
42-
| Latest version: <https://docs.rs/mio/badge.svg> | ![mio](https://docs.rs/mio/badge.svg) |
43-
| Version 0.4.4: <https://docs.rs/mio/badge.svg?version=0.4.4> | ![mio](https://docs.rs/mio/badge.svg?version=0.4.4) |
44-
| Version 0.1.0: <https://docs.rs/mio/badge.svg?version=0.1.0> | ![mio](https://docs.rs/mio/badge.svg?version=0.1.0) |
27+
Docs.rs requires at least the following native C dependencies.
4528

29+
- gcc
30+
- g++
31+
- pkg-config
32+
- git
33+
- make
34+
- cmake
35+
- zlib
36+
- openssl
4637

47-
## Development
48-
49-
We strongly recommend using [docker-compose](https://docs.docker.com/compose/),
50-
which will make it easier to get started without adding new users and packages
51-
to your host machine.
38+
There may be other dependencies that have not been documented.
5239

5340
### Getting started
5441

@@ -57,35 +44,42 @@ Make sure you have docker-compose and are able to download ~10GB data on the fir
5744
```sh
5845
git clone https://github.com/rust-lang/docs.rs.git docs.rs
5946
cd docs.rs
47+
# Configure the default settings for external services
6048
cp .env.sample .env
61-
62-
docker-compose build # This builds the docs.rs binary
63-
49+
# Builds the docs.rs binary
50+
cargo build
51+
# Start the extenal services
52+
docker-compose up -d db s3
6453
# Build a sample crate to make sure it works
6554
# This sets up the docs.rs build environment, including installing the nightly
6655
# Rust toolchain. This will take a while the first time but will be cached afterwards.
67-
docker-compose run web build crate regex 1.3.1
68-
56+
cargo run web build crate regex 1.3.1
6957
# This starts the web server but does not build any crates.
70-
# If you want to build crates, see below under `build` subcommand.
71-
# It should print a link to the website once it finishes initializing.
72-
docker-compose up
73-
58+
cargo run start-web-server
7459
```
7560

7661
If you need to store big files in the repository's directory it's recommended to
7762
put them in the `ignored/` subdirectory, which is ignored both by git and
7863
Docker.
7964

65+
### Pure docker-compose
66+
67+
If you have trouble with the above commands, consider using `docker-compose up`,
68+
which uses docker-compose for the web server as well.
69+
This will not cache dependencies as well - in particular, you'll have to rebuild all 400 whenever the lockfile changes -
70+
but makes sure that you're in a known environment so you should have fewer problems getting started.
71+
72+
Please file bugs for any trouble you have running docs.rs!
73+
8074
### Running tests
8175

82-
Tests are run outside of the docker-compose environment, and can be run with:
76+
Tests are only supported via cargo, not docker-compose.
8377

8478
```
8579
cargo test
8680
```
8781

88-
Some tests require access to the database. To run them, set the
82+
Most tests require access to the database. To run them, set the
8983
`CRATESFYI_DATABASE_URL` in `.env` to the url of a PostgreSQL database,
9084
and set the `AWS_ACCESS_KEY_ID`, `S3_ENDPOINT`, and `AWS_SECRET_ACCESS_KEY` variables.
9185
We have some reasonable default parameters in `.env.sample`.
@@ -101,7 +95,7 @@ If you don't want to use docker-compose, see the
10195
for more information on how to setup this environment.
10296
Note that either way, you will need docker installed for sandboxing with Rustwide.
10397

104-
[wiki-no-compose]: https://github.com/rust-lang/docs.rs/wiki/Developing-without-docker-compose
98+
[wiki-no-compose]: https://forge.rust-lang.org/docs-rs/no-docker-compose.html
10599

106100
### Docker-Compose
107101

@@ -111,7 +105,7 @@ Three services are defined:
111105
| name | access | credentials | description |
112106
|------|-------------------------------------------------|----------------------------|----------------------------------------|
113107
| web | http://localhost:3000 | N/A | A container running the docs.rs binary |
114-
| db | postgresql://cratesfyi:password@localhost:15432/ | - | Postgres database used by web |
108+
| db | postgresql://cratesfyi:password@localhost:15432 | - | Postgres database used by web |
115109
| s3 | http://localhost:9000 | `cratesfyi` - `secret_key` | Minio (simulates AWS S3) used by web |
116110

117111
[docker-compose.yml]: ./docker-compose.yml
@@ -133,12 +127,13 @@ This is probably because you have `git.autocrlf` set to true,
133127

134128
### CLI
135129

136-
#### Starting web server
130+
See `cargo run -- --help` for a full list of commands.
131+
132+
#### Starting the web server
137133

138134
```sh
139-
# This command will start web interface of docs.rs and you can access it from
140-
# http://localhost:3000/`
141-
docker-compose up
135+
# This command will start web interface of docs.rs on http://localhost:3000
136+
cargo run start-web-server
142137
```
143138

144139
#### `build` subcommand
@@ -147,16 +142,16 @@ docker-compose up
147142
# Builds <CRATE_NAME> <CRATE_VERSION> and adds it into database
148143
# This is the main command to build and add a documentation into docs.rs.
149144
# For example, `docker-compose run web build crate regex 1.1.6`
150-
docker-compose run web build crate <CRATE_NAME> <CRATE_VERSION>
145+
cargo run web build crate <CRATE_NAME> <CRATE_VERSION>
151146

152-
# Builds every crate and adds them into database
147+
# Builds every crate on crates.io and adds them into database
153148
# (beware: this may take months to finish)
154-
docker-compose run web build world
149+
cargo run web build world
155150

156151
# Builds a local package you have at <SOURCE> and adds it to the database.
157152
# The package does not have to be on crates.io.
158153
# The package must be on the local filesystem, git urls are not allowed.
159-
docker-compose run -v "$(realpath <SOURCE>)":/build web build crate --local /build
154+
cargo build crate --local /path/to/source
160155
```
161156

162157
#### `database` subcommand
@@ -176,40 +171,32 @@ If you want to explore or edit database manually, you can connect to the databas
176171
with the `psql` command.
177172

178173
```sh
179-
# NOTE: this creates a new container that will keep running after you exit
180-
# To remove the new container, run `docker-compose down`.
181-
docker exec -it "$(docker-compose run -d db && sleep 1)" psql -U cratesfyi
182-
# You only need to start the container once, in the future you can attach to it like so:
183-
docker exec -it "$(docker container ps | grep postgres | cut -d ' ' -f 1)" psql -U cratesfyi
174+
. .env
175+
psql $CRATESFYI_DATABASE_URL
184176
```
185177

186178
The database contains a blacklist of crates that should not be built.
187179

188180
```sh
189181
# List the crates on the blacklist
190-
docker-compose run web database blacklist list
182+
cargo run web database blacklist list
191183

192184
# Adds <CRATE_NAME> to the blacklist
193-
docker-compose run web database blacklist add <CRATE_NAME>
185+
cargo run web database blacklist add <CRATE_NAME>
194186

195187
# Removes <CRATE_NAME> from the blacklist
196-
docker-compose run web database blacklist remove <CRATE_NAME>
188+
cargo run web database blacklist remove <CRATE_NAME>
197189
```
198190

199191
#### `daemon` subcommand
200192

201193
```sh
202194
# Run a persistent daemon which queues builds and starts a web server.
203-
# Warning: This will try to queue hundreds of packages on crates.io, only start it
204-
# if you have enough resources!
205-
docker-compose run -p 3000:3000 web daemon
195+
cargo run daemon --registry-watcher disabled
196+
# Add crates to the queue
197+
cargo run queue add <CRATE> <VERSION>
206198
```
207199

208-
### Changing the build environment
209-
210-
To make a change to [the build environment](https://github.com/rust-lang/crates-build-env)
211-
and test that it works on docs.rs, see [the wiki](https://github.com/rust-lang/docs.rs/wiki/Making-changes-to-the-build-environment).
212-
213200
### Contact
214201

215202
Docs.rs is run and maintained by the [docs.rs team](https://www.rust-lang.org/governance/teams/dev-tools#docs-rs).

0 commit comments

Comments
 (0)