@@ -48,13 +48,17 @@ fn copy_files_and_handle_html(source: PathBuf,
48
48
target : bool )
49
49
-> Result < ( ) > {
50
50
51
+ // FIXME: handle_html is useless since we started using --resource-suffix
52
+ // argument with rustdoc
53
+
51
54
// Make sure destination directory is exists
52
55
if !destination. exists ( ) {
53
56
try!( fs:: create_dir_all ( & destination) ) ;
54
57
}
55
58
56
- // Avoid copying duplicated files
57
- let dup_regex = Regex :: new ( r"(\.lock|\.txt|\.woff|jquery\.js|playpen\.js|main\.js|\.css)$" )
59
+ // Avoid copying common files
60
+ let dup_regex = Regex :: new (
61
+ r"(\.lock|\.txt|\.woff|\.svg|\.css|main-.*\.css|main-.*\.js|normalize-.*\.js|rustdoc-.*\.css|storage-.*\.js|theme-.*\.js)$" )
58
62
. unwrap ( ) ;
59
63
60
64
for file in try!( source. read_dir ( ) ) {
@@ -72,8 +76,6 @@ fn copy_files_and_handle_html(source: PathBuf,
72
76
handle_html,
73
77
& rustc_version,
74
78
target) ) ;
75
- } else if handle_html && file. file_name ( ) . into_string ( ) . unwrap ( ) . ends_with ( ".html" ) {
76
- try!( copy_html ( & file. path ( ) , & destination_full_path, rustc_version, target) ) ;
77
79
} else if handle_html && dup_regex. is_match ( & file. file_name ( ) . into_string ( ) . unwrap ( ) [ ..] ) {
78
80
continue ;
79
81
} else {
@@ -85,45 +87,6 @@ fn copy_files_and_handle_html(source: PathBuf,
85
87
}
86
88
87
89
88
- fn copy_html ( source : & PathBuf ,
89
- destination : & PathBuf ,
90
- rustc_version : & str ,
91
- target : bool )
92
- -> Result < ( ) > {
93
-
94
- let source_file = try!( fs:: File :: open ( source) ) ;
95
- let mut destination_file = try!( fs:: OpenOptions :: new ( )
96
- . write ( true )
97
- . create ( true )
98
- . open ( destination) ) ;
99
-
100
- let reader = io:: BufReader :: new ( source_file) ;
101
-
102
- // FIXME: We don't need to store common libraries (jquery and normalize) for the each version
103
- // of rustc. I believe storing only one version of this files should work in every
104
- // documentation page.
105
- let replace_regex =
106
- Regex :: new ( r#"(href|src)="(.*)(main|jquery|rustdoc|playpen|normalize)\.(css|js)""# )
107
- . unwrap ( ) ;
108
- let replace_str = format ! ( "$1=\" {}../../$2$3-{}.$4\" " ,
109
- if target { "../" } else { "" } ,
110
- rustc_version) ;
111
-
112
- for line in reader. lines ( ) {
113
- let mut line = try!( line) ;
114
-
115
- // replace css links
116
- line = replace_regex. replace_all ( & line[ ..] , & replace_str[ ..] ) . into_owned ( ) ;
117
-
118
- try!( destination_file. write ( line. as_bytes ( ) ) ) ;
119
- // need to write consumed newline
120
- try!( destination_file. write ( & [ '\n' as u8 ] ) ) ;
121
- }
122
-
123
- Ok ( ( ) )
124
- }
125
-
126
-
127
90
128
91
#[ cfg( test) ]
129
92
mod test {
0 commit comments