-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor docstring params #1790
Conversation
^(\s{8}|\s{4})(?!try|else|doi|DOI|Warning|Access|Requests|Note)(\w*): (?!.*=|.*:)(.+)$ This matches strings in test_pvsystem.py wrongly
Deleting negative lookahead |.*: ^(\s{8}|\s{4})(?!try|else|doi|DOI|Warning|Access|Requests|Note)(\w*): (?!.*=)(.+)$ Reason: too many `default: ` strings
Exclude .*=| from negative lookahead ^(\s{8}|\s{4})(?!try|else|doi|DOI|Warning|Access|Requests|Note)(\w*): (?!.*:)(.+)$ Reason: just this line 🌝 Remaining matches are type annotations in modelchain.py and pvsystem.py
Regex: (?<spaces>\s{8}|\s{4})(?<name>\w*) : (?<type>.*) \(optional, default=(?<default>.*)\)$ Subs pattern: $1$2 : $3, default $4 Including: pvlib/**/*.py Excluding: docs No more "(optional, " found in .py files
(?<spaces> {8}| {4})(?<name>\w*) : (?<types>.*), default None$ $1$2 : $3, optional (?<spaces> {8}| {4})(?<name>\w*) : None or (?<type>.*), optional$ $1$2 : $3, optional (?<spaces> {8}| {4})(?<name>\w*) : (?<type>.*) or [nN]one, optional$ $1$2 : $3, optional Over files: pvlib/**/*.py
…y-ls/pvlib-python into refactor-docstring-params
Thanks for submitting this PR @echedey-ls! I think the main priority for docstring formatting is that the sphinx HTML output is correctly rendered. Since spaces before colons and For changing
Since |
Good points. I forgot to add an explanation to what I really want to address since I've been travelling a bit and didn't bother to check what I had written. I intend to open a PR to hint contributors of docstring errors. I've come up to two options that may be useful. Both may be used at the same time:
Also, they recently added a pre-commit hook, although I feel that is a bit overwhelming to add to pvlib since it is currently not being used, I believe. Anyway, for choice 1, it doesn't mind having these "issues" in the docstrings, since contributor would only apply the checker to their function/class/method... The problem with that is that I haven't found a way to include/exclude rules (it checks all of them) and that's definitely not desired. Some rules just don't apply to the pvlib style, like mandatory examples section, some punctuation or capitalisation, and users may not know of that. Adding a On the other hand, choice 2 allows to check for a custom subset of rules, so there is a cleaner output. However, it checks all sphinx docstrings. This PR would allow using the most of them that seem useful. For example, the "See Also" change allows using the rule that checks that all sections exists (it raises a warning for all of them). Adding a space before a colon and removing parentheses makes the default validator parse the argument name and the type correctly. To sum it up, most of the changes in this PR remove false positives and typos that mess with the validator, as a previous step. Personally, I like this option the most. And these superfluous changes, well, since they almost don't have an impact on the docs, I thought of doing them via an independent PR. So checking another PR with the tool is not a pain (I'm aware this one is). I will check the |
Thanks for this in-depth research @echedey-ls :) One thing relevant especially for option 2 is that we don't actually use numpydoc, we use the napoleon sphinx extension (#691). I'm guessing that enabling both of them in the build would cause problems, but I don't know that for sure. |
Good point, it does. I will pursue choice 1, but I'd like to wait for the numpydoc issue to get resolved then. Thanks for the review. Which changes should I keep? Changes 2 to 4 in the "changes" section from PR body? |
Continued work over #1828 |
[ ] Tests added[ ] Updates entries indocs/sphinx/source/reference
for API changes.[ ] Adds description and name entries in the appropriate "what's new" file indocs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.I just want the docstrings to be homogeneus and compliant with numpydoc.
Changes in this PR
solar_azimuth: numeric
->solar_azimuth : numeric
return_components : bool (optional, default=False)
->return_components : bool, default False
logical_records : list or tuple, default: ('0100',)
->logical_records : list or tuple, default ('0100',)
See also
->See Also