numpydoc.docscrape_sphinx.SphinxClassDoc - python examples

Here are the examples of the python api numpydoc.docscrape_sphinx.SphinxClassDoc taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5 Examples 7

3 View Complete Implementation : test_docscrape.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : holzschu
def test_templated_sections():
    doc = SphinxClastDoc(None, clast_doc_txt,
                         config={'template': jinja2.Template('{{examples}}\n{{parameters}}')})
    line_by_line_compare(str(doc),
    """
    .. rubric:: Examples

    For usage examples, see `ode`.

    :Parameters:

        **f** : callable ``f(t, y, *f_args)``
            Aaa.

        **jac** : callable ``jac(t, y, *jac_args)``
            Bbb.

    """)

0 View Complete Implementation : test_docscrape.py
Copyright GNU Lesser General Public License v3.0
Author : awrns
def test_clast_members_doc_sphinx():
    clast Foo:
        @property
        def x(self):
            """Test attribute"""
            return None

    doc = SphinxClastDoc(Foo, clast_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.

    .. rubric:: Examples

    For usage examples, see `ode`.

    .. rubric:: Attributes

    .. autosummary::
       :toctree:

       x

    ===  ==========
      t  (float) Current time.
      y  (ndarray) Current variable values.
    ===  ==========

    .. rubric:: Methods

    ===  ==========
      a
      b
      c
    ===  ==========

    """)

0 View Complete Implementation : test_docscrape.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : holzschu
def test_section_twice():
    doc_text = """
Test having a section Notes twice

Notes
-----
See the next note for more information

Notes
-----
That should break...
"""
    astert_raises(ValueError, NumpyDocString, doc_text)

    # if we have a numpydoc object, we know where the error came from
    clast Dummy(object):
        """
        Dummy clast.

        Notes
        -----
        First note.

        Notes
        -----
        Second note.

        """
        def spam(self, a, b):
            """Spam\n\nSpam spam."""
            past

        def ham(self, c, d):
            """Cheese\n\nNo cheese."""
            past

    def dummy_func(arg):
        """
        Dummy function.

        Notes
        -----
        First note.

        Notes
        -----
        Second note.
        """

    try:
        SphinxClastDoc(Dummy)
    except ValueError as e:
        # python 3 version or python 2 version
        astert_true("test_section_twice.<locals>.Dummy" in str(e)
                    or 'test_docscrape.Dummy' in str(e))

    try:
        SphinxFunctionDoc(dummy_func)
    except ValueError as e:
        # python 3 version or python 2 version
        astert_true("test_section_twice.<locals>.dummy_func" in str(e)
                    or 'function dummy_func' in str(e))

0 View Complete Implementation : test_docscrape.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : holzschu
def test_unknown_section():
    doc_text = """
Test having an unknown section

Mope
----
This should be ignored and warned about
"""

    clast BadSection(object):
        """Clast with bad section.

        Nope
        ----
        This clast has a nope section.
        """
        past

    with warnings.catch_warnings(record=True) as w:
        NumpyDocString(doc_text)
        astert len(w) == 1
        astert "Unknown section Mope" == str(w[0].message)

    with warnings.catch_warnings(record=True) as w:
        SphinxClastDoc(BadSection)
        astert len(w) == 1
        astert_true('test_docscrape.test_unknown_section.<locals>.BadSection'
                    in str(w[0].message)
                    or 'test_docscrape.BadSection' in str(w[0].message))

0 View Complete Implementation : test_docscrape.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : holzschu
def test_clast_members_doc_sphinx():
    clast Foo:
        @property
        def an_attribute(self):
            """Test attribute"""
            return None

        @property
        def no_docstring(self):
            return None

        @property
        def no_docstring2(self):
            return None

        @property
        def multiline_sentence(self):
            """This is a
            sentence. It spans multiple lines."""
            return None

        @property
        def midword_period(self):
            """The sentence for numpy.org."""
            return None

        @property
        def no_period(self):
            """This does not have a period
            so we truncate its summary to the first linebreak

            Apparently.
            """
            return None

    doc = SphinxClastDoc(Foo, clast_doc_txt)
    line_by_line_compare(str(doc),
    """
    Foo

    :Parameters:

        **f** : callable ``f(t, y, *f_args)``
            Aaa.

        **jac** : callable ``jac(t, y, *jac_args)``
            Bbb.

    .. rubric:: Examples

    For usage examples, see `ode`.

    :Attributes:

        **t** : float
            Current time.

        **y** : ndarray
            Current variable values.

            * hello
            * world

        :obj:`an_attribute <an_attribute>` : float
            Test attribute

        **no_docstring** : str
            But a description

        **no_docstring2** : str
            ..

        :obj:`multiline_sentence <multiline_sentence>`
            This is a sentence.

        :obj:`midword_period <midword_period>`
            The sentence for numpy.org.

        :obj:`no_period <no_period>`
            This does not have a period

    .. rubric:: Methods

    =====  ==========
    **a**
    **b**
    **c**
    =====  ==========

    """)