Skip to content

Add docformatter to format plain text in docstrings #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- name: Install packages
run: |
pip install black blackdoc flake8 pylint isort
pip install black blackdoc docformatter flake8 pylint isort
sudo apt-get install dos2unix

- name: Formatting check (black and flake8)
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ We use some tools:

- [Black](https://github.com/ambv/black)
- [blackdoc](https://github.com/keewis/blackdoc)
- [docformatter](https://github.com/myint/docformatter)
- [isort](https://pycqa.github.io/isort/)

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

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

```bash
make check # Runs flake8, black, blackdoc and isort (in check mode)
make check # Runs flake8, black, blackdoc, docformatter and isort (in check mode)
make lint # Runs pylint, which is a bit slower
```

Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PYTEST_COV_ARGS=--cov=$(PROJECT) --cov-config=../pyproject.toml \
--pyargs ${PYTEST_EXTRA}
BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples
BLACKDOC_OPTIONS=--line-length 79
DOCFORMATTER_FILES=$(PROJECT) setup.py doc/conf.py examples
DOCFORMATTER_OPTIONS=--recursive --pre-summary-newline --make-summary-multi-line --wrap-summaries 79 --wrap-descriptions 79
FLAKE8_FILES=$(PROJECT) setup.py doc/conf.py
LINT_FILES=$(PROJECT) setup.py doc/conf.py

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

format:
isort .
docformatter --in-place $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
black $(BLACK_FILES)
blackdoc $(BLACKDOC_OPTIONS) $(BLACK_FILES)

check:
isort . --check
docformatter --check $(DOCFORMATTER_OPTIONS) $(DOCFORMATTER_FILES)
black --check $(BLACK_FILES)
blackdoc --check $(BLACKDOC_OPTIONS) $(BLACK_FILES)
flake8 $(FLAKE8_FILES)
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- black
- blackdoc
- isort>=5
- docformatter
- pylint
- flake8
- sphinx
Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_grdcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def fixture_grid():


def test_grdcut_file_in_file_out():
"grduct an input grid file, and output to a grid file"
"grdcut an input grid file, and output to a grid file"
with GMTTempFile(suffix=".nc") as tmpfile:
result = grdcut("@earth_relief_01d", outgrid=tmpfile.name, region="0/180/0/90")
assert result is None # return value is None
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ coverage[toml]
black
blackdoc
isort>=5
docformatter
pylint
flake8
sphinx
Expand Down