Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #80 from docascode/yitian/add-example
Browse files Browse the repository at this point in the history
Add test examples for previous bug fix.
  • Loading branch information
killa1218 committed Aug 27, 2018
2 parents cc864b3 + 6ff6c92 commit 68471ce
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/example/conflict/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# coding: utf-8

""" Package used to test YAML file conflicting.
"""

from .foo import Foo

__all__ = ['Foo']
170 changes: 170 additions & 0 deletions tests/example/conflict/foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# coding: utf-8

""" Docstring of :mod:`conflict.foo` module.
"""

foo_var = []
""" Docstring of module variable :any:`conflict.foo.foo_var`."""


def function(arg1, arg2, arg3, arg4):
""" Docstring of :func:`conflict.foo.function` function.
:param int arg1: Parameter arg1 of :func:`~conflict.foo.function`.
:param float arg2: Parameter arg2 of :func:`~conflict.foo.function`.
:param boolean arg3: Parameter arg3 of :func:`~conflict.foo.function`.
:param str arg4: Parameter arg4 of :func:`~conflict.foo.function`.
"""
pass


class Foo(object):
""" Docstring of :class:`conflict.foo.Foo` class in rst format.
:var attr: Docstring of :class:`conflict.foo.Foo.attr` from class docstring.
:vartype attr: ~conflict.enum.EnumFoo
:param init_arg1: Parameter init_arg1 from class docstring.
:type init_arg1: float
:param list[int] init_arg2: Parameter init_arg2 from class docstring.
"""

attr = 1
""" Docstring of :class:`conflict.foo.Foo.attr` from attrbute docstring."""

def __init__(self, init_arg1, init_arg2):
""" Docstring of constructor of Foo. Will not be shown.
:param init_arg1: Parameter init_arg1 from constructor's docstring.
:type init_arg1: float
:param list[int] init_arg2: Parameter init_arg2 from constructor's docstring.
"""

@property
def attr_getter(self):
""" Docstring of :meth:`conflict.foo.Foo.attr_getter` @property.
"""
return self.attr

@classmethod
def class_method(cls, arg1):
""" Docstring of :class:`conflict.foo.Foo.class_method` @classmethod.
:param cls: Class object of :class:`conflict.foo.Foo`.
:type cls: class
:param str arg1: Parameter arg1 of :meth:`conflict.foo.Foo.class_method`.
"""
pass

@staticmethod
def static_method():
""" Docstring of :meth:`conflict.foo.Foo.static_method` @staticmethod.
"""
pass

def method(self):
""" Docstring of normal class method :meth:`conflict.foo.Foo.method`.
"""
pass

def method_return(self):
""" Docstring of :meth:`conflict.foo.Foo.method_return`.
:return: This method returns a value.
:rtype: boolean
"""
return False

def method_multiline(self):
""" Docstring of :meth:`conflict.foo.Foo.method_multiline`.
This docstring has multiple lines of contents.
And this should work perfectly.
"""
pass

def method_exception(self):
""" Docstring of :meth:`conflict.foo.Foo.method_exception`.
:raises: :class:`Exception` This function raises
exception.
"""
raise Exception()

def method_external_link(self):
""" Docstring of :meth:`conflict.foo.Foo.method_external_link`.
Inline link should be transformed to markdown: `Link Text <http://inline.external.link>`_.
And seperated link will fail: `Seperated Link`_
.. _Seperated Link: http://seperated.external.link
"""
pass

def method_seealso(self):
""" Docstring of :meth:`conflict.foo.Foo.method_seealso`.
.. seealso::
Seealso contents.
Multi-line should be supported.
And reference to :class:`conflict.foo.Foo` should be okay.
"""
pass

def method_note(self):
""" Docstring of :meth:`conflict.foo.Foo.method_note`.
.. note::
This is content of note.
Another line of note contents.
"""
pass

def method_warning(self):
""" Docstring of :meth:`conflict.foo.Foo.method_warning`.
.. warning::
This is content of warning.
"""
pass

def method_code(self):
""" Docstring of :meth:`conflict.foo.Foo.method_code`.
.. code-block:: python
>>> import numpy as np
>>> a = np.ndarray([1,2,3,4,5])
Another way of code block::
import numpy as np
b = np.random.random(10)
"""
pass

def method_example(self):
""" Docstring of :meth:`conflict.foo.Foo.method_example`.
.. admonition::
This is Example content.
Should support multi-line.
Can also include file:
.. literalinclude:: ../format/rst/enum.py
"""
pass

def method_default_value(self, arg1='default string', arg2=None):
""" Docstring of :meth:`conflict.foo.Foo.method_default_value`.
:param str arg1: Parameter arg1 of :meth:`conflict.foo.Foo.method_default_value`, default value is 'default string'.
:param object arg2: Paremeter arg2 of :meth:`conflict.foo.Foo.method_default_value` default value is None.
"""
pass

def method_default_value_comma(self, arg1=(1,2,3)):
""" Docstring of :meth:`conflict.foo.Foo.method_default_value_comma`.
The default value of method parameter contains comma thus will fail to parse.
:param tuple arg1: Parameter arg1 of :meth:`conflict.foo.Foo.method_default_value_comma`, default value is (1,2,3).
"""
pass
2 changes: 1 addition & 1 deletion tests/example/format/rst/foo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def function(arg1, arg2, arg3, arg4):
class Foo(object):
""" Docstring of :class:`format.rst.foo.Foo` class in rst format.
:ivar attr: Docstring of :class:`format.rst.foo.Foo.attr` from class docstring.
:var attr: Docstring of :class:`format.rst.foo.Foo.attr` from class docstring.
:vartype attr: ~format.rst.enum.EnumFoo
:param init_arg1: Parameter init_arg1 from class docstring.
Expand Down

0 comments on commit 68471ce

Please sign in to comment.