Skip to content

Commit

Permalink
doc generation: do not insert line breaks (tweag#1879)
Browse files Browse the repository at this point in the history
The code generating markdown documentation from a Nickel configuration
used to unconditionally insert hard line breaks between a field's
signature and the rest of its documentation. However, one can't insert a
hard line break immediately followed by a blocks in commonmark (or put
differently: it's not representable as a source), and those line breaks
were just rendered as spurious backslashes at best, or sometimes
interpreted differently (see tweag#1706 for more details).

A bit of experimentation showed that what comes after this line break is
always a block in the sense of commonmark (even when it's simple
documentation text, it's wrapped as a Markdown paragraph). Thus this
commit just removes the line break altogether, which is not useful and
never legal anyway.
  • Loading branch information
yannham authored Apr 3, 2024
1 parent cb91eeb commit b4b1779
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ expression: out
---
# `Hello`

\
World\!

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ expression: out

- `Hello : Number`
- `Hello | std.string.Stringable`
\
World\!

2 changes: 0 additions & 2 deletions core/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,6 @@ mod doc {
))
}

document.append(arena.alloc(AstNode::from(NodeValue::LineBreak)));

if let Some(ref doc) = field.documentation {
document.append(parse_markdown_string(header_level + 1, arena, doc, options));
}
Expand Down

0 comments on commit b4b1779

Please sign in to comment.