aboutsummaryrefslogtreecommitdiffstats
path: root/src/repr_latex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/repr_latex.rs')
-rw-r--r--src/repr_latex.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/repr_latex.rs b/src/repr_latex.rs
index 4c4e34c..b5426e8 100644
--- a/src/repr_latex.rs
+++ b/src/repr_latex.rs
@@ -8,6 +8,9 @@ pub trait ReprLaTeX {
fn repr_latex(&self) -> Result<String>;
}
+pub trait ReprVarsHTML {
+ fn repr_vars_html(&self) -> Result<String>;
+}
impl ReprLaTeX for ModelicaModel {
fn repr_latex(&self) -> Result<String> {
@@ -25,6 +28,43 @@ impl ReprLaTeX for ModelicaModel {
}
}
+impl ReprVarsHTML for ModelicaModel {
+
+ fn repr_vars_html(&self) -> Result<String> {
+
+ 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>"#,
+ prefix = if let Some(ref cp) = c.prefix {
+ format!("{:?}", cp) }
+ else { "free".to_string() },
+ specifier = c.specifier,
+ name = try!(Expr::Ident(c.name.clone()).repr_latex()),
+ default = if let Some(ref v) = c.value {
+ try!(v.repr_latex()) }
+ else { "".to_string() },
+ description = if let Some(ref d) = c.description {
+ d.clone() }
+ 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))
+ }
+}
+
fn is_latexy_ident(s: &str) -> bool {
let latexy_idents = [
"alpha", "Alpha", "beta", "gamma", "Gamma", "delta", "Delta",