@@ -9,46 +9,33 @@ of crates for the Rust Programming Language.
9
9
Docs.rs automatically builds crates' documentation released on crates.io using
10
10
the nightly release of the Rust compiler.
11
11
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.
14
13
15
- ### Redirections
14
+ ## Changing the build environment
16
15
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 ) .
29
18
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
34
20
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.
37
24
38
- Example badges for ` mio ` crate:
25
+ ### Dependencies
39
26
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.
45
28
29
+ - gcc
30
+ - g++
31
+ - pkg-config
32
+ - git
33
+ - make
34
+ - cmake
35
+ - zlib
36
+ - openssl
46
37
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.
52
39
53
40
### Getting started
54
41
@@ -57,35 +44,42 @@ Make sure you have docker-compose and are able to download ~10GB data on the fir
57
44
``` sh
58
45
git clone https://github.com/rust-lang/docs.rs.git docs.rs
59
46
cd docs.rs
47
+ # Configure the default settings for external services
60
48
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
64
53
# Build a sample crate to make sure it works
65
54
# This sets up the docs.rs build environment, including installing the nightly
66
55
# 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
69
57
# 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
74
59
```
75
60
76
61
If you need to store big files in the repository's directory it's recommended to
77
62
put them in the ` ignored/ ` subdirectory, which is ignored both by git and
78
63
Docker.
79
64
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
+
80
74
### Running tests
81
75
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.
83
77
84
78
```
85
79
cargo test
86
80
```
87
81
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
89
83
` CRATESFYI_DATABASE_URL ` in ` .env ` to the url of a PostgreSQL database,
90
84
and set the ` AWS_ACCESS_KEY_ID ` , ` S3_ENDPOINT ` , and ` AWS_SECRET_ACCESS_KEY ` variables.
91
85
We have some reasonable default parameters in ` .env.sample ` .
@@ -101,7 +95,7 @@ If you don't want to use docker-compose, see the
101
95
for more information on how to setup this environment.
102
96
Note that either way, you will need docker installed for sandboxing with Rustwide.
103
97
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
105
99
106
100
### Docker-Compose
107
101
@@ -111,7 +105,7 @@ Three services are defined:
111
105
| name | access | credentials | description |
112
106
| ------| -------------------------------------------------| ----------------------------| ----------------------------------------|
113
107
| 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 |
115
109
| s3 | http://localhost:9000 | ` cratesfyi ` - ` secret_key ` | Minio (simulates AWS S3) used by web |
116
110
117
111
[ docker-compose.yml ] : ./docker-compose.yml
@@ -133,12 +127,13 @@ This is probably because you have `git.autocrlf` set to true,
133
127
134
128
### CLI
135
129
136
- #### Starting web server
130
+ See ` cargo run -- --help ` for a full list of commands.
131
+
132
+ #### Starting the web server
137
133
138
134
``` 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
142
137
```
143
138
144
139
#### ` build ` subcommand
@@ -147,16 +142,16 @@ docker-compose up
147
142
# Builds <CRATE_NAME> <CRATE_VERSION> and adds it into database
148
143
# This is the main command to build and add a documentation into docs.rs.
149
144
# 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>
151
146
152
- # Builds every crate and adds them into database
147
+ # Builds every crate on crates.io and adds them into database
153
148
# (beware: this may take months to finish)
154
- docker-compose run web build world
149
+ cargo run web build world
155
150
156
151
# Builds a local package you have at <SOURCE> and adds it to the database.
157
152
# The package does not have to be on crates.io.
158
153
# 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
160
155
```
161
156
162
157
#### ` database ` subcommand
@@ -176,40 +171,32 @@ If you want to explore or edit database manually, you can connect to the databas
176
171
with the ` psql ` command.
177
172
178
173
``` 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
184
176
```
185
177
186
178
The database contains a blacklist of crates that should not be built.
187
179
188
180
``` sh
189
181
# List the crates on the blacklist
190
- docker-compose run web database blacklist list
182
+ cargo run web database blacklist list
191
183
192
184
# 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>
194
186
195
187
# 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>
197
189
```
198
190
199
191
#### ` daemon ` subcommand
200
192
201
193
``` sh
202
194
# 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 >
206
198
```
207
199
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
-
213
200
### Contact
214
201
215
202
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