Check for incorrect sphinx directives
MarcoGorelli opened this issue · 3 comments
MarcoGorelli commented
Hi,
In pandas, there's a local hook which checks for instances of, e.g.
.. warning:
instead of
.. warning::
:
- id: incorrect-sphinx-directives
name: Check for incorrect Sphinx directives
language: pygrep
entry: |
(?x)
# Check for cases of e.g. .. warning: instead of .. warning::
\.\.\ (
autosummary|contents|currentmodule|deprecated|
function|image|important|include|ipython|literalinclude|
math|module|note|raw|seealso|toctree|versionadded|
versionchanged|warning
):[^:]
files: \.(py|pyx|rst)$
It's not specific to pandas, and others might find it useful - would a PR to include it in pygrep hooks be welcome?
asottile commented
does it make sense to have a list of things instead of:
^\s*\.\. [a-z]+:$
basically, is there ever a case where .. foo:
is expected / wanted?
MarcoGorelli commented
basically, is there ever a case where .. foo: is expected / wanted?
😂 not that I can think of
asottile commented
I checked a few repos: pytest-dev/pytest, pandas-dev/pandas, python/cpython and got zero hits, let's go with the simpler regex
as for naming maybe rst-directives
? rst-directive-colons
?