Skip to content

Commit f63b354

Browse files
asottilegaborbernat
authored andcommitted
blacken-docs (#835)
Hi friends, I made a terrific (terrible? terrifying?) thing. I needed one manual `,` addition to the `setup.py` example so it could be parsed -- otherwise this is fully automated! Using the new thing I made today: https://github.com/asottile/blacken-docs Heavily inspired by pytest-dev/pytest#3525. See also psf/black#292, psf/black#294.
1 parent 607ec95 commit f63b354

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

.pre-commit-config.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ repos:
22
- repo: https://github.com/ambv/black
33
rev: 18.5b1
44
hooks:
5-
- id: black
6-
args: [--line-length=99, --safe]
7-
python_version: python3.6
5+
- id: black
6+
args: [--line-length=99, --safe]
7+
language_version: python3.6
8+
- repo: https://github.com/asottile/blacken-docs
9+
rev: v0.1.0
10+
hooks:
11+
- id: blacken-docs
12+
additional_dependencies: [black==18.5b1]
13+
language_version: python3.6
814
- repo: https://github.com/asottile/seed-isort-config
915
rev: v0.1.0
1016
hooks:

doc/example/jenkins.rst

+13-10
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ using these steps:
2525
2626
import tox
2727
28-
os.chdir(os.getenv('WORKSPACE'))
29-
tox.cmdline() # environment is selected by ``TOXENV`` env variable
28+
os.chdir(os.getenv("WORKSPACE"))
29+
tox.cmdline() # environment is selected by ``TOXENV`` env variable
3030
3131
* check ``Publish JUnit test result report`` and enter
3232
``**/junit-*.xml`` as the pattern so that Jenkins collects
@@ -58,11 +58,12 @@ with this:
5858
.. code-block:: python
5959
6060
import urllib, os
61+
6162
url = "https://bitbucket.org/hpk42/tox/raw/default/toxbootstrap.py"
62-
#os.environ['USETOXDEV']="1" # use tox dev version
63-
d = dict(__file__='toxbootstrap.py')
63+
# os.environ['USETOXDEV']="1" # use tox dev version
64+
d = dict(__file__="toxbootstrap.py")
6465
exec urllib.urlopen(url).read() in d
65-
d['cmdline'](['--recreate'])
66+
d["cmdline"](["--recreate"])
6667
6768
The downloaded `toxbootstrap.py` file downloads all necessary files to
6869
install ``tox`` in a virtual sub environment. Notes:
@@ -105,19 +106,21 @@ Here is an example:
105106
import py
106107
import subprocess
107108
109+
108110
def test_linkcheck(tmpdir):
109111
doctrees = tmpdir.join("doctrees")
110112
htmldir = tmpdir.join("html")
111113
subprocess.check_call(
112-
["sphinx-build", "-W", "-blinkcheck",
113-
"-d", str(doctrees), ".", str(htmldir)])
114+
["sphinx-build", "-W", "-blinkcheck", "-d", str(doctrees), ".", str(htmldir)]
115+
)
116+
114117
115118
def test_build_docs(tmpdir):
116119
doctrees = tmpdir.join("doctrees")
117120
htmldir = tmpdir.join("html")
118-
subprocess.check_call([
119-
"sphinx-build", "-W", "-bhtml",
120-
"-d", str(doctrees), ".", str(htmldir)])
121+
subprocess.check_call(
122+
["sphinx-build", "-W", "-bhtml", "-d", str(doctrees), ".", str(htmldir)]
123+
)
121124
122125
3. run ``tox -e docs`` and then you may integrate this environment
123126
along with your other environments into Jenkins.

doc/plugins.rst

+9-3
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,17 @@ contents of ``tox_fireworks.py``:
110110
111111
hookimpl = pluggy.HookimplMarker("tox")
112112
113+
113114
@hookimpl
114115
def tox_addoption(parser):
115116
"""Add command line option to display fireworks on request."""
116117
118+
117119
@hookimpl
118120
def tox_configure(config):
119121
"""Post process config after parsing."""
120122
123+
121124
@hookimpl
122125
def tox_runenvreport(config):
123126
"""Display fireworks if all was fine and requested."""
@@ -132,9 +135,12 @@ contents of ``setup.py``:
132135
133136
from setuptools import setup
134137
135-
setup(name='tox-fireworks', py_modules=['tox_fireworks'],
136-
entry_points={'tox': ['fireworks = tox_fireworks']}
137-
classifiers=['Framework:: tox'])
138+
setup(
139+
name="tox-fireworks",
140+
py_modules=["tox_fireworks"],
141+
entry_points={"tox": ["fireworks = tox_fireworks"]},
142+
classifiers=["Framework:: tox"],
143+
)
138144
139145
Using the **tox-** prefix in ``tox-fireworks`` is an established convention to be able to
140146
see from the project name that this is a plugin for tox. It also makes it easier to find with

0 commit comments

Comments
 (0)