@@ -17,6 +17,17 @@ pub(crate) trait FormatRenderer<'tcx>: Sized {
17
17
///
18
18
/// This is true for html, and false for json. See #80664
19
19
const RUN_ON_MODULE : bool ;
20
+ /// This associated type is the type where the current module information is stored.
21
+ ///
22
+ /// For each module, we go through their items by calling for each item:
23
+ ///
24
+ /// 1. make_child_renderer
25
+ /// 2. item
26
+ /// 3. set_back_info
27
+ ///
28
+ /// However,the `item` method might update information in `self` (for example if the child is
29
+ /// a module). To prevent it to impact the other children of the current module, we need to
30
+ /// reset the information between each call to `item` by using `set_back_info`.
20
31
type InfoType ;
21
32
22
33
/// Sets up any state required for the renderer. When this is called the cache has already been
@@ -28,9 +39,20 @@ pub(crate) trait FormatRenderer<'tcx>: Sized {
28
39
tcx : TyCtxt < ' tcx > ,
29
40
) -> Result < ( Self , clean:: Crate ) , Error > ;
30
41
31
- /// Make a new renderer to render a child of the item currently being rendered.
42
+ /// This method is called right before call [`Self::item`]. This method returns a type
43
+ /// containing information that needs to be reset after the [`Self::item`] method has been
44
+ /// called with the [`Self::set_back_info`] method.
45
+ ///
46
+ /// In short it goes like this:
47
+ ///
48
+ /// ```ignore (not valid code)
49
+ /// let reset_data = type.make_child_renderer();
50
+ /// type.item(item)?;
51
+ /// type.set_back_info(reset_data);
52
+ /// ```
32
53
fn make_child_renderer ( & mut self ) -> Self :: InfoType ;
33
- fn set_back_info ( & mut self , _info : Self :: InfoType ) ;
54
+ /// Used to reset current module's information.
55
+ fn set_back_info ( & mut self , info : Self :: InfoType ) ;
34
56
35
57
/// Renders a single non-module item. This means no recursive sub-item rendering is required.
36
58
fn item ( & mut self , item : clean:: Item ) -> Result < ( ) , Error > ;
0 commit comments