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