我想写一个pygrep
钩子pre-commit
来查找案例,例如
.. warning:
(什么时候应该.. warning::
)。
如果我写
- repo: local
- id: incorrect-sphinx-directives
name: Check for incorrect Sphinx directives
language: pygrep
entry: \.\. (autosummary|contents|currentmodule|deprecated|function|image|important|include|ipython|literalinclude|math|module|note|raw|seealso|toctree|versionadded|versionchanged|warning):[^:]
files: \.(py|pyx|rst)$
然后这行得通 - 但是,字符串太长了。有没有办法把它分成多行?
我试过了
entry: "\
.. (autosummary|contents|currentmodule|deprecated\
|function|image|important|include|ipython\
|literalinclude|math|module|note|raw|seealso\
|toctree|versionadded|versionchanged|warning\
):[^:]"
但这不起作用(生成的正则表达式不同)。
有什么建议么?