Return a dict with type, name, doc and nested doc (if any).

def _doc_object(obj, obj_type, nest=None, config=default_config):
    """Return a dict with type, name, doc and nested doc (if any)."""
    doc = inspect.getdoc(obj)

    if not doc and not nest:
        return None

    result = {
        'type': obj_type,
        'name': obj.__name__,
        'doc': doc
    }

    if nest:
        result['nest'] = nest

    return result