-
Notifications
You must be signed in to change notification settings - Fork 1
/
rustdoc.rs
40 lines (38 loc) · 939 Bytes
/
rustdoc.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use super::Result;
use crate::rustc::Edition;
use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
pub struct RustDoc {
edition: Edition,
crate_name: String,
lib_path: PathBuf,
}
impl RustDoc {
pub fn new(
edition: Edition,
crate_name: impl Into<String>,
lib_path: impl Into<PathBuf>,
) -> Self {
Self {
edition,
crate_name: crate_name.into(),
lib_path: lib_path.into(),
}
}
pub fn test(&self, path: impl AsRef<Path>) -> Result<()> {
let path = path.as_ref();
Command::new("rustdoc")
.arg("--test")
.arg(path)
.arg("--crate-name")
.arg(&self.crate_name)
.arg("--edition")
.arg(self.edition.to_string())
.arg("-L")
.arg(&self.lib_path)
.spawn()?
.wait()?;
Ok(())
}
}