Skip to content

enable crate maintainers to trigger docs.rs rebuilds from crates.io #11169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ crates_io_cdn_logs = { path = "crates/crates_io_cdn_logs" }
crates_io_database = { path = "crates/crates_io_database" }
crates_io_database_dump = { path = "crates/crates_io_database_dump" }
crates_io_diesel_helpers = { path = "crates/crates_io_diesel_helpers" }
crates_io_docs_rs = { path = "crates/crates_io_docs_rs" }
crates_io_env_vars = { path = "crates/crates_io_env_vars" }
crates_io_github = { path = "crates/crates_io_github" }
crates_io_index = { path = "crates/crates_io_index" }
Expand Down Expand Up @@ -138,6 +139,7 @@ utoipa-axum = "=0.2.0"

[dev-dependencies]
bytes = "=1.10.1"
crates_io_docs_rs = { path = "crates/crates_io_docs_rs", features = ["mock"] }
crates_io_github = { path = "crates/crates_io_github", features = ["mock"] }
crates_io_index = { path = "crates/crates_io_index", features = ["testing"] }
crates_io_tarball = { path = "crates/crates_io_tarball", features = ["builder"] }
Expand Down
31 changes: 31 additions & 0 deletions crates/crates_io_docs_rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "crates_io_docs_rs"
version = "0.0.0"
license = "MIT OR Apache-2.0"
edition = "2024"

[lints]
workspace = true

[features]
mock = ["dep:mockall"]

[dependencies]
anyhow = "=1.0.98"
async-trait = "=0.1.88"
crates_io_env_vars = { path = "../crates_io_env_vars" }
http = "=1.3.1"
mockall = { version = "=0.13.1", optional = true }
reqwest = { version = "=0.12.15", features = ["json"] }
serde = { version = "=1.0.219", features = ["derive"] }
thiserror = "=2.0.12"
tracing = "=0.1.41"
url = "=2.5.4"

[dev-dependencies]
claims = "=0.8.0"
serde_json = "=1.0.140"
mockito = "=1.7.0"
test-case = "=3.3.1"
tokio = { version = "=1.45.0", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = "=0.3.19"
12 changes: 12 additions & 0 deletions crates/crates_io_docs_rs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# crates_io_docs_rs

This package implements functionality for interacting with the docs.rs API.

It contains a `DocsRsClient` trait that defines the supported operations, that
the crates.io codebase needs to interact with docs.rs. The `RealDocsRsClient`
struct is an implementation of this trait that uses the `reqwest` crate to
perform the actual HTTP requests.

If the `mock` feature is enabled, a `MockDocsRsClient` struct is available,
which can be used for testing purposes. This struct is generated automatically
by the [`mockall`](https://docs.rs/mockall) crate.
18 changes: 18 additions & 0 deletions crates/crates_io_docs_rs/examples/test_docs_rs_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use anyhow::{Result, anyhow};
use crates_io_docs_rs::{DocsRsClient, RealDocsRsClient};
use std::env;

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();

let access_token = env::args()
.nth(1)
.ok_or_else(|| anyhow!("Missing access token"))?;

let docs_rs = RealDocsRsClient::new("https://docs.rs", access_token)?;

docs_rs.rebuild_docs("empty-library", "1.0.0").await?;

Ok(())
}
Loading