aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/classic_gravitation/examples.toml (renamed from examples/classic_gravitation/metadata.toml)4
-rw-r--r--examples/classic_gravitation/model.modelica1
-rw-r--r--examples/hodgkin_huxley/model.modelica1
-rw-r--r--examples/lotka_volterra/examples.toml (renamed from examples/lotka_volterra/metadata.toml)4
-rw-r--r--examples/van_der_pol/examples.toml (renamed from examples/van_der_pol/metadata.toml)0
-rw-r--r--src/bin/mt-webface.rs5
-rw-r--r--src/lib.rs28
-rw-r--r--tests/lib.rs14
8 files changed, 4 insertions, 53 deletions
diff --git a/examples/classic_gravitation/metadata.toml b/examples/classic_gravitation/examples.toml
index 9f43ae7..516b16c 100644
--- a/examples/classic_gravitation/metadata.toml
+++ b/examples/classic_gravitation/examples.toml
@@ -1,8 +1,4 @@
-[model]
-name-en = "Classic Gravitation"
-description-en = "Newtonian"
-
[examples]
[examples.earth_surface]
diff --git a/examples/classic_gravitation/model.modelica b/examples/classic_gravitation/model.modelica
index e0f7b60..7d5d327 100644
--- a/examples/classic_gravitation/model.modelica
+++ b/examples/classic_gravitation/model.modelica
@@ -1,4 +1,5 @@
model ClassicGravitation
+ "Newtonian"
parameter Real G=6.674e-11 "Gravitational Constant";
Real m1(unit="kilogram") "mass #1";
Real m2(unit="kilogram") "mass #2";
diff --git a/examples/hodgkin_huxley/model.modelica b/examples/hodgkin_huxley/model.modelica
index 9153799..532bdac 100644
--- a/examples/hodgkin_huxley/model.modelica
+++ b/examples/hodgkin_huxley/model.modelica
@@ -1,4 +1,5 @@
model HodgkinHuxley
+ "Predator-Prey Model"
parameter Real G_Na =120 "conductance";
parameter Real G_K =36 "conductance";
parameter Real G_lk =0.3 "conductance";
diff --git a/examples/lotka_volterra/metadata.toml b/examples/lotka_volterra/examples.toml
index 9753537..0f5fb85 100644
--- a/examples/lotka_volterra/metadata.toml
+++ b/examples/lotka_volterra/examples.toml
@@ -1,8 +1,4 @@
-[model]
-name-en = "Lotka–Volterra equations"
-description-en = "Predator-Prey Model"
-
[examples]
[examples.mathworld]
diff --git a/examples/van_der_pol/metadata.toml b/examples/van_der_pol/examples.toml
index e69de29..e69de29 100644
--- a/examples/van_der_pol/metadata.toml
+++ b/examples/van_der_pol/examples.toml
diff --git a/src/bin/mt-webface.rs b/src/bin/mt-webface.rs
index b5b4fe0..3b280e2 100644
--- a/src/bin/mt-webface.rs
+++ b/src/bin/mt-webface.rs
@@ -44,9 +44,8 @@ fn model_view(r: &mut Request) -> PencilResult {
Ok(me) => {
let mut context = BTreeMap::new();
context.insert("model_slug".to_string(), model_slug.to_string());
- context.insert("model_name".to_string(), me.metadata.name_en);
- context.insert("model_description".to_string(), me.metadata.description_en.unwrap_or("".to_string()));
- //context.insert("metadata".to_string(), me.metadata);
+ context.insert("model_name".to_string(), me.ast.name.clone());
+ context.insert("model_description".to_string(), me.ast.description.clone().unwrap_or("".to_string()));
context.insert("markdown_html".to_string(), markdown::to_html(&me.markdown));
context.insert("markdown".to_string(), me.markdown);
context.insert("modelica".to_string(), format!("{:?}", me.ast));
diff --git a/src/lib.rs b/src/lib.rs
index 91c99ea..f93f7fa 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -15,12 +15,6 @@ use std::io::Read;
use std::fs::File;
#[derive(Debug, PartialEq)]
-pub struct ModelMetadata {
- pub name_en: String,
- pub description_en: Option<String>,
-}
-
-#[derive(Debug, PartialEq)]
pub enum ModelVarType {
Independent,
Dependent,
@@ -42,22 +36,9 @@ pub struct ModelVar {
#[derive(Debug, PartialEq)]
pub struct ModelEntry {
pub ast: modelica_parser::ModelicaModel,
- pub metadata: ModelMetadata,
pub markdown: String,
}
-pub fn parse_metadata(raw: String) -> Result<ModelMetadata, String> {
- let root = toml::Parser::new(&raw).parse().unwrap();
- let model = root.get("model")
- .expect("missing 'model' section")
- .as_table()
- .unwrap();
- Ok(ModelMetadata {
- name_en: model.get("name-en").unwrap().as_str().unwrap().to_string(),
- description_en: model.get("description-en").map(|x| x.as_str().unwrap().to_string()),
- })
-}
-
pub fn load_model_entry(p: &Path) -> Result<ModelEntry, String> {
debug!("Attempting to load model from: {:?}", p);
@@ -69,14 +50,6 @@ pub fn load_model_entry(p: &Path) -> Result<ModelEntry, String> {
try!(modelica_parser::parse_model(&s).map_err(|e| format!("{:?}", e)))
};
- let metadata = {
- let mut s = String::new();
- try!(File::open(p.join("metadata.toml"))
- .and_then(|mut f| f.read_to_string(&mut s))
- .map_err(|e| e.to_string()));
- parse_metadata(s).unwrap()
- };
-
let markdown = {
let mut s = String::new();
try!(File::open(p.join("page.md"))
@@ -87,7 +60,6 @@ pub fn load_model_entry(p: &Path) -> Result<ModelEntry, String> {
Ok(ModelEntry {
ast: ast,
- metadata: metadata,
markdown: markdown,
})
}
diff --git a/tests/lib.rs b/tests/lib.rs
index de19f5b..8899e0b 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -9,20 +9,6 @@ use modelica_parser::*;
#[test]
-fn test_parse_metadata() {
- let raw =
-r#"
-[model]
-name-en = "Bogus Dummy Model"
-"#.to_string();
- assert_eq!(parse_metadata(raw).unwrap(),
- ModelMetadata {
- name_en: "Bogus Dummy Model".to_string(),
- description_en: None,
- });
-}
-
-#[test]
fn test_load_model_entry() {
load_model_entry(Path::new("./examples/classic_gravitation/")).unwrap();
}