/// Main method for rendering a crate.
///
/// This currently isn't parallelized, but it'd be pretty easy to add
/// parallelization to this function.
Main method for rendering a crate.
This currently isn't parallelized, but it'd be pretty easy to add
parallelization to this function.
Main method for rendering a crate . This currently isn ' t parallelized but it ' d be pretty easy to add parallelization to this function .
fn krate(self, mut krate: clean::Crate) -> Result<(), Error> {
        let mut item = match krate.module.take() {
            Some(i) => i,
            None => return Ok(()),
        };
        let final_file = self.dst.join(&krate.name)
                                 .join("all.html");
        let settings_file = self.dst.join("settings.html");
        let crate_name = krate.name.clone();
        item.name = Some(krate.name);
        let mut all = AllTypes::new();
        {
            // Render the crate documentation
            let mut work = vec![(self.clone(), item)];
            while let Some((mut cx, item)) = work.pop() {
                cx.item(item, &mut all, |cx, item| {
                    work.push((cx.clone(), item))
                })?
            }
        }
        let mut root_path = self.dst.to_str().expect("invalid path").to_owned();
        if !root_path.ends_with('/') {
            root_path.push('/');
        }
        let mut page = layout::Page {
            title: "List of all items in this crate",
            css_class: "mod",
            root_path: "../",
            static_root_path: self.shared.static_root_path.as_deref(),
            description: "List of all items in this crate",
            keywords: BASIC_KEYWORDS,
            resource_suffix: &self.shared.resource_suffix,
            extra_scripts: &[],
            static_extra_scripts: &[],
        };
        let sidebar = if let Some(ref version) = self.cache.crate_version {
            format!("<p class='location'>Crate {}</p>\
                     <div class='block version'>\
                         <p>Version {}</p>\
                     </div>\
                     <a id='all-types' href='index.html'><p>Back to index</p></a>",
                    crate_name, version)
        } else {
            String::new()
        };
        let v = layout::render(&self.shared.layout,
                       &page, sidebar, |buf: &mut Buffer| all.print(buf),
                       &self.shared.themes);
        self.shared.fs.write(&final_file, v.as_bytes())?;
        // Generating settings page.
        page.title = "Rustdoc settings";
        page.description = "Settings of Rustdoc";
        page.root_path = "./";
        let mut themes = self.shared.themes.clone();
        let sidebar = "<p class='location'>Settings</p><div class='sidebar-elems'></div>";
        themes.push(PathBuf::from("settings.css"));
        let v = layout::render(
            &self.shared.layout,
            &page, sidebar, settings(
                self.shared.static_root_path.as_deref().unwrap_or("./"),
                &self.shared.resource_suffix
            ),
            &themes);
        self.shared.fs.write(&settings_file, v.as_bytes())?;
        Ok(())
    }
fn krate ( self , mut krate : clean :: Crate ) -> Result < ( ) , Error > { let mut item = match krate . module . take ( ) { Some ( i ) => i , None => return Ok ( ( ) ) , } ; let final_file = self . dst . join ( & krate . name ) . join ( " " ) ; let settings_file = self . dst . join ( " " ) ; let crate_name = krate . name . clone ( ) ; item . name = Some ( krate . name ) ; let mut all = AllTypes :: new ( ) ; { // Render the crate documentation let mut work = vec ! [ ( self clone ( ) item ) ] ; while let Some ( ( mut cx , item ) ) = work . pop ( ) { cx . item ( item , & mut all , | cx , item | { work . push ( ( cx . clone ( ) , item ) ) } ) ? } } let mut root_path = self . dst . to_str ( ) . expect ( " " ) . to_owned ( ) ; if ! root_path . ends_with ( '/' ) { root_path . push ( '/' ) ; } let mut page = layout :: Page { title : " " , css_class : " " , root_path : " " , static_root_path : self . shared . static_root_path . as_deref ( ) , description : " " , keywords : BASIC_KEYWORDS , resource_suffix : & self . shared . resource_suffix , extra_scripts : & [ ] , static_extra_scripts : & [ ] , } ; let sidebar = if let Some ( ref version ) = self . cache . crate_version { format ! ( " \
 \
 \
 \
 " crate_name version ) } else { String :: new ( ) } ; let v = layout :: render ( & self . shared . layout , & page , sidebar , | buf : & mut Buffer | all . print ( buf ) , & self . shared . themes ) ; self . shared . fs . write ( & final_file , v . as_bytes ( ) ) ? ; // Generating settings page. page . title = " " ; page . description = " " ; page . root_path = " " ; let mut themes = self . shared . themes . clone ( ) ; let sidebar = " " ; themes . push ( PathBuf :: from ( " " ) ) ; let v = layout :: render ( & self . shared . layout , & page , sidebar , settings ( self . shared . static_root_path . as_deref ( ) . unwrap_or ( " " ) , & self . shared . resource_suffix ) , & themes ) ; self . shared . fs . write ( & settings_file , v . as_bytes ( ) ) ? ; Ok ( ( ) ) }
Main method for rendering a crate.
Main method for rendering a crate .
self
krate
clean::Crate