@@ -35,32 +35,30 @@ mod write_shared;
35
35
crate use context:: * ;
36
36
crate use write_shared:: FILES_UNVERSIONED ;
37
37
38
- use std:: cell:: { Cell , RefCell } ;
38
+ use std:: cell:: Cell ;
39
39
use std:: collections:: VecDeque ;
40
40
use std:: default:: Default ;
41
41
use std:: fmt;
42
- use std:: path:: { Path , PathBuf } ;
42
+ use std:: path:: PathBuf ;
43
43
use std:: str;
44
44
use std:: string:: ToString ;
45
- use std:: sync:: mpsc:: Receiver ;
46
45
47
46
use itertools:: Itertools ;
48
47
use rustc_ast_pretty:: pprust;
49
48
use rustc_attr:: { Deprecation , StabilityLevel } ;
50
- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
49
+ use rustc_data_structures:: fx:: FxHashSet ;
51
50
use rustc_hir as hir;
52
51
use rustc_hir:: def:: CtorKind ;
53
52
use rustc_hir:: def_id:: DefId ;
54
53
use rustc_hir:: Mutability ;
55
54
use rustc_middle:: middle:: stability;
56
55
use rustc_middle:: ty:: TyCtxt ;
57
- use rustc_span:: edition:: Edition ;
58
56
use rustc_span:: symbol:: { kw, sym, Symbol } ;
59
57
use serde:: ser:: SerializeSeq ;
60
58
use serde:: { Serialize , Serializer } ;
61
59
62
60
use crate :: clean:: { self , GetDefId , RenderedLink , SelfTy , TypeKind } ;
63
- use crate :: docfs:: { DocFS , PathError } ;
61
+ use crate :: docfs:: PathError ;
64
62
use crate :: error:: Error ;
65
63
use crate :: formats:: cache:: Cache ;
66
64
use crate :: formats:: item_type:: ItemType ;
@@ -70,8 +68,7 @@ use crate::html::format::{
70
68
href, print_abi_with_space, print_default_space, print_generic_bounds, print_where_clause,
71
69
Buffer , PrintWithSpace ,
72
70
} ;
73
- use crate :: html:: layout;
74
- use crate :: html:: markdown:: { self , ErrorCodes , Markdown , MarkdownHtml , MarkdownSummaryLine } ;
71
+ use crate :: html:: markdown:: { Markdown , MarkdownHtml , MarkdownSummaryLine } ;
75
72
76
73
/// A pair of name and its optional document.
77
74
crate type NameDoc = ( String , Option < String > ) ;
@@ -82,74 +79,6 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
82
79
} )
83
80
}
84
81
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
-
153
82
// Helper structs for rendering items/sidebars and carrying along contextual
154
83
// information
155
84
0 commit comments