-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docstring's param descriptions to task's and workflow's input and…
… output variables (#557) Signed-off-by: Sean Lin <[email protected]> Co-authored-by: wild-endeavor <[email protected]>
- Loading branch information
1 parent
1f10fa5
commit 8c6764c
Showing
16 changed files
with
314 additions
and
35 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
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,27 @@ | ||
from typing import Callable, Dict, Optional | ||
|
||
from docstring_parser import parse | ||
|
||
|
||
class Docstring(object): | ||
def __init__(self, docstring: str = None, callable_: Callable = None): | ||
if docstring is not None: | ||
self._parsed_docstring = parse(docstring) | ||
else: | ||
self._parsed_docstring = parse(callable_.__doc__) | ||
|
||
@property | ||
def input_descriptions(self) -> Dict[str, str]: | ||
return {p.arg_name: p.description for p in self._parsed_docstring.params} | ||
|
||
@property | ||
def output_descriptions(self) -> Dict[str, str]: | ||
return {p.return_name: p.description for p in self._parsed_docstring.many_returns} | ||
|
||
@property | ||
def short_description(self) -> Optional[str]: | ||
return self._parsed_docstring.short_description | ||
|
||
@property | ||
def long_description(self) -> Optional[str]: | ||
return self._parsed_docstring.long_description |
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
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
Oops, something went wrong.