feat: check indentation of doc-strings#27897
Conversation
PR summary 424dce2f30Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
This pull request has conflicts, please merge |
…community#27899) Continuation of leanprover-community#24166. Works towards the linter in leanprover-community#27897.
|
This pull request has conflicts, please merge |
|
This pull request has conflicts, please merge |
…community#27899) Continuation of leanprover-community#24166. Works towards the linter in leanprover-community#27897.
…community#27899) Continuation of leanprover-community#24166. Works towards the linter in leanprover-community#27897.
| namespace Style | ||
|
|
||
| /-- Check if a doc-string conforms to some basic style guidelines. | ||
| TODO: flesh out which ones and why! -/ |
There was a problem hiding this comment.
is this still a draft-PR?
| if indent.contains '\t' then | ||
| msgs := msgs.push m!"error: line '{line}' starts with a tab; use spaces instead" |
There was a problem hiding this comment.
Out of curiosity, isn't this already covered by another linter?
| let indent := line.takeWhile Char.isWhitespace | ||
| if let some n := prev_ident then | ||
| if line.trimLeft.startsWith "- " || line.startsWith "* " then | ||
| -- De-denting is possibly by any number of levels. |
|
Thanks for your review! I added a lot of tests, fixed all errors in mathlib --- and just completely rewrote the algorithm (which might find further locations to fix). To keep history sane, I just force-pushed (sorry for that!). Before progressing further, probably most mathlib fixes should be merged first. |
There is no reason for this, and this makes it easier to lint them. Found by the linter in #27897.
Found by the linter in #27897, but I expect the move to Verso would also have discovered this.
There is no reason for this, and this makes it easier to lint them. Found by the linter in #27897.
Found by the linter in #27897, but I expect the move to Verso would also have discovered this.
There is no reason for this, and this makes it easier to lint them. Found by the linter in #27897.
There is no reason for this, and this makes it easier to lint them. Found by the linter in #27897.
These are strictly speaking, required by markdown, and make it more clear to the reader that a new paragraph begins. This corrects some generated documentation entries to have proper paragraph breaks. Found by the linter in #27897.
|
For the record, the new algorithm has a new class of false positives: for doc-strings which are indented, it warns too much. |
Likely will require further adaptations to mathlib. May land piece-wise. But at first, let's see how big the overall fallout actually is.
(So far: 100 lines of implementation and tests, and 170 lines of fix-ups; which are probably mostly complete, but not entirely.)