Skip to content

Commit 545bc62

Browse files
authored
Update README.md
1 parent 493e474 commit 545bc62

File tree

1 file changed

+28
-166
lines changed

1 file changed

+28
-166
lines changed

README.md

+28-166
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
A tool to automatically format Python docstrings to follow recommendations from
1010
[`PEP 8`](https://www.python.org/dev/peps/pep-0008/) and
11-
[`PEP 257`](https://www.python.org/dev/peps/pep-0257/).
11+
[`PEP 257`](https://www.python.org/dev/peps/pep-0257/) (or other supported style guides.)
1212

1313
See [What it does](#what-it-does) for currently supported auto-formatting.
1414

@@ -19,7 +19,7 @@ This project is heavily inspired by
1919

2020
When this project was started `docformatter` did not meet all of the requirements the
2121
[`pylint`](https://github.com/PyCQA/pylint) project had for its docstring formatter and
22-
sadly `docformatter` is now also no longer fully supported. Therefore, some contributors
22+
was no longer actively maintained (this has changed since then). Therefore, some contributors
2323
of `pylint` got together and started working on our own formatter to fulfill our needs.
2424

2525
When asked we defined the objective of the tool as:
@@ -45,23 +45,6 @@ pip install pydocstringformatter
4545
[`Click here`](https://pydocstringformatter.readthedocs.io/en/latest/usage.html) for a
4646
full Usage overview.
4747

48-
```shell
49-
usage: pydocstringformatter [-h] [-w] [--exclude EXCLUDE] [-v] [files ...]
50-
51-
positional arguments:
52-
files The directory or files to format.
53-
54-
options:
55-
-h, --help show this help message and exit
56-
-w, --write Write the changes to file instead of printing the diffs to stdout.
57-
--quiet Do not print any logging or status messages to stdout.
58-
-v, --version Show version number and exit.
59-
--max-line-length The maximum docstring line length. Default set to 88.
60-
61-
configuration:
62-
--exclude EXCLUDE A comma separated list of glob patterns of file path names not to be formatted.
63-
```
64-
6548
### Configuration
6649

6750
Pydocstringformatter will also read any configuration added to the
@@ -77,6 +60,16 @@ exclude = "**/my_dir/**,**/my_other_dir/**"
7760
exclude = ["**/my_dir/**", "**/my_other_dir/**"]
7861
```
7962

63+
#### Style
64+
65+
Pydocstringformatter can be configured to use a specific style. The default is ``pep257`` but
66+
we support other styles as well.
67+
These can also be used at the same time. For example with:
68+
69+
```console
70+
pydocstringformatter --style=pep257 --style=numpydoc myfile.py
71+
```
72+
8073
## Pre-commit
8174

8275
Pydocstringformatter can also be used as a [pre-commit hook](https://pre-commit.com).
@@ -91,77 +84,20 @@ Add the following to your `.pre-commit-config.yaml` file:
9184
9285
## What it does
9386
94-
The following examples show what pydocstringformatter will pick up on. All _bad_
95-
examples will be rewritten to follow the _good_ patterns.
96-
97-
**PEP 8: _Note that most importantly, the """ that ends a multiline docstring should be
98-
on a line by itself:_**
87+
The following examples show some of the changes pydocstringformatter will apply. For a full
88+
overview of all potential changes you can check out the [`Usage`](https://pydocstringformatter.readthedocs.io/en/latest/usage.html) page which
89+
shows an up to date list of all formatters and their description.
9990

10091
```python
10192
# Bad
102-
"""My
103-
multi-line docstring"""
104-
105-
# Good
106-
"""My
107-
multi-line docstring
108-
"""
109-
```
110-
111-
**PEP 257: _The closing quotes are on the same line as the opening quotes_**
112-
113-
This can be enforced on multi-line docstrings with the `--summary-quotes-same-line`
114-
option. This behaviour is turned off by default.
115-
116-
```python
117-
# Bad
118-
"""
119-
My docstring"""
120-
121-
"""My docstring
122-
"""
123-
124-
"""
125-
My
126-
multi-line docstring
127-
"""
128-
129-
# With --summary-quotes-same-line
130-
"""
131-
My
132-
multi-line docstring
133-
"""
134-
135-
# Good
136-
"""My docstring"""
137-
138-
"""My docstring"""
139-
140-
"""
141-
My
142-
multi-line docstring
143-
"""
144-
145-
# With --summary-quotes-same-line
146-
"""My
147-
multi-line docstring
148-
"""
149-
```
150-
151-
**PEP 257: _The docstring is a phrase ending in a period & Multi-line docstrings consist
152-
of a summary line just like a one-line docstring_**
153-
154-
Since the first line should be a phrase or summary the first character gets capitalized.
155-
156-
When the second line is one recurring character we consider the summary line to be a
157-
title as used in many Sphinx documentation schemes and do not add a period.
93+
'''
94+
my docstring'''
15895
159-
```python
160-
# Bad
161-
"""my docstring"""
96+
""" my
97+
multi-line docstring """
16298
163-
"""
164-
summary
99+
"""my title
100+
===========
165101
166102
my docstring
167103
"""
@@ -170,103 +106,29 @@ my docstring
170106
# Good
171107
"""My docstring."""
172108
173-
"""
174-
Summary.
175-
176-
my docstring
109+
"""My
110+
multi-line docstring.
177111
"""
178112
179113
"""My title
180114
===========
181115
182116
My docstring
183117
"""
184-
```
185-
186-
**PEP 257: _Multi-line docstrings consist of a summary line just like a one-line
187-
docstring, followed by a blank line, followed by a more elaborate description._**
188118
189-
When the second line is one recurring character we consider the summary line to be a
190-
title as used in many Sphinx documentation schemes and do not add a white line.
191-
192-
```python
119+
# With --summary-quotes-same-line
193120
# Bad
194-
"""Summary. Body."""
195-
196-
"""Summary.
197-
Body.
198121
"""
199-
200-
# Good
201-
"""Summary.
202-
203-
Body.
204-
"""
205-
206-
"""My title
207-
===========
208-
209-
My docstring
122+
My
123+
multi-line docstring
210124
"""
211-
```
212-
213-
**PEP 257: _For consistency, always use """triple double quotes""" around docstrings._**
214-
215-
```python
216-
# Bad
217-
"My docstring"
218-
219-
'My docstring'
220-
221-
'''My docstring'''
222-
223-
'''Summary.
224-
225-
Body.
226-
'''
227125
228126
# Good
229-
"""My docstring"""
230-
231-
"""My docstring"""
232-
233-
"""My docstring"""
234-
235-
"""Summary.
236-
237-
Body.
127+
"""My
128+
multi-line docstring
238129
"""
239130
```
240131

241-
**_Trailing or leading whitespaces get removed as well._**
242-
243-
```python
244-
# Bad
245-
""" My docstring. """
246-
247-
""" Summary.
248-
249-
Body
250-
"""
251-
252-
""" My docstring.
253-
254-
My indented section
255-
"""
256-
257-
# Good
258-
"""My docstring."""
259-
260-
""" Summary.
261-
262-
Body
263-
"""
264-
265-
"""My docstring.
266-
267-
My indented section
268-
"""
269-
```
270132

271133
## Development
272134

0 commit comments

Comments
 (0)