mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Records in docs rendering
This commit is contained in:
parent
d5c729b817
commit
0a42a04765
2 changed files with 98 additions and 1 deletions
|
@ -342,6 +342,34 @@ fn type_annotation_to_html(indent_level: usize, buf: &mut String, type_ann: &Typ
|
|||
buf.push(')');
|
||||
}
|
||||
}
|
||||
TypeAnnotation::Record { fields } => {
|
||||
buf.push_str("<br>");
|
||||
let record_indent = indent_level + 1;
|
||||
indent(buf, record_indent);
|
||||
buf.push('{');
|
||||
buf.push_str("<br>");
|
||||
|
||||
let next_indent_level = record_indent + 1;
|
||||
for (index, field) in fields.iter().enumerate() {
|
||||
indent(buf, next_indent_level);
|
||||
buf.push_str(field.name.as_str());
|
||||
|
||||
let separator = if field.optional { " ? " } else { " : " };
|
||||
|
||||
buf.push_str(separator);
|
||||
|
||||
type_annotation_to_html(next_indent_level, buf, &field.type_annotation);
|
||||
|
||||
if index < (fields.len() - 1) {
|
||||
buf.push(',');
|
||||
}
|
||||
|
||||
buf.push_str("<br>");
|
||||
}
|
||||
|
||||
indent(buf, record_indent);
|
||||
buf.push('}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue