Module Import alias ImportFrom alias ImportFrom alias alias alias alias Assign NameStore Call AttributeLoad NameLoad attr Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str TryExcept body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr IfExp CompareIs NameLoad NameLoad Dict NameLoad Assign AttributeStore NameLoad attr ListLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Num Expr Call AttributeLoad NameLoad attr While UnaryOpNot AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad orelse AugAssignAdd AttributeStore NameLoad attr Num Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str Assign NameStore Call AttributeLoad Str attr TupleLoad Str NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad Str attr NameLoad Assign NameStore ListLoad AugAssignAdd NameStore ListLoad NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore IfExp CompareIs NameLoad NameLoad NameLoad NameLoad Assign NameStore AttributeLoad NameLoad attr Assign NameStore ListLoad While BoolOpAnd UnaryOpNot AttributeLoad NameLoad attr BoolOpOr Call NameLoad Call AttributeLoad NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr Num body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Assign NameStore ListComp Call AttributeLoad NameLoad attr NameLoad comprehension NameStore NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore BinOpAdd Call NameLoad NameLoad Str Assign NameStore ListLoad NameLoad While UnaryOpNot AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num If BoolOpOr BoolOpAnd Call NameLoad NameLoad UnaryOpNot Call AttributeLoad NameLoad attr NameLoad BoolOpAnd UnaryOpNot Call NameLoad NameLoad UnaryOpNot Call AttributeLoad NameLoad attr NameLoad body Break orelse Assign NameStore Call AttributeLoad NameLoad attr AugAssignAdd NameStore ListLoad Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If AttributeLoad NameLoad attr body Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Str Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Str NameLoad If BoolOpOr CompareEq Call AttributeLoad Call AttributeLoad NameLoad attr attr NameLoad CompareEq Call AttributeLoad Call AttributeLoad NameLoad attr attr NameLoad body Return Call AttributeLoad NameLoad attr orelse Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr For NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad AugAssignAdd AttributeStore NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr For NameStore SubscriptLoad NameLoad Slice AttributeLoad NameLoad attr body If UnaryOpNot Call NameLoad NameLoad body Break AugAssignAdd AttributeStore NameLoad attr Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad While BoolOpAnd UnaryOpNot AttributeLoad NameLoad attr UnaryOpNot Call NameLoad Call AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad AugAssignAdd AttributeStore NameLoad attr Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Num body Expr Str Assign NameStore AttributeLoad NameLoad attr Delete SubscriptDel NameLoad Slice NameLoad BinOpAdd NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Assign AttributeStore NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Assign NameStore BinOpAdd AttributeLoad NameLoad attr NameLoad TryExcept body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad handlers ExceptHandler type NameLoad body Assign NameStore Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore IfExp CompareIs NameLoad NameLoad AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return CompareGtE AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list NameLoad decorator_list
N/A N/A re definition_items DefinitionItem line_functions is_empty get_indent fix_backspace NEW_LINE N/A underline_regex N/A N/A re compile \s*\S+\s*\Z BaseDoc N/A object N/A N/A Base abstract docstring refactoring class.

    The class' main purpose is to parse the dosctring and find the
    sections that need to be refactored. Subclasses should provide
    the methods responsible for refactoring the sections.

    Attributes
    ----------
    docstring : list
        A list of strings (lines) that holds docstrings

    index : int
        The current zero-based line number of the docstring that is currently
        proccessed.

    headers : dict
        The sections that the class refactors. Each entry in the
        dictionary should have as key the name of the section in the
        form that it appears in the docstrings. The value should be
        the postfix of the method, in the subclasses, that is
        responsible for refactoring (e.g. {'Methods': 'method'}).

    BaseDoc also provides a number of methods that operate on the docstring to
    help with the refactoring. This is neccessary because the docstring has to
    change inplace and thus it is better to live the docstring manipulation to
    the class methods instead of accessing the lines directly.

     __init__ N/A N/A self lines headers N/A None N/A N/A  Initialize the class

        The method setups the class attributes and starts parsing the
        docstring to find and refactor the sections.

        Arguments
        ---------
        lines : list of strings
            The docstring to refactor

        headers : dict
            The sections for which the class has custom refactor methods.
            Each entry in the dictionary should have as key the name of
            the section in the form that it appears in the docstrings.
            The value should be the postfix of the method, in the
            subclasses, that is responsible for refactoring (e.g.
            {'Methods': 'method'}).

         N/A N/A N/A N/A self _docstring N/A N/A lines splitlines N/A N/A N/A AttributeError N/A N/A N/A self _docstring lines N/A N/A self headers N/A N/A headers None N/A headers N/A N/A self bookmarks N/A N/A parse N/A N/A self N/A N/A N/A  Parse the docstring.

        The docstring is parsed for sections. If a section is found then
        the corresponding refactoring method is called.

         N/A N/A self index 0 N/A N/A N/A self seek_to_next_non_empty_line N/A N/A N/A self eod N/A N/A header N/A N/A self is_section N/A header N/A N/A N/A N/A self _refactor header N/A N/A N/A self index 1 N/A N/A N/A self seek_to_next_non_empty_line N/A _refactor N/A N/A self header N/A N/A N/A Call the heading refactor method.

        The header is removed from the docstring and the docstring
        refactoring is dispatched to the appropriate refactoring method.

        The name of the refctoring method is constructed using the form
        _refactor_<header>. Where <header> is the value corresponding to
        ``self.headers[header]``. If there is no custom method for the
        section then the self._refactor_header() is called with the
        found header name as input.

         N/A N/A N/A self remove_lines N/A self index 2 N/A N/A N/A self remove_if_empty N/A self index N/A refactor_postfix N/A N/A N/A self headers get header header N/A method_name N/A N/A join N/A _refactor_ refactor_postfix N/A method N/A getattr self method_name N/A lines N/A method header N/A N/A N/A self insert_and_move lines N/A self index N/A _refactor_header N/A N/A self header N/A N/A N/A  Refactor the header section using the rubric directive.

        The method has been tested and supports refactoring single word
        headers, two word headers and headers that include a backslash
        ''''.

        Arguments
        ---------
        header : string
            The header string to use with the rubric directive.

         N/A header N/A fix_backspace header N/A directive N/A N/A .. rubric:: {0} format header N/A lines N/A N/A lines N/A directive NEW_LINE N/A lines N/A extract_items N/A N/A self item_class N/A None N/A N/A  Extract the definition items from a docstring.

        Parse the items in the description of a section into items of the
        provided class time. Given a DefinitionItem or a subclass defined by
        the ``item_class`` parameter. Staring from the current index position,
        the method checks if in the next two lines a valid  header exists.
        If successful, then the lines that belong to the item description
        block (i.e. header + definition) are poped put from the docstring and
        passed to the ``item_class`` parser and create an instance of
        ``item_class``.

        The process is repeated until there is no compatible ``item_class``
        found or we run out of docstring. Then the method returns a list of
        item_class instances.

        The exit conditions allow for two valid section item layouts:

        1. No lines between items::

            <header1>
                <description1>

                <more description>
            <header2>
                <description2>

        2. One line between items::

            <header1>
                <description1>

                <more description>

            <header2>
                <description2>


        Arguments
        ---------
        item_class : DefinitionItem
            A DefinitionItem or a subclass. This argument is used to check
            if a line in the docstring is a valid item and to parse the
            individual list items in the section. When ``None`` (default) the
            base DefinitionItem class is used.


        Returns
        -------
        parameters : list
            List of the parsed item instances of ``item_class`` type.

         N/A item_type N/A N/A item_class None DefinitionItem item_class N/A is_item N/A item_type is_definition N/A item_blocks N/A N/A N/A N/A N/A self eod N/A N/A is_item N/A N/A self peek N/A is_item N/A N/A self peek 1 N/A N/A N/A N/A self remove_if_empty N/A self index N/A N/A N/A item_blocks append N/A N/A self get_next_block N/A items N/A N/A N/A item_type parse block N/A block item_blocks N/A items N/A get_next_block N/A N/A self N/A N/A N/A  Get the next item block from the docstring.

        The method reads the next item block in the docstring. The first line
        is assumed to be the DefinitionItem header and the following lines to
        belong to the definition::

            <header line>
                <definition>

        The end of the field is designated by a line with the same indent
        as the field header or two empty lines are found in sequence.

         N/A item_header N/A N/A self pop N/A sub_indent N/A N/A get_indent item_header N/A block N/A item_header N/A N/A N/A self eod N/A N/A peek_0 N/A N/A self peek N/A peek_1 N/A N/A self peek 1 N/A N/A N/A N/A is_empty peek_0 N/A N/A N/A peek_1 startswith sub_indent N/A N/A N/A is_empty peek_0 N/A N/A N/A peek_0 startswith sub_indent N/A N/A N/A N/A line N/A N/A self pop N/A block N/A N/A N/A line rstrip N/A block N/A is_section N/A N/A self N/A N/A N/A  Check if the current line defines a section.

        .. todo:: split and cleanup this method.

         N/A N/A self eod N/A N/A False N/A header N/A N/A self peek N/A line2 N/A N/A self peek 1 N/A underline N/A N/A underline_regex match line2 N/A N/A underline None N/A N/A False N/A striped_header N/A N/A header rstrip N/A expected_underline1 N/A N/A re sub [A-Za-z\\]|\b\s - striped_header N/A expected_underline2 N/A N/A re sub [A-Za-z\\]|\b\s = striped_header N/A N/A N/A N/A N/A N/A N/A underline group rstrip expected_underline1 N/A N/A N/A N/A N/A underline group rstrip expected_underline2 N/A N/A N/A N/A header strip N/A N/A False N/A insert_lines N/A N/A self lines index N/A N/A N/A  Insert refactored lines

        Arguments
        ---------
        new_lines : list
            The list of lines to insert

        index : int
            Index to start the insertion
         N/A docstring N/A self docstring N/A line N/A reversed lines N/A N/A N/A N/A docstring insert index line N/A insert_and_move N/A N/A self lines index N/A N/A N/A  Insert refactored lines and move current index to the end.

         N/A N/A N/A self insert_lines lines index N/A N/A self index N/A len lines N/A seek_to_next_non_empty_line N/A N/A self N/A N/A N/A  Goto the next non_empty line.

         N/A docstring N/A self docstring N/A line N/A docstring N/A N/A self index N/A N/A N/A N/A is_empty line N/A N/A N/A N/A self index 1 N/A get_next_paragraph N/A N/A self N/A N/A N/A  Get the next paragraph designated by an empty line.

         N/A lines N/A N/A N/A N/A N/A self eod N/A N/A is_empty N/A N/A self peek N/A N/A line N/A N/A self pop N/A N/A N/A lines append line N/A lines N/A read N/A N/A self N/A N/A N/A  Return the next line and advance the index.

         N/A index N/A self index N/A line N/A N/A self _docstring N/A index N/A N/A self index 1 N/A line N/A remove_lines N/A N/A self index count N/A 1 N/A N/A  Removes the lines from the docstring

         N/A docstring N/A self docstring N/A N/A docstring N/A index N/A index count N/A remove_if_empty N/A N/A self index N/A None N/A N/A  Remove the line from the docstring if it is empty.

         N/A N/A is_empty N/A N/A self docstring N/A index N/A N/A N/A N/A self remove_lines index N/A bookmark N/A N/A self N/A N/A N/A  append the current index to the end of the list of bookmarks.

         N/A N/A N/A N/A self bookmarks append N/A self index N/A goto_bookmark N/A N/A self bookmark_index N/A -1 N/A N/A  Move to bookmark.

        Move the current index to the  docstring line given my the
        ``self.bookmarks[bookmark_index]`` and  remove it fromn the bookmark
        list. Default value will pop the last entry.

        Returns
        -------
        bookmark : int

         N/A N/A self index N/A N/A self bookmarks N/A bookmark_index N/A N/A N/A N/A self bookmarks pop bookmark_index N/A peek N/A N/A self ahead N/A 0 N/A N/A  Peek ahead a number of lines

        The function retrieves the line that is ahead of the current
        index. If the index is at the end of the list then it returns an
        empty string.

        Arguments
        ---------
        ahead : int
            The number of lines to look ahead.


         N/A position N/A N/A self index ahead N/A N/A N/A line N/A N/A self docstring N/A position N/A N/A N/A IndexError N/A N/A line N/A line N/A pop N/A N/A self index N/A None N/A N/A  Pop a line from the dostrings.

         N/A index N/A N/A index None N/A self index index N/A N/A N/A N/A self _docstring pop index N/A eod N/A N/A self N/A N/A N/A  End of docstring.

         N/A N/A N/A self index N/A len N/A self docstring N/A property docstring N/A N/A self N/A N/A N/A  Get the docstring lines.

         N/A N/A self _docstring N/A property N/A