Skip to content

Commit d0460de

Browse files
committed
tests-sample-autodocs: adding sample set
Signed-off-by: James Knight <[email protected]>
1 parent bad8ad1 commit d0460de

File tree

7 files changed

+137
-0
lines changed

7 files changed

+137
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
sphinx.ext.autodocs
2+
===================
3+
4+
This page shows an example of various autodoc capabilities.
5+
6+
autodocs - automodule
7+
---------------------
8+
9+
The automodule directive:
10+
11+
.. automodule:: Hello
12+
:members:
13+
14+
----
15+
16+
The autoclass directive:
17+
18+
.. autoclass:: Hello
19+
:members: say_hello
20+
:noindex:
21+
22+
.. method:: foo(arg1, arg2)
23+
:noindex:
24+
25+
An overwritten description of the method ``foo``.
26+
27+
----
28+
29+
The autofunction directive:
30+
31+
.. currentmodule:: func
32+
33+
.. autofunction:: my_custom_function
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sphinx.ext.autosummary
2+
======================
3+
4+
An example of a local docstring:
5+
6+
.. autosummary::
7+
8+
Hello
9+
10+
An example of an external module docstring:
11+
12+
.. currentmodule:: sphinx
13+
14+
.. autosummary::
15+
16+
environment.BuildEnvironment
17+
util.relative_uri

tests/sample-sets/autodocs/conf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pathlib import Path
2+
import sys
3+
4+
5+
extensions = [
6+
'sphinx.ext.autodoc',
7+
'sphinx.ext.autosummary',
8+
'sphinxcontrib.confluencebuilder',
9+
]
10+
11+
12+
test_dir = Path(__file__).parent.resolve()
13+
src_dir = test_dir / 'src'
14+
sys.path.insert(0, str(src_dir))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Autodocs
2+
========
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
7+
autodocs
8+
autosummary
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
This is a module docstring
3+
"""
4+
5+
6+
class Hello:
7+
"""
8+
This is a Hello class docstring
9+
"""
10+
11+
def __init__(self, name, name2):
12+
"""
13+
This is an __init__ method docstring.
14+
Creates a new :class:`Hello` instance.
15+
:param name: name for the hello
16+
:param name2: name2 for the hello
17+
:param name3: name3 for the hello
18+
:type name: str
19+
"""
20+
self.name = name
21+
22+
def say_hello(self):
23+
"""
24+
This is a say_hello method decorator
25+
"""
26+
print('Hello %s' % self.name)
27+
28+
def foo(self, arg1, arg2):
29+
"""
30+
A method's docstring with parameters and return value.
31+
32+
Use all the cool Sphinx capabilities in this description, e.g. to give
33+
usage examples ...
34+
35+
:Example:
36+
37+
>>> another_class.foo('', AClass())
38+
39+
:param arg1: first argument
40+
:type arg1: string
41+
:param arg2: second argument
42+
:type arg2: :class:`module.AClass`
43+
:return: something
44+
:rtype: string
45+
:raises: TypeError
46+
"""
47+
return '' + 1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
def my_custom_function(obj):
3+
"""
4+
A function's docstring with a parameter.
5+
6+
:param obj: the function argument
7+
"""

tests/sample-sets/autodocs/tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tox]
2+
package_root={toxinidir}{/}..{/}..{/}..
3+
4+
[testenv]
5+
commands =
6+
{envpython} -m tests.test_sample {posargs}
7+
setenv =
8+
PYTHONDONTWRITEBYTECODE=1
9+
TOX_INI_DIR={toxinidir}
10+
passenv = *
11+
use_develop = true

0 commit comments

Comments
 (0)