5. API documentation and generated content

5.1. test_py_module

Test Module for sphinx_rtd_theme.

class test_py_module.test.Foo(qux, spam=False)[source]

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.


It is also possible to include definitions inside docstrings. They should be styled as a normal definition list.

Field List:

It is also possible to include definitions inside docstrings. They should be styled as a normal definition list.


A citation contains body elements, consistently indented by at least 3 spaces.

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')


Here is a link to capitalize(). Here is a link to __init__().

__init__(qux, spam=False)[source]

Start the Foo.

  • qux (string) – The first argument to initialize class.

  • spam (bool) – Spam me yes or no…


list of weak references to the object (if defined)

add(val1, val2)[source]

Return the added values.

  • val1 (int) – First number to add.

  • val2 (int) – Second number to add.

Return type:


The parameters of this method are described in the parameter list.

another_function(a, b, **kwargs)[source]

Here is another function.

  • a (int) – The number of green hats you own.

  • b (int) – The number of non-green hats you own.

  • kwargs (float) – 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.


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: \(a + b\).

Return type:



ValueError – When a is not an integer.

New in version 1.0: This was added in 1.0

Changed in version 2.0: This was changed in 2.0

Deprecated since version 3.0: This is deprecated since 3.0

bar = 1

Doc comment for class attribute Foo.bar. It can have multiple lines.

baz = 2

Docstring for class attribute Foo.baz.


Return a string as uppercase.


myvalue (string) – String to change

Return type:


flox = 1.5

Doc comment for Foo.flox. One line only.


Doc comment for instance attribute qux.


Docstring for instance attribute spam.

test_py_module.test.add_numbers(a: int, b: int = 0) int[source]

Add two numbers together

  • a – The first number

  • b – The second number

Here is some more text.

test_py_module.test.subtract_numbers(a: int, b: int = 0) int[source]

Subtract two numbers

  • a – The first number

  • b – The second number

5.2. C++ API

type MyType

Some type

const MyType Foo(const MyType bar)

Some function type thing

template<typename T, std::size_t N>
class std::array

Some cpp class

float Sphinx::version

The description of Sphinx::version.

int version

The description of version.

typedef std::vector<int> List

The description of List type.

enum MyEnum

An unscoped enum.

enumerator A
enum class MyScopedEnum

A scoped enum.

enumerator B
protected enum struct MyScopedVisibilityEnum : std::underlying_type<MySpecificEnum>::type

A scoped enum with non-default visibility, and with a specified underlying type.

enumerator B

5.3. JavaScript API

class module_a.submodule.ModTopLevel()
  • Link to ModTopLevel()

class module_b.submodule.ModNested()

5.4. Generated Index

Part of the sphinx build process is to generate an index file: Index.

5.5. Optional parameter args

At this point optional parameters cannot be generated from code. However, some projects will manually do it, like so:

This example comes from django-payments module docs.

class payments.dotpay.DotpayProvider(seller_id, pin[, channel=0[, lock=False], lang='pl'])

This backend implements payments using a popular Polish gateway, Dotpay.pl.

Due to API limitations there is no support for transferring purchased items.

  • seller_id – Seller ID assigned by Dotpay

  • pin – PIN assigned by Dotpay

  • channel – Default payment channel (consult reference guide)

  • lang – UI language

  • lock – Whether to disable channels other than the default selected above

5.6. Data


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce congue elit eu hendrerit mattis.

Some data link Data_item_1.

5.7. Sphinx Extensions

5.7.1. sphinx.ext.autosummary

test_py_module.test.add_numbers(a[, b])

Add two numbers together

test_py_module.test.subtract_numbers(a[, b])

Subtract two numbers

test_py_module.test.Foo(qux[, spam])

Docstring for class Foo.