當前位置: 首頁>>代碼示例>>Python>>正文


Python docscrape.ClassDoc方法代碼示例

本文整理匯總了Python中numpydoc.docscrape.ClassDoc方法的典型用法代碼示例。如果您正苦於以下問題:Python docscrape.ClassDoc方法的具體用法?Python docscrape.ClassDoc怎麽用?Python docscrape.ClassDoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpydoc.docscrape的用法示例。


在下文中一共展示了docscrape.ClassDoc方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: find_documented_attributes

# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import ClassDoc [as 別名]
def find_documented_attributes(class_name, attrs):
        """Parse the documentation to retrieve all attributes that have been
        documented and their documentation
        """
        # If a class is not documented we return an empty list
        if '__doc__' not in attrs:
            return []

        current_class_doc = inspect.cleandoc(attrs['__doc__'])
        parsed_doc = docscrape.ClassDoc(None, doc=current_class_doc)
        attr_docs = parsed_doc['Parameters'] + parsed_doc['Attributes'] + \
            parsed_doc['Other Parameters']

        attr_and_doc = []

        create_property_doc = BaseMeta.create_property_doc
        for attr_doc in attr_docs:
            attr_name = attr_doc[0]
            if ':' in attr_name:
                raise ValueError("Attribute '%s' has not a proper "
                                 "documentation, a space might be missing "
                                 "before colon" % attr_name)
            attr_and_doc += [(attr_name,
                              create_property_doc(class_name, attr_doc))]
        return attr_and_doc 
開發者ID:X-DataInitiative,項目名稱:tick,代碼行數:27,代碼來源:base.py

示例2: test_docstring_parameters

# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import ClassDoc [as 別名]
def test_docstring_parameters():
    """Test module docstring formatting."""
    from numpydoc import docscrape

    public_modules_ = public_modules[:]

    incorrect = []
    for name in public_modules_:
        with warnings.catch_warnings(record=True):  # traits warnings
            module = __import__(name, globals())
        for submod in name.split('.')[1:]:
            module = getattr(module, submod)
        classes = inspect.getmembers(module, inspect.isclass)
        for cname, cls in classes:
            if cname.startswith('_'):
                continue
            with warnings.catch_warnings(record=True) as w:
                cdoc = docscrape.ClassDoc(cls)
            if len(w):
                raise RuntimeError('Error for __init__ of %s in %s:\n%s'
                                   % (cls, name, w[0]))
            if hasattr(cls, '__init__'):
                incorrect += check_parameters_match(cls.__init__, cdoc)
            for method_name in cdoc.methods:
                method = getattr(cls, method_name)
                incorrect += check_parameters_match(method)
            if hasattr(cls, '__call__'):
                incorrect += check_parameters_match(cls.__call__)
        functions = inspect.getmembers(module, inspect.isfunction)
        for fname, func in functions:
            if fname.startswith('_'):
                continue
            incorrect += check_parameters_match(func)
    msg = '\n' + '\n'.join(sorted(list(set(incorrect))))
    if len(incorrect) > 0:
        raise AssertionError(msg) 
開發者ID:mathurinm,項目名稱:celer,代碼行數:38,代碼來源:test_docstring_parameters.py

示例3: _get_help_for_estimator

# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import ClassDoc [as 別名]
def _get_help_for_estimator(prefix, estimator, defaults=None):
    """Yield help lines for the given estimator and prefix."""
    from numpydoc.docscrape import ClassDoc

    defaults = defaults or {}
    estimator = _extract_estimator_cls(estimator)
    yield "<{}> options:".format(estimator.__name__)

    doc = ClassDoc(estimator)
    yield from _get_help_for_params(
        doc['Parameters'],
        prefix=prefix,
        defaults=defaults,
    )
    yield ''  # add a newline line between estimators 
開發者ID:skorch-dev,項目名稱:skorch,代碼行數:17,代碼來源:cli.py

示例4: test_class_members

# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import ClassDoc [as 別名]
def test_class_members():

    class Dummy(object):
        """
        Dummy class.

        """
        def spam(self, a, b):
            """Spam\n\nSpam spam."""
            pass
        def ham(self, c, d):
            """Cheese\n\nNo cheese."""
            pass
        @property
        def spammity(self):
            """Spammity index"""
            return 0.95

        class Ignorable(object):
            """local class, to be ignored"""
            pass

    for cls in (ClassDoc, SphinxClassDoc):
        doc = cls(Dummy, config=dict(show_class_members=False))
        assert 'Methods' not in str(doc), (cls, str(doc))
        assert 'spam' not in str(doc), (cls, str(doc))
        assert 'ham' not in str(doc), (cls, str(doc))
        assert 'spammity' not in str(doc), (cls, str(doc))
        assert 'Spammity index' not in str(doc), (cls, str(doc))

        doc = cls(Dummy, config=dict(show_class_members=True))
        assert 'Methods' in str(doc), (cls, str(doc))
        assert 'spam' in str(doc), (cls, str(doc))
        assert 'ham' in str(doc), (cls, str(doc))
        assert 'spammity' in str(doc), (cls, str(doc))

        if cls is SphinxClassDoc:
            assert '.. autosummary::' in str(doc), str(doc)
        else:
            assert 'Spammity index' in str(doc), str(doc) 
開發者ID:nguy,項目名稱:artview,代碼行數:42,代碼來源:test_docscrape.py

示例5: test_class_members_doc

# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import ClassDoc [as 別名]
def test_class_members_doc():
    doc = ClassDoc(None, class_doc_txt)
    non_blank_line_by_line_compare(str(doc),
    """
    Foo

    Parameters
    ----------
    f : callable ``f(t, y, *f_args)``
        Aaa.
    jac : callable ``jac(t, y, *jac_args)``
        Bbb.

    Examples
    --------
    For usage examples, see `ode`.

    Attributes
    ----------
    t : float
        Current time.
    y : ndarray
        Current variable values.

    Methods
    -------
    a : 

    b : 

    c : 

    .. index:: 

    """) 
開發者ID:nguy,項目名稱:artview,代碼行數:37,代碼來源:test_docscrape.py

示例6: test_class_members_doc

# 需要導入模塊: from numpydoc import docscrape [as 別名]
# 或者: from numpydoc.docscrape import ClassDoc [as 別名]
def test_class_members_doc():
    doc = ClassDoc(None, class_doc_txt)
    non_blank_line_by_line_compare(str(doc),
    """
    Foo

    Parameters
    ----------
    f : callable ``f(t, y, *f_args)``
        Aaa.
    jac : callable ``jac(t, y, *jac_args)``
        Bbb.

    Examples
    --------
    For usage examples, see `ode`.

    Attributes
    ----------
    t : float
        Current time.
    y : ndarray
        Current variable values.

    Methods
    -------
    a

    b

    c

    .. index::

    """) 
開發者ID:djordon,項目名稱:queueing-tool,代碼行數:37,代碼來源:test_docscrape.py


注:本文中的numpydoc.docscrape.ClassDoc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。