Skip to content

Commit 17fe7a9

Browse files
committed
Add docformatter to format docstrings following a subset of PEP 257
1 parent 4b630b3 commit 17fe7a9

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

.github/workflows/ci_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Install packages
3434
run: |
35-
pip install black blackdoc flake8 pylint isort
35+
pip install black blackdoc docformatter flake8 pylint isort
3636
sudo apt-get install dos2unix
3737
3838
- name: Formatting check (black and flake8)

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ We use some tools:
249249

250250
- [Black](https://github.com/ambv/black)
251251
- [blackdoc](https://github.com/keewis/blackdoc)
252+
- [docformatter](https://github.com/myint/docformatter)
252253
- [isort](https://pycqa.github.io/isort/)
253254

254255
to format the code so we don't have to think about it.
255-
Black loosely follows the [PEP8](http://pep8.org) guide but with a few differences.
256+
Black and blackdoc loosely follows the [PEP8](http://pep8.org) guide but with a few differences.
256257
Regardless, you won't have to worry about formatting the code yourself.
257258
Before committing, run it to automatically format your code:
258259

@@ -273,7 +274,7 @@ common errors.
273274
The [`Makefile`](Makefile) contains rules for running both checks:
274275

275276
```bash
276-
make check # Runs flake8, black, blackdoc and isort (in check mode)
277+
make check # Runs flake8, black, blackdoc, docformatter and isort (in check mode)
277278
make lint # Runs pylint, which is a bit slower
278279
```
279280

Makefile

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

@@ -14,8 +16,8 @@ help:
1416
@echo ""
1517
@echo " install install in editable mode"
1618
@echo " test run the test suite (including doctests) and report coverage"
17-
@echo " format run black and blackdoc to automatically format the code"
18-
@echo " check run code style and quality checks (black, blackdoc, isort and flake8)"
19+
@echo " format run black, blackdoc, docformatter and isort to automatically format the code"
20+
@echo " check run code style and quality checks (black, blackdoc, docformatter, isort and flake8)"
1921
@echo " lint run pylint for a deeper (and slower) quality check"
2022
@echo " clean clean up build and generated files"
2123
@echo " distclean clean up build and generated files, including project metadata files"
@@ -37,11 +39,13 @@ test:
3739

3840
format:
3941
isort .
42+
docformatter --in-place $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
4043
black $(BLACK_FILES)
4144
blackdoc $(BLACKDOC_OPTIONS) $(BLACK_FILES)
4245

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

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies:
2121
- black
2222
- blackdoc
2323
- isort>=5
24+
- docformatter
2425
- pylint
2526
- flake8
2627
- sphinx

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ coverage[toml]
99
black
1010
blackdoc
1111
isort>=5
12+
docformatter
1213
pylint
1314
flake8
1415
sphinx

0 commit comments

Comments
 (0)