Python Documentation Best Practices - BKJackson/BKJackson_Wiki GitHub Wiki

Sphinx intro guides

First Steps with Sphinx
Sphinx Syntax
An introduction to Sphinx and Read the Docs for Technical Writers

Example docstrings

Example NumPy Style Python Docstrings

Example from Hitchhiker's Guide link

def random_number_generator(arg1, arg2):
    """
    Summary line.

    Extended description of function.

    Parameters
    ----------
    arg1 : int
        Description of arg1
    arg2 : str
        Description of arg2

    Returns
    -------
    int
        Description of return value

    """
    return 42
class Template(object):
    '''
    Class for rendering templates.

    Usage example::

        >>> t = Template('somefile')
        >>> document = t.render(variables={'ID': 1234})

    Rendered document is always returned as a unicode string.
    '''

    def render(self, **args):
        '''
        Render template. Keyword arguments are passed `as-is` to renderer.
        '''