pub fn run(mut krate: clean::Crate,
           options: RenderOptions,
           renderinfo: RenderInfo,
           diag: &errors::Handler,
           edition: Edition) -> Result<(), Error> {
    // need to save a copy of the options for rendering the index page
    let md_opts = options.clone();
    let RenderOptions {
        output,
        external_html,
        id_map,
        playground_url,
        sort_modules_alphabetically,
        themes,
        extension_css,
        extern_html_root_urls,
        resource_suffix,
        static_root_path,
        generate_search_filter,
        generate_redirect_pages,
        ..
    } = options;

    let src_root = match krate.src {
        FileName::Real(ref p) => match p.parent() {
            Some(p) => p.to_path_buf(),
            None => PathBuf::new(),
        },
        _ => PathBuf::new(),
    };
    let mut errors = Arc::new(ErrorStorage::new());
    // If user passed in `--playground-url` arg, we fill in crate name here
    let mut playground = None;
    if let Some(url) = playground_url {
        playground = Some(markdown::Playground {
            crate_name: Some(krate.name.clone()),
            url,
        });
    }
    let mut layout = layout::Layout {
        logo: String::new(),
        favicon: String::new(),
        external_html,
        krate: krate.name.clone(),
        css_file_extension: extension_css,
        generate_search_filter,
    };
    let mut issue_tracker_base_url = None;
    let mut include_sources = true;

    // Crawl the crate attributes looking for attributes which control how we're
    // going to emit HTML
    if let Some(attrs) = krate.module.as_ref().map(|m| &m.attrs) {
        for attr in attrs.lists(sym::doc) {
            match (attr.name_or_empty(), attr.value_str()) {
                (sym::html_favicon_url, Some(s)) => {
                    layout.favicon = s.to_string();
                }
                (sym::html_logo_url, Some(s)) => {
                    layout.logo = s.to_string();
                }
                (sym::html_playground_url, Some(s)) => {
                    playground = Some(markdown::Playground {
                        crate_name: Some(krate.name.clone()),
                        url: s.to_string(),
                    });
                }
                (sym::issue_tracker_base_url, Some(s)) => {
                    issue_tracker_base_url = Some(s.to_string());
                }
                (sym::html_no_source, None) if attr.is_word() => {
                    include_sources = false;
                }
                _ => {}
            }
        }
    }
    let mut scx = SharedContext {
        collapsed: krate.collapsed,
        src_root,
        include_sources,
        local_sources: Default::default(),
        issue_tracker_base_url,
        layout,
        created_dirs: Default::default(),
        sort_modules_alphabetically,
        themes,
        resource_suffix,
        static_root_path,
        generate_redirect_pages,
        fs: DocFS::new(&errors),
        edition,
        codes: ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build()),
        playground,
    };

    let dst = output;
    scx.ensure_dir(&dst)?;
    krate = sources::render(&dst, &mut scx, krate)?;
    let (new_crate, index, cache) = Cache::from_krate(
        renderinfo,
        &extern_html_root_urls,
        &dst,
        krate,
    );
    krate = new_crate;
    let cache = Arc::new(cache);
    let mut cx = Context {
        current: Vec::new(),
        dst,
        render_redirect_pages: false,
        id_map: Rc::new(RefCell::new(id_map)),
        shared: Arc::new(scx),
        cache: cache.clone(),
    };

    // Freeze the cache now that the index has been built. Put an Arc into TLS
    // for future parallelization opportunities
    CACHE_KEY.with(|v| *v.borrow_mut() = cache.clone());
    CURRENT_DEPTH.with(|s| s.set(0));

    // Write shared runs within a flock; disable thread dispatching of IO temporarily.
    Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
    write_shared(&cx, &krate, index, &md_opts, diag)?;
    Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);

    // And finally render the whole crate's documentation
    let ret = cx.krate(krate);
    let nb_errors = Arc::get_mut(&mut errors).map_or_else(|| 0, |errors| errors.write_errors(diag));
    if ret.is_err() {
        ret
    } else if nb_errors > 0 {
        Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
    } else {
        Ok(())
    }
}
/// Generates the documentation for `crate` into the directory `dst`
Generates the documentation for `crate` into the directory `dst`
Generates the documentation for ` crate ` into the directory ` dst `
pub fn run(mut krate: clean::Crate,
           options: RenderOptions,
           renderinfo: RenderInfo,
           diag: &errors::Handler,
           edition: Edition) -> Result<(), Error> {
    // need to save a copy of the options for rendering the index page
    let md_opts = options.clone();
    let RenderOptions {
        output,
        external_html,
        id_map,
        playground_url,
        sort_modules_alphabetically,
        themes,
        extension_css,
        extern_html_root_urls,
        resource_suffix,
        static_root_path,
        generate_search_filter,
        generate_redirect_pages,
        ..
    } = options;
    let src_root = match krate.src {
        FileName::Real(ref p) => match p.parent() {
            Some(p) => p.to_path_buf(),
            None => PathBuf::new(),
        },
        _ => PathBuf::new(),
    };
    let mut errors = Arc::new(ErrorStorage::new());
    // If user passed in `--playground-url` arg, we fill in crate name here
    let mut playground = None;
    if let Some(url) = playground_url {
        playground = Some(markdown::Playground {
            crate_name: Some(krate.name.clone()),
            url,
        });
    }
    let mut layout = layout::Layout {
        logo: String::new(),
        favicon: String::new(),
        external_html,
        krate: krate.name.clone(),
        css_file_extension: extension_css,
        generate_search_filter,
    };
    let mut issue_tracker_base_url = None;
    let mut include_sources = true;
    // Crawl the crate attributes looking for attributes which control how we're
    // going to emit HTML
    if let Some(attrs) = krate.module.as_ref().map(|m| &m.attrs) {
        for attr in attrs.lists(sym::doc) {
            match (attr.name_or_empty(), attr.value_str()) {
                (sym::html_favicon_url, Some(s)) => {
                    layout.favicon = s.to_string();
                }
                (sym::html_logo_url, Some(s)) => {
                    layout.logo = s.to_string();
                }
                (sym::html_playground_url, Some(s)) => {
                    playground = Some(markdown::Playground {
                        crate_name: Some(krate.name.clone()),
                        url: s.to_string(),
                    });
                }
                (sym::issue_tracker_base_url, Some(s)) => {
                    issue_tracker_base_url = Some(s.to_string());
                }
                (sym::html_no_source, None) if attr.is_word() => {
                    include_sources = false;
                }
                _ => {}
            }
        }
    }
    let mut scx = SharedContext {
        collapsed: krate.collapsed,
        src_root,
        include_sources,
        local_sources: Default::default(),
        issue_tracker_base_url,
        layout,
        created_dirs: Default::default(),
        sort_modules_alphabetically,
        themes,
        resource_suffix,
        static_root_path,
        generate_redirect_pages,
        fs: DocFS::new(&errors),
        edition,
        codes: ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build()),
        playground,
    };
    let dst = output;
    scx.ensure_dir(&dst)?;
    krate = sources::render(&dst, &mut scx, krate)?;
    let (new_crate, index, cache) = Cache::from_krate(
        renderinfo,
        &extern_html_root_urls,
        &dst,
        krate,
    );
    krate = new_crate;
    let cache = Arc::new(cache);
    let mut cx = Context {
        current: Vec::new(),
        dst,
        render_redirect_pages: false,
        id_map: Rc::new(RefCell::new(id_map)),
        shared: Arc::new(scx),
        cache: cache.clone(),
    };
    // Freeze the cache now that the index has been built. Put an Arc into TLS
    // for future parallelization opportunities
    CACHE_KEY.with(|v| *v.borrow_mut() = cache.clone());
    CURRENT_DEPTH.with(|s| s.set(0));
    // Write shared runs within a flock; disable thread dispatching of IO temporarily.
    Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
    write_shared(&cx, &krate, index, &md_opts, diag)?;
    Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
    // And finally render the whole crate's documentation
    let ret = cx.krate(krate);
    let nb_errors = Arc::get_mut(&mut errors).map_or_else(|| 0, |errors| errors.write_errors(diag));
    if ret.is_err() {
        ret
    } else if nb_errors > 0 {
        Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))
    } else {
        Ok(())
    }
}
pub fn run ( mut krate : clean :: Crate , options : RenderOptions , renderinfo : RenderInfo , diag : & errors :: Handler , edition : Edition ) -> Result < ( ) , Error > { // need to save a copy of the options for rendering the index page let md_opts = options . clone ( ) ; let RenderOptions { output , external_html , id_map , playground_url , sort_modules_alphabetically , themes , extension_css , extern_html_root_urls , resource_suffix , static_root_path , generate_search_filter , generate_redirect_pages , .. } = options ; let src_root = match krate . src { FileName :: Real ( ref p ) => match p . parent ( ) { Some ( p ) => p . to_path_buf ( ) , None => PathBuf :: new ( ) , } , _ => PathBuf :: new ( ) , } ; let mut errors = Arc :: new ( ErrorStorage :: new ( ) ) ; // If user passed in `--playground-url` arg, we fill in crate name here let mut playground = None ; if let Some ( url ) = playground_url { playground = Some ( markdown :: Playground { crate_name : Some ( krate . name . clone ( ) ) , url , } ) ; } let mut layout = layout :: Layout { logo : String :: new ( ) , favicon : String :: new ( ) , external_html , krate : krate . name . clone ( ) , css_file_extension : extension_css , generate_search_filter , } ; let mut issue_tracker_base_url = None ; let mut include_sources = true ; // Crawl the crate attributes looking for attributes which control how we're // going to emit HTML if let Some ( attrs ) = krate . module . as_ref ( ) . map ( | m | & m . attrs ) { for attr in attrs . lists ( sym :: doc ) { match ( attr . name_or_empty ( ) , attr . value_str ( ) ) { ( sym :: html_favicon_url , Some ( s ) ) => { layout . favicon = s . to_string ( ) ; } ( sym :: html_logo_url , Some ( s ) ) => { layout . logo = s . to_string ( ) ; } ( sym :: html_playground_url , Some ( s ) ) => { playground = Some ( markdown :: Playground { crate_name : Some ( krate . name . clone ( ) ) , url : s . to_string ( ) , } ) ; } ( sym :: issue_tracker_base_url , Some ( s ) ) => { issue_tracker_base_url = Some ( s . to_string ( ) ) ; } ( sym :: html_no_source , None ) if attr . is_word ( ) => { include_sources = false ; } _ => { } } } } let mut scx = SharedContext { collapsed : krate . collapsed , src_root , include_sources , local_sources : Default :: default ( ) , issue_tracker_base_url , layout , created_dirs : Default :: default ( ) , sort_modules_alphabetically , themes , resource_suffix , static_root_path , generate_redirect_pages , fs : DocFS :: new ( & errors ) , edition , codes : ErrorCodes :: from ( UnstableFeatures :: from_environment ( ) . is_nightly_build ( ) ) , playground , } ; let dst = output ; scx . ensure_dir ( & dst ) ? ; krate = sources :: render ( & dst , & mut scx , krate ) ? ; let ( new_crate , index , cache ) = Cache :: from_krate ( renderinfo , & extern_html_root_urls , & dst , krate , ) ; krate = new_crate ; let cache = Arc :: new ( cache ) ; let mut cx = Context { current : Vec :: new ( ) , dst , render_redirect_pages : false , id_map : Rc :: new ( RefCell :: new ( id_map ) ) , shared : Arc :: new ( scx ) , cache : cache . clone ( ) , } ; // Freeze the cache now that the index has been built. Put an Arc into TLS // for future parallelization opportunities CACHE_KEY . with ( | v | * v . borrow_mut ( ) = cache . clone ( ) ) ; CURRENT_DEPTH . with ( | s | s . set ( 0 ) ) ; // Write shared runs within a flock; disable thread dispatching of IO temporarily. Arc :: get_mut ( & mut cx . shared ) . unwrap ( ) . fs . set_sync_only ( true ) ; write_shared ( & cx , & krate , index , & md_opts , diag ) ? ; Arc :: get_mut ( & mut cx . shared ) . unwrap ( ) . fs . set_sync_only ( false ) ; // And finally render the whole crate's documentation let ret = cx . krate ( krate ) ; let nb_errors = Arc :: get_mut ( & mut errors ) . map_or_else ( | | 0 , | errors | errors . write_errors ( diag ) ) ; if ret . is_err ( ) { ret } else if nb_errors > 0 { Err ( Error :: new ( io :: Error :: new ( io :: ErrorKind :: Other , " " ) , " " ) ) } else { Ok ( ( ) ) } }
Generates the documentation for `crate` into the directory `dst`
Generates the documentation for ` crate ` into the directory ` dst `
krate
clean::Crate
options
RenderOptions
renderinfo
RenderInfo
diag
&errors::Handler
edition
Edition
krate
clean::Crate
options
RenderOptions
renderinfo
RenderInfo
diag
&errors::Handler
edition
Edition