From: Guillaume Gomez Date: Thu, 20 Dec 2018 12:28:55 +0000 (+0100) Subject: Add no-crate filter option on rustdoc X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=dbcf68951c564f946ab0021c7699ea1a4bf861d0;p=rust.git Add no-crate filter option on rustdoc --- diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index f9a46fe362e..7962b45907a 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -195,6 +195,9 @@ pub struct RenderOptions { /// If present, playground URL to use in the "Run" button added to code samples generated from /// standalone Markdown files. If not present, `playground_url` is used. pub markdown_playground_url: Option, + /// If false, the `select` element to have search filtering by crates on rendered docs + /// won't be generated. + pub generate_search_filter: bool, } impl Options { @@ -437,6 +440,7 @@ pub fn from_matches(matches: &getopts::Matches) -> Result { let crate_version = matches.opt_str("crate-version"); let enable_index_page = matches.opt_present("enable-index-page") || index_page.is_some(); let static_root_path = matches.opt_str("static-root-path"); + let generate_search_filter = !matches.opt_present("disable-per-crate-search"); let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format); @@ -479,6 +483,7 @@ pub fn from_matches(matches: &getopts::Matches) -> Result { markdown_no_toc, markdown_css, markdown_playground_url, + generate_search_filter, } }) } diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index d8a57bc93fd..9caeec39ab1 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -35,10 +35,15 @@ pub struct Page<'a> { } pub fn render( - dst: &mut dyn io::Write, layout: &Layout, page: &Page, sidebar: &S, t: &T, - css_file_extension: bool, themes: &[PathBuf]) - -> io::Result<()> -{ + dst: &mut dyn io::Write, + layout: &Layout, + page: &Page, + sidebar: &S, + t: &T, + css_file_extension: bool, + themes: &[PathBuf], + generate_search_filter: bool, +) -> io::Result<()> { let static_root_path = page.static_root_path.unwrap_or(page.root_path); write!(dst, "\ @@ -91,10 +96,7 @@ pub fn render(