MyClass1
- class rtd_testing.MyClass1(a: float, b: float)[source]
A whatever-you-are-doing.
- 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.Refer to a class this way:
MyClass2
(except as a type indication, cf.update_b_from_class_2()
).Refer to a method this way:
addition()
.Refer to a method in another class:
MyClass2.addition()
.Refer to an attribute this way:
my_string
.Refer to a property this way:
a_square
.Refer to a parameter or variable this way: a.
Examples
>>> my_object = MyClass1(a=5, b=3)
- A_NICE_CONSTANT = 42
This is a nice constant.
- A_VERY_NICE_CONSTANT = 51
- 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