From 1aec9b6479beecd327456780ae7c711040011933 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sat, 28 Jan 2017 21:25:37 -0800 Subject: fiddling with whitespace for other reprs --- src/repr_latex.rs | 33 ++++++++++++++++++--------------- src/transpile_js.rs | 32 +++++++++++++++++--------------- src/transpile_scheme.rs | 13 +++++++------ 3 files changed, 42 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/repr_latex.rs b/src/repr_latex.rs index b5426e8..51c9e7a 100644 --- a/src/repr_latex.rs +++ b/src/repr_latex.rs @@ -34,12 +34,13 @@ impl ReprVarsHTML for ModelicaModel { let mut rows = vec![]; for c in &self.components { - rows.push(format!(r#"\({name}\) - {prefix} - {description} - \({default}\) - {specifier} - "#, + rows.push(format!( +r#"\({name}\) + {prefix} + {description} + \({default}\) + {specifier} + "#, prefix = if let Some(ref cp) = c.prefix { format!("{:?}", cp) } else { "free".to_string() }, @@ -53,15 +54,17 @@ impl ReprVarsHTML for ModelicaModel { else { "".to_string() })); } let rows = rows.join("\n"); - Ok(format!(r#" - - - - - - {rows} -
VariableTypeDescriptionValue (default)Datatype
"#, - rows = rows)) + Ok(format!( +r#" + + {rows} +
Variable + Type + Description + Value (default) + Datatype +
"#, + rows = rows.join("\n ")) } } diff --git a/src/transpile_js.rs b/src/transpile_js.rs index 97eff68..586abc1 100644 --- a/src/transpile_js.rs +++ b/src/transpile_js.rs @@ -40,11 +40,12 @@ impl TranspileJS for ModelicaModel { let mut args: Vec = self.get_free_vars().iter().map(|s| s.clone()).collect(); args.sort(); args.extend(params); - Ok(format!(r#"function ({args}) {{ - {constants} - {binds} - return [{outputs}]; - }};"#, + Ok(format!( +r#"function ({args}) {{ + {constants} + {binds} + return [{outputs}]; +}};"#, args = args.join(", "), constants = constants.join("\n "), binds = binds.join("\n "), @@ -83,18 +84,19 @@ impl TranspileJSODE for ModelicaModel { } let mut args: Vec = self.get_free_vars().iter().map(|s| s.clone()).collect(); args.sort(); - Ok(format!(r#"function ({params}) {{ - return function({args}) {{ - {constants} - return [ - {expressions} - ]; - }}; - }};"#, + Ok(format!( +r#"function ({params}) {{ + return function({args}) {{ + {constants} + return [ + {expressions} + ]; + }}; +}};"#, params = params.join(", "), args = args.join(", "), - constants = constants.join("\n "), - expressions = exprs.join(",\n "))) + constants = constants.join("\n "), // NB: whitespace + expressions = exprs.join(",\n "))) // NB: whitespace } } diff --git a/src/transpile_scheme.rs b/src/transpile_scheme.rs index 6f993b3..d6f437a 100644 --- a/src/transpile_scheme.rs +++ b/src/transpile_scheme.rs @@ -36,13 +36,14 @@ impl TranspileScheme for ModelicaModel { let mut args: Vec = self.get_free_vars().iter().map(|s| s.clone()).collect(); args.sort(); args.extend(params); - Ok(format!(r#"(lambda ({args}) - (let ({constants}) - (letrec ({binds}) - (list {outputs}))))"#, + Ok(format!( +r#"(lambda ({args}) + (let ({constants}) + (letrec ({binds}) + (list {outputs}))))"#, args = args.join(" "), - constants = constants.join("\n "), - binds = binds.join("\n "), + constants = constants.join("\n "), // NB: whitespace + binds = binds.join("\n "), // NB: whitespace outputs = outputs.join(" "))) } } -- cgit v1.2.3