|
1 |
| - |
2 |
| -# docs.rs |
| 1 | +# Docs.rs |
3 | 2 |
|
4 | 3 | [](https://travis-ci.org/onur/docs.rs)
|
5 | 4 | [](https://raw.githubusercontent.com/onur/docs.rs/master/LICENSE)
|
6 | 5 |
|
7 |
| -Documentation host for the Rust Programming Language crates. |
8 |
| - |
9 |
| - |
10 |
| -## Installation |
11 |
| - |
12 |
| -cratesfyi needs `cratesfyi-prefix` directory and a postgresql server to run. |
13 |
| -This directory must have: |
14 |
| - |
15 |
| -* Clone of `crates.io-index` repository. |
16 |
| -* `sources` directory for crate sources. |
17 |
| -* `cratesfyi-container` lxc container for building crates. This container |
18 |
| - must use exact same operating system as host machine to avoid conflicts |
19 |
| - (or you can build cratesfyi in guest system). |
20 |
| -* `documentations` directory for crate documentations. |
21 |
| - |
22 |
| - |
23 |
| -An example script to create cratesfyi-prefix directory. Make sure you have |
24 |
| -`git` and `lxc` packages installed. **Run this script as a normal user**: |
25 |
| - |
26 |
| - |
27 |
| -```sh |
28 |
| -#!/bin/sh |
29 |
| -# Creates cratesfyi-prefix directory for cratesfyi |
30 |
| -# This script is designed to run on Debian based operating systems, |
31 |
| -# and tested under Debian jessie and sid |
32 |
| - |
33 |
| -set -e |
34 |
| - |
35 |
| -PREFIX=$(pwd)/cratesfyi-prefix |
36 |
| -DIST_TEMPLATE=debian |
37 |
| -DIST_RELEASE=jessie |
38 |
| -DIST_MIRROR=http://httpredir.debian.org/debian |
39 |
| - |
40 |
| -mkdir $PREFIX |
41 |
| -mkdir -p $PREFIX/sources $PREFIX/documentations |
42 |
| -git clone https://github.com/rust-lang/crates.io-index.git $PREFIX/crates.io-index |
43 |
| - |
44 |
| -# Create debian8 lxc container into cratesfyi-container directory |
45 |
| -# Use your own distribution template and release name |
46 |
| -sudo LANG=C MIRROR=$DIST_MIRROR \ |
47 |
| - lxc-create -n cratesfyi-container -P $PREFIX \ |
48 |
| - -t $DIST_TEMPLATE -- -r $DIST_RELEASE |
49 |
| - |
50 |
| -# Due to some bug in lxc-attach this container |
51 |
| -# must have a symbolic link in /var/lib/lxc |
52 |
| -sudo ln -s $PREFIX/cratesfyi-container /var/lib/lxc |
53 |
| - |
54 |
| -# Container directory must be accessible by current user |
55 |
| -sudo chmod 755 $PREFIX/cratesfyi-container |
56 |
| - |
57 |
| -# Setup lxc network |
58 |
| -echo 'USE_LXC_BRIDGE="true" |
59 |
| -LXC_BRIDGE="lxcbr0" |
60 |
| -LXC_ADDR="10.0.3.1" |
61 |
| -LXC_NETMASK="255.255.255.0" |
62 |
| -LXC_NETWORK="10.0.3.0/24" |
63 |
| -LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" |
64 |
| -LXC_DHCP_MAX="253" |
65 |
| -LXC_DHCP_CONFILE="" |
66 |
| -LXC_DOMAIN=""' | sudo tee /etc/default/lxc-net |
67 |
| - |
68 |
| -# Start network interface |
69 |
| -sudo service lxc-net restart |
70 |
| - |
71 |
| -# Setup network for container |
72 |
| -sudo sed -i 's/lxc.network.type.*/lxc.network.type = veth\nlxc.network.link = lxcbr0/' \ |
73 |
| - $PREFIX/cratesfyi-container/config |
74 |
| - |
75 |
| -# Start lxc container |
76 |
| -sudo lxc-start -n cratesfyi-container |
77 |
| - |
78 |
| -# Add user accounts into container |
79 |
| -# cratesfyi is using multiple user accounts to run cargo simultaneously |
80 |
| -for user in $(whoami) cratesfyi updater; do |
81 |
| - sudo lxc-attach -n cratesfyi-container -- \ |
82 |
| - adduser --disabled-login --disabled-password --gecos "" $user |
83 |
| -done |
84 |
| - |
85 |
| -# Install required packages for rust installation |
86 |
| -sudo lxc-attach -n cratesfyi-container -- apt-get update |
87 |
| -sudo lxc-attach -n cratesfyi-container -- apt-get install -y file git curl sudo ca-certificates |
88 |
| - |
89 |
| -# Install rust nightly into container |
90 |
| -sudo lxc-attach -n cratesfyi-container -- \ |
91 |
| - su - -c 'curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly' |
92 |
| -``` |
93 |
| - |
94 |
| - |
95 |
| -The last step is to install cratesfyi into the guest machine |
96 |
| -(or build in guest machine). If your host and guest |
97 |
| -operating system is same simply build cratesfyi in release mode and copy into |
98 |
| -`/usr/local/bin` directory of guest system: |
| 6 | +Docs.rs (formerly cratesfyi) is an open source project to host documentation |
| 7 | +of crates for the Rust Programming Language. |
99 | 8 |
|
100 |
| -```sh |
101 |
| -cargo build --release |
102 |
| -cp target/release/cratesfyi CRATESFYI_PREFIX_DIR/rootfs/usr/local/bin/ |
103 |
| -``` |
| 9 | +Docs.rs automatically builds crates' documentation released on crates.io using |
| 10 | +the nightly release of the Rust compiler. |
104 | 11 |
|
105 |
| -cratesfyi is only using `lxd-attach` command with sudo. Make sure your user |
106 |
| -account can use this command without root password. Example `sudoers` entry: |
| 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. |
107 | 14 |
|
108 |
| -```text |
109 |
| -yourusername ALL=(ALL) NOPASSWD: /usr/sbin/chroot |
110 |
| -``` |
| 15 | +### Redirections |
111 | 16 |
|
| 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: |
112 | 19 |
|
113 |
| -### Setting up database |
| 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) | |
114 | 26 |
|
115 |
| -cratesfyi is using postgresql database to store crate and build |
116 |
| -information. You need to set up database before using chroot builder. To do |
117 |
| -this: |
| 27 | +The crates.fyi domain will redirect to docs.rs, supporting all of the |
| 28 | +redirects discussed above |
118 | 29 |
|
119 |
| -```sh |
120 |
| -$ sudo su - postgres -c psql |
121 |
| -# First create a user |
122 |
| -postgres=# CREATE USER cratesfyi WITH PASSWORD 'password'; |
123 |
| -postgres=# CREATE DATABASE cratesfyi OWNER cratesfyi; |
124 |
| -postgres=# \q |
125 |
| -# Initialize database with cratesfyi |
126 |
| -CRATESFYI_DATABASE_URL=postgresql://cratesfyi:password@localhost ./cratesfyi database init |
127 |
| -``` |
| 30 | +#### Contributors |
128 | 31 |
|
129 |
| -Make sure to export `CRATESFYI_DATABASE_URL` environment variable before |
130 |
| -using cratesfyi. |
| 32 | +* [https://github.com/onur](Onur Aslan) |
| 33 | +* [https://github.com/frewsxcv](Corey Farwell) |
| 34 | +* [https://github.com/jonhoo](Jon Gjengset) |
| 35 | +* [https://github.com/mattyhall](Matthew Hall) |
| 36 | +* [https://github.com/GuillaumeGomez](Guillaume Gomez) |
| 37 | +* [https://github.com/Mark-Simulacrum](Mark Simulacrum) |
131 | 38 |
|
| 39 | +#### Sponsors |
132 | 40 |
|
133 |
| -## Environment variables |
| 41 | +Hosting generously provided by: |
134 | 42 |
|
135 |
| -cratesfyi is using few environment variables: |
| 43 | + |
136 | 44 |
|
137 |
| -* `CRATESFYI_PREFIX` Prefix directory for cratesfyi |
138 |
| -* `CRATESFYI_DATABASE_URL` Postgresql database URL |
139 |
| -* `RUST_LOG` Set this to desired log level to get log messages |
| 45 | +If you are interested in sponsoring Docs.rs, please don't hesitate to |
| 46 | +contact us at TODO. |
0 commit comments