mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
started on supprting comments in editor+docs
This commit is contained in:
parent
44cf238a67
commit
30c1d218a7
@ -161,6 +161,13 @@ pub enum Expr2 {
|
||||
},
|
||||
Blank, // Rendered as empty box in editor
|
||||
|
||||
Comment(PoolStr),
|
||||
WithComment {
|
||||
expr_id: ExprId,
|
||||
comment_id: ExprId
|
||||
},
|
||||
Comments(PoolVec<ExprId>),
|
||||
|
||||
// Compiles, but will crash if reached
|
||||
RuntimeError(/* TODO make a version of RuntimeError that fits in 15B */),
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ pub fn expr_to_expr2<'a>(
|
||||
bad_expr
|
||||
);
|
||||
}
|
||||
bad_expr @ SpaceBefore(_, _) => {
|
||||
bad_expr @ SpaceBefore(_, _) => { // TODO no panic, move in Expr2::Comment
|
||||
panic!(
|
||||
"A SpaceBefore did not get removed during operator desugaring somehow: {:#?}",
|
||||
bad_expr
|
||||
|
@ -19,6 +19,8 @@ pub enum HighlightStyle {
|
||||
Import,
|
||||
Provides,
|
||||
Blank,
|
||||
Comment,
|
||||
DocsComment,
|
||||
}
|
||||
|
||||
pub fn default_highlight_map() -> HashMap<HighlightStyle, RgbaTup> {
|
||||
@ -42,7 +44,8 @@ pub fn default_highlight_map() -> HashMap<HighlightStyle, RgbaTup> {
|
||||
(Import, from_hsb(225, 50, 100)),
|
||||
(Provides, from_hsb(225, 50, 100)),
|
||||
(Blank, from_hsb(258, 50, 90)),
|
||||
// comment from_hsb(285, 6, 47) or 186, 35, 40
|
||||
(Comment, from_hsb(258, 50, 90)), // TODO check color
|
||||
(DocsComment, from_hsb(258, 50, 90)), // TODO check color
|
||||
]
|
||||
.iter()
|
||||
.for_each(|tup| {
|
||||
|
@ -44,6 +44,8 @@ pub fn mark_node_to_html<'a>(
|
||||
Import => "import",
|
||||
Provides => "provides",
|
||||
Blank => "blank",
|
||||
Comment => "comment",
|
||||
DocsComment => "docs-comment",
|
||||
};
|
||||
|
||||
write_html_to_buf(content, css_class, buf);
|
||||
|
@ -188,4 +188,12 @@ main = "Hello, world!"
|
||||
"<span class=\"syntax-value\">myId</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-operator\">\\</span><span class=\"syntax-function-arg-name\">something</span><span class=\"syntax-operator\"> -> </span>\n<span class=\"syntax-indent\"> </span><span class=\"syntax-value\">something</span>\n\n",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tld_with_comment() {
|
||||
expect_html_def(
|
||||
r#"myVal = "Hello, World!" # COMMENT"#,
|
||||
"<span class=\"syntax-value\">myVal</span><span class=\"syntax-operator\"> = </span><span class=\"syntax-string\">\"Hello, World!\"</span><span class=\"syntax-comment\"> # COMMENT</span>\n\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user