Skip to content

Commit 332056d

Browse files
committed
Use a workspace for separate crates
1 parent aafd713 commit 332056d

File tree

4 files changed

+42
-16
lines changed

4 files changed

+42
-16
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ jobs:
5858
psql "${CRATESFYI_DATABASE_URL}"
5959
6060
- name: Build
61-
run: cargo build --locked
61+
run: cargo build --all --locked
6262

6363
- name: Test
64-
run: cargo test --locked
64+
run: cargo test --all --locked
6565

6666
- name: Clean up the database
6767
run: docker-compose down --volumes

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ repository = "https://github.com/rust-lang/docs.rs"
88
build = "build.rs"
99
edition = "2018"
1010

11+
[workspace]
12+
1113
[dependencies]
1214
log = "0.4"
1315
regex = "1"

metadata/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

metadata/lib.rs

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(missing_docs)]
2-
32
// N.B. requires nightly rustdoc to document until intra-doc links are stabilized.
43
//! Collect information that allows you to build a crate the same way that docs.rs would.
54
//!
@@ -33,7 +32,7 @@
3332
//! # }
3433
//! ```
3534
36-
use std::collections::{HashSet, HashMap};
35+
use std::collections::{HashMap, HashSet};
3736
use std::io;
3837
use std::path::Path;
3938

@@ -170,7 +169,7 @@ impl Metadata {
170169
///
171170
/// [`from_str`]: std::str::FromStr
172171
pub fn from_manifest<P: AsRef<Path>>(path: P) -> Result<Metadata, MetadataError> {
173-
use std::{str::FromStr, fs};
172+
use std::{fs, str::FromStr};
174173
let buf = fs::read_to_string(path)?;
175174
Metadata::from_str(&buf).map_err(Into::into)
176175
}
@@ -234,9 +233,7 @@ impl Metadata {
234233

235234
/// Return the environment variables that should be set when building this crate.
236235
pub fn environment_variables(&self) -> HashMap<&'static str, String> {
237-
let joined = |v: &Option<Vec<_>>| v.as_ref()
238-
.map(|args| args.join(" "))
239-
.unwrap_or_default();
236+
let joined = |v: &Option<Vec<_>>| v.as_ref().map(|args| args.join(" ")).unwrap_or_default();
240237

241238
let mut map = HashMap::new();
242239
map.insert("RUSTFLAGS", joined(&self.rustc_args));
@@ -332,8 +329,8 @@ impl Default for Metadata {
332329

333330
#[cfg(test)]
334331
mod test_parsing {
335-
use std::str::FromStr;
336332
use super::*;
333+
use std::str::FromStr;
337334

338335
#[test]
339336
fn test_cratesfyi_metadata() {
@@ -402,7 +399,8 @@ mod test_parsing {
402399
[package]
403400
name = "test"
404401
"#,
405-
).unwrap();
402+
)
403+
.unwrap();
406404
assert!(metadata.targets.is_none());
407405

408406
// targets explicitly set to empty array
@@ -411,7 +409,8 @@ mod test_parsing {
411409
[package.metadata.docs.rs]
412410
targets = []
413411
"#,
414-
).unwrap();
412+
)
413+
.unwrap();
415414
assert!(metadata.targets.unwrap().is_empty());
416415
}
417416
}
@@ -616,16 +615,42 @@ mod test_calculations {
616615

617616
// rustdocflags
618617
let metadata = Metadata {
619-
rustdoc_args: Some(vec!["-Z".into(), "unstable-options".into(), "--static-root-path".into(), "/".into(), "--cap-lints".into(), "warn".into()]),
618+
rustdoc_args: Some(vec![
619+
"-Z".into(),
620+
"unstable-options".into(),
621+
"--static-root-path".into(),
622+
"/".into(),
623+
"--cap-lints".into(),
624+
"warn".into(),
625+
]),
620626
..Metadata::default()
621627
};
622-
assert_eq!(metadata.environment_variables().get("RUSTDOCFLAGS").map(String::as_str), Some("-Z unstable-options --static-root-path / --cap-lints warn"));
628+
assert_eq!(
629+
metadata
630+
.environment_variables()
631+
.get("RUSTDOCFLAGS")
632+
.map(String::as_str),
633+
Some("-Z unstable-options --static-root-path / --cap-lints warn")
634+
);
623635

624636
// rustdocflags
625637
let metadata = Metadata {
626-
rustc_args: Some(vec!["-Z".into(), "unstable-options".into(), "--static-root-path".into(), "/".into(), "--cap-lints".into(), "warn".into()]),
638+
rustc_args: Some(vec![
639+
"-Z".into(),
640+
"unstable-options".into(),
641+
"--static-root-path".into(),
642+
"/".into(),
643+
"--cap-lints".into(),
644+
"warn".into(),
645+
]),
627646
..Metadata::default()
628647
};
629-
assert_eq!(metadata.environment_variables().get("RUSTFLAGS").map(String::as_str), Some("-Z unstable-options --static-root-path / --cap-lints warn"));
648+
assert_eq!(
649+
metadata
650+
.environment_variables()
651+
.get("RUSTFLAGS")
652+
.map(String::as_str),
653+
Some("-Z unstable-options --static-root-path / --cap-lints warn")
654+
);
630655
}
631656
}

0 commit comments

Comments
 (0)