hammerlab / survivalstan

Library of Stan Models for Survival Analysis
Apache License 2.0
124 stars 23 forks source link

Clean up docstring formatting #59

Open jburos opened 7 years ago

jburos commented 7 years ago

Currently docstrings are in a variety of formats since I was testing out which could be rendered best by sphinx, to generate online documentation.

A todo item is to clean then up to apply consistent formatting. Now that we have the napoleon sphinx extension installed when generating docs, we can use Google-style docstrings. The older docstrings should be converted to a more legible style.

Style examples (from Napoleon's RTD site):

RST format

This is the "old" style, which we want to move away from.

:param path: The path of the file to wrap
:type path: str
:param field_storage: The :class:`FileStorage` instance to wrap
:type field_storage: FileStorage
:param temporary: Whether or not to delete the file when the File
   instance is destructed
:type temporary: bool
:returns: A buffered writable file descriptor
:rtype: BufferedFileStorage

Google style

This is one of the recommended styles, per Google's style guide.

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

    Extended description of function.

    Args:
        arg1 (int): Description of arg1
        arg2 (str): Description of arg2

    Returns:
        bool: Description of return value

    """
    return True

NumPy style

Another common & more legible style.

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

    Extended description of function.

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

    Returns
    -------
    bool
        Description of return value

    """
    return True