Repository: Geal/cargo-external-doc (language: rust)

Issue:
generated paths not normalized
In a crate with a `-` character, `cargo doc` converts it into an underscore whereas this puts generated files into a directory with the same name as the crate rather than doing the same sanitization routine.


Discussion / hints:
Looks like based on [cargo's logic](https://github.com/rust-lang/cargo/blob/fb03dad54fdd3cd32afc33f3b031e408e92b5847/src/cargo/ops/cargo_doc.rs#L44), it is a simple find/replace.


Fix patch:
diff --git a/src/main.rs b/src/main.rs
index a431262..bcdc1a8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,7 +18,7 @@ fn get_package_name() -> String {
                      .expect("invalid encoding");
     let value: Value = serde_json::from_str(&stdout).expect("invalid JSON metadata");
     let main: &Map<String, Value> = value.as_object().expect("top level value is not an object");
-    String::from(main["name"].as_str().expect("invalid main string"))
+    String::from(main["name"].as_str().expect("invalid main string")).replace('-', "_")
 }
 
 fn generate_wrapper(name: &str) -> (NamedTempFile,NamedTempFile) {


Test patch: