-
Notifications
You must be signed in to change notification settings - Fork 301
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
Add docstring's param descriptions to task's and workflow's input and output variables #557
Conversation
Signed-off-by: Sean Lin <[email protected]>
Thank you for opening this pull request! 🙌 |
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
* Remove old code Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
make doc-requirements.txt Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #557 +/- ##
==========================================
- Coverage 85.47% 85.46% -0.01%
==========================================
Files 372 376 +4
Lines 28995 29158 +163
Branches 2318 2338 +20
==========================================
+ Hits 24783 24921 +138
- Misses 3569 3606 +37
+ Partials 643 631 -12
Continue to review full report at Codecov.
|
* add support for named output descriptions in docstring Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
…#562) Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin [email protected]
TL;DR
This PR fills out the description field in an input
Variable
with parameter descriptions parsed from thedocstring
of a Python task.reStructuredText
numpydoc
googledocstring
TODOs:Support for different styles of docstring (Sphinx reStructuredText, numpy, and google)Figure out the best way to add descriptions to anamedtuple
output when:returns:
contains shared description. Maybe encourage the use of:returns foo: bar
?Move the parser out of common/utilType
Are all requirements met?
Complete description
Style guide
https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html#the-sphinx-docstring-format
https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard
https://google.github.io/styleguide/pyguide.html
Library
As tempted as it sounds to write a new parser, there are a few helpful libraries out there:
docutils
Often used as a command line tool, the library can be used for parsing reStructuredText programatically.
Pros:
Cons:
Sphinx (with Napoleon extension)
A documentation generator. Can be used for parsing docstring programatically.
Pros:
Cons:
docstring_parser (recommend)
Small docstring library that showed up in Google. Seems legit.
https://github.com/rr-/docstring_parser
Pros:
Cons:
Doesn't support multiple return values in numpy style docstring(fixed in this PR)function.__doc__
vsinspect.getdoc()
function.__doc__
provides raw docstring, which is good for ascii arts or other creative stuff. WYSIWYG. The raw docstring may come with extra indentations that screws up parser.inspect.getdoc()
cleans up the extra indentations. Looks like the clean up is part of PEP 257, so we're going with that.Output descriptions
Usually the return value doesn't have a name associated with it, so we have to work with that. In the future, maybe we can encourage task authors to separate the return values for namedtuples similar to the input parameters.
Example multiple return values:
numpydoc
Seems like numpydoc supports multiple return values, but Sphinx reStructuredText and google docstring do not. Similar to params, we can encourage the use of
:returns o1: description
. It's valid reStructuredText and it's not going to break Spinx, but this style is not recognized.Sticking with replicating the output description for now.
Tracking Issue
flyteorg/flyte#1235
Follow-up issue
NA