Skip to content

Commit

Permalink
[Move SDK codegen] Bump textwrap from 0.13.2 to 0.13.3
Browse files Browse the repository at this point in the history
Textwrap behavior changed after mgeisler/textwrap#279

Closes: diem#7705
  • Loading branch information
ma2bd authored and zgfzgf committed Jun 8, 2021
1 parent d0430fa commit a9b1510
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion language/transaction-builder/generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ anyhow = "1.0.38"
heck = "0.3.2"
regex = "1.4.3"
structopt = "0.3.21"
textwrap = "0.13.2"
textwrap = "0.13.3"
serde-reflection = "0.3.2"
serde-generate = "0.18.0"
serde_yaml = "0.8.17"
Expand Down
9 changes: 5 additions & 4 deletions language/transaction-builder/generator/src/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ using namespace diem_types;
}

fn output_builder_declaration(&mut self, abi: &ScriptABI) -> Result<()> {
write!(self.out, "\n{}", Self::quote_doc(abi.doc()))?;
self.output_doc(abi.doc())?;
writeln!(
self.out,
"Script encode_{}_script({});",
Expand All @@ -134,7 +134,7 @@ using namespace diem_types;

fn output_builder_definition(&mut self, abi: &ScriptABI) -> Result<()> {
if self.inlined_definitions {
write!(self.out, "\n{}", Self::quote_doc(abi.doc()))?;
self.output_doc(abi.doc())?;
}
writeln!(
self.out,
Expand Down Expand Up @@ -167,9 +167,10 @@ using namespace diem_types;
Ok(())
}

fn quote_doc(doc: &str) -> String {
fn output_doc(&mut self, doc: &str) -> Result<()> {
let doc = crate::common::prepare_doc_string(doc);
textwrap::indent(&doc, "/// ").replace("\n\n", "\n///\n")
let text = textwrap::indent(&doc, "/// ").replace("\n\n", "\n///\n");
write!(self.out, "\n{}\n", text)
}

fn quote_type_parameters(ty_args: &[TypeArgumentABI]) -> Vec<String> {
Expand Down
2 changes: 1 addition & 1 deletion language/transaction-builder/generator/src/golang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func DecodeScript(script *diemtypes.Script) (ScriptCall, error) {{
fn output_script_encoder_function(&mut self, abi: &ScriptABI) -> Result<()> {
writeln!(
self.out,
"\n{}func Encode{}Script({}) diemtypes.Script {{",
"\n{}\nfunc Encode{}Script({}) diemtypes.Script {{",
Self::quote_doc(abi.doc()),
abi.name().to_camel_case(),
[
Expand Down
2 changes: 1 addition & 1 deletion language/transaction-builder/generator/src/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ private static {} decode_{}_argument(TransactionArgument arg) {{
}
doc = format!("{}\n@return {}", doc, return_doc);
let text = textwrap::indent(&doc, " * ").replace("\n\n", "\n *\n");
format!("/**\n{} */\n", text)
format!("/**\n{}\n */\n", text)
}

fn quote_type_arguments(ty_args: &[TypeArgumentABI]) -> String {
Expand Down
2 changes: 1 addition & 1 deletion language/transaction-builder/generator/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn decode(script: &Script) -> Option<ScriptCall> {{
let prefix = " ".repeat(indentation) + "/// ";
let empty_line = "\n".to_string() + &" ".repeat(indentation) + "///\n";
let text = textwrap::indent(doc, &prefix).replace("\n\n", &empty_line);
write!(self.out, "\n{}", text)
write!(self.out, "\n{}\n", text)
}

fn output_script_encoder_function(&mut self, abi: &ScriptABI) -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion language/transaction-builder/generator/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ return new DiemTypes.Script(code, tyArgs, args);"#,
fn quote_doc(doc: &str) -> String {
let doc = crate::common::prepare_doc_string(doc);
let text = textwrap::indent(&doc, " * ").replace("\n\n", "\n *\n");
format!("/**\n{} */\n", text)
format!("/**\n{}\n */\n", text)
}

fn quote_type_parameters(ty_args: &[TypeArgumentABI]) -> Vec<String> {
Expand Down

0 comments on commit a9b1510

Please sign in to comment.