mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Treat two hash marks followed by text as a doc comment
This commit is contained in:
parent
4dca0546f4
commit
723c390f52
3 changed files with 3 additions and 15 deletions
|
@ -208,7 +208,7 @@ fn fmt_docs(buf: &mut Buf, docs: &str) {
|
||||||
/// * Removing comments
|
/// * Removing comments
|
||||||
/// * Removing parens in Exprs
|
/// * Removing parens in Exprs
|
||||||
///
|
///
|
||||||
/// Long term, we actuall want this transform to preserve comments (so we can assert they're maintained by formatting)
|
/// Long term, we actually want this transform to preserve comments (so we can assert they're maintained by formatting)
|
||||||
/// - but there are currently several bugs where they're _not_ preserved.
|
/// - but there are currently several bugs where they're _not_ preserved.
|
||||||
/// TODO: ensure formatting retains comments
|
/// TODO: ensure formatting retains comments
|
||||||
pub trait RemoveSpaces<'a> {
|
pub trait RemoveSpaces<'a> {
|
||||||
|
|
|
@ -847,15 +847,6 @@ impl<'a> CommentOrNewline<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_string_repr(&self) -> std::string::String {
|
|
||||||
use CommentOrNewline::*;
|
|
||||||
match self {
|
|
||||||
Newline => "\n".to_owned(),
|
|
||||||
LineComment(comment_str) => format!("#{comment_str}"),
|
|
||||||
DocComment(comment_str) => format!("##{comment_str}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn comment_str(&'a self) -> Option<&'a str> {
|
pub fn comment_str(&'a self) -> Option<&'a str> {
|
||||||
match self {
|
match self {
|
||||||
CommentOrNewline::LineComment(s) => Some(*s),
|
CommentOrNewline::LineComment(s) => Some(*s),
|
||||||
|
|
|
@ -437,11 +437,8 @@ where
|
||||||
Some(b'#') => {
|
Some(b'#') => {
|
||||||
state.advance_mut(1);
|
state.advance_mut(1);
|
||||||
|
|
||||||
let is_doc_comment = state.bytes().first() == Some(&b'#')
|
let is_doc_comment =
|
||||||
&& (state.bytes().get(1) == Some(&b' ')
|
state.bytes().first() == Some(&b'#') && state.bytes().get(1) != Some(&b'#');
|
||||||
|| state.bytes().get(1) == Some(&b'\n')
|
|
||||||
|| begins_with_crlf(&state.bytes()[1..])
|
|
||||||
|| Option::is_none(&state.bytes().get(1)));
|
|
||||||
|
|
||||||
if is_doc_comment {
|
if is_doc_comment {
|
||||||
state.advance_mut(1);
|
state.advance_mut(1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue