summaryrefslogtreecommitdiff
path: root/doc/exts
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-07-06 17:51:32 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2016-07-06 17:51:32 +0100
commit35019b87f2f12e3684870040810fa87bc2991a10 (patch)
tree142dcd6b825627495f4fc9734cac1044d2ee5b47 /doc/exts
parent81a0c24f4e6cc3ec0c6ecfd72d0fe3f7e709194d (diff)
downloadpylint-git-35019b87f2f12e3684870040810fa87bc2991a10.tar.gz
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.
Diffstat (limited to 'doc/exts')
-rw-r--r--doc/exts/pylint_features.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/exts/pylint_features.py b/doc/exts/pylint_features.py
new file mode 100644
index 000000000..552d68468
--- /dev/null
+++ b/doc/exts/pylint_features.py
@@ -0,0 +1,29 @@
+# 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__}