twolfson / restructuredtext-lint

reStructuredText linter
The Unlicense
170 stars 20 forks source link

Is pygments a requirement? #41

Closed cthoyt closed 7 years ago

cthoyt commented 7 years ago

I tried adding a very simple step in my tox build to check that my readme is correct:

[testenv:readme]
deps =
    restructuredtext-lint
skip_install = true
commands = rst-lint README.rst

But, it errors out.

$ tox -e readme
GLOB sdist-make: /Users/cthoyt/dev/OCSPdash/setup.py
readme installed: asn1crypto==0.22.0,censys==0.0.7,certifi==2017.7.27.1,cffi==1.10.0,chardet==3.0.4,click==6.7,docutils==0.14,dominate==2.3.1,flasgger==0.6.6,Flask==0.12.2,Flask-Admin==1.5.0,Flask-Bootstrap==3.3.7.1,idna==2.6,itsdangerous==0.24,Jinja2==2.9.6,jsonschema==2.6.0,MarkupSafe==1.0,mistune==0.7.4,netaddr==0.7.19,ocspbuilder==0.10.2,OCSPdash==0.1.0.dev0,oscrypto==0.18.0,pycparser==2.18,PyNaCl==1.1.2,PyYAML==3.12,requests==2.18.4,restructuredtext-lint==1.1.1,six==1.10.0,SQLAlchemy==1.1.13,urllib3==1.22,visitor==0.1.3,Werkzeug==0.12.2,WTForms==2.1
readme runtests: PYTHONHASHSEED='4184528113'
readme runtests: commands[0] | rst-lint README.rst
WARNING README.rst:14 Cannot analyze code. Pygments package not found.
ERROR: InvocationError: '/Users/cthoyt/dev/OCSPdash/.tox/readme/bin/rst-lint README.rst'

After adding pygments as a dependency (below), it works.

[testenv:readme]
deps =
    restructuredtext-lint
    pygments
skip_install = true
commands = rst-lint README.rst

I'd be happy to submit a PR to add this as a dependency, but I'd also be interested if you have more insight.

twolfson commented 7 years ago

We rely on docutils for our RST parsing/error generation and docutils relies on pygments for parsing code blocks:

https://sourceforge.net/p/docutils/code/HEAD/tree/tags/docutils-0.14/docutils/utils/code_analyzer.py#l59

This functionality isn't anything that's required but due to the import logic and a code block, rst-lint will complain about missing pygments as a result