mod axis;
mod dates;
mod db;
mod lexer;
mod parser;
mod render;
#[cfg(test)]
mod tests;
pub(crate) use db::GanttDb;
pub(crate) use render::layout;
use crate::errors::Error;
use crate::value::{Map, Value};
pub(crate) fn parse(source: &str, config: &Map, title: Option<&str>) -> Result<GanttDb, Error> {
let mut db = GanttDb::default();
if let Some(title) = title.filter(|t| !t.is_empty()) {
db.title = Some(title.to_string());
}
let mode = config
.get("gantt")
.and_then(Value::as_object)
.and_then(|g| g.get("displayMode"));
if let Some(Value::String(mode)) = mode {
db.display_mode = mode.clone();
}
parser::parse_gantt(source, &mut db)?;
Ok(db)
}