本文整理匯總了Python中numpydoc.docscrape.FunctionDoc方法的典型用法代碼示例。如果您正苦於以下問題:Python docscrape.FunctionDoc方法的具體用法?Python docscrape.FunctionDoc怎麽用?Python docscrape.FunctionDoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpydoc.docscrape
的用法示例。
在下文中一共展示了docscrape.FunctionDoc方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_see_also_print
# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import FunctionDoc [as 別名]
def test_see_also_print():
class Dummy(object):
"""
See Also
--------
func_a, func_b
func_c : some relationship
goes here
func_d
"""
pass
obj = Dummy()
s = str(FunctionDoc(obj, role='func'))
assert(':func:`func_a`, :func:`func_b`' in s)
assert(' some relationship' in s)
assert(':func:`func_d`' in s)
示例2: get_function_summary
# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import FunctionDoc [as 別名]
def get_function_summary(func):
"""Get summary of doc string of function."""
doc = FunctionDoc(func)
summary = ''
for s in doc['Summary']:
summary += s
return summary.rstrip('.')
示例3: test_docs_match_signature
# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import FunctionDoc [as 別名]
def test_docs_match_signature(name, func):
sig = inspect.signature(func)
docs = FunctionDoc(func)
sig_params = set(sig.parameters)
doc_params = {p.name for p in docs.get('Parameters')}
assert sig_params == doc_params, (
f"Signature parameters for hook specification '{name}' do "
"not match the parameters listed in the docstring:\n"
f"{sig_params} != {doc_params}"
)
示例4: check_parameters_match
# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import FunctionDoc [as 別名]
def check_parameters_match(func, doc=None):
"""Check docstring, return list of incorrect results."""
from numpydoc import docscrape
incorrect = []
name_ = get_name(func)
if not name_.startswith('celer.'):
return incorrect
if inspect.isdatadescriptor(func):
return incorrect
args = _get_args(func)
# drop self
if len(args) > 0 and args[0] == 'self':
args = args[1:]
if doc is None:
with warnings.catch_warnings(record=True) as w:
try:
doc = docscrape.FunctionDoc(func)
except Exception as exp:
incorrect += [name_ + ' parsing error: ' + str(exp)]
return incorrect
if len(w):
raise RuntimeError('Error for %s:\n%s' % (name_, w[0]))
# check set
param_names = [name for name, _, _ in doc['Parameters']]
# clean up some docscrape output:
param_names = [name.split(':')[0].strip('` ') for name in param_names]
param_names = [name for name in param_names if '*' not in name]
if len(param_names) != len(args):
bad = str(sorted(list(set(param_names) - set(args)) +
list(set(args) - set(param_names))))
if not any(re.match(d, name_) for d in _docstring_ignores) and \
'deprecation_wrapped' not in func.__code__.co_name:
incorrect += [name_ + ' arg mismatch: ' + bad]
else:
for n1, n2 in zip(param_names, args):
if n1 != n2:
incorrect += [name_ + ' ' + n1 + ' != ' + n2]
return incorrect
# TODO: readd numpydoc
# @requires_numpydoc