Hack for distutils check --restructuredtext #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A Python distutils bug (http://bugs.python.org/issue23063) causes
python setup.py check --restructuredtextto fail on documents withcode blocks.
Fixes: SF-270 (https://sourceforge.net/p/docutils/bugs/270/)
python setup.py check --restructuredtext --strict --metadatafails with:if the RST document uses
codeorcode-blockdirectives.This is annoying because the document is valid, but it appears to be invalid and confuses people. For an example, see ionelmc/pytest-benchmark#4 (comment).
How to reproduce this bug
Clone a repo that has a
README.rstwithcode-blockdirectives in it. E.g.:$ git clone git@github.com:ionelmc/pytest-benchmark.git $ cd pytest-benchmark $ git checkout ab0b08f6fccb06a7909905a8409f8faa8b01e0d8Observe that it has "code-blocks" in it:
Observe that RST document is valid, according to
rst2html.py:Observe that
python setup.py check --restructuredtext --strict --metadatafails:What was expected:
python setup.py check --restructuredtext --strict --metadatashould succeed with no warnings, just asrst2html.py did, becauseREADME.rstis a valid RST document.What actually happened:
python setup.py check --restructuredtext --strict --metadataprints a warning and an error and fails, unlikerst2html.pyThe error is coming from here:
https://github.com/python/cpython/blob/master/Lib/distutils/command/check.py#L142
It's happening because of this line:
https://github.com/python/cpython/blob/master/Lib/distutils/command/check.py#L125
If this is changed to:
then things work much better (this is how
tools/quicktest.pydoes it for example)so this might actually be a bug in distutils, but changing CPython (and maybe PyPy) is a more laborious and slow process, so I'm thinking it might be nice to work around this in docutils, if isn't too much of a burden. Docutils is on a much shorter release cycle than CPython, so changing docutils is a way to get this fix out to users much faster.