@@ -24,6 +24,7 @@ use utils;
24
24
struct RustdocPage {
25
25
pub head : String ,
26
26
pub body : String ,
27
+ pub body_class : String ,
27
28
pub name : String ,
28
29
pub full : String ,
29
30
pub version : String ,
@@ -37,6 +38,7 @@ impl Default for RustdocPage {
37
38
RustdocPage {
38
39
head : String :: new ( ) ,
39
40
body : String :: new ( ) ,
41
+ body_class : String :: new ( ) ,
40
42
name : String :: new ( ) ,
41
43
full : String :: new ( ) ,
42
44
version : String :: new ( ) ,
@@ -52,6 +54,7 @@ impl ToJson for RustdocPage {
52
54
let mut m: BTreeMap < String , Json > = BTreeMap :: new ( ) ;
53
55
m. insert ( "rustdoc_head" . to_string ( ) , self . head . to_json ( ) ) ;
54
56
m. insert ( "rustdoc_body" . to_string ( ) , self . body . to_json ( ) ) ;
57
+ m. insert ( "rustdoc_body_class" . to_string ( ) , self . body_class . to_json ( ) ) ;
55
58
m. insert ( "rustdoc_full" . to_string ( ) , self . full . to_json ( ) ) ;
56
59
m. insert ( "rustdoc_status" . to_string ( ) , true . to_json ( ) ) ;
57
60
m. insert ( "name" . to_string ( ) , self . name . to_json ( ) ) ;
@@ -160,10 +163,18 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
160
163
161
164
let file_content = ctry ! ( String :: from_utf8( file. content) ) ;
162
165
163
- let ( head, body) = ctry ! ( utils:: extract_head_and_body( & file_content) ) ;
166
+ let ( head, body, mut body_class ) = ctry ! ( utils:: extract_head_and_body( & file_content) ) ;
164
167
content. head = head;
165
168
content. body = body;
166
169
170
+ if body_class. is_empty ( ) {
171
+ body_class = "rustdoc container-rustdoc" . to_string ( ) ;
172
+ } else {
173
+ // rustdoc adds its own "rustdoc" class to the body
174
+ body_class. push_str ( " container-rustdoc" ) ;
175
+ }
176
+ content. body_class = body_class;
177
+
167
178
content. full = file_content;
168
179
let crate_details = cexpect ! ( CrateDetails :: new( & conn, & name, & version) ) ;
169
180
let latest_version = latest_version ( & crate_details. versions , & version) ;
0 commit comments