src.amodule module

This module demonstrates a generic function with in-line comments for Sphinx auto documentation.

This module contains utility functions and classes to showcase how Sphinx autodoc can extract and format Python documentation.

Classes:

ExampleClass: A simple example class with methods.

Functions:

main(): Performs an example operation. calculate_sum(a, b): Returns the sum of two numbers. process_data(data): Processes a list of data items.

Examples

Basic usage of the module:

from src import amodule

# Call the main function
amodule.main()

# Use the calculator
result = amodule.calculate_sum(5, 3)
print(f"Result: {result}")
class src.amodule.ExampleClass(name: str, value: int = 0)[source]

Bases: object

An example class to demonstrate Sphinx documentation for classes.

This class provides basic functionality for demonstration purposes.

name

The name of the instance.

Type:

str

value

A numeric value associated with the instance.

Type:

int

Parameters:
  • name (str) – The name to assign to this instance.

  • value (int, optional) – Initial value. Defaults to 0.

Examples

Creating and using an ExampleClass instance:

>>> obj = ExampleClass("test", 42)
>>> obj.get_info()
'Name: test, Value: 42'
__init__(name: str, value: int = 0)[source]

Initialize the ExampleClass instance.

get_info() str[source]

Get formatted information about this instance.

Returns:

A formatted string containing the name and value.

Return type:

str

update_value(new_value: int) None[source]

Update the value attribute.

Parameters:

new_value (int) – The new value to set.

Raises:

TypeError – If new_value is not an integer.

src.amodule.main() None[source]

Main function to run the program.

This function demonstrates basic functionality and serves as an entry point for the module. It creates an example instance and performs some operations.

Returns:

None

Examples

>>> main()
src.amodule.calculate_sum(a: int | float, b: int | float) int | float[source]

Calculate the sum of two numbers.

This function adds two numeric values together and returns the result. It supports both integers and floating-point numbers.

Parameters:
  • a (Union[int, float]) – The first number to add.

  • b (Union[int, float]) – The second number to add.

Returns:

The sum of a and b.

Return type:

Union[int, float]

Examples

>>> calculate_sum(2, 3)
5
>>> calculate_sum(2.5, 1.5)
4.0
>>> calculate_sum(-1, 1)
0
src.amodule.process_data(data: List[int | float]) List[int | float] | None[source]

Process a list of numeric data.

This function takes a list of numbers and performs basic processing: - Filters out negative numbers - Multiplies each remaining number by 2

Parameters:

data (List[Union[int, float]]) – A list of numeric values to process.

Returns:

Processed list of numbers, or None if input is empty.

Return type:

Optional[List[Union[int, float]]]

Raises:

TypeError – If data is not a list or contains non-numeric values.

Examples

>>> process_data([1, 2, 3])
[2, 4, 6]
>>> process_data([1, -2, 3, -4, 5])
[2, 6, 10]
>>> process_data([])