Skip to content

Commit 4c4f300

Browse files
committed
Make requested changes
1 parent a59b8c1 commit 4c4f300

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

src/librustdoc/formats/cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub struct Cache {
126126

127127
impl Cache {
128128
pub fn from_krate(
129-
renderinfo: RenderInfo,
129+
render_info: RenderInfo,
130130
document_private: bool,
131131
extern_html_root_urls: &BTreeMap<String, String>,
132132
dst: &Path,
@@ -142,7 +142,7 @@ impl Cache {
142142
deref_mut_trait_did,
143143
owned_box_did,
144144
..
145-
} = renderinfo;
145+
} = render_info;
146146

147147
let external_paths =
148148
external_paths.into_iter().map(|(k, (v, t))| (k, (v, ItemType::from(t)))).collect();

src/librustdoc/formats/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ use rustc_span::def_id::DefId;
99
use crate::clean;
1010
use crate::clean::types::GetDefId;
1111

12+
/// Specifies whether rendering directly implemented trait items or ones from a certain Deref
13+
/// impl.
1214
pub enum AssocItemRender<'a> {
1315
All,
1416
DerefFor { trait_: &'a clean::Type, type_: &'a clean::Type, deref_mut_: bool },
1517
}
1618

19+
/// For different handling of associated items from the Deref target of a type rather than the type
20+
/// itself.
1721
#[derive(Copy, Clone, PartialEq)]
1822
pub enum RenderMode {
1923
Normal,

src/librustdoc/formats/renderer.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@ use crate::config::{RenderInfo, RenderOptions};
77
use crate::error::Error;
88
use crate::formats::cache::{Cache, CACHE_KEY};
99

10+
/// Allows for different backends to rustdoc to be used with the `Renderer::run()` function. Each
11+
/// backend renderer has hooks for initialization, documenting an item, entering and exiting a
12+
/// module, and cleanup/finalizing output.
1013
pub trait FormatRenderer: Clone {
11-
type Output: FormatRenderer;
12-
13-
/// Sets up any state required for the emulator. When this is called the cache has already been
14+
/// Sets up any state required for the renderer. When this is called the cache has already been
1415
/// populated.
1516
fn init(
1617
krate: clean::Crate,
1718
options: RenderOptions,
18-
renderinfo: RenderInfo,
19+
render_info: RenderInfo,
1920
edition: Edition,
2021
cache: &mut Cache,
21-
) -> Result<(Self::Output, clean::Crate), Error>;
22+
) -> Result<(Self, clean::Crate), Error>;
2223

2324
/// Renders a single non-module item. This means no recursive sub-item rendering is required.
2425
fn item(&mut self, item: clean::Item, cache: &Cache) -> Result<(), Error>;
2526

26-
/// Renders a module (doesn't need to handle recursing into children).
27+
/// Renders a module (should not handle recursing into children).
2728
fn mod_item_in(
2829
&mut self,
2930
item: &clean::Item,
@@ -54,19 +55,20 @@ impl Renderer {
5455
self,
5556
krate: clean::Crate,
5657
options: RenderOptions,
57-
renderinfo: RenderInfo,
58+
render_info: RenderInfo,
5859
diag: &rustc_errors::Handler,
5960
edition: Edition,
6061
) -> Result<(), Error> {
6162
let (krate, mut cache) = Cache::from_krate(
62-
renderinfo.clone(),
63+
render_info.clone(),
6364
options.document_private,
6465
&options.extern_html_root_urls,
6566
&options.output,
6667
krate,
6768
);
6869

69-
let (mut renderer, mut krate) = T::init(krate, options, renderinfo, edition, &mut cache)?;
70+
let (mut format_renderer, mut krate) =
71+
T::init(krate, options, render_info, edition, &mut cache)?;
7072

7173
let cache = Arc::new(cache);
7274
// Freeze the cache now that the index has been built. Put an Arc into TLS for future
@@ -81,7 +83,7 @@ impl Renderer {
8183
item.name = Some(krate.name.clone());
8284

8385
// Render the crate documentation
84-
let mut work = vec![(renderer.clone(), item)];
86+
let mut work = vec![(format_renderer.clone(), item)];
8587

8688
while let Some((mut cx, item)) = work.pop() {
8789
if item.is_mod() {
@@ -98,7 +100,7 @@ impl Renderer {
98100
_ => unreachable!(),
99101
};
100102
for it in module.items {
101-
info!("Adding {:?} to worklist", it.name);
103+
debug!("Adding {:?} to worklist", it.name);
102104
work.push((cx.clone(), it));
103105
}
104106

@@ -108,7 +110,7 @@ impl Renderer {
108110
}
109111
}
110112

111-
renderer.after_krate(&krate, &cache)?;
112-
renderer.after_run(diag)
113+
format_renderer.after_krate(&krate, &cache)?;
114+
format_renderer.after_run(diag)
113115
}
114116
}

src/librustdoc/html/render/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,12 @@ pub fn initial_ids() -> Vec<String> {
371371
.collect()
372372
}
373373

374+
/// Generates the documentation for `crate` into the directory `dst`
374375
impl FormatRenderer for Context {
375-
type Output = Self;
376-
377-
/// Generates the documentation for `crate` into the directory `dst`
378376
fn init(
379377
mut krate: clean::Crate,
380378
options: RenderOptions,
381-
_renderinfo: RenderInfo,
379+
_render_info: RenderInfo,
382380
edition: Edition,
383381
cache: &mut Cache,
384382
) -> Result<(Context, clean::Crate), Error> {

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod doctree;
6767
mod error;
6868
mod fold;
6969
crate mod formats;
70-
crate mod html;
70+
pub mod html;
7171
mod markdown;
7272
mod passes;
7373
mod test;

0 commit comments

Comments
 (0)