示例#1
0
def format_endpoint_argument_doc(argument):
    """Return documentation about the argument that an endpoint accepts."""
    doc = argument.doc_dict()

    # Trim the strings a bit
    doc['description'] = py_doc_trim(doc['description'])
    details = doc.get('detailed_description', None)
    if details is not None:
        doc['detailed_description'] = py_doc_trim(details)

    return doc
示例#2
0
文件: doc.py 项目: awwright/pale
def format_endpoint_argument_doc(argument):
    """Return documentation about the argument that an endpoint accepts."""
    doc = argument.doc_dict()

    # Trim the strings a bit
    doc['description'] = py_doc_trim(doc['description'])
    details = doc.get('detailed_description', None)
    if details is not None:
        doc['detailed_description'] = py_doc_trim(details)

    return doc
示例#3
0
文件: doc.py 项目: awwright/pale
def format_endpoint_returns_doc(endpoint):
    """Return documentation about the resource that an endpoint returns."""
    description = py_doc_trim(endpoint._returns._description)
    return {
        'description': description,
        'resource_name': endpoint._returns._value_type,
        'resource_type': endpoint._returns.__class__.__name__
    }
示例#4
0
def format_endpoint_returns_doc(endpoint):
    """Return documentation about the resource that an endpoint returns."""
    description = py_doc_trim(endpoint._returns._description)
    return {
        'description': description,
        'resource_name': endpoint._returns._value_type,
        'resource_type': endpoint._returns.__class__.__name__
    }
示例#5
0
文件: doc.py 项目: awwright/pale
def document_endpoint(endpoint):
    """Extract the full documentation dictionary from the endpoint."""
    descr = 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)
    }
    return docs
示例#6
0
def document_endpoint(endpoint):
    """Extract the full documentation dictionary from the endpoint."""
    descr = 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)
    }
    return docs
示例#7
0
文件: doc.py 项目: awwright/pale
def document_resource(resource):
    field_doc = { name: field.doc_dict() for name, field \
            in resource._fields.iteritems() }

    res_doc = {
        'name': resource._value_type,
        'description': py_doc_trim(resource.__doc__),
        'fields': field_doc,
        'default_fields': None,
    }
    if resource._default_fields:
        res_doc['default_fields'] = list(resource._default_fields)
    return res_doc
示例#8
0
def document_resource(resource):
    field_doc = { name: field.doc_dict() for name, field \
            in resource._fields.iteritems() }

    res_doc = {
        'name': resource._value_type,
        'description': py_doc_trim(resource.__doc__),
        'fields': field_doc,
        'default_fields': None,
    }
    if resource._default_fields:
        res_doc['default_fields'] = list(resource._default_fields)
    return res_doc
示例#9
0
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
示例#10
0
def document_resource(resource):

    field_doc = {}

    for name, field in resource._fields.iteritems():
        doc_dict = field.doc_dict()
        if doc_dict.get("description") != None:
            doc_dict["description"] = clean_description(doc_dict["description"])
        if doc_dict.get("extended_description") != None:
            doc_dict["extended_description"] = clean_description(doc_dict["extended_description"])
        field_doc[name] = doc_dict

    res_doc = {
        'name': resource._value_type,
        'description': clean_description(py_doc_trim(resource.__doc__)),
        'fields': field_doc,
        'default_fields': None,
    }
    if resource._default_fields:
        res_doc['default_fields'] = list(resource._default_fields)
    return res_doc