diff options
| author | Mateusz Mikuła <matti@marinelayer.io> | 2019-08-06 14:55:57 +0200 |
|---|---|---|
| committer | Mateusz Mikuła <mati865@gmail.com> | 2019-08-09 10:32:34 +0200 |
| commit | c7e16c5f47ac86877ab6c52db61709349e4cf276 (patch) | |
| tree | d53dacf567b536a14d641ee6ca7c4efe719b5f72 /src/tools/rustbook | |
| parent | d8f8be4636f6f49d28f548e0b8730f8e916b070d (diff) | |
| download | rust-c7e16c5f47ac86877ab6c52db61709349e4cf276.tar.gz rust-c7e16c5f47ac86877ab6c52db61709349e4cf276.zip | |
Check links on all platforms when running locally
Diffstat (limited to 'src/tools/rustbook')
| -rw-r--r-- | src/tools/rustbook/Cargo.toml | 7 | ||||
| -rw-r--r-- | src/tools/rustbook/src/main.rs | 13 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index bb10d06851b..a7188f0d11e 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -5,14 +5,15 @@ version = "0.1.0" license = "MIT OR Apache-2.0" edition = "2018" +[features] +linkcheck = ["mdbook-linkcheck"] + [dependencies] clap = "2.25.0" failure = "0.1" +mdbook-linkcheck = { version = "0.3.0", optional = true } [dependencies.mdbook] version = "0.3.0" default-features = false features = ["search"] - -[target.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.dependencies] -mdbook-linkcheck = "0.3.0" diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 6bce7c3a978..95530b210af 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -8,10 +8,9 @@ use clap::{App, ArgMatches, SubCommand, AppSettings}; use mdbook::MDBook; use mdbook::errors::{Result as Result3}; -#[cfg(all(target_arch = "x86_64", target_os = "linux"))] +#[cfg(feature = "linkcheck")] use mdbook::renderer::RenderContext; - -#[cfg(all(target_arch = "x86_64", target_os = "linux"))] +#[cfg(feature = "linkcheck")] use mdbook_linkcheck::{self, errors::BrokenLinks}; use failure::Error; @@ -52,7 +51,7 @@ fn main() { if let Err(err) = linkcheck(sub_matches) { eprintln!("Error: {}", err); - #[cfg(all(target_arch = "x86_64", target_os = "linux"))] + #[cfg(feature = "linkcheck")] { if let Ok(broken_links) = err.downcast::<BrokenLinks>() { for cause in broken_links.links().iter() { @@ -68,7 +67,7 @@ fn main() { }; } -#[cfg(all(target_arch = "x86_64", target_os = "linux"))] +#[cfg(feature = "linkcheck")] pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> { let book_dir = get_book_dir(args); let book = MDBook::load(&book_dir).unwrap(); @@ -78,9 +77,9 @@ pub fn linkcheck(args: &ArgMatches<'_>) -> Result<(), Error> { mdbook_linkcheck::check_links(&render_ctx) } -#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))] +#[cfg(not(feature = "linkcheck"))] pub fn linkcheck(_args: &ArgMatches<'_>) -> Result<(), Error> { - println!("mdbook-linkcheck only works on x86_64 linux targets."); + println!("mdbook-linkcheck is disabled."); Ok(()) } |
