Skip to content

Commit 0712ae8

Browse files
Add extern_ method to Rustdoc
1 parent 0761802 commit 0712ae8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: src/tools/run-make-support/src/rustdoc.rs

+15
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ impl Rustdoc {
4545
Self { cmd, stdin: None }
4646
}
4747

48+
/// Specify where an external library is located.
49+
pub fn extern_<P: AsRef<Path>>(&mut self, crate_name: &str, path: P) -> &mut Self {
50+
assert!(
51+
!crate_name.contains(|c: char| c.is_whitespace() || c == '\\' || c == '/'),
52+
"crate name cannot contain whitespace or path separators"
53+
);
54+
55+
let path = path.as_ref().to_string_lossy();
56+
57+
self.cmd.arg("--extern");
58+
self.cmd.arg(format!("{crate_name}={path}"));
59+
60+
self
61+
}
62+
4863
/// Specify path to the input file.
4964
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
5065
self.cmd.arg(path.as_ref());

0 commit comments

Comments
 (0)