Python numpydoc.docscrape.FunctionDoc() Examples
The following are 5
code examples of numpydoc.docscrape.FunctionDoc().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpydoc.docscrape
, or try the search function
.
Example #1
Source File: test_docscrape.py From artview with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example #2
Source File: test_docscrape.py From queueing-tool with MIT License | 6 votes |
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)
Example #3
Source File: interactions.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
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('.')
Example #4
Source File: test_hook_specifications.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
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}" )
Example #5
Source File: test_docstring_parameters.py From celer with BSD 3-Clause "New" or "Revised" License | 4 votes |
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