docstringify 0.5.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. docstringify-0.6.0/.github/pull_request_template.md +14 -0
  2. {docstringify-0.5.0 → docstringify-0.6.0}/.github/workflows/ci.yml +2 -2
  3. {docstringify-0.5.0 → docstringify-0.6.0}/.github/workflows/pypi-publish.yml +4 -4
  4. {docstringify-0.5.0 → docstringify-0.6.0}/.pre-commit-config.yaml +13 -1
  5. docstringify-0.6.0/CODE_OF_CONDUCT.md +128 -0
  6. docstringify-0.6.0/CONTRIBUTING.md +54 -0
  7. {docstringify-0.5.0 → docstringify-0.6.0}/PKG-INFO +60 -9
  8. {docstringify-0.5.0 → docstringify-0.6.0}/README.md +58 -5
  9. {docstringify-0.5.0 → docstringify-0.6.0}/pyproject.toml +18 -3
  10. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/__init__.py +1 -1
  11. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/cli.py +38 -16
  12. docstringify-0.6.0/src/docstringify/converters/base.py +251 -0
  13. docstringify-0.6.0/src/docstringify/converters/google.py +140 -0
  14. docstringify-0.6.0/src/docstringify/converters/numpydoc.py +141 -0
  15. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/traversal/transformer.py +51 -2
  16. docstringify-0.6.0/src/docstringify/traversal/visitor.py +257 -0
  17. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify.egg-info/PKG-INFO +60 -9
  18. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify.egg-info/SOURCES.txt +3 -0
  19. docstringify-0.5.0/src/docstringify/converters/base.py +0 -92
  20. docstringify-0.5.0/src/docstringify/converters/google.py +0 -54
  21. docstringify-0.5.0/src/docstringify/converters/numpydoc.py +0 -55
  22. docstringify-0.5.0/src/docstringify/traversal/visitor.py +0 -99
  23. {docstringify-0.5.0 → docstringify-0.6.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  24. {docstringify-0.5.0 → docstringify-0.6.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  25. {docstringify-0.5.0 → docstringify-0.6.0}/.github/dependabot.yml +0 -0
  26. {docstringify-0.5.0 → docstringify-0.6.0}/.github/release.yml +0 -0
  27. {docstringify-0.5.0 → docstringify-0.6.0}/.github/workflows/greetings.yml +0 -0
  28. {docstringify-0.5.0 → docstringify-0.6.0}/.gitignore +0 -0
  29. {docstringify-0.5.0 → docstringify-0.6.0}/.pre-commit-hooks.yaml +0 -0
  30. {docstringify-0.5.0 → docstringify-0.6.0}/LICENSE +0 -0
  31. {docstringify-0.5.0 → docstringify-0.6.0}/setup.cfg +0 -0
  32. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/__main__.py +0 -0
  33. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/components.py +0 -0
  34. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/converters/__init__.py +0 -0
  35. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/exceptions.py +0 -0
  36. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/nodes/__init__.py +0 -0
  37. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/nodes/base.py +0 -0
  38. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/nodes/function.py +0 -0
  39. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify/traversal/__init__.py +0 -0
  40. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify.egg-info/dependency_links.txt +0 -0
  41. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify.egg-info/entry_points.txt +0 -0
  42. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify.egg-info/requires.txt +0 -0
  43. {docstringify-0.5.0 → docstringify-0.6.0}/src/docstringify.egg-info/top_level.txt +0 -0
@@ -0,0 +1,14 @@
1
+ <!-- Which issue does this address? -->
2
+ Fixes #
3
+
4
+ **Describe your changes**
5
+
6
+ <!-- TODO -->
7
+
8
+ **Checklist**
9
+
10
+ <!-- Place an X between the [ ] for completed tasks -->
11
+
12
+ - [ ] Test cases have been modified/added to cover any code changes.
13
+ - [ ] Docstrings have been modified/created for any code changes.
14
+ - [ ] All linting and formatting checks pass (see the [contributing guidelines](https://github.com/stefmolin/docstringify/blob/main/CONTRIBUTING.md) for more information).
@@ -41,13 +41,13 @@ jobs:
41
41
  fail-fast: false
42
42
  matrix:
43
43
  os: [macos-latest, ubuntu-latest, windows-latest]
44
- python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
44
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
45
45
 
46
46
  steps:
47
47
  - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48
48
 
49
49
  - name: Set up Python ${{ matrix.python-version }}
50
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
50
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
51
51
  with:
52
52
  python-version: ${{ matrix.python-version }}
53
53
 
@@ -12,7 +12,7 @@ jobs:
12
12
  steps:
13
13
  - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
14
14
  - name: Set up Python
15
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
15
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
16
16
  with:
17
17
  python-version: "3.x"
18
18
  - name: Install pypa/build
@@ -44,7 +44,7 @@ jobs:
44
44
 
45
45
  steps:
46
46
  - name: Download all the dists
47
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
47
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
48
48
  with:
49
49
  name: python-package-distributions
50
50
  path: dist/
@@ -65,7 +65,7 @@ jobs:
65
65
 
66
66
  steps:
67
67
  - name: Download all the dists
68
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
68
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
69
69
  with:
70
70
  name: python-package-distributions
71
71
  path: dist/
@@ -110,7 +110,7 @@ jobs:
110
110
 
111
111
  steps:
112
112
  - name: Download all the dists
113
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
113
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
114
114
  with:
115
115
  name: python-package-distributions
116
116
  path: dist/
@@ -11,8 +11,14 @@ repos:
11
11
  - id: end-of-file-fixer
12
12
  - id: trailing-whitespace
13
13
 
14
+ - repo: https://github.com/stefmolin/docstringify
15
+ rev: 0.5.1
16
+ hooks:
17
+ - id: docstringify
18
+ args: [--make-changes-inplace=numpydoc]
19
+
14
20
  - repo: https://github.com/astral-sh/ruff-pre-commit
15
- rev: v0.11.2
21
+ rev: v0.11.9
16
22
  hooks:
17
23
  - id: ruff
18
24
  args: [--fix, --exit-non-zero-on-fix, --show-fixes]
@@ -23,3 +29,9 @@ repos:
23
29
  hooks:
24
30
  - id: pyproject-fmt
25
31
  args: [--keep-full-version, --no-print-diff]
32
+
33
+ - repo: https://github.com/numpy/numpydoc
34
+ rev: v1.8.0
35
+ hooks:
36
+ - id: numpydoc-validation
37
+ exclude: (tests|docs)/.*
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ docstringify-coc@stefaniemolin.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
@@ -0,0 +1,54 @@
1
+ # Contributing Guidelines
2
+
3
+ Contributions are welcome. Please adhere to the following process.
4
+
5
+ ## 1. Open an issue
6
+ Open up an issue describing in detail the bug or feature request you are proposing. Be sure to fill out all the information requested in the template. Please wait for confirmation from a maintainer that this unit of work is in line with the project's roadmap *before* submitting a pull request.
7
+
8
+ ## 2. Work on your changes
9
+ Once you have been given the go ahead, you can start working on the code. Start by forking the project, cloning locally, and then creating a branch to work on. You will need to then install main dependencies as well as the `dev` dependencies, which can be done by running the following command:
10
+
11
+ ```shell
12
+ $ pip install -e '.[dev]'
13
+ ```
14
+
15
+ Set up the pre-commit hooks to make sure you can pass the CI checks:
16
+
17
+ ```shell
18
+ $ pre-commit install
19
+ ```
20
+
21
+ All commits will be squashed, so just make sure that the final commit passes all linting, documentation, and testing checks. These will run in GitHub Actions when you open a pull request, but you should also run them locally:
22
+
23
+ ```shell
24
+ $ pre-commit run --all-files # linting and documentation checks
25
+ $ pytest # run the test suite
26
+ ```
27
+
28
+ Some things to remember:
29
+
30
+ - All code must be documented using docstrings in the [numpydoc style](https://numpydoc.readthedocs.io/en/latest/format.html) &ndash; the pre-commit hooks will check for this.
31
+ - Any changes to the API must be accompanied by either an additional test case or a new test. Run `pytest` to make sure your changes are covered.
32
+
33
+ ## 3. Open a pull request
34
+
35
+ Once you have finished with the task you are working on and all the checks and tests pass, you can create a pull request. Please consult [GitHub's guide on how to do this](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork), if you need some guidance.
36
+
37
+ In your description, please do the following:
38
+ 1. Link to the corresponding issue for this unit of work.
39
+ 2. Describe what you changed and why.
40
+ 3. Include, if applicable, any testing instructions.
41
+
42
+ When you create your pull request, first-time contributors will need to wait for a maintainer to approve running the GitHub Actions workflows. Please be patient until this happens.
43
+
44
+ Once it does, the same checks described above (testing, documentation, linting) that you ran on your machine will run on Linux, macOS, and Windows with multiple versions of Python. Please note that it is possible that differences in operating systems and/or Python versions results in a failure, despite it working on your machine.
45
+
46
+ If anything fails, please attempt to fix it as we're unlikely to review your code until everything passes. If stuck, please feel free to leave a note in the pull request enumerating what you have already tried and someone may be able to offer assistance.
47
+
48
+ ## 4. Code review
49
+
50
+ After all checks in your pull request pass, a maintainer will review your code. In many cases, there will be some feedback to address, and this may require a few iterations to get to the best implementation. Remember to be patient and polite during this process.
51
+
52
+ ## 5. Congratulations!
53
+
54
+ When the pull request is approved, it will be merged into the `main` branch. Users of this project won't have your changes until the next release is made.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstringify
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Flag missing docstrings and, optionally, generate them from signatures and type annotations.
5
5
  Author-email: Stefanie Molin <docstringify@stefaniemolin.com>
6
6
  License: MIT License
@@ -30,16 +30,14 @@ Project-URL: Homepage, https://github.com/stefmolin/docstringify
30
30
  Project-URL: Source, https://github.com/stefmolin/docstringify
31
31
  Keywords: ast,docstring generation,google-style docstring,numpydoc-style docstring,pre-commit
32
32
  Classifier: Development Status :: 3 - Alpha
33
- Classifier: License :: OSI Approved :: MIT License
34
33
  Classifier: Programming Language :: Python
35
34
  Classifier: Programming Language :: Python :: 3 :: Only
36
- Classifier: Programming Language :: Python :: 3.8
37
35
  Classifier: Programming Language :: Python :: 3.9
38
36
  Classifier: Programming Language :: Python :: 3.10
39
37
  Classifier: Programming Language :: Python :: 3.11
40
38
  Classifier: Programming Language :: Python :: 3.12
41
39
  Classifier: Programming Language :: Python :: 3.13
42
- Requires-Python: >=3.8
40
+ Requires-Python: >=3.9
43
41
  Description-Content-Type: text/markdown
44
42
  License-File: LICENSE
45
43
  Provides-Extra: dev
@@ -49,9 +47,58 @@ Requires-Dist: pytest-cov; extra == "dev"
49
47
  Requires-Dist: pytest-randomly; extra == "dev"
50
48
  Dynamic: license-file
51
49
 
52
- # docstringify
50
+ # Docstringify
53
51
  Flag missing docstrings and, optionally, generate them from signatures and type annotations.
54
52
 
53
+ ## About
54
+
55
+ Given a file, `test.py`, with the following contents:
56
+
57
+ ```python
58
+ def say_hello(name: str = 'World') -> None:
59
+ print(f'Hello, {name}!')
60
+ ```
61
+
62
+ You can use Docstringify in three modes:
63
+
64
+ 1. Flag missing docstrings:
65
+ ```
66
+ test is missing a docstring
67
+ test.say_hello is missing a docstring
68
+ ```
69
+ 2. Suggest docstring templates based on type annotations:
70
+ ```
71
+ test is missing a docstring
72
+ Hint:
73
+ """__description__"""
74
+
75
+ test.say_hello is missing a docstring
76
+ Hint:
77
+ """
78
+ __description__
79
+
80
+ Parameters
81
+ ----------
82
+ name : str, default="World"
83
+ __description__
84
+ """
85
+ ```
86
+ 3. Add docstring templates to source code files:
87
+ ```python
88
+ """__description__"""
89
+
90
+ def say_hello(name: str = 'World') -> None:
91
+ """
92
+ __description__
93
+
94
+ Parameters
95
+ ----------
96
+ name : str, default="World"
97
+ __description__
98
+ """
99
+ print(f'Hello, {name}!')
100
+ ```
101
+
55
102
  ## Usage
56
103
 
57
104
  ### Pre-commit hook
@@ -60,7 +107,7 @@ Add the following to your `.pre-commit-config.yaml` file to block commits with m
60
107
 
61
108
  ```yaml
62
109
  - repo: https://github.com/stefmolin/docstringify
63
- rev: 0.5.0
110
+ rev: 0.6.0
64
111
  hooks:
65
112
  - id: docstringify
66
113
  ```
@@ -69,7 +116,7 @@ By default, all docstrings are required. If you want to be more lenient, you can
69
116
 
70
117
  ```yaml
71
118
  - repo: https://github.com/stefmolin/docstringify
72
- rev: 0.5.0
119
+ rev: 0.6.0
73
120
  hooks:
74
121
  - id: docstringify
75
122
  args: [--threshold=0.75]
@@ -79,7 +126,7 @@ If you would like to see suggested docstring templates (inferred from type annot
79
126
 
80
127
  ```yaml
81
128
  - repo: https://github.com/stefmolin/docstringify
82
- rev: 0.5.0
129
+ rev: 0.6.0
83
130
  hooks:
84
131
  - id: docstringify
85
132
  args: [--suggest-changes=numpydoc]
@@ -89,7 +136,7 @@ Use `--make-changes` to create a copy of each file with docstring templates. Her
89
136
 
90
137
  ```yaml
91
138
  - repo: https://github.com/stefmolin/docstringify
92
- rev: 0.5.0
139
+ rev: 0.6.0
93
140
  hooks:
94
141
  - id: docstringify
95
142
  args: [--make-changes=google]
@@ -170,3 +217,7 @@ Docstring templates written to /.../test_docstringify.py
170
217
  ```
171
218
 
172
219
  If you want to overwrite the file with the edits, pass `overwrite=True` to `DocstringTransformer()`.
220
+
221
+ ## Contributing
222
+
223
+ Please consult the [contributing guidelines](https://github.com/stefmolin/docstringify/blob/main/CONTRIBUTING.md).
@@ -1,6 +1,55 @@
1
- # docstringify
1
+ # Docstringify
2
2
  Flag missing docstrings and, optionally, generate them from signatures and type annotations.
3
3
 
4
+ ## About
5
+
6
+ Given a file, `test.py`, with the following contents:
7
+
8
+ ```python
9
+ def say_hello(name: str = 'World') -> None:
10
+ print(f'Hello, {name}!')
11
+ ```
12
+
13
+ You can use Docstringify in three modes:
14
+
15
+ 1. Flag missing docstrings:
16
+ ```
17
+ test is missing a docstring
18
+ test.say_hello is missing a docstring
19
+ ```
20
+ 2. Suggest docstring templates based on type annotations:
21
+ ```
22
+ test is missing a docstring
23
+ Hint:
24
+ """__description__"""
25
+
26
+ test.say_hello is missing a docstring
27
+ Hint:
28
+ """
29
+ __description__
30
+
31
+ Parameters
32
+ ----------
33
+ name : str, default="World"
34
+ __description__
35
+ """
36
+ ```
37
+ 3. Add docstring templates to source code files:
38
+ ```python
39
+ """__description__"""
40
+
41
+ def say_hello(name: str = 'World') -> None:
42
+ """
43
+ __description__
44
+
45
+ Parameters
46
+ ----------
47
+ name : str, default="World"
48
+ __description__
49
+ """
50
+ print(f'Hello, {name}!')
51
+ ```
52
+
4
53
  ## Usage
5
54
 
6
55
  ### Pre-commit hook
@@ -9,7 +58,7 @@ Add the following to your `.pre-commit-config.yaml` file to block commits with m
9
58
 
10
59
  ```yaml
11
60
  - repo: https://github.com/stefmolin/docstringify
12
- rev: 0.5.0
61
+ rev: 0.6.0
13
62
  hooks:
14
63
  - id: docstringify
15
64
  ```
@@ -18,7 +67,7 @@ By default, all docstrings are required. If you want to be more lenient, you can
18
67
 
19
68
  ```yaml
20
69
  - repo: https://github.com/stefmolin/docstringify
21
- rev: 0.5.0
70
+ rev: 0.6.0
22
71
  hooks:
23
72
  - id: docstringify
24
73
  args: [--threshold=0.75]
@@ -28,7 +77,7 @@ If you would like to see suggested docstring templates (inferred from type annot
28
77
 
29
78
  ```yaml
30
79
  - repo: https://github.com/stefmolin/docstringify
31
- rev: 0.5.0
80
+ rev: 0.6.0
32
81
  hooks:
33
82
  - id: docstringify
34
83
  args: [--suggest-changes=numpydoc]
@@ -38,7 +87,7 @@ Use `--make-changes` to create a copy of each file with docstring templates. Her
38
87
 
39
88
  ```yaml
40
89
  - repo: https://github.com/stefmolin/docstringify
41
- rev: 0.5.0
90
+ rev: 0.6.0
42
91
  hooks:
43
92
  - id: docstringify
44
93
  args: [--make-changes=google]
@@ -119,3 +168,7 @@ Docstring templates written to /.../test_docstringify.py
119
168
  ```
120
169
 
121
170
  If you want to overwrite the file with the edits, pass `overwrite=True` to `DocstringTransformer()`.
171
+
172
+ ## Contributing
173
+
174
+ Please consult the [contributing guidelines](https://github.com/stefmolin/docstringify/blob/main/CONTRIBUTING.md).
@@ -21,13 +21,11 @@ license = { file = "LICENSE" }
21
21
  authors = [
22
22
  { name = "Stefanie Molin", email = "docstringify@stefaniemolin.com" },
23
23
  ]
24
- requires-python = ">=3.8"
24
+ requires-python = ">=3.9"
25
25
  classifiers = [
26
26
  "Development Status :: 3 - Alpha",
27
- "License :: OSI Approved :: MIT License",
28
27
  "Programming Language :: Python",
29
28
  "Programming Language :: Python :: 3 :: Only",
30
- "Programming Language :: Python :: 3.8",
31
29
  "Programming Language :: Python :: 3.9",
32
30
  "Programming Language :: Python :: 3.10",
33
31
  "Programming Language :: Python :: 3.11",
@@ -94,3 +92,20 @@ lint.extend-per-file-ignores."tests/*" = [ "ANN" ] # don't require annotations f
94
92
  lint.isort.known-first-party = [
95
93
  "docstringify",
96
94
  ]
95
+
96
+ [tool.numpydoc_validation]
97
+ checks = [
98
+ "all", # report on all checks
99
+ "ES01", # but don't require an extended summary
100
+ "EX01", # or examples
101
+ "SA01", # or a see also section
102
+ "SS06", # and don't require the summary to fit on one line
103
+ ]
104
+ exclude = [ # don't report on checks for these
105
+ '\.__init__$',
106
+ '\.__repr__$',
107
+ '\.__str__$',
108
+ ]
109
+ override_SS05 = [ # override SS05 to allow docstrings starting with these words
110
+ '^Process ',
111
+ ]
@@ -3,4 +3,4 @@ Flag missing docstrings and, optionally, generate them from signatures and
3
3
  type annotations.
4
4
  """
5
5
 
6
- __version__ = '0.5.0'
6
+ __version__ = '0.6.0'
@@ -1,29 +1,46 @@
1
+ """CLI for Docstringify."""
2
+
1
3
  from __future__ import annotations
2
4
 
3
5
  import argparse
4
6
  import sys
5
7
  from functools import partial
6
- from typing import Sequence
8
+ from typing import TYPE_CHECKING
7
9
 
10
+ from . import __doc__ as pkg_description
8
11
  from . import __version__
9
12
  from .converters import GoogleDocstringConverter, NumpydocDocstringConverter
10
13
  from .traversal import DocstringTransformer, DocstringVisitor
11
14
 
12
- PROG = __package__
15
+ if TYPE_CHECKING:
16
+ from collections.abc import Sequence
13
17
 
14
- STYLES = {
15
- 'google': GoogleDocstringConverter,
16
- 'numpydoc': NumpydocDocstringConverter,
17
- }
18
+ PROG = __package__
19
+ STYLES = {'google': GoogleDocstringConverter, 'numpydoc': NumpydocDocstringConverter}
18
20
  CLI_DEFAULTS = {'threshold': 1.0}
19
21
 
20
22
 
21
23
  def main(argv: Sequence[str] | None = None) -> int:
22
- parser = argparse.ArgumentParser(prog=PROG)
24
+ """
25
+ Flag missing docstrings and, optionally, generate them from signatures and
26
+ type annotations.
27
+
28
+ Parameters
29
+ ----------
30
+ argv : Sequence[str] | None, default=None
31
+ The arguments passed on the command line.
32
+
33
+ Returns
34
+ -------
35
+ int
36
+ Exit code for the process, where non-zero values indicate errors, and ``1``
37
+ indicates that more than the allowed percentage of docstrings were missing.
38
+ """
39
+
40
+ parser = argparse.ArgumentParser(prog=PROG, description=pkg_description)
41
+ parser.add_argument('filenames', nargs='*', help='Filenames to process')
23
42
  parser.add_argument(
24
- 'filenames',
25
- nargs='*',
26
- help='Filenames to process',
43
+ '-v', '--verbose', action='store_true', help='Run in verbose mode'
27
44
  )
28
45
  parser.add_argument(
29
46
  '--version', action='version', version=f'%(prog)s {__version__}'
@@ -57,7 +74,9 @@ def main(argv: Sequence[str] | None = None) -> int:
57
74
  )
58
75
  args = parser.parse_args(argv)
59
76
 
60
- if style := args.make_changes or args.make_changes_inplace or args.suggest_changes:
77
+ if style := (
78
+ args.make_changes or args.make_changes_inplace or args.suggest_changes
79
+ ):
61
80
  converter = STYLES[style]
62
81
  else:
63
82
  converter = None
@@ -66,10 +85,11 @@ def main(argv: Sequence[str] | None = None) -> int:
66
85
  partial(
67
86
  DocstringTransformer,
68
87
  converter=converter,
69
- **{'overwrite': bool(args.make_changes_inplace)},
88
+ overwrite=bool(args.make_changes_inplace),
89
+ verbose=args.verbose,
70
90
  )
71
91
  if args.make_changes or args.make_changes_inplace
72
- else partial(DocstringVisitor, converter=converter)
92
+ else partial(DocstringVisitor, converter=converter, verbose=args.verbose)
73
93
  )
74
94
 
75
95
  docstrings_processed = missing_docstrings = 0
@@ -79,9 +99,11 @@ def main(argv: Sequence[str] | None = None) -> int:
79
99
  missing_docstrings += len(processor.missing_docstrings)
80
100
  docstrings_processed += processor.docstrings_inspected
81
101
 
82
- if docstrings_processed and (
83
- missing_percentage := (missing_docstrings / docstrings_processed)
84
- ) > (1 - args.threshold):
102
+ if (
103
+ docstrings_processed
104
+ and (missing_percentage := (missing_docstrings / docstrings_processed))
105
+ > 1 - args.threshold
106
+ ):
85
107
  print(f'Missing {missing_percentage:.0%} of docstrings', file=sys.stderr)
86
108
  print(
87
109
  f'Your settings require {args.threshold:.0%} of docstrings to be present',