Skip to content

Commit 0602f95

Browse files
authored
Merge pull request #10293 from Turbo87/package-docs
Add `README.md` files to subpackages
2 parents 6d6a8ac + 3190022 commit 0602f95

File tree

26 files changed

+178
-8
lines changed

26 files changed

+178
-8
lines changed

crates/crates_io_database/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# crates_io_database
2+
3+
This package contains the crates.io database schema as derived by `diesel print-schema`
4+
from the database after all the migrations have been applied.
5+
6+
After creating new migrations (via `diesel migration generate`), you can update
7+
the schema by running:
8+
9+
```sh
10+
diesel print-schema > crates/crates_io_database/src/schema.rs
11+
```
12+
13+
## `schema.patch`
14+
15+
Note that there is also a `schema.patch` file in this package, since the output
16+
of `diesel-cli` needs to be tweaked a little for our purposes. For example,
17+
it currently does not support printing materialized views in the same way as
18+
regular tables, so we have to manually add them to the schema file.
19+
20+
If you need to update the patch file, you can do so by following these steps:
21+
22+
1. prefix `patch_file = "src/schema.patch"` in `diesel.toml` with a `#` to comment it out.
23+
2. use `diesel print-schema` and save the output to `src/schema.rs.orig`
24+
3. use `patch -o src/schema.rs src/schema.rs.orig src/schema.patch` to apply the patch file and solve remaining issues in the `src/schema.rs` file
25+
4. use `diff -Naur src/schema.rs.orig src/schema.rs` to generate the new content for the `src/schema.patch` file
26+
5. enable the `patch_file` option in the `diesel.toml` file again.

crates/crates_io_database/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
#![doc = include_str!("../README.md")]
2+
13
pub mod schema;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# crates_io_database_dump
2+
3+
This package contains the code and data to create a database dump for the
4+
crates.io database.
5+
6+
The most important file in this package is the `dump-db.toml` file, which
7+
defines how the database tables are serialized into CSV files. Specifically,
8+
it can be used to skip certain columns for privacy reasons, it can declare the
9+
serialization order of the tables, and it can declare filters, if not all rows
10+
should be dumped.

crates/crates_io_database_dump/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../README.md")]
2+
13
use anyhow::{anyhow, Context};
24
use serde::Serialize;
35
use std::fs;

crates/crates_io_env_vars/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# crates_io_env_vars
2+
3+
This package contains convenient wrappers for the `std::env::var()` function.
4+
5+
These functions use the `dotenvy` crate to automatically load environment
6+
variables from a `.env` file, if it exists. This is useful for development
7+
environments, where you don't want to set all environment variables manually.
8+
9+
There are also variants of the functions that make use of the `FromStr` trait to
10+
automatically parse the environment variables into the desired types or fail
11+
with corresponding error messages.
12+
13+
Finally, there are `list()` functions that allow parsing of comma-separated
14+
lists of values.

crates/crates_io_env_vars/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../README.md")]
2+
13
use anyhow::{anyhow, Context};
24
use std::error::Error;
35
use std::str::FromStr;

crates/crates_io_github/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# crates_io_github
2+
3+
This package implements functionality for interacting with the GitHub API.
4+
5+
It contains a `GitHubClient` trait that defines the supported operations, that
6+
the crates.io codebase needs to interact with GitHub. The `RealGitHubClient`
7+
struct is an implementation of this trait that uses the `reqwest` crate to
8+
perform the actual HTTP requests.
9+
10+
If the `mock` feature is enabled, a `MockGitHubClient` struct is available,
11+
which can be used for testing purposes. This struct is generated automatically
12+
by the [`mockall`](https://docs.rs/mockall) crate.

crates/crates_io_github/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! This module implements functionality for interacting with GitHub.
1+
#![doc = include_str!("../README.md")]
22

33
#[macro_use]
44
extern crate tracing;

crates/crates_io_index/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# crates_io_index
2+
3+
This package contains the code necessary to interact with the
4+
[crates.io-index repository](https://github.com/rust-lang/crates.io-index).
5+
6+
Specifically, it contains:
7+
8+
- the data structures used to serialize and deserialize the files in the index
9+
- a `Repository` abstraction to perform various operations on the index
10+
- and, for testing purposes, an `UpstreamIndex` struct that can be used to
11+
create a fake index locally.

crates/crates_io_index/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("README.md")]
2+
13
#[macro_use]
24
extern crate serde;
35
#[macro_use]

0 commit comments

Comments
 (0)