typedargs/doc_parser.py
def parse_return(return_line, include_desc=False):
    """Parse a single return statement declaration.

    The valid types of return declarion are a Returns: section heading
    followed a line that looks like:
    type [format-as formatter]: description

    OR

    type [show-as (string | context)]: description sentence
    """

    ret_def, _colon, desc = return_line.partition(':')
    if _colon == "":
        raise ValidationError("Invalid return declaration in docstring, missing colon", declaration=ret_def)

    if not include_desc:
        desc = None

    if 'show-as' in ret_def:
        ret_type, _showas, show_type = ret_def.partition('show-as')
        ret_type = ret_type.strip()
        show_type = show_type.strip()

        if show_type not in ('string', 'context'):
            raise ValidationError("Unkown show-as formatting specifier", found=show_type, expected=['string', 'context'])

        if show_type == 'string':
            return ReturnInfo(None, str, True, desc)

        return ReturnInfo(None, None, False, desc)

    if 'format-as' in ret_def:
        ret_type, _showas, formatter = ret_def.partition('format-as')
        ret_type = ret_type.strip()
        formatter = formatter.strip()

        return ReturnInfo(ret_type, formatter, True, desc)

    return ReturnInfo(ret_def, None, True, desc)
def parse_return(return_line, include_desc=False):
    ret_def, _colon, desc = return_line.partition(':')
    if _colon == "":
        raise ValidationError("Invalid return declaration in docstring, missing colon", declaration=ret_def)

    if not include_desc:
        desc = None

    if 'show-as' in ret_def:
        ret_type, _showas, show_type = ret_def.partition('show-as')
        ret_type = ret_type.strip()
        show_type = show_type.strip()

        if show_type not in ('string', 'context'):
            raise ValidationError("Unkown show-as formatting specifier", found=show_type, expected=['string', 'context'])

        if show_type == 'string':
            return ReturnInfo(None, str, True, desc)

        return ReturnInfo(None, None, False, desc)

    if 'format-as' in ret_def:
        ret_type, _showas, formatter = ret_def.partition('format-as')
        ret_type = ret_type.strip()
        formatter = formatter.strip()

        return ReturnInfo(ret_type, formatter, True, desc)

    return ReturnInfo(ret_def, None, True, desc)
def parse_return ( return_line , include_desc = False ) : ret_def , _colon , desc = return_line . partition ( ':' ) if _colon == "" : raise ValidationError ( "Invalid return declaration in docstring, missing colon" , declaration = ret_def ) if not include_desc : desc = None if 'show-as' in ret_def : ret_type , _showas , show_type = ret_def . partition ( 'show-as' ) ret_type = ret_type . strip ( ) show_type = show_type . strip ( ) if show_type not in ( 'string' , 'context' ) : raise ValidationError ( "Unkown show-as formatting specifier" , found = show_type , expected = [ 'string' , 'context' ] ) if show_type == 'string' : return ReturnInfo ( None , str , True , desc ) return ReturnInfo ( None , None , False , desc ) if 'format-as' in ret_def : ret_type , _showas , formatter = ret_def . partition ( 'format-as' ) ret_type = ret_type . strip ( ) formatter = formatter . strip ( ) return ReturnInfo ( ret_type , formatter , True , desc ) return ReturnInfo ( ret_def , None , True , desc )
Parse a single return statement declaration.

    The valid types of return declarion are a Returns: section heading
    followed a line that looks like:
    type [format-as formatter]: description

    OR

    type [show-as (string | context)]: description sentence
Parse a single return statement declaration .