Skip to content

Commit 06a54f5

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

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,16 @@ directory).
245245

246246
### Code style
247247

248+
<<<<<<< HEAD
248249
We use some tools:
249250

250251
- [Black](https://github.com/ambv/black)
251252
- [blackdoc](https://github.com/keewis/blackdoc)
253+
- [docformatter](https://github.com/myint/docformatter)
252254
- [isort](https://pycqa.github.io/isort/)
253255

254256
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.
257+
Black and blackdoc loosely follows the [PEP8](http://pep8.org) guide but with a few differences.
256258
Regardless, you won't have to worry about formatting the code yourself.
257259
Before committing, run it to automatically format your code:
258260

@@ -273,7 +275,11 @@ common errors.
273275
The [`Makefile`](Makefile) contains rules for running both checks:
274276

275277
```bash
278+
<<<<<<< HEAD
276279
make check # Runs flake8, black, blackdoc and isort (in check mode)
280+
=======
281+
make check # Runs flake8, black, blackdoc and docformatter (in check mode)
282+
>>>>>>> f347f709 (Add docformatter to format docstrings following a subset of PEP 257)
277283
make lint # Runs pylint, which is a bit slower
278284
```
279285

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"
@@ -39,11 +41,13 @@ format:
3941
isort .
4042
black $(BLACK_FILES)
4143
blackdoc $(BLACKDOC_OPTIONS) $(BLACK_FILES)
44+
docformatter --in-place $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
4245

4346
check:
4447
isort . --check
4548
black --check $(BLACK_FILES)
4649
blackdoc --check $(BLACKDOC_OPTIONS) $(BLACK_FILES)
50+
docformatter --check $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
4751
flake8 $(FLAKE8_FILES)
4852

4953
lint:

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)