def document_endpoint(endpoint):
    """Extract the full documentation dictionary from the endpoint."""
    descr = clean_description(py_doc_trim(endpoint.__doc__))
    docs = {
        'name': endpoint._route_name,
        'http_method': endpoint._http_method,
        'uri': endpoint._uri,
        'description': descr,
        'arguments': extract_endpoint_arguments(endpoint),
        'returns': format_endpoint_returns_doc(endpoint),
    }
    if hasattr(endpoint, "_success"):
        docs["success"] = endpoint._success
    if hasattr(endpoint, "_requires_permission"):
        docs["requires_permission"] = endpoint._requires_permission
    return docs