Skip to content

Commit

Permalink
Add extern_ method to Rustdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed May 11, 2024
1 parent 0761802 commit 0712ae8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tools/run-make-support/src/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ impl Rustdoc {
Self { cmd, stdin: None }
}

/// Specify where an external library is located.
pub fn extern_<P: AsRef<Path>>(&mut self, crate_name: &str, path: P) -> &mut Self {
assert!(
!crate_name.contains(|c: char| c.is_whitespace() || c == '\\' || c == '/'),
"crate name cannot contain whitespace or path separators"
);

let path = path.as_ref().to_string_lossy();

self.cmd.arg("--extern");
self.cmd.arg(format!("{crate_name}={path}"));

self
}

/// Specify path to the input file.
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
Expand Down

0 comments on commit 0712ae8

Please sign in to comment.