@@ -7,23 +7,24 @@ use crate::config::{RenderInfo, RenderOptions};
7
7
use crate :: error:: Error ;
8
8
use crate :: formats:: cache:: { Cache , CACHE_KEY } ;
9
9
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.
10
13
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
14
15
/// populated.
15
16
fn init (
16
17
krate : clean:: Crate ,
17
18
options : RenderOptions ,
18
- renderinfo : RenderInfo ,
19
+ render_info : RenderInfo ,
19
20
edition : Edition ,
20
21
cache : & mut Cache ,
21
- ) -> Result < ( Self :: Output , clean:: Crate ) , Error > ;
22
+ ) -> Result < ( Self , clean:: Crate ) , Error > ;
22
23
23
24
/// Renders a single non-module item. This means no recursive sub-item rendering is required.
24
25
fn item ( & mut self , item : clean:: Item , cache : & Cache ) -> Result < ( ) , Error > ;
25
26
26
- /// Renders a module (doesn't need to handle recursing into children).
27
+ /// Renders a module (should not handle recursing into children).
27
28
fn mod_item_in (
28
29
& mut self ,
29
30
item : & clean:: Item ,
@@ -54,19 +55,20 @@ impl Renderer {
54
55
self ,
55
56
krate : clean:: Crate ,
56
57
options : RenderOptions ,
57
- renderinfo : RenderInfo ,
58
+ render_info : RenderInfo ,
58
59
diag : & rustc_errors:: Handler ,
59
60
edition : Edition ,
60
61
) -> Result < ( ) , Error > {
61
62
let ( krate, mut cache) = Cache :: from_krate (
62
- renderinfo . clone ( ) ,
63
+ render_info . clone ( ) ,
63
64
options. document_private ,
64
65
& options. extern_html_root_urls ,
65
66
& options. output ,
66
67
krate,
67
68
) ;
68
69
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) ?;
70
72
71
73
let cache = Arc :: new ( cache) ;
72
74
// Freeze the cache now that the index has been built. Put an Arc into TLS for future
@@ -81,7 +83,7 @@ impl Renderer {
81
83
item. name = Some ( krate. name . clone ( ) ) ;
82
84
83
85
// Render the crate documentation
84
- let mut work = vec ! [ ( renderer . clone( ) , item) ] ;
86
+ let mut work = vec ! [ ( format_renderer . clone( ) , item) ] ;
85
87
86
88
while let Some ( ( mut cx, item) ) = work. pop ( ) {
87
89
if item. is_mod ( ) {
@@ -98,7 +100,7 @@ impl Renderer {
98
100
_ => unreachable ! ( ) ,
99
101
} ;
100
102
for it in module. items {
101
- info ! ( "Adding {:?} to worklist" , it. name) ;
103
+ debug ! ( "Adding {:?} to worklist" , it. name) ;
102
104
work. push ( ( cx. clone ( ) , it) ) ;
103
105
}
104
106
@@ -108,7 +110,7 @@ impl Renderer {
108
110
}
109
111
}
110
112
111
- renderer . after_krate ( & krate, & cache) ?;
112
- renderer . after_run ( diag)
113
+ format_renderer . after_krate ( & krate, & cache) ?;
114
+ format_renderer . after_run ( diag)
113
115
}
114
116
}
0 commit comments