@@ -35,32 +35,30 @@ mod write_shared;
3535crate use context:: * ;
3636crate use write_shared:: FILES_UNVERSIONED ;
3737
38- use std:: cell:: { Cell , RefCell } ;
38+ use std:: cell:: Cell ;
3939use std:: collections:: VecDeque ;
4040use std:: default:: Default ;
4141use std:: fmt;
42- use std:: path:: { Path , PathBuf } ;
42+ use std:: path:: PathBuf ;
4343use std:: str;
4444use std:: string:: ToString ;
45- use std:: sync:: mpsc:: Receiver ;
4645
4746use itertools:: Itertools ;
4847use rustc_ast_pretty:: pprust;
4948use rustc_attr:: { Deprecation , StabilityLevel } ;
50- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
49+ use rustc_data_structures:: fx:: FxHashSet ;
5150use rustc_hir as hir;
5251use rustc_hir:: def:: CtorKind ;
5352use rustc_hir:: def_id:: DefId ;
5453use rustc_hir:: Mutability ;
5554use rustc_middle:: middle:: stability;
5655use rustc_middle:: ty:: TyCtxt ;
57- use rustc_span:: edition:: Edition ;
5856use rustc_span:: symbol:: { kw, sym, Symbol } ;
5957use serde:: ser:: SerializeSeq ;
6058use serde:: { Serialize , Serializer } ;
6159
6260use crate :: clean:: { self , GetDefId , RenderedLink , SelfTy , TypeKind } ;
63- use crate :: docfs:: { DocFS , PathError } ;
61+ use crate :: docfs:: PathError ;
6462use crate :: error:: Error ;
6563use crate :: formats:: cache:: Cache ;
6664use crate :: formats:: item_type:: ItemType ;
@@ -70,8 +68,7 @@ use crate::html::format::{
7068 href, print_abi_with_space, print_default_space, print_generic_bounds, print_where_clause,
7169 Buffer , PrintWithSpace ,
7270} ;
73- use crate :: html:: layout;
74- use crate :: html:: markdown:: { self , ErrorCodes , Markdown , MarkdownHtml , MarkdownSummaryLine } ;
71+ use crate :: html:: markdown:: { Markdown , MarkdownHtml , MarkdownSummaryLine } ;
7572
7673/// A pair of name and its optional document.
7774crate type NameDoc = ( String , Option < String > ) ;
@@ -82,74 +79,6 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
8279 } )
8380}
8481
85- /// Shared mutable state used in [`Context`] and elsewhere.
86- crate struct SharedContext < ' tcx > {
87- crate tcx : TyCtxt < ' tcx > ,
88- /// The path to the crate root source minus the file name.
89- /// Used for simplifying paths to the highlighted source code files.
90- crate src_root : PathBuf ,
91- /// This describes the layout of each page, and is not modified after
92- /// creation of the context (contains info like the favicon and added html).
93- crate layout : layout:: Layout ,
94- /// This flag indicates whether `[src]` links should be generated or not. If
95- /// the source files are present in the html rendering, then this will be
96- /// `true`.
97- crate include_sources : bool ,
98- /// The local file sources we've emitted and their respective url-paths.
99- crate local_sources : FxHashMap < PathBuf , String > ,
100- /// Whether the collapsed pass ran
101- collapsed : bool ,
102- /// The base-URL of the issue tracker for when an item has been tagged with
103- /// an issue number.
104- issue_tracker_base_url : Option < String > ,
105- /// The directories that have already been created in this doc run. Used to reduce the number
106- /// of spurious `create_dir_all` calls.
107- created_dirs : RefCell < FxHashSet < PathBuf > > ,
108- /// This flag indicates whether listings of modules (in the side bar and documentation itself)
109- /// should be ordered alphabetically or in order of appearance (in the source code).
110- sort_modules_alphabetically : bool ,
111- /// Additional CSS files to be added to the generated docs.
112- crate style_files : Vec < StylePath > ,
113- /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes
114- /// "light-v2.css").
115- crate resource_suffix : String ,
116- /// Optional path string to be used to load static files on output pages. If not set, uses
117- /// combinations of `../` to reach the documentation root.
118- crate static_root_path : Option < String > ,
119- /// The fs handle we are working with.
120- crate fs : DocFS ,
121- /// The default edition used to parse doctests.
122- crate edition : Edition ,
123- codes : ErrorCodes ,
124- playground : Option < markdown:: Playground > ,
125- all : RefCell < AllTypes > ,
126- /// Storage for the errors produced while generating documentation so they
127- /// can be printed together at the end.
128- errors : Receiver < String > ,
129- /// `None` by default, depends on the `generate-redirect-map` option flag. If this field is set
130- /// to `Some(...)`, it'll store redirections and then generate a JSON file at the top level of
131- /// the crate.
132- redirections : Option < RefCell < FxHashMap < String , String > > > ,
133- }
134-
135- impl SharedContext < ' _ > {
136- crate fn ensure_dir ( & self , dst : & Path ) -> Result < ( ) , Error > {
137- let mut dirs = self . created_dirs . borrow_mut ( ) ;
138- if !dirs. contains ( dst) {
139- try_err ! ( self . fs. create_dir_all( dst) , dst) ;
140- dirs. insert ( dst. to_path_buf ( ) ) ;
141- }
142-
143- Ok ( ( ) )
144- }
145-
146- /// Based on whether the `collapse-docs` pass was run, return either the `doc_value` or the
147- /// `collapsed_doc_value` of the given item.
148- crate fn maybe_collapsed_doc_value < ' a > ( & self , item : & ' a clean:: Item ) -> Option < String > {
149- if self . collapsed { item. collapsed_doc_value ( ) } else { item. doc_value ( ) }
150- }
151- }
152-
15382// Helper structs for rendering items/sidebars and carrying along contextual
15483// information
15584
0 commit comments