forked from radian-software/apheleia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
docformatter
which formats Python docstrings to PEP 257 (radian…
…-software#267) Add [docformatter](https://github.com/PyCQA/docformatter) for Python docstrings. By default it outputs diffs but changes in-place with `--in-place`. On successful change it exits with an error code of `3` (found out by trial), so I had to add a formatter wrapping-script. Initially I used `--in-place` with the special `in-place` symbol in apheleia. But now I tried an approach where I transform the diff into usable stdout using `patch` instead. Related to radian-software#266 , where I had used the example of docformatter to ask how to add scripts with positive exit codes and @raxod502 showed me the `phpcs` solution. --------- Co-authored-by: Radon Rosborough <[email protected]>
- Loading branch information
Showing
7 changed files
with
119 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
docformatter --in-place "$@" | ||
if [ "$?" -eq 3 ]; then | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
apt-get install -y python3-pip | ||
pip3 install docformatter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
def single_line_doc(): | ||
""" | ||
Line break not necessary | ||
""" | ||
|
||
|
||
def extend_first_line(): | ||
"""First line | ||
first line continuation | ||
""" | ||
|
||
|
||
def add_line_break(): | ||
"""First line. | ||
Second line. | ||
""" | ||
|
||
|
||
def long_lines(): | ||
""" | ||
Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros. Sed id ligula quis est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a sapien. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
def single_line_doc(): | ||
"""Line break not necessary.""" | ||
|
||
|
||
def extend_first_line(): | ||
"""First line first line continuation.""" | ||
|
||
|
||
def add_line_break(): | ||
"""First line. | ||
Second line. | ||
""" | ||
|
||
|
||
def long_lines(): | ||
"""Nullam eu ante vel est convallis dignissim. | ||
Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, | ||
quis tempor ligula erat quis odio. Nunc porta vulputate tellus. | ||
Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc | ||
aliquet, augue nec adipiscing interdum, lacus tellus malesuada | ||
massa, quis varius mi purus non odio. Pellentesque condimentum, | ||
magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus | ||
diam neque sit amet urna. Curabitur vulputate vestibulum lorem. | ||
Fusce sagittis, libero non molestie mollis, magna orci ultrices | ||
dolor, at vulputate neque nulla lacinia eros. Sed id ligula quis | ||
est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a | ||
sapien. | ||
""" |