Treat two hash marks followed by text as a doc comment

This commit is contained in:
Jonathan Schear 2024-03-16 14:26:50 -04:00
parent 4dca0546f4
commit 723c390f52
No known key found for this signature in database
GPG key ID: 0F4D841667534076
3 changed files with 3 additions and 15 deletions

View file

@ -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> {
match self {
CommentOrNewline::LineComment(s) => Some(*s),

View file

@ -437,11 +437,8 @@ where
Some(b'#') => {
state.advance_mut(1);
let is_doc_comment = 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)));
let is_doc_comment =
state.bytes().first() == Some(&b'#') && state.bytes().get(1) != Some(&b'#');
if is_doc_comment {
state.advance_mut(1);