Skip to content

Commit 488fdbe

Browse files
committed
Add docformatter to format docstrings following a subset of PEP 257
1 parent 1bf0a30 commit 488fdbe

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

.github/workflows/ci_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
python-version: 3.7
2929

3030
- name: Install packages
31-
run: pip install black blackdoc flake8 pylint
31+
run: pip install black blackdoc docformatter flake8 pylint
3232

3333
- name: Formatting check (black and flake8)
3434
run: make check

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ directory).
245245

246246
### Code style
247247

248-
We use [Black](https://github.com/ambv/black) and [blackdoc](https://github.com/keewis/blackdoc)
248+
We use [Black](https://github.com/ambv/black), [blackdoc](https://github.com/keewis/blackdoc)
249+
and [docformatter](https://github.com/myint/docformatter)
249250
to format the code so we don't have to think about it.
250-
Black loosely follows the [PEP8](http://pep8.org) guide but with a few differences.
251+
Black and blackdoc loosely follows the [PEP8](http://pep8.org) guide but with a few differences.
251252
Regardless, you won't have to worry about formatting the code yourself.
252253
Before committing, run it to automatically format your code:
253254

@@ -265,7 +266,7 @@ common errors.
265266
The [`Makefile`](Makefile) contains rules for running both checks:
266267

267268
```bash
268-
make check # Runs flake8, black and blackdoc (in check mode)
269+
make check # Runs flake8, black, blackdoc and docformatter (in check mode)
269270
make lint # Runs pylint, which is a bit slower
270271
```
271272

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PYTEST_ARGS=--cov=$(PROJECT) --cov-config=../.coveragerc \
77
--pyargs ${PYTEST_EXTRA}
88
BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples
99
BLACKDOC_OPTIONS=--line-length 79
10+
DOCFORMATTER_FILES=$(PROJECT) setup.py doc/conf.py examples
11+
DOCFORMATTER_OPTIONS=--recursive --pre-summary-newline --wrap-summaries 79 --wrap-descriptions 79
1012
FLAKE8_FILES=$(PROJECT) setup.py doc/conf.py
1113
LINT_FILES=$(PROJECT) setup.py doc/conf.py
1214

@@ -15,8 +17,8 @@ help:
1517
@echo ""
1618
@echo " install install in editable mode"
1719
@echo " test run the test suite (including doctests) and report coverage"
18-
@echo " format run black and blackdoc to automatically format the code"
19-
@echo " check run code style and quality checks (black, blackdoc and flake8)"
20+
@echo " format run black, blackdoc and docformatter to automatically format the code"
21+
@echo " check run code style and quality checks (black, blackdoc, docformatter and flake8)"
2022
@echo " lint run pylint for a deeper (and slower) quality check"
2123
@echo " clean clean up build and generated files"
2224
@echo ""
@@ -38,10 +40,12 @@ test:
3840
format:
3941
black $(BLACK_FILES)
4042
blackdoc $(BLACKDOC_OPTIONS) $(BLACK_FILES)
43+
docformatter --in-place $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
4144

4245
check:
4346
black --check $(BLACK_FILES)
4447
blackdoc --check $(BLACKDOC_OPTIONS) $(BLACK_FILES)
48+
docformatter --check $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
4549
flake8 $(FLAKE8_FILES)
4650

4751
lint:

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies:
2020
- coverage
2121
- black
2222
- blackdoc
23+
- docformatter
2324
- pylint
2425
- flake8
2526
- sphinx=2.2.1

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pytest-mpl
88
coverage
99
black
1010
blackdoc
11+
docformatter
1112
pylint
1213
flake8
1314
sphinx=2.2.1

0 commit comments

Comments
 (0)