当前位置: 首页>>代码示例>>Python>>正文


Python docscrape.FunctionDoc方法代码示例

本文整理汇总了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) 
开发者ID:nguy,项目名称:artview,代码行数:19,代码来源:test_docscrape.py

示例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('.') 
开发者ID:napari,项目名称:napari,代码行数:9,代码来源:interactions.py

示例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}"
    ) 
开发者ID:napari,项目名称:napari,代码行数:12,代码来源:test_hook_specifications.py

示例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 
开发者ID:mathurinm,项目名称:celer,代码行数:45,代码来源:test_docstring_parameters.py


注:本文中的numpydoc.docscrape.FunctionDoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。