third_party.pylibs.pylint.src/doc/exts/pylint_features.py
Claudiu Popa 35019b87f2 Add a Sphinx hook for generating the features file of Pylint's documentation
Currently we can generate this locally using the makefiles, but, unfortunately,
on ReadThedocs we are running only sphinx-build, which means that we have no
pre-generated features.rst file before actually building the documentation.
This commit just adds one, which does the same thing as the makefiles.
2016-07-06 17:51:32 +01:00

30 lines
836 B
Python

# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
"""Script used to generate the features file before building the actual documentation."""
import os
import subprocess
import sys
import sphinx
def builder_inited(app):
popen = subprocess.Popen([sys.executable, "-m", "pylint", "--full-documentation"],
stdout=subprocess.PIPE)
output, _ = popen.communicate()
if not output:
print("Pylint might not be available.")
return
features = os.path.join(os.path.dirname('.'), 'features.rst')
with open(features, 'wb') as stream:
stream.write(output)
def setup(app):
app.connect('builder-inited', builder_inited)
return {'version': sphinx.__display_version__}