You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Recommend sphinx as the docstring format
* Update docs/Coding-Conventions.md
Co-authored-by: mshafer-NI <[email protected]>
* Change the convention to be Google style
* Update docs/Coding-Conventions.md
Co-authored-by: Ryan Zoeller <[email protected]>
* Allow any convention style
* add org-check to PR notify
* touch conventions file to prompt PR checks
* touch again
* set docstring convention to Google
* add some debug output
* document D412
* rname vars and re-work to bettter show what the error is
* switch to "all" and suprress the codes that we see that don't fit the "suggest Google"
* format
* revert most of the docstring changes
* remove blank lines before closing quotes
* fix branch name in notify action
* add note about using sphinx.ext.napolean to handle docs
* Revert "revert most of the docstring changes"
This reverts commit c09c931.
* more docstrings to active form
* add D406 to excluded rules
* s/sell/sells/g
* add all the codes pydocstyle would ignore if we were explicitly stating Google style
* don't need that twice
Co-authored-by: Joshua Cannon <[email protected]>
Co-authored-by: Joshua Cannon <[email protected]>
Co-authored-by: Ryan Zoeller <[email protected]>
Copy file name to clipboardExpand all lines: docs/Coding-Conventions.md
+53-10Lines changed: 53 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -982,6 +982,12 @@ def go_shopping():
982
982
983
983
ℹ️ You can document a package by documenting the module docstring of the package directory's `__init__.py`
984
984
985
+
### Which docstring format should I follow?
986
+
987
+
We recommend (and internally use) the [Google docstring format](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods) but you can choose any format so long as you are consistent.
988
+
989
+
**Note**: Through the use of the [Sphinx napoleon](https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#getting-started) extension, Sphinx docs generation can interpret [Google style docstrings](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods).
990
+
985
991
### [D.1.2] ✔️ **DO** List exported modules and subpackages in a package's docstring
986
992
987
993
> 🐍 This rule stems from [PEP 257](https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings)
@@ -1070,7 +1076,7 @@ The summary line should be on the same line as the opening quotes.
1070
1076
```python
1071
1077
# Bad - will produce D205
1072
1078
defsell(type_):
1073
-
"""Sell the specified type of cheese.
1079
+
"""Sells the specified type of cheese.
1074
1080
Will throw an OutOfStockException if the specified type of cheese is out of stock.
1075
1081
"""
1076
1082
```
@@ -1079,7 +1085,7 @@ def sell(type_):
1079
1085
# Bad - will produce D212
1080
1086
defsell(type_):
1081
1087
"""
1082
-
Sell the specified type of cheese.
1088
+
Sells the specified type of cheese.
1083
1089
1084
1090
Will throw an OutOfStockException if the specified type of cheese is out of stock.
1085
1091
"""
@@ -1088,7 +1094,7 @@ def sell(type_):
1088
1094
```python
1089
1095
# Good
1090
1096
defsell(type_):
1091
-
"""Sell the specified type of cheese.
1097
+
"""Sells the specified type of cheese.
1092
1098
1093
1099
Will throw an OutOfStockException if the specified type of cheese is out of stock.
1094
1100
"""
@@ -1100,7 +1106,7 @@ class CheeseShop(object):
1100
1106
"""Finest cheese shop in the district, offering a wide variety of cheeses."""
1101
1107
1102
1108
defsell(self, type_):
1103
-
"""Sell the specified type of cheese."""
1109
+
"""Sells the specified type of cheese."""
1104
1110
```
1105
1111
1106
1112
### [D.1.11] ✔️ **DO** Put closing `"""` on its own line for multiline docstrings 💻
@@ -1117,7 +1123,7 @@ class CheeseShop(object):
1117
1123
Cheeses are sold first-come-first-served, and can run out of stock rather quickly."""
1118
1124
1119
1125
defsell(self, type_):
1120
-
"""Sell the specified type of cheese.
1126
+
"""Sells the specified type of cheese.
1121
1127
1122
1128
Will throw an OutOfStockException if the specified type of cheese is out of stock."""
1123
1129
```
@@ -1131,7 +1137,7 @@ class CheeseShop(object):
1131
1137
"""
1132
1138
1133
1139
defsell(self, type_):
1134
-
"""Sell the specified type of cheese.
1140
+
"""Sells the specified type of cheese.
1135
1141
1136
1142
Will throw an OutOfStockException if the specified type of cheese is out of stock.
1137
1143
"""
@@ -1157,7 +1163,7 @@ class CheeseShop(object):
1157
1163
classCheeseShop(object):
1158
1164
defsell(self, type_):
1159
1165
1160
-
"""Sell the specified type of cheese."""
1166
+
"""Sells the specified type of cheese."""
1161
1167
```
1162
1168
1163
1169
```python
@@ -1166,7 +1172,7 @@ class CheeseShop(object):
1166
1172
"""Finest cheese shop in the district, offering a wide variety of cheeses."""
1167
1173
1168
1174
defsell(self, type_):
1169
-
"""Sell the specified type of cheese."""
1175
+
"""Sells the specified type of cheese."""
1170
1176
```
1171
1177
1172
1178
### [D.1.13] ❌ **DO NOT** Put a blank line after a one line function docstring 💻
@@ -1178,18 +1184,55 @@ class CheeseShop(object):
1178
1184
```python
1179
1185
# Bad
1180
1186
defsell(self, type_):
1181
-
"""Sell the specified type of cheese."""
1187
+
"""Sells the specified type of cheese."""
1182
1188
1183
1189
self._do_transaction(type_)
1184
1190
```
1185
1191
1186
1192
```python
1187
1193
# Good
1188
1194
defsell(self, type_):
1189
-
"""Sell the specified type of cheese."""
1195
+
"""Sells the specified type of cheese."""
1190
1196
self._do_transaction(type_)
1191
1197
```
1192
1198
1199
+
1200
+
### [D.1.14] ❌ **DO NOT** Put a blank line after section headers 💻
Copy file name to clipboardExpand all lines: ni_python_styleguide/config.ini
+22-1Lines changed: 22 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,15 @@ ignore =
65
65
F812
66
66
67
67
# flake8-docstrings
68
+
# Ignoring the requirement on imperative mood, as not all conventions agree on this
69
+
# and ultimately is up to the developer. If, in the future, the mood was enforced based on
70
+
# convention choice we can consider removing this supression as that would make documentation
71
+
# consistent within a standard (but maybe not a codebase)
72
+
# Developers are welcome to turn back on this error in their specific projects.
73
+
# The same goes for the "descriptive"-mood error, if one was to be added to pydocstyle.
74
+
D401
75
+
# Conflicts with recommending Google style DocStrings
76
+
D406 # Section name should end with a newline -> forces a newline at end of DocString
68
77
# Ignoring things enforced by black
69
78
D200 # One-line docstring should fit on one line with quotes
70
79
D206 # Docstring should be indented with spaces, not tabs
@@ -76,7 +85,19 @@ ignore =
76
85
D203 # 1 blank line required before class docstring
77
86
D213 # Multi-line docstring summary should start at the second line
78
87
D400 # First line should end with a period
79
-
88
+
# Recommending Google, so these don't apply - http://www.pydocstyle.org/en/stable/error_codes.html#:~:text=The%20google%20convention%20added%20in%20v4.0.0
89
+
D203
90
+
D204
91
+
D213
92
+
D215
93
+
D400
94
+
D401
95
+
D404
96
+
D406
97
+
D407
98
+
D408
99
+
D409
100
+
D413
80
101
# flake8-import-order
81
102
I101 # The names in your from import are in the wrong order. (Enforced by E401)
0 commit comments