Skip to content

API

Mkdocstrings Documentation

Google-Style format

--Module-level docstring--

This module allows the user to make mathematical calculations.

Examples:

>>> from calculator import calculations
>>> calculations.add(2, 4)
6.0
>>> calculations.multiply(2.0, 4.0)
8.0
>>> from calculator.calculations import divide
>>> divide(4.0, 2)
2.0

The module contains the following functions:

  • add(a, b) - Returns the sum of two numbers.
  • subtract(a, b) - Returns the difference of two numbers.
  • multiply(a, b) - Returns the product of two numbers.
  • divide(a, b) - Returns the quotient of two numbers.

MyClass

--Class-level docstring--

Source code in element_array_ephys/docstring_example.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class MyClass:
    """--Class-level docstring--"""

    def method_a(self):
        """Print A!"""
        print("A!")

    def method_b(self):
        """Print B!"""
        print("B!")

    def method_c(self):
        """Print C!"""
        print("C!")

method_a()

Print A!

Source code in element_array_ephys/docstring_example.py
50
51
52
def method_a(self):
    """Print A!"""
    print("A!")

method_b()

Print B!

Source code in element_array_ephys/docstring_example.py
54
55
56
def method_b(self):
    """Print B!"""
    print("B!")

method_c()

Print C!

Source code in element_array_ephys/docstring_example.py
58
59
60
def method_c(self):
    """Print C!"""
    print("C!")

add(a, b)

--Function-level docstring--

Compute and return the sum of two numbers.

Examples:

>>> add(4.0, 2.0)
6.0
>>> add(4, 2)
6.0

Parameters:

Name Type Description Default
a Union[float, int]

A number representing the first addend in the addition.

required
b Union[float, int]

A number representing the second addend in the addition.

required

Returns:

Type Description
float

A number representing the artihmetic sum of a and b.

Source code in element_array_ephys/docstring_example.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def add(a: Union[float, int], b: Union[float, int]) -> float:
    """--Function-level docstring--

    Compute and return the sum of two numbers.

    Examples:
        >>> add(4.0, 2.0)
        6.0
        >>> add(4, 2)
        6.0

    Args:
        a: A number representing the first addend in the addition.
        b: A number representing the second addend in the addition.

    Returns:
        A number representing the artihmetic sum of `a` and `b`.
    """
    return float(a + b)