@@ -7,23 +7,24 @@ use crate::config::{RenderInfo, RenderOptions};
77use crate :: error:: Error ;
88use 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.
1013pub 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}
0 commit comments