@@ -66,7 +66,7 @@ use tracing::{debug, info};
6666pub ( crate ) use self :: context:: * ;
6767pub ( crate ) use self :: span_map:: { LinkFromSrc , collect_spans_and_sources} ;
6868pub ( crate ) use self :: write_shared:: * ;
69- use crate :: clean:: { self , ItemId , RenderedLink } ;
69+ use crate :: clean:: { self , Item , ItemId , RenderedLink } ;
7070use crate :: display:: { Joined as _, MaybeDisplay as _} ;
7171use crate :: error:: Error ;
7272use crate :: formats:: Impl ;
@@ -79,7 +79,7 @@ use crate::html::format::{
7979 print_impl, print_path, print_type, print_where_clause, visibility_print_with_space,
8080} ;
8181use crate :: html:: markdown:: {
82- HeadingOffset , IdMap , Markdown , MarkdownItemInfo , MarkdownSummaryLine ,
82+ HeadingOffset , IdMap , Markdown , MarkdownItemInfo , MarkdownSummaryLine , short_markdown_summary ,
8383} ;
8484use crate :: html:: static_files:: SCRAPE_EXAMPLES_HELP_MD ;
8585use crate :: html:: { highlight, sources} ;
@@ -124,6 +124,31 @@ enum RenderMode {
124124// Helper structs for rendering items/sidebars and carrying along contextual
125125// information
126126
127+ #[ derive( Debug ) ]
128+ pub ( crate ) struct IndexItemInfo {
129+ pub ( crate ) desc : String ,
130+ pub ( crate ) search_type : Option < IndexItemFunctionType > ,
131+ pub ( crate ) aliases : Box < [ Symbol ] > ,
132+ pub ( crate ) deprecation : Option < Deprecation > ,
133+ }
134+
135+ impl IndexItemInfo {
136+ pub ( crate ) fn new (
137+ tcx : TyCtxt < ' _ > ,
138+ cache : & Cache ,
139+ item : & Item ,
140+ parent_did : Option < DefId > ,
141+ impl_generics : Option < & ( clean:: Type , clean:: Generics ) > ,
142+ ) -> Self {
143+ let desc = short_markdown_summary ( & item. doc_value ( ) , & item. link_names ( cache) ) ;
144+ let search_type =
145+ search_index:: get_function_type_for_search ( item, tcx, impl_generics, parent_did, cache) ;
146+ let aliases = item. attrs . get_doc_aliases ( ) ;
147+ let deprecation = item. deprecation ( tcx) ;
148+ Self { desc, search_type, aliases, deprecation }
149+ }
150+ }
151+
127152/// Struct representing one entry in the JS search index. These are all emitted
128153/// by hand to a large JS file at the end of cache-creation.
129154#[ derive( Debug ) ]
@@ -132,16 +157,13 @@ pub(crate) struct IndexItem {
132157 pub ( crate ) defid : Option < DefId > ,
133158 pub ( crate ) name : Symbol ,
134159 pub ( crate ) module_path : Vec < Symbol > ,
135- pub ( crate ) desc : String ,
136160 pub ( crate ) parent : Option < DefId > ,
137161 pub ( crate ) parent_idx : Option < usize > ,
138162 pub ( crate ) trait_parent : Option < DefId > ,
139163 pub ( crate ) trait_parent_idx : Option < usize > ,
140164 pub ( crate ) exact_module_path : Option < Vec < Symbol > > ,
141165 pub ( crate ) impl_id : Option < DefId > ,
142- pub ( crate ) search_type : Option < IndexItemFunctionType > ,
143- pub ( crate ) aliases : Box < [ Symbol ] > ,
144- pub ( crate ) deprecation : Option < Deprecation > ,
166+ pub ( crate ) info : IndexItemInfo ,
145167}
146168
147169/// A type used for the search index.
0 commit comments