2013-11-04 11:39:37 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-11-05 08:37:01 +08:00
|
|
|
"""Test Module for sphinx_rtd_theme."""
|
2013-11-04 11:39:37 +08:00
|
|
|
|
2013-11-05 23:32:48 +08:00
|
|
|
|
2013-11-04 11:39:37 +08:00
|
|
|
class Foo:
|
2013-11-05 08:37:01 +08:00
|
|
|
|
|
|
|
r"""Docstring for class Foo.
|
|
|
|
|
|
|
|
This text tests for the formatting of docstrings generated from output
|
|
|
|
``sphinx.ext.autodoc``. Which contain reST, but sphinx nests it in the
|
|
|
|
``<dl>``, and ``<dt>`` tags. Also, ``<tt>`` is used for class, method names
|
|
|
|
and etc, but those will *always* have the ``.descname`` or
|
|
|
|
``.descclassname`` class.
|
|
|
|
|
|
|
|
Normal ``<tt>`` (like the <tt> I just wrote here) needs to be shown with
|
|
|
|
the same style as anything else with ````this type of markup````.
|
|
|
|
|
|
|
|
It's common for programmers to give a code example inside of their
|
|
|
|
docstring::
|
|
|
|
|
|
|
|
from test_py_module import Foo
|
|
|
|
|
|
|
|
myclass = Foo()
|
|
|
|
myclass.dothismethod('with this argument')
|
|
|
|
myclass.flush()
|
|
|
|
|
|
|
|
print(myclass)
|
|
|
|
|
2015-04-23 04:39:19 +08:00
|
|
|
|
|
|
|
Here is a link to :py:meth:`capitalize`.
|
|
|
|
Here is a link to :py:meth:`__init__`.
|
|
|
|
|
2013-11-05 08:37:01 +08:00
|
|
|
"""
|
2013-11-04 11:39:37 +08:00
|
|
|
|
|
|
|
#: Doc comment for class attribute Foo.bar.
|
|
|
|
#: It can have multiple lines.
|
|
|
|
bar = 1
|
|
|
|
|
|
|
|
flox = 1.5 #: Doc comment for Foo.flox. One line only.
|
|
|
|
|
|
|
|
baz = 2
|
|
|
|
"""Docstring for class attribute Foo.baz."""
|
|
|
|
|
2013-11-04 12:32:22 +08:00
|
|
|
def __init__(self, qux, spam=False):
|
|
|
|
"""Start the Foo.
|
|
|
|
|
|
|
|
:param qux: The first argument to initialize class.
|
|
|
|
:type qux: string
|
|
|
|
:param spam: Spam me yes or no...
|
|
|
|
:type spam: bool
|
|
|
|
|
|
|
|
"""
|
2013-11-04 11:39:37 +08:00
|
|
|
#: Doc comment for instance attribute qux.
|
|
|
|
self.qux = 3
|
|
|
|
|
|
|
|
self.spam = 4
|
|
|
|
"""Docstring for instance attribute spam."""
|
2013-11-04 11:44:47 +08:00
|
|
|
|
|
|
|
def add(self, val1, val2):
|
|
|
|
"""Return the added values.
|
|
|
|
|
|
|
|
:param val1: First number to add.
|
|
|
|
:type val1: int
|
|
|
|
:param val2: Second number to add.
|
|
|
|
:type val2: int
|
|
|
|
:rtype: int
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return val1 + val2
|
|
|
|
|
|
|
|
def capitalize(self, myvalue):
|
|
|
|
"""Return a string as uppercase.
|
|
|
|
|
|
|
|
:param myvalue: String to change
|
|
|
|
:type myvalue: string
|
|
|
|
:rtype: string
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return myvalue.upper()
|
2013-11-06 03:10:39 +08:00
|
|
|
|
|
|
|
def another_function(self, a, b, **kwargs):
|
|
|
|
"""
|
|
|
|
Here is another function.
|
|
|
|
|
|
|
|
:param a: The number of green hats you own.
|
|
|
|
:type a: int
|
|
|
|
|
|
|
|
:param b: The number of non-green hats you own.
|
|
|
|
:type b: int
|
|
|
|
|
|
|
|
:param kwargs: Additional keyword arguments. Each keyword parameter
|
|
|
|
should specify the name of your favorite cuisine.
|
|
|
|
The values should be floats, specifying the mean price
|
|
|
|
of your favorite dish in that cooking style.
|
|
|
|
:type kwargs: float
|
|
|
|
|
|
|
|
:returns: A 2-tuple. The first element is the mean price of all dishes
|
|
|
|
across cuisines. The second element is the total number of
|
|
|
|
hats you own: :math:`a + b`.
|
|
|
|
:rtype: tuple
|
|
|
|
|
|
|
|
:raises ValueError: When ``a`` is not an integer.
|
|
|
|
|
|
|
|
"""
|
|
|
|
return sum(kwargs.values()) / len(kwargs), a + b
|