diff options
author | bnewbold <bnewbold@robocracy.org> | 2017-01-28 21:25:37 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2017-01-28 21:25:37 -0800 |
commit | 1aec9b6479beecd327456780ae7c711040011933 (patch) | |
tree | 036c4beb4ac2732d67adab5b9fc68ef0c384c7a2 /src | |
parent | 26737fe52301080b6c0573cd19c1c53715835e9e (diff) | |
download | modelthing-1aec9b6479beecd327456780ae7c711040011933.tar.gz modelthing-1aec9b6479beecd327456780ae7c711040011933.zip |
fiddling with whitespace for other reprs
Diffstat (limited to 'src')
-rw-r--r-- | src/repr_latex.rs | 33 | ||||
-rw-r--r-- | src/transpile_js.rs | 32 | ||||
-rw-r--r-- | src/transpile_scheme.rs | 13 |
3 files changed, 42 insertions, 36 deletions
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#"<tr><td>\({name}\)</td> - <td>{prefix}</td> - <td>{description}</td> - <td>\({default}\)</td> - <td>{specifier}</td> - </tr>"#, + rows.push(format!( +r#"<tr><td>\({name}\)</td> + <td>{prefix}</td> + <td>{description}</td> + <td>\({default}\)</td> + <td>{specifier}</td> + </tr>"#, 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#"<table> - <tr><th>Variable</th> - <th>Type</th> - <th>Description</th> - <th>Value (default)</th> - <th>Datatype</th> - {rows} - </table>"#, - rows = rows)) + Ok(format!( +r#"<table> + <tr><th>Variable + <th>Type + <th>Description + <th>Value (default) + <th>Datatype + </tr> + {rows} +</table>"#, + 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<String> = 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<String> = 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<String> = 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(" "))) } } |