improved whitespace handling (#6)
This commit is contained in:
parent
874f959a75
commit
7e16140b78
|
@ -175,6 +175,7 @@ dependencies = [
|
|||
"openapiv3",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustfmt-wrapper",
|
||||
"schemars",
|
||||
"serde",
|
||||
|
|
|
@ -13,6 +13,7 @@ indexmap = "1.7.0"
|
|||
openapiv3 = "1.0.0-beta.2"
|
||||
proc-macro2 = "1.0.29"
|
||||
quote = "1.0.9"
|
||||
regex = "1.5.4"
|
||||
rustfmt-wrapper = { git = "https://github.com/oxidecomputer/typify" }
|
||||
schemars = "0.8.5"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
|
|
|
@ -824,10 +824,10 @@ fn generate(api: &OpenAPI, ts: &mut TypeSpace) -> Result<String> {
|
|||
#(#methods)*
|
||||
}
|
||||
};
|
||||
let file = rustfmt_wrapper::rustfmt(file)
|
||||
.unwrap()
|
||||
// Format any indented item.
|
||||
.replace(" }\n", " }\n\n");
|
||||
let regex = regex::Regex::new(r#"(})(\n\s*[^} ])"#).unwrap();
|
||||
let file = rustfmt_wrapper::rustfmt(file).unwrap();
|
||||
|
||||
let file = regex.replace_all(&file, "$1\n$2").to_string();
|
||||
|
||||
Ok(file)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue