Add new unescaped_pipe_in_table_cell rustdoc lint#159583
Add new unescaped_pipe_in_table_cell rustdoc lint#159583GuillaumeGomez wants to merge 3 commits into
unescaped_pipe_in_table_cell rustdoc lint#159583Conversation
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,16 @@ | |||
| #![deny(rustdoc::unescaped_pipe_in_table_cell)] | |||
|
|
|||
| //! | col1 | | |||
There was a problem hiding this comment.
Would be good to test edge-cases, what about adding another test case with two tables on the same doc comment.
Would also be interesting to have a test case with multiple wrong rows for the same table.
| if c == '\\' { | ||
| iter.next(); |
There was a problem hiding this comment.
Would be good to have a test case for this escaping as well.
| #[help("to escape `|` characters in tables, add a `\\` before them like `\\|`")] | ||
| struct UnescapedPipeInTableCell { | ||
| #[primary_span] | ||
| #[suggestion("any content after this column divider is discarded", code = "")] |
There was a problem hiding this comment.
Shouldn't this be a label instead of an empty suggestion?
| #[suggestion("any content after this column divider is discarded", code = "")] | |
| #[label("any content after this column divider is discarded")] |
There was a problem hiding this comment.
Yes it should. ^^'
| if let Event::Start(Tag::Table(_)) = event | ||
| && let Some((Event::Start(Tag::TableHead), _)) = p.next() | ||
| { | ||
| let mut expected_count = 0; |
There was a problem hiding this comment.
| let mut expected_count = 0; | |
| let mut expected_cells = 0; |
| // was left out. We now check the number of unescaped `|`. | ||
| let row = &dox[range.clone()]; | ||
| let mut iter = row.chars(); | ||
| let mut count = 0; |
There was a problem hiding this comment.
| let mut count = 0; | |
| let mut divider_count = 0; |
| if let Some(prev_range) = &prev_range | ||
| && prev_range.end + 1 != range.end |
There was a problem hiding this comment.
I'm not sure what this is checking. Is it checking the line width? or is it checking the position of the last TableCell with the last TableRow?
Either way, a comment would greatly help.
There was a problem hiding this comment.
Code comment it is!
| if let Event::Start(Tag::Table(_)) = event | ||
| && let Some((Event::Start(Tag::TableHead), _)) = p.next() |
There was a problem hiding this comment.
It's too bad that we have to do this checking manually, I don't suppose could pulldown_cmark to do this checking for us?
There was a problem hiding this comment.
I don't think so? How do you think pulldown-cmark would achieve that?
045f5a3 to
6fd9b1b
Compare
Fixes #159186.
r? @Urgau