use maud::Markup;
use maud::html;
use wdl_ast::AstToken;
use wdl_ast::v1::StructDefinition;
#[derive(Debug)]
pub struct Struct {
def: StructDefinition,
}
impl Struct {
pub fn new(def: StructDefinition) -> Self {
Self { def }
}
pub fn name(&self) -> String {
self.def.name().text().to_string()
}
pub fn members(&self) -> impl Iterator<Item = (String, String)> + '_ {
self.def.members().map(|decl| {
let name = decl.name().text().to_owned();
let ty = decl.ty().to_string();
(name, ty)
})
}
pub fn render(&self) -> Markup {
html! {
div class="table-auto border-collapse" {
h1 { (self.name()) }
h2 { "Members" }
ul {
@for (name, ty) in self.members() {
li {
b { (name) ":" } " " code { (ty) }
}
}
}
}
}
}
}