def add_param_docs(param_map):
"""
Append documentation from FLAG_MAP to a function's docstring.
:param param_map:
A mapping of argument names (strings) to FlagInfo objects.
:return:
A decorator that appends flag information to a function's docstring.
"""
def decorator(func):
func.__doc__ = textwrap.dedent(func.__doc__) + '\n'.join(
':param {}:\n{}'.format(name, textwrap.indent(arg.doc, ' '))
for name, arg in param_map.items())
return func
return decorator
# Mypy generates messages in the format:
# blabla.py: note: In function "f":
# blabla.py:2: error: Unsupported operand types for ...
# The "note" messages are only adding info coala should already know,
# so discard those. We're only capturing the errors.
评论列表
文章目录