Skip to content

Commit c749fc6

Browse files
authored
Fix adding whitespaces in numpydoc style to single line docstrings (#158)
1 parent 7a97321 commit c749fc6

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

docs/usage.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ Current usage of ``pydocstringformatter``:
1212
[--style {pep257,numpydoc} [{pep257,numpydoc} ...]]
1313
[--strip-whitespaces --no-strip-whitespaces]
1414
[--split-summary-body --no-split-summary-body]
15+
[--numpydoc-section-order --no-numpydoc-section-order]
16+
[--numpydoc-name-type-spacing --no-numpydoc-name-type-spacing]
17+
[--numpydoc-section-spacing --no-numpydoc-section-spacing]
18+
[--numpydoc-section-hyphen-length --no-numpydoc-section-hyphen-length]
1519
[--linewrap-full-docstring --no-linewrap-full-docstring]
1620
[--beginning-quotes --no-beginning-quotes]
1721
[--closing-quotes --no-closing-quotes]
1822
[--capitalize-first-letter --no-capitalize-first-letter]
1923
[--final-period --no-final-period]
2024
[--quotes-type --no-quotes-type]
21-
[--numpydoc-section-order --no-numpydoc-section-order]
22-
[--numpydoc-name-type-spacing --no-numpydoc-name-type-spacing]
23-
[--numpydoc-section-spacing --no-numpydoc-section-spacing]
24-
[--numpydoc-section-hyphen-length --no-numpydoc-section-hyphen-length]
2525
[files ...]
2626
2727
positional arguments:
@@ -66,6 +66,22 @@ Current usage of ``pydocstringformatter``:
6666
max length. The maximum length of a summary can be set
6767
with the --max-summary-lines option. Styles: pep257.
6868
(default: True)
69+
--numpydoc-section-order, --no-numpydoc-section-order
70+
Activate or deactivate numpydoc-section-order: Change
71+
section order to match numpydoc guidelines. Styles:
72+
numpydoc. (default: True)
73+
--numpydoc-name-type-spacing, --no-numpydoc-name-type-spacing
74+
Activate or deactivate numpydoc-name-type-spacing:
75+
Ensure proper spacing around the colon separating
76+
names from types. Styles: numpydoc. (default: True)
77+
--numpydoc-section-spacing, --no-numpydoc-section-spacing
78+
Activate or deactivate numpydoc-section-spacing:
79+
Ensure proper spacing between sections. Styles:
80+
numpydoc. (default: True)
81+
--numpydoc-section-hyphen-length, --no-numpydoc-section-hyphen-length
82+
Activate or deactivate numpydoc-section-hyphen-length:
83+
Ensure hyphens after section header lines are proper
84+
length. Styles: numpydoc. (default: True)
6985
--beginning-quotes, --no-beginning-quotes
7086
Activate or deactivate beginning-quotes: Fix the
7187
position of the opening quotes. Styles: default.
@@ -86,22 +102,6 @@ Current usage of ``pydocstringformatter``:
86102
Activate or deactivate quotes-type: Change all opening
87103
and closing quotes to be triple quotes. Styles:
88104
default. (default: True)
89-
--numpydoc-section-order, --no-numpydoc-section-order
90-
Activate or deactivate numpydoc-section-order: Change
91-
section order to match numpydoc guidelines. Styles:
92-
numpydoc. (default: True)
93-
--numpydoc-name-type-spacing, --no-numpydoc-name-type-spacing
94-
Activate or deactivate numpydoc-name-type-spacing:
95-
Ensure proper spacing around the colon separating
96-
names from types. Styles: numpydoc. (default: True)
97-
--numpydoc-section-spacing, --no-numpydoc-section-spacing
98-
Activate or deactivate numpydoc-section-spacing:
99-
Ensure proper spacing between sections. Styles:
100-
numpydoc. (default: True)
101-
--numpydoc-section-hyphen-length, --no-numpydoc-section-hyphen-length
102-
Activate or deactivate numpydoc-section-hyphen-length:
103-
Ensure hyphens after section header lines are proper
104-
length. Styles: numpydoc. (default: True)
105105
106106
optional formatters:
107107
these formatters are turned off by default

pydocstringformatter/_formatting/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
FORMATTERS: list[Formatter] = [
3232
StripWhitespacesFormatter(),
3333
SplitSummaryAndDocstringFormatter(),
34+
NumpydocSectionOrderingFormatter(),
35+
NumpydocNameColonTypeFormatter(),
36+
NumpydocSectionSpacingFormatter(),
37+
NumpydocSectionHyphenLengthFormatter(),
3438
LineWrapperFormatter(),
3539
BeginningQuotesFormatter(),
3640
ClosingQuotesFormatter(),
3741
CapitalizeFirstLetterFormatter(),
3842
FinalPeriodFormatter(),
3943
QuotesTypeFormatter(),
40-
NumpydocSectionOrderingFormatter(),
41-
NumpydocNameColonTypeFormatter(),
42-
NumpydocSectionSpacingFormatter(),
43-
NumpydocSectionHyphenLengthFormatter(),
4444
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--style=numpydoc
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def func():
2+
"""
3+
A docstring"""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def func():
2+
"""A docstring."""

0 commit comments

Comments
 (0)