sphinx-lint icon indicating copy to clipboard operation
sphinx-lint copied to clipboard

Detecting missing newline before lists

Open oscargus opened this issue 3 years ago • 2 comments
trafficstars

This may be at risk of false positives, but it would be great if sphinx-lint could warn for missing newlines before lists. That is something that I personally tend to forget and have seen others miss as well.

The main problem, I guess, is to detect what a list is. A line starting with a list marker (*, -, +, 1., #., ...) may not be enough if one would like to fail it. At least two items will probably decrease the risk quite a bit.

oscargus avatar Apr 26 '22 10:04 oscargus

Bullet lists can be marked by a surprisingly large number of characters:

"*", "+", "-", "•", "‣", or "⁃"

Enumerated lists take arabic, alphabetic, or roman enumerators (https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#enumerated-lists).

For bulleted lists I'd say two or more identifiers at the same indent level, enumerated would be trickier I think, as you'd need to have a counter for the next expected character or similar.

A

AA-Turner avatar Apr 26 '22 22:04 AA-Turner

This is a very common error both because other languages like MarkDown don't need the empty line and because the requirement itself is not very intuitive.

Example
.. this looks ok but is invalid
* foo
  * bar
  * bar
* foo
* foo

.. this also looks ok but is invalid
* foo
  * bar
  * bar

* foo
* foo

.. this looks weird but is valid
* foo

  * bar
  * bar
* foo
* foo

.. this looks ok and is valid
* foo

  * bar
  * bar

* foo
* foo

Checking for at least two items sounds like a good compromise. I don't think I've ever seen and (or even +) used in the wild, but they are also uncommon in general, so including them in the check shouldn't increase the risk of false positives.

ezio-melotti avatar Sep 06 '22 16:09 ezio-melotti