@@ -179,7 +179,11 @@ fn generate_doc_file(docs: &[&str], fname: String, delims: Delimiters) -> DocFil
179
179
180
180
/// Given a file path and delimiters, generate a DocFile for all files requested.
181
181
pub fn start ( p : & str , is_directory : bool , delims : Delimiters ) -> Vec < DocFile > {
182
- let dir = p. replace ( "~" , home_dir ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ) ;
182
+ let dir = if cfg ! ( windows) {
183
+ String :: from ( p)
184
+ } else {
185
+ p. replace ( "~" , home_dir ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) )
186
+ } ;
183
187
if is_directory {
184
188
let files: Vec < _ > = glob ( & dir) . unwrap ( ) . filter_map ( |x| x. ok ( ) ) . collect ( ) ;
185
189
let every_doc: Vec < DocFile > = files
@@ -292,7 +296,11 @@ pub fn printer(thedocs: &DocFile) {
292
296
/// Given a list of `DocFile` and a file path, write the JSON representation to a file.
293
297
pub fn to_json ( docstrings : & [ DocFile ] , file_name : & str ) {
294
298
let json = serde_json:: to_string_pretty ( & docstrings) . expect ( "Could not convert to JSON" ) ;
295
- let path_as_str = file_name. replace ( "~" , home_dir ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ) ;
299
+ let path_as_str = if cfg ! ( windows) {
300
+ String :: from ( file_name)
301
+ } else {
302
+ file_name. replace ( "~" , home_dir ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) )
303
+ } ;
296
304
let path = Path :: new ( & path_as_str) ;
297
305
let mut file = File :: create ( Path :: new ( & path) ) . expect ( "Invalid file path." ) ;
298
306
file. write_all ( & json. as_bytes ( ) )
0 commit comments