Autoappend Returns None to Sphinx Documentation

  autodoc, python, python-sphinx, sphinx, sphinx-napoleon

For module level functions, is there a way to auto generate content that frequently appears, namely ‘Returns: None’ , so that it wouldn’t be repeatedly written in many docstrings?

I’ve seen some formatting using napoleon_custom_sections, but that doesn’t seem to be my direct use case.

Example would be if the following generated documentation that contained a None Return or other specified addition to the base docstring:

def module_level_function(param1, param2=None, *args, **kwargs):
    """This is an example of a module level function.
    Args:
        param1 (int): The first parameter.
        param2 (Optional[str]): The second parameter. Defaults to None.
    """

Source: Python Questions

LEAVE A COMMENT