(title, text)
Re-formats ``text`` written in NumPy style documenting Parameters, Returns, Raises sections into
    explicit `:<param>:` style.

    Algorithm searches for the pattern:
    `<alpha_numeric_value> : <text>`
         `<text continued with indent>`
         `<text continued with indent>`
    Reformat to the following:
    `:<alpha_numeric_value>:`
         `<text>`
         `<text continued with indent>`
         `<text continued with indent>`


    :param title:
    :param text:
    :return: Reformatted text
Re-formats ``text`` written in NumPy style documenting Parameters, Returns, Raises sections into
    explicit `:<param>:` style.
Re - formats text written in NumPy style documenting Parameters Returns Raises sections into explicit : <param > : style .
def reformat_pandas_params(title, text):
    """
    Re-formats ``text`` written in NumPy style documenting Parameters, Returns, Raises sections into
    explicit `:<param>:` style.

    Algorithm searches for the pattern:
    `<alpha_numeric_value> : <text>`
         `<text continued with indent>`
         `<text continued with indent>`
    Reformat to the following:
    `:<alpha_numeric_value>:`
         `<text>`
         `<text continued with indent>`
         `<text continued with indent>`


    :param title:
    :param text:
    :return: Reformatted text
    """

    # Internal function. Returns correct markup for :param <param>:, :return:, and :raises <exception>:
    def _get_param_text(title, param):
        title = title.strip()
        if title == 'Parameters':
            return ':param ' + param + ':'
        elif title == 'Return' or title == 'Returns':
            return ':return:'
        elif title == 'Raises':
            return ':raises:'

    # Internal function. Returns correct markup for Parameters section
    def _reformat_parameters(title, text):
        lines = text.split('\n')
        new_text = ''

        if len(lines) == 0:
            return new_text

        indent = get_indent(text)
        param = ''
        description = ''
        while len(lines) > 0:
            line = lines[0]
            line = line.strip()
            idx = line.find(' : ')
            if idx >= 0 & line[0:idx].isalnum() and line[0:idx].isidentifier():
                # Check if previous parameter existed. If so, need to add it to reformatted text
                if param != '':
                    new_text += _get_param_text(title, param) + '\n' + reindent(description, indent+4) + '\n'

                # Found parameter. Extract the description (can be multi-line)
                param = line[0:idx]
                description = line[idx+3:] + '\n'
                lines.pop(0)
            else:
                # There is no parameter description starting in this line.
                # Check if it is continuation of parameter description from previous lines
                if param != '':
                    # It is continuation of multi-line parameter description
                    description += reindent(line, indent+4) + '\n'
                else:
                    # This is not the description of parameter. Copy as is
                    new_text += reindent(line, indent) + '\n'
                lines.pop(0)

        if param != '' and description != '':
            new_text += _get_param_text(title, param) + '\n' + reindent(description, indent+4) + '\n'
        return new_text

    # Internal function. Returns correct markup for Raises section
    def _reformat_raises(title, text):
        lines = text.split('\n')
        new_text = ''

        if len(lines) == 0:
            return new_text

        indent = get_indent(text)
        param = ''
        description = ''
        while len(lines) > 0:
            line = lines[0]
            line = line.strip()

            # Check if it is continuation of parameter description from previous lines
            if param != '':
                # It is continuation of multi-line parameter description
                description += reindent(line, indent + 8) + '\n'
            else:
                # This is the first line of ``raises`` description
                param = _get_param_text(title, '') + '\n' + reindent(line, indent + 4)
                new_text += param + '\n'
            lines.pop(0)

        if param != '' and description != '':
            new_text += reindent(description, indent + 8) + '\n'
        return new_text + '\n'

    # Internal function. Returns correct markup for Returns section
    def _reformat_returns(title, text):
        lines = text.split('\n')
        new_text = ''

        if len(lines) == 0:
            return new_text

        indent = get_indent(text)
        param = ''
        description = ''
        while len(lines) > 0:
            line = lines[0]
            line = line.strip()

            # Check if it is continuation of parameter description from previous lines
            if param != '':
                # It is continuation of multi-line parameter description
                description += reindent(line, indent + 4) + '\n'
            else:
                # This is the first line of ``return`` description
                param = _get_param_text(title, '') + ' ' + line
                new_text += reindent(param, indent) + '\n'
            lines.pop(0)

        if param != '' and description != '':
            new_text += reindent(description, indent + 4) + '\n'
        return new_text + '\n'

    if title.strip() == 'Parameters':
        return _reformat_parameters(title, text)
    elif title.strip() == 'Returns' or title.strip() == 'Return':
        return _reformat_returns(title, text)
    elif title.strip() == 'Raises':
        return _reformat_raises(title, text)
    else:
        return text
def reformat_pandas_params ( title , text ) : # Internal function. Returns correct markup for :param <param>:, :return:, and :raises <exception>: def _get_param_text ( title , param ) : title = title . strip ( ) if title == 'Parameters' : return ':param ' + param + ':' elif title == 'Return' or title == 'Returns' : return ':return:' elif title == 'Raises' : return ':raises:' # Internal function. Returns correct markup for Parameters section def _reformat_parameters ( title , text ) : lines = text . split ( '\n' ) new_text = '' if len ( lines ) == 0 : return new_text indent = get_indent ( text ) param = '' description = '' while len ( lines ) > 0 : line = lines [ 0 ] line = line . strip ( ) idx = line . find ( ' : ' ) if idx >= 0 & line [ 0 : idx ] . isalnum ( ) and line [ 0 : idx ] . isidentifier ( ) : # Check if previous parameter existed. If so, need to add it to reformatted text if param != '' : new_text += _get_param_text ( title , param ) + '\n' + reindent ( description , indent + 4 ) + '\n' # Found parameter. Extract the description (can be multi-line) param = line [ 0 : idx ] description = line [ idx + 3 : ] + '\n' lines . pop ( 0 ) else : # There is no parameter description starting in this line. # Check if it is continuation of parameter description from previous lines if param != '' : # It is continuation of multi-line parameter description description += reindent ( line , indent + 4 ) + '\n' else : # This is not the description of parameter. Copy as is new_text += reindent ( line , indent ) + '\n' lines . pop ( 0 ) if param != '' and description != '' : new_text += _get_param_text ( title , param ) + '\n' + reindent ( description , indent + 4 ) + '\n' return new_text # Internal function. Returns correct markup for Raises section def _reformat_raises ( title , text ) : lines = text . split ( '\n' ) new_text = '' if len ( lines ) == 0 : return new_text indent = get_indent ( text ) param = '' description = '' while len ( lines ) > 0 : line = lines [ 0 ] line = line . strip ( ) # Check if it is continuation of parameter description from previous lines if param != '' : # It is continuation of multi-line parameter description description += reindent ( line , indent + 8 ) + '\n' else : # This is the first line of ``raises`` description param = _get_param_text ( title , '' ) + '\n' + reindent ( line , indent + 4 ) new_text += param + '\n' lines . pop ( 0 ) if param != '' and description != '' : new_text += reindent ( description , indent + 8 ) + '\n' return new_text + '\n' # Internal function. Returns correct markup for Returns section def _reformat_returns ( title , text ) : lines = text . split ( '\n' ) new_text = '' if len ( lines ) == 0 : return new_text indent = get_indent ( text ) param = '' description = '' while len ( lines ) > 0 : line = lines [ 0 ] line = line . strip ( ) # Check if it is continuation of parameter description from previous lines if param != '' : # It is continuation of multi-line parameter description description += reindent ( line , indent + 4 ) + '\n' else : # This is the first line of ``return`` description param = _get_param_text ( title , '' ) + ' ' + line new_text += reindent ( param , indent ) + '\n' lines . pop ( 0 ) if param != '' and description != '' : new_text += reindent ( description , indent + 4 ) + '\n' return new_text + '\n' if title . strip ( ) == 'Parameters' : return _reformat_parameters ( title , text ) elif title . strip ( ) == 'Returns' or title . strip ( ) == 'Return' : return _reformat_returns ( title , text ) elif title . strip ( ) == 'Raises' : return _reformat_raises ( title , text ) else : return text