(self)
return elem_list
Parses the input file's content and generates a list of its elements/docstrings.

        :returns: the list of elements
Parses the input file's content and generates a list of its elements/docstrings.
Parses the input file s content and generates a list of its elements / docstrings .
def _parse(self):
        """Parses the input file's content and generates a list of its elements/docstrings.

        :returns: the list of elements

        """
        #TODO manage decorators
        #TODO manage default params with strings escaping chars as (, ), ', ', #, ...
        #TODO manage elements ending with comments like: def func(param): # blabla
        elem_list = []
        reading_element = None
        reading_docs = None
        waiting_docs = False
        elem = ''
        raw = ''
        start = 0
        end = 0
        before_lim = ""

        try:
            if self.input_file == '-':
                fd = sys.stdin
            else:
                fd = open(self.input_file)

            self.input_lines = fd.readlines()

            if self.input_file != '-':
                fd.close()

        except IOError:
            msg = BaseException('Failed to open file "' + self.input_file + '". Please provide a valid file.')
            raise msg
        for i, ln in enumerate(self.input_lines):
            l = ln.strip()
            if reading_element:
                elem += l
                if l.endswith(':'):
                    reading_element = 'end'
            elif (l.startswith('async def ') or l.startswith('def ') or l.startswith('class ')) and not reading_docs:
                if self.ignore_private and l[l.find(' '):].strip().startswith("__"):
                    continue
                reading_element = 'start'
                elem = l
                m = re.match(r'^(\s*)[adc]', ln)  # a for async, d for def, c for class
                if m is not None and m.group(1) is not None:
                    spaces = m.group(1)
                else:
                    spaces = ''
                # the end of definition should be ':' and eventually a comment following
                # FIXME: but this is missing eventually use of # inside a string value of parameter
                if re.search(r''':(|\s*#[^'"]*)$''', l):
                    reading_element = 'end'
            if reading_element == 'end':
                reading_element = None
                # if currently reading an element content
                waiting_docs = True
                # *** Creates the DocString object ***
                e = DocString(elem.replace('\n', ' '), spaces, quotes=self.quotes,
                              input_style=self.input_style,
                              output_style=self.output_style,
                              first_line=self.first_line,
                              **self.kwargs)
                elem_list.append({'docs': e, 'location': (-i, -i)})
            else:
                if waiting_docs and ('"""' in l or "'''" in l):
                    # not docstring
                    if not reading_docs and not (
                            l[:3] in ['"""', "'''"] or
                            (l[0] in ['r', 'u', 'f'] and l[1:4] in ['"""', "'''"]) or
                            (l[0] in ['r', 'u', 'f'] and l[1] in ['r', 'u', 'f'] and l[2:5] in ['"""', "'''"])
                    ):
                        waiting_docs = False
                    # start of docstring bloc
                    elif not reading_docs:
                        start = i
                        # determine which delimiter
                        idx_c = l.find('"""')
                        idx_dc = l.find("'''")
                        lim = '"""'
                        if idx_c >= 0 and idx_dc >= 0:
                            if idx_c < idx_dc:
                                lim = '"""'
                            else:
                                lim = "'''"
                        elif idx_c < 0:
                            lim = "'''"
                        reading_docs = lim
                        # check if the docstring starts with 'r', 'u', or 'f' or combination thus extract it
                        if not l.startswith(lim):
                            idx_strip_lim = l.find(lim)
                            idx_abs_lim = ln.find(lim)
                            # remove and keep the prefix r|f|u
                            before_lim = l[:idx_strip_lim]
                            ln = ln[:idx_abs_lim-idx_strip_lim]+ln[idx_abs_lim:]
                        raw = ln
                        # one line docstring
                        if l.count(lim) == 2:
                            end = i
                            elem_list[-1]['docs'].parse_docs(raw, before_lim)
                            elem_list[-1]['location'] = (start, end)
                            reading_docs = None
                            waiting_docs = False
                            reading_element = False
                            raw = ''
                    # end of docstring bloc
                    elif waiting_docs and lim in l:
                        end = i
                        raw += ln
                        elem_list[-1]['docs'].parse_docs(raw, before_lim)
                        elem_list[-1]['location'] = (start, end)
                        reading_docs = None
                        waiting_docs = False
                        reading_element = False
                        raw = ''
                    # inside a docstring bloc
                    elif waiting_docs:
                        raw += ln
                # no docstring found for current element
                elif waiting_docs and l != '' and reading_docs is None:
                    waiting_docs = False
                else:
                    if reading_docs is not None:
                        raw += ln
        if self.convert_only:
            i = 0
            while i < len(elem_list):
                if elem_list[i]['docs'].get_input_docstring() is None:
                    elem_list.pop(i)
                else:
                    i += 1
        self.docs_list = elem_list

        self.parsed = True
        return elem_list
def _parse ( self ) : #TODO manage decorators #TODO manage default params with strings escaping chars as (, ), ', ', #, ... #TODO manage elements ending with comments like: def func(param): # blabla elem_list = [ ] reading_element = None reading_docs = None waiting_docs = False elem = '' raw = '' start = 0 end = 0 before_lim = "" try : if self . input_file == '-' : fd = sys . stdin else : fd = open ( self . input_file ) self . input_lines = fd . readlines ( ) if self . input_file != '-' : fd . close ( ) except IOError : msg = BaseException ( 'Failed to open file "' + self . input_file + '". Please provide a valid file.' ) raise msg for i , ln in enumerate ( self . input_lines ) : l = ln . strip ( ) if reading_element : elem += l if l . endswith ( ':' ) : reading_element = 'end' elif ( l . startswith ( 'async def ' ) or l . startswith ( 'def ' ) or l . startswith ( 'class ' ) ) and not reading_docs : if self . ignore_private and l [ l . find ( ' ' ) : ] . strip ( ) . startswith ( "__" ) : continue reading_element = 'start' elem = l m = re . match ( r'^(\s*)[adc]' , ln ) # a for async, d for def, c for class if m is not None and m . group ( 1 ) is not None : spaces = m . group ( 1 ) else : spaces = '' # the end of definition should be ':' and eventually a comment following # FIXME: but this is missing eventually use of # inside a string value of parameter if re . search ( r''':(|\s*#[^'"]*)$''' , l ) : reading_element = 'end' if reading_element == 'end' : reading_element = None # if currently reading an element content waiting_docs = True # *** Creates the DocString object *** e = DocString ( elem . replace ( '\n' , ' ' ) , spaces , quotes = self . quotes , input_style = self . input_style , output_style = self . output_style , first_line = self . first_line , * * self . kwargs ) elem_list . append ( { 'docs' : e , 'location' : ( - i , - i ) } ) else : if waiting_docs and ( '"""' in l or "'''" in l ) : # not docstring if not reading_docs and not ( l [ : 3 ] in [ '"""' , "'''" ] or ( l [ 0 ] in [ 'r' , 'u' , 'f' ] and l [ 1 : 4 ] in [ '"""' , "'''" ] ) or ( l [ 0 ] in [ 'r' , 'u' , 'f' ] and l [ 1 ] in [ 'r' , 'u' , 'f' ] and l [ 2 : 5 ] in [ '"""' , "'''" ] ) ) : waiting_docs = False # start of docstring bloc elif not reading_docs : start = i # determine which delimiter idx_c = l . find ( '"""' ) idx_dc = l . find ( "'''" ) lim = '"""' if idx_c >= 0 and idx_dc >= 0 : if idx_c < idx_dc : lim = '"""' else : lim = "'''" elif idx_c < 0 : lim = "'''" reading_docs = lim # check if the docstring starts with 'r', 'u', or 'f' or combination thus extract it if not l . startswith ( lim ) : idx_strip_lim = l . find ( lim ) idx_abs_lim = ln . find ( lim ) # remove and keep the prefix r|f|u before_lim = l [ : idx_strip_lim ] ln = ln [ : idx_abs_lim - idx_strip_lim ] + ln [ idx_abs_lim : ] raw = ln # one line docstring if l . count ( lim ) == 2 : end = i elem_list [ - 1 ] [ 'docs' ] . parse_docs ( raw , before_lim ) elem_list [ - 1 ] [ 'location' ] = ( start , end ) reading_docs = None waiting_docs = False reading_element = False raw = '' # end of docstring bloc elif waiting_docs and lim in l : end = i raw += ln elem_list [ - 1 ] [ 'docs' ] . parse_docs ( raw , before_lim ) elem_list [ - 1 ] [ 'location' ] = ( start , end ) reading_docs = None waiting_docs = False reading_element = False raw = '' # inside a docstring bloc elif waiting_docs : raw += ln # no docstring found for current element elif waiting_docs and l != '' and reading_docs is None : waiting_docs = False else : if reading_docs is not None : raw += ln if self . convert_only : i = 0 while i < len ( elem_list ) : if elem_list [ i ] [ 'docs' ] . get_input_docstring ( ) is None : elem_list . pop ( i ) else : i += 1 self . docs_list = elem_list self . parsed = True return elem_list