import re


def get_main_desc(source):
    """
    Retrieves the main description of the provided object `source` and returns
    it.

    The main description is defined as the first paragraph of its docstring.

    Parameters
    ----------
    source : object
        The object whose main description must be retrieved.

    Returns
    -------
    main_desc : str or None
        The main description string of the provided `source` or *None* if
        `source` has not docstring.

    """

    # Retrieve the docstring of provided source
    doc = source.__doc__

    # If doc is None, return None
    if doc is None:
        return(None)

    # Obtain the index of the last character of the first paragraph
    index = doc.find('\n\n')

    # If index is -1, there is only 1 paragraph
    if(index == -1):
        index = len(doc)

    # Gather everything up to this index
    doc = doc[:index]

    # Replace all occurances of 2 or more whitespace characters by a space
    doc = re.sub(r"\s{2,}", ' ', doc)

    # Return doc
    return(doc.strip())