Add new invalid_markdown_table rustdoc lint#159583
Conversation
This comment has been minimized.
This comment has been minimized.
045f5a3 to
6fd9b1b
Compare
|
Applied comments. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
|
2nd try. Let's do an FCP.
|
|
@Urgau has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
| ```rust | ||
| //! | col1 | | ||
| //! | ---- | | ||
| //! | `code_with(|arg| arg)` | |
There was a problem hiding this comment.
Wow TIL that this is how GFM works. Very strange design...
There was a problem hiding this comment.
Yeah I was super confused as well.
|
Minor nits about the implementation, but massive approval for the lint in concept! |
|
Definitely in favor of the lint itself, but I wonder if we should have a more generic lint name and then we group together this and any related (current or future) lints about Markdown gotchas? E.g. we have For example, it could be On a related note, my feeling with #158709 is that additions of new cases to an existing warn-by-default lint do not require FCP since they are not part of stability guarantees, but please let me know if you disagree. |
|
@camelid: Very fair point. I think having a lint group for all such lints is a good idea. As for the current lint name, I'll rename it as |
6fd9b1b to
52c8615
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
52c8615 to
a88e74a
Compare
unescaped_pipe_in_table_cell rustdoc lintinvalid_markdown_table rustdoc lint
|
Ok all done. |
|
I noticed that this lint scans the entire row to count pipes, but it only actually needs to scan the part between the end of the last cell and the end of the row. Worse, this scanning has a corner case where it gives less-than-perfect results. Here's a commit that implements the fixes. notriddle@3c70378ff60 The essential problem is that, with this table: And this logic: let too_many_pipes = divider_count > expected_cells + 1;
We really want our warning to give the suggest-escaping flow, like this: |
The essential problem is that, with this table: ```text one | ----| a | b | c a | b | a | b a | ``` And this logic: ```rust let too_many_pipes = divider_count > expected_cells + 1; ``` `expected_cells + 1` winds up as 2, so you get this warning: ```text error: unused content after last table cell --> $DIR/invalid_markdown_table.rs:81:14 | LL | //! a | b | c | ^^^^^^ this content is discarded error: unused content after last table cell --> $DIR/invalid_markdown_table.rs:83:14 | LL | //! a | b | | ^^^^ this content is discarded error: unused content after last table cell --> $DIR/invalid_markdown_table.rs:85:14 | LL | //! a | b | ^^ this content is discarded ``` We really want our warning to give the suggest-escaping flow, like this: ```text error: table row has too many columns --> $DIR/invalid_markdown_table.rs:81:13 | LL | //! a | b | c | ^ any content after this column divider is discarded | = help: to escape `|` characters in tables, add a `\` before them like `\|` error: table row has too many columns --> $DIR/invalid_markdown_table.rs:83:13 | LL | //! a | b | | ^ any content after this column divider is discarded | = help: to escape `|` characters in tables, add a `\` before them like `\|` error: unused content after last table cell --> $DIR/invalid_markdown_table.rs:85:14 | LL | //! a | b | ^^ this content is discarded ``` By only scanning the text between the end of the last cell and the row, instead of doing the entire row, we don't have to re-implement as much of pulldown-cmark's logic.
|
@notriddle Please push it to my branch, don't want to steal ownership for your work. :) |
|
Sure. |
|
Nice, thanks! @camelid: Is your concern resolved? |
|
Well, I would prefer the lint name to be even more general like I can't think of a case where people would want to control them separately. It seems more likely they'd want all these lints to be either enabled or disabled rather than one-by-one controlling them. |
|
I can’t think of a case where anyone would want to disable this table lint at all. The HTML lint, however, you might disable it if you intentionally rely on HTML tag correction. The rules are spelled out in the spec, after all, and they allow you to write more terse markup. |
|
|
|
Based on @notriddle's comment, I propose we rename this lint to just |
|
It's too general: we already have other "invalid markdown" specialized lints. If we want to make a group out of them, that's a good name for the group. But otherwise I think it's too general. |
|
What other invalid markdown lints do we have? All of the lints I see are either specific to rustdoc features (like invalid Rust code blocks) or stylistic issues (redundant explicit links). https://doc.rust-lang.org/rustdoc/lints.html That said, I'm not going to block on this since ultimately it's a matter of taste. I would just prefer not creating too many overly specific lints -- like I can't imagine why someone would want to control linting of tables separately from other markdown features, unless they were doing something really unusual. |
|
I see at least EDIT: copied the wrong lint name, replaced it. |
|
Right, but @rfcbot resolve overly specific lint name |
View all comments
Fixes #159186.
r? @Urgau