fml_doc_gen.generate_template

Attributes

Functions

generate_template(→ str)

Generates a formatted docstring template for a function based on its name, inputs, and output type.

Module Contents

fml_doc_gen.generate_template.DOCSTRING_TEMPLATE = Multiline-String
Show Value
"""
    {function_name}:
    ### INSERT FUNCTION DEFINITION HERE ###
    {function_parameters}
    {function_output}

    Examples:
    --------
    ### INSERT FUNCTION EXAMPLE USAGES HERE ###
"""
fml_doc_gen.generate_template.DOCSTRING_PARAMETERS_TEMPLATE = Multiline-String
Show Value
"""
    Parameters:
    ----------
    {function_params_str}
"""
fml_doc_gen.generate_template.DOCSTRING_PARAMETER_TEMPLATE = Multiline-String
Show Value
"""
    {param_name}: {param_type}
    ### INSERT PARAMETER DEFINITION HERE ###

"""
fml_doc_gen.generate_template.DOCSTRING_OUTPUT_TEMPLATE = Multiline-String
Show Value
"""
    Returns:
    -------
    {function_output_type}
        ### INSERT ADDITIONAL FUNCTION OUTPUT INFORMATION HERE ###
"""
fml_doc_gen.generate_template.DOCSTRING_PARAMETER_TYPE_PLACEHOLDER = '...'
fml_doc_gen.generate_template.generate_template(function_signature: fml_doc_gen.func_dto.FunctionDTO) str[source]

Generates a formatted docstring template for a function based on its name, inputs, and output type.

Parameters:

function_signature (FunctionDTO) – An object containing metadata about the function, including its name, input parameters, and output type. The inputs attribute should be a list of tuples where each tuple contains the name and type of a parameter.

Returns:

A string representing the generated docstring template for the function, formatted with placeholders for detailed parameter and return value descriptions.

Return type:

str

Raises:

ValueError – If the name attribute of the function_signature is empty.

Example

>>> function_signature = FunctionDTO(
...     name="add_numbers",
...     output="int",
...     inputs=[("a", "int"), ("b", "int")]
... )
>>> generate_template(function_signature)