]> git.lizzy.rs Git - rust.git/commitdiff
Make requested changes
authorJoseph Ryan <josephryan3.14@gmail.com>
Mon, 29 Jun 2020 23:22:58 +0000 (18:22 -0500)
committerJoseph Ryan <josephryan3.14@gmail.com>
Mon, 27 Jul 2020 21:00:39 +0000 (16:00 -0500)
src/librustdoc/formats/cache.rs
src/librustdoc/formats/mod.rs
src/librustdoc/formats/renderer.rs
src/librustdoc/html/render/mod.rs
src/librustdoc/lib.rs

index 1ca462b181d8dd04be28395625d1b3c92d4fd491..72881eccf3edb28c0ac8df3229357adcdd35455c 100644 (file)
@@ -126,7 +126,7 @@ pub struct Cache {
 
 impl Cache {
     pub fn from_krate(
-        renderinfo: RenderInfo,
+        render_info: RenderInfo,
         document_private: bool,
         extern_html_root_urls: &BTreeMap<String, String>,
         dst: &Path,
@@ -142,7 +142,7 @@ pub fn from_krate(
             deref_mut_trait_did,
             owned_box_did,
             ..
-        } = renderinfo;
+        } = render_info;
 
         let external_paths =
             external_paths.into_iter().map(|(k, (v, t))| (k, (v, ItemType::from(t)))).collect();
index 97e1af13b8a56fa6ab63a95fe51dc80e5d90601c..7757ee7e515e14eb9253ffddc551fc3a12f27141 100644 (file)
@@ -9,11 +9,15 @@
 use crate::clean;
 use crate::clean::types::GetDefId;
 
+/// Specifies whether rendering directly implemented trait items or ones from a certain Deref
+/// impl.
 pub enum AssocItemRender<'a> {
     All,
     DerefFor { trait_: &'a clean::Type, type_: &'a clean::Type, deref_mut_: bool },
 }
 
+/// For different handling of associated items from the Deref target of a type rather than the type
+/// itself.
 #[derive(Copy, Clone, PartialEq)]
 pub enum RenderMode {
     Normal,
index d4ba6726cd22a44f8f7bd7d8c5aaa31393f0d30d..7d23c7b8aff7cfb1bdf4b179c66d8d1642d83e81 100644 (file)
@@ -7,23 +7,24 @@
 use crate::error::Error;
 use crate::formats::cache::{Cache, CACHE_KEY};
 
+/// Allows for different backends to rustdoc to be used with the `Renderer::run()` function. Each
+/// backend renderer has hooks for initialization, documenting an item, entering and exiting a
+/// module, and cleanup/finalizing output.
 pub trait FormatRenderer: Clone {
-    type Output: FormatRenderer;
-
-    /// Sets up any state required for the emulator. When this is called the cache has already been
+    /// Sets up any state required for the renderer. When this is called the cache has already been
     /// populated.
     fn init(
         krate: clean::Crate,
         options: RenderOptions,
-        renderinfo: RenderInfo,
+        render_info: RenderInfo,
         edition: Edition,
         cache: &mut Cache,
-    ) -> Result<(Self::Output, clean::Crate), Error>;
+    ) -> Result<(Self, clean::Crate), Error>;
 
     /// Renders a single non-module item. This means no recursive sub-item rendering is required.
     fn item(&mut self, item: clean::Item, cache: &Cache) -> Result<(), Error>;
 
-    /// Renders a module (doesn't need to handle recursing into children).
+    /// Renders a module (should not handle recursing into children).
     fn mod_item_in(
         &mut self,
         item: &clean::Item,
@@ -54,19 +55,20 @@ pub fn run<T: FormatRenderer + Clone>(
         self,
         krate: clean::Crate,
         options: RenderOptions,
-        renderinfo: RenderInfo,
+        render_info: RenderInfo,
         diag: &rustc_errors::Handler,
         edition: Edition,
     ) -> Result<(), Error> {
         let (krate, mut cache) = Cache::from_krate(
-            renderinfo.clone(),
+            render_info.clone(),
             options.document_private,
             &options.extern_html_root_urls,
             &options.output,
             krate,
         );
 
-        let (mut renderer, mut krate) = T::init(krate, options, renderinfo, edition, &mut cache)?;
+        let (mut format_renderer, mut krate) =
+            T::init(krate, options, render_info, edition, &mut cache)?;
 
         let cache = Arc::new(cache);
         // Freeze the cache now that the index has been built. Put an Arc into TLS for future
@@ -81,7 +83,7 @@ pub fn run<T: FormatRenderer + Clone>(
         item.name = Some(krate.name.clone());
 
         // Render the crate documentation
-        let mut work = vec![(renderer.clone(), item)];
+        let mut work = vec![(format_renderer.clone(), item)];
 
         while let Some((mut cx, item)) = work.pop() {
             if item.is_mod() {
@@ -98,7 +100,7 @@ pub fn run<T: FormatRenderer + Clone>(
                     _ => unreachable!(),
                 };
                 for it in module.items {
-                    info!("Adding {:?} to worklist", it.name);
+                    debug!("Adding {:?} to worklist", it.name);
                     work.push((cx.clone(), it));
                 }
 
@@ -108,7 +110,7 @@ pub fn run<T: FormatRenderer + Clone>(
             }
         }
 
-        renderer.after_krate(&krate, &cache)?;
-        renderer.after_run(diag)
+        format_renderer.after_krate(&krate, &cache)?;
+        format_renderer.after_run(diag)
     }
 }
index 7140cf00b6e9375fa6532fe9524dbaf583bfefdc..46c1b27986de4a00ec928dd4adb749a1b880c72e 100644 (file)
@@ -371,14 +371,12 @@ pub fn initial_ids() -> Vec<String> {
     .collect()
 }
 
+/// Generates the documentation for `crate` into the directory `dst`
 impl FormatRenderer for Context {
-    type Output = Self;
-
-    /// Generates the documentation for `crate` into the directory `dst`
     fn init(
         mut krate: clean::Crate,
         options: RenderOptions,
-        _renderinfo: RenderInfo,
+        _render_info: RenderInfo,
         edition: Edition,
         cache: &mut Cache,
     ) -> Result<(Context, clean::Crate), Error> {
index 0de9c6336bbd854312f730d42c3a2509ed473b24..04651da4d095d50e63bd7e226e75b8c17c2da3e8 100644 (file)
@@ -67,7 +67,7 @@
 mod error;
 mod fold;
 crate mod formats;
-crate mod html;
+pub mod html;
 mod markdown;
 mod passes;
 mod test;