1313//! is cloned per-thread and contains information about what is currently being
1414//! rendered.
1515//!
16+ //! The main entry point to the rendering system is the implementation of
17+ //! `FormatRenderer` on `Context`.
18+ //!
1619//! In order to speed up rendering (mostly because of markdown rendering), the
1720//! rendering process has been parallelized. This parallelization is only
1821//! exposed through the `crate` method on the context, and then also from the
@@ -90,15 +93,15 @@ pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display {
9093/// Specifies whether rendering directly implemented trait items or ones from a certain Deref
9194/// impl.
9295#[ derive( Copy , Clone ) ]
93- pub ( crate ) enum AssocItemRender < ' a > {
96+ enum AssocItemRender < ' a > {
9497 All ,
9598 DerefFor { trait_ : & ' a clean:: Path , type_ : & ' a clean:: Type , deref_mut_ : bool } ,
9699}
97100
98101/// For different handling of associated items from the Deref target of a type rather than the type
99102/// itself.
100103#[ derive( Copy , Clone , PartialEq ) ]
101- pub ( crate ) enum RenderMode {
104+ enum RenderMode {
102105 Normal ,
103106 ForDeref { mut_ : bool } ,
104107}
@@ -110,23 +113,55 @@ pub(crate) enum RenderMode {
110113/// by hand to a large JS file at the end of cache-creation.
111114#[ derive( Debug ) ]
112115pub ( crate ) struct IndexItem {
113- pub ( crate ) ty : ItemType ,
114- pub ( crate ) defid : Option < DefId > ,
115- pub ( crate ) name : Symbol ,
116- pub ( crate ) path : String ,
117- pub ( crate ) desc : String ,
118- pub ( crate ) parent : Option < DefId > ,
119- pub ( crate ) parent_idx : Option < isize > ,
120- pub ( crate ) exact_path : Option < String > ,
121- pub ( crate ) impl_id : Option < DefId > ,
122- pub ( crate ) search_type : Option < IndexItemFunctionType > ,
123- pub ( crate ) aliases : Box < [ Symbol ] > ,
124- pub ( crate ) deprecation : Option < Deprecation > ,
116+ ty : ItemType ,
117+ defid : Option < DefId > ,
118+ name : Symbol ,
119+ path : String ,
120+ desc : String ,
121+ parent : Option < DefId > ,
122+ parent_idx : Option < isize > ,
123+ exact_path : Option < String > ,
124+ impl_id : Option < DefId > ,
125+ search_type : Option < IndexItemFunctionType > ,
126+ aliases : Box < [ Symbol ] > ,
127+ deprecation : Option < Deprecation > ,
128+ }
129+
130+ impl IndexItem {
131+ pub fn new (
132+ ty : ItemType ,
133+ defid : Option < DefId > ,
134+ name : Symbol ,
135+ path : String ,
136+ desc : String ,
137+ parent : Option < DefId > ,
138+ parent_idx : Option < isize > ,
139+ exact_path : Option < String > ,
140+ impl_id : Option < DefId > ,
141+ search_type : Option < IndexItemFunctionType > ,
142+ aliases : Box < [ Symbol ] > ,
143+ deprecation : Option < Deprecation > ,
144+ ) -> Self {
145+ Self {
146+ ty,
147+ defid,
148+ name,
149+ path,
150+ desc,
151+ parent,
152+ parent_idx,
153+ exact_path,
154+ impl_id,
155+ search_type,
156+ aliases,
157+ deprecation,
158+ }
159+ }
125160}
126161
127162/// A type used for the search index.
128163#[ derive( Debug , Eq , PartialEq ) ]
129- pub ( crate ) struct RenderType {
164+ struct RenderType {
130165 id : Option < RenderTypeId > ,
131166 generics : Option < Vec < RenderType > > ,
132167 bindings : Option < Vec < ( RenderTypeId , Vec < RenderType > ) > > ,
@@ -137,7 +172,7 @@ impl RenderType {
137172 // The contents of the lists are always integers in self-terminating hex
138173 // form, handled by `RenderTypeId::write_to_string`, so no commas are
139174 // needed to separate the items.
140- pub fn write_to_string ( & self , string : & mut String ) {
175+ fn write_to_string ( & self , string : & mut String ) {
141176 fn write_optional_id ( id : Option < RenderTypeId > , string : & mut String ) {
142177 // 0 is a sentinel, everything else is one-indexed
143178 match id {
@@ -177,7 +212,7 @@ impl RenderType {
177212}
178213
179214#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
180- pub ( crate ) enum RenderTypeId {
215+ enum RenderTypeId {
181216 DefId ( DefId ) ,
182217 Primitive ( clean:: PrimitiveType ) ,
183218 AssociatedType ( Symbol ) ,
@@ -186,7 +221,7 @@ pub(crate) enum RenderTypeId {
186221}
187222
188223impl RenderTypeId {
189- pub fn write_to_string ( & self , string : & mut String ) {
224+ fn write_to_string ( & self , string : & mut String ) {
190225 let id: i32 = match & self {
191226 // 0 is a sentinel, everything else is one-indexed
192227 // concrete type
@@ -209,7 +244,7 @@ pub(crate) struct IndexItemFunctionType {
209244}
210245
211246impl IndexItemFunctionType {
212- pub fn write_to_string < ' a > (
247+ fn write_to_string < ' a > (
213248 & ' a self ,
214249 string : & mut String ,
215250 backref_queue : & mut VecDeque < & ' a IndexItemFunctionType > ,
@@ -309,7 +344,7 @@ impl ItemEntry {
309344}
310345
311346impl ItemEntry {
312- pub ( crate ) fn print ( & self ) -> impl fmt:: Display {
347+ fn print ( & self ) -> impl fmt:: Display {
313348 fmt:: from_fn ( move |f| write ! ( f, "<a href=\" {}\" >{}</a>" , self . url, Escape ( & self . name) ) )
314349 }
315350}
@@ -760,7 +795,7 @@ fn short_item_info(
760795
761796// Render the list of items inside one of the sections "Trait Implementations",
762797// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages).
763- pub ( crate ) fn render_impls (
798+ fn render_impls (
764799 cx : & Context < ' _ > ,
765800 mut w : impl Write ,
766801 impls : & [ & Impl ] ,
@@ -1201,7 +1236,7 @@ impl<'a> AssocItemLink<'a> {
12011236 }
12021237}
12031238
1204- pub fn write_section_heading (
1239+ fn write_section_heading (
12051240 title : & str ,
12061241 id : & str ,
12071242 extra_class : Option < & str > ,
@@ -1226,7 +1261,7 @@ fn write_impl_section_heading(title: &str, id: &str) -> impl fmt::Display {
12261261 write_section_heading ( title, id, None , "" )
12271262}
12281263
1229- pub ( crate ) fn render_all_impls (
1264+ fn render_all_impls (
12301265 mut w : impl Write ,
12311266 cx : & Context < ' _ > ,
12321267 containing_item : & clean:: Item ,
@@ -1461,10 +1496,7 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) ->
14611496 }
14621497}
14631498
1464- pub ( crate ) fn notable_traits_button (
1465- ty : & clean:: Type ,
1466- cx : & Context < ' _ > ,
1467- ) -> Option < impl fmt:: Display > {
1499+ fn notable_traits_button ( ty : & clean:: Type , cx : & Context < ' _ > ) -> Option < impl fmt:: Display > {
14681500 if ty. is_unit ( ) {
14691501 // Very common fast path.
14701502 return None ;
@@ -1576,10 +1608,7 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
15761608 ( format ! ( "{:#}" , ty. print( cx) ) , out)
15771609}
15781610
1579- pub ( crate ) fn notable_traits_json < ' a > (
1580- tys : impl Iterator < Item = & ' a clean:: Type > ,
1581- cx : & Context < ' _ > ,
1582- ) -> String {
1611+ fn notable_traits_json < ' a > ( tys : impl Iterator < Item = & ' a clean:: Type > , cx : & Context < ' _ > ) -> String {
15831612 let mut mp: Vec < ( String , String ) > = tys. map ( |ty| notable_traits_decl ( ty, cx) ) . collect ( ) ;
15841613 mp. sort_by ( |( name1, _html1) , ( name2, _html2) | name1. cmp ( name2) ) ;
15851614 struct NotableTraitsMap ( Vec < ( String , String ) > ) ;
@@ -2159,7 +2188,7 @@ fn render_rightside(
21592188 } )
21602189}
21612190
2162- pub ( crate ) fn render_impl_summary (
2191+ fn render_impl_summary (
21632192 cx : & Context < ' _ > ,
21642193 i : & Impl ,
21652194 parent : & clean:: Item ,
0 commit comments