@@ -17,6 +17,17 @@ pub(crate) trait FormatRenderer<'tcx>: Sized {
1717 ///
1818 /// This is true for html, and false for json. See #80664
1919 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`.
2031 type InfoType ;
2132
2233 /// 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 {
2839 tcx : TyCtxt < ' tcx > ,
2940 ) -> Result < ( Self , clean:: Crate ) , Error > ;
3041
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+ /// ```
3253 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 ) ;
3456
3557 /// Renders a single non-module item. This means no recursive sub-item rendering is required.
3658 fn item ( & mut self , item : clean:: Item ) -> Result < ( ) , Error > ;
0 commit comments