Reference

A Nice Section

class nice_package_of_fanfan.MyClass1(a: float, b: float)[source]

A whatever-you-are-doing.

Parameters:
  • a (float) – The a of the system. Must be non-negative.
  • b (float) – The b of the system.
my_string

A nice string.

Type:str
Raises:ValueError – If a is negative.

Notes

Document the __init__() method in the docstring of the class itself, because the docstring of the __init__() method does not appear in the documentation.

Examples

>>> my_object = MyClass1(a=5, b=3)
A_NICE_CONSTANT = 42

This is a nice constant.

A_VERY_NICE_CONSTANT = 51
a_square

The square of a.

addition() → float[source]

Add a and b.

Returns:The sum of a and b.
Return type:Number

Examples

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.addition()
8
divide_a_by_c_and_add_d(c: float, d: float) → float[source]

Divide a by something and add something else.

Parameters:
  • c (Number) – A non-zero number. You can say many things about this parameter in several indented lines, like this.
  • d (Number) – A beautiful number.
Returns:

The result of a / c + d.

Return type:

Number

Raises:

ZeroDivisionError – If c = 0.

Notes

This function gives an example of documentation with typical features.

Examples

We can write some text to explain the following example:

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.divide_a_by_c_and_add_d(c=2, d=10)
12.5

And we can explain a second example here:

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.divide_a_by_c_and_add_d(c=2, d=20)
22.5
update_b_from_class_2(object_of_class_2)[source]

Update b from a MyClass2 object.

Parameters:object_of_class_2 (MyClass2) –

An object from the other class. The purpose of this function is essentially to show how to document when an argument is an object of another class.

N.B.: for the type of an argument, you can enter only the name of the class, e.g. MyClass2. However, in the rest of the documentation, you must use the full syntax, like :class:`MyClass2`.

Examples

>>> my_object = MyClass1(a=5, b=3)
>>> my_object.update_b_from_class_2(MyClass2(42, 51))
>>> my_object.b
51

Another Nice Section

class nice_package_of_fanfan.MyClass2(a: float, b: float)[source]

A whatever-you-are-doing.

Parameters:
  • a (float) – The a of the system.
  • b (float) – The b of the system.

Examples

>>> my_object = MyClass2(a = 5, b = 3)
addition() → float[source]

Add a and b.

Returns:The sum of a and b.
Return type:Float

Examples

>>> my_object = MyClass2(a=5, b=3)
>>> my_object.addition()
8
class nice_package_of_fanfan.MyClass3(a: float, b: float)[source]

A whatever-you-are-doing.

Parameters:
  • a (float) – The a of the system.
  • b (float) – The b of the system.

Examples

>>> my_object = MyClass3(a = 5, b = 3)
addition() → float[source]

Add a and b.

Returns:The sum of a and b.
Return type:Float

Examples

>>> my_object = MyClass3(a=5, b=3)
>>> my_object.addition()
8