mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
ToHtml trait for docs and some rudimentary syntax highlighting that is definitely a work in progress
This commit is contained in:
parent
c72400c619
commit
9e12f6d3ec
11 changed files with 472 additions and 134 deletions
57
docs/src/def.rs
Normal file
57
docs/src/def.rs
Normal file
|
@ -0,0 +1,57 @@
|
|||
use crate::html::ToHtml;
|
||||
use roc_parse::ast::Def;
|
||||
|
||||
impl<'a> ToHtml<'a> for Def<'a> {
|
||||
fn css_class(&self) -> Option<&'a str> {
|
||||
match self {
|
||||
// Def::Annotation(_, _) => {}
|
||||
// Def::Alias { .. } => {}
|
||||
Def::Body(_, _) => None,
|
||||
// Def::AnnotatedBody { .. } => {}
|
||||
// Def::Expect(_) => {}
|
||||
Def::SpaceBefore(_, _) => None,
|
||||
Def::SpaceAfter(_, _) => None,
|
||||
// Def::NotYetImplemented(_) => {}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn html_body(&self, buf: &mut bumpalo::collections::String<'a>) {
|
||||
match self {
|
||||
// Def::Annotation(_, _) => {}
|
||||
// Def::Alias { .. } => {}
|
||||
Def::Body(pattern, expr) => {
|
||||
pattern.html(buf);
|
||||
EqualSign.html(buf);
|
||||
expr.html(buf);
|
||||
}
|
||||
// Def::AnnotatedBody { .. } => {}
|
||||
// Def::Expect(_) => {}
|
||||
Def::SpaceBefore(sub_def, spaces) => {
|
||||
for space in spaces.iter() {
|
||||
space.html(buf);
|
||||
}
|
||||
sub_def.html(buf);
|
||||
}
|
||||
Def::SpaceAfter(sub_def, spaces) => {
|
||||
sub_def.html(buf);
|
||||
for space in spaces.iter() {
|
||||
space.html(buf);
|
||||
}
|
||||
}
|
||||
// Def::NotYetImplemented(_) => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EqualSign;
|
||||
|
||||
impl<'a> ToHtml<'a> for EqualSign {
|
||||
fn css_class(&self) -> Option<&'a str> {
|
||||
Some("operator")
|
||||
}
|
||||
fn html_body(&self, buf: &mut bumpalo::collections::String<'a>) {
|
||||
buf.push_str(" = ")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue