doxyth/doxyth.py
def __modify_lines(self):
        """
        ### &doc_id doxyth:modify_lines

        The main function of this class. Processes the file_name lines to replace the doc_ids.

        The function reads the file_name line per line, and only looks for a doc_id in doclines. If multiple IDs are found in
        one doc, only the first is kept as an ID.
        Once the file_name is entirely read, each doclines containing a doc ID are replaced by the matching doclines
        registered in the translations file_name(s) of this language.

        Returns:
            The modified file_name lines
        """

        import re
        from sys import stderr

        final = self.lines.copy()
        to_change = []
        in_doc = False
        doclines = [None, None]

        offset = None
        doc_id = None

        # Find the lines that are to replace
        for n, line in enumerate(final):
            try:
                stripped_line = line.strip()
            except UnicodeEncodeError:
                stripped_line = ascii_encode(line).strip()
            if stripped_line == '"""':
                if not in_doc:
                    # We just entered in a doc, set the starting line number and the offset
                    doclines[0] = n
                    offset = re.split(r'(\s*)"""', line)[1]
                if in_doc:
                    # If no doc_id has been found, we leave the doclines untouched.
                    if doc_id:
                        # We are exiting a doc, set the ending line and register the thing to replace
                        doclines[1] = n
                        to_change.append({"lines": tuple(doclines), "id": doc_id, "offset": offset})
                    # Reset values to what they were initially
                    offset = None
                    doc_id = None
                    doclines = [None, None]

                in_doc = False if in_doc else True

            if in_doc:
                if re.match(r"\s*###\s*&doc_id\s*", line):
                    # Found, we now split by regex and register the doc id
                    try:
                        new = re.split(r"\s*###\s*&doc_id\s*", line.rstrip())[-1]
                    except UnicodeEncodeError:
                        new = re.split(r"\s*###\s*&doc_id\s*", ascii_encode(line).rstrip())[-1]
                    if doc_id:
                        print(f"{self.filename}:{n}: warning: Found multiple IDs in the same doclines:"
                              f" 1st '{doc_id}'; 2nd '{new}'.", file=stderr)
                    else:
                        if new in self.docs:
                            doc_id = new
                        else:
                            print(f"{self.filename}:{n}: warning: ID {new} could not be found in the "
                                  f"doc_IDs.", file=stderr)

        if in_doc:
            raise Exception(f"Unexpected EOF while reading.")

        # Now reverse the list, and replace the doclines
        to_change.reverse()

        for el in to_change:
            if el['id'] in self.docs:
                dls, dle = el['lines']

                modified_doc = [el['offset'] + line for line in self.docs[el['id']]]
                modified_doc.insert(0, el['offset'] + '"""')
                modified_doc.append(el['offset'] + '"""')

                final[dls:dle+1] = modified_doc

        return final

        ### &doc_id doxyth:modify_lines

        The main function of this class. Processes the file_name lines to replace the doc_ids.

        The function reads the file_name line per line, and only looks for a doc_id in doclines. If multiple IDs are found in
        one doc, only the first is kept as an ID.
        Once the file_name is entirely read, each doclines containing a doc ID are replaced by the matching doclines
        registered in the translations file_name(s) of this language.

        Returns:
            The modified file_name lines
        
&doc_id doxyth:modify_lines
The main function of this class. Processes the file_name lines to replace the doc_ids.

The function reads the file_name line per line, and only looks for a doc_id in doclines. If multiple IDs are found in
one doc, only the first is kept as an ID.
Once the file_name is entirely read, each doclines containing a doc ID are replaced by the matching doclines
registered in the translations file_name(s) of this language.
&doc_id doxyth : modify_lines The main function of this class . Processes the file_name lines to replace the doc_ids . The function reads the file_name line per line and only looks for a doc_id in doclines . If multiple IDs are found in one doc only the first is kept as an ID . Once the file_name is entirely read each doclines containing a doc ID are replaced by the matching doclines registered in the translations file_name ( s ) of this language .
def __modify_lines(self):
        import re
        from sys import stderr
        final = self.lines.copy()
        to_change = []
        in_doc = False
        doclines = [None, None]
        offset = None
        doc_id = None
        for n, line in enumerate(final):
            try:
                stripped_line = line.strip()
            except UnicodeEncodeError:
                stripped_line = ascii_encode(line).strip()
            if stripped_line == '"""':
                if not in_doc:
                    doclines[0] = n
                    offset = re.split(r'(\s*)"""', line)[1]
                if in_doc:
                    if doc_id:
                        doclines[1] = n
                        to_change.append({"lines": tuple(doclines), "id": doc_id, "offset": offset})
                    offset = None
                    doc_id = None
                    doclines = [None, None]
                in_doc = False if in_doc else True
            if in_doc:
                if re.match(r"\s*###\s*&doc_id\s*", line):
                    try:
                        new = re.split(r"\s*###\s*&doc_id\s*", line.rstrip())[-1]
                    except UnicodeEncodeError:
                        new = re.split(r"\s*###\s*&doc_id\s*", ascii_encode(line).rstrip())[-1]
                    if doc_id:
                        print(f"{self.filename}:{n}: warning: Found multiple IDs in the same doclines:"
                              f" 1st '{doc_id}'; 2nd '{new}'.", file=stderr)
                    else:
                        if new in self.docs:
                            doc_id = new
                        else:
                            print(f"{self.filename}:{n}: warning: ID {new} could not be found in the "
                                  f"doc_IDs.", file=stderr)
        if in_doc:
            raise Exception(f"Unexpected EOF while reading.")
        to_change.reverse()
        for el in to_change:
            if el['id'] in self.docs:
                dls, dle = el['lines']
                modified_doc = [el['offset'] + line for line in self.docs[el['id']]]
                modified_doc.insert(0, el['offset'] + '"""')
                modified_doc.append(el['offset'] + '"""')
                final[dls:dle+1] = modified_doc
        return final
def __modify_lines ( self ) : import re from sys import stderr final = self . lines . copy ( ) to_change = [ ] in_doc = False doclines = [ None , None ] offset = None doc_id = None for n , line in enumerate ( final ) : try : stripped_line = line . strip ( ) except UnicodeEncodeError : stripped_line = ascii_encode ( line ) . strip ( ) if stripped_line == '"""' : if not in_doc : doclines [ 0 ] = n offset = re . split ( r'(\s*)"""' , line ) [ 1 ] if in_doc : if doc_id : doclines [ 1 ] = n to_change . append ( { "lines" : tuple ( doclines ) , "id" : doc_id , "offset" : offset } ) offset = None doc_id = None doclines = [ None , None ] in_doc = False if in_doc else True if in_doc : if re . match ( r"\s*###\s*&doc_id\s*" , line ) : try : new = re . split ( r"\s*###\s*&doc_id\s*" , line . rstrip ( ) ) [ - 1 ] except UnicodeEncodeError : new = re . split ( r"\s*###\s*&doc_id\s*" , ascii_encode ( line ) . rstrip ( ) ) [ - 1 ] if doc_id : print ( f"{self.filename}:{n}: warning: Found multiple IDs in the same doclines:" f" 1st '{doc_id}'; 2nd '{new}'." , file = stderr ) else : if new in self . docs : doc_id = new else : print ( f"{self.filename}:{n}: warning: ID {new} could not be found in the " f"doc_IDs." , file = stderr ) if in_doc : raise Exception ( f"Unexpected EOF while reading." ) to_change . reverse ( ) for el in to_change : if el [ 'id' ] in self . docs : dls , dle = el [ 'lines' ] modified_doc = [ el [ 'offset' ] + line for line in self . docs [ el [ 'id' ] ] ] modified_doc . insert ( 0 , el [ 'offset' ] + '"""' ) modified_doc . append ( el [ 'offset' ] + '"""' ) final [ dls : dle + 1 ] = modified_doc return final
&doc_id doxyth:modify_lines
The main function of this class.
&doc_id doxyth : modify_lines The main function of this class .
"""
        ### &doc_id doxyth:modify_lines

        The main function of this class. Processes the file_name lines to replace the doc_ids.

        The function reads the file_name line per line, and only looks for a doc_id in doclines. If multiple IDs are found in
        one doc, only the first is kept as an ID.
        Once the file_name is entirely read, each doclines containing a doc ID are replaced by the matching doclines
        registered in the translations file_name(s) of this language.

        Returns:
            The modified file_name lines
        """ # Find the lines that are to replace # We just entered in a doc, set the starting line number and the offset # If no doc_id has been found, we leave the doclines untouched. # We are exiting a doc, set the ending line and register the thing to replace # Reset values to what they were initially # Found, we now split by regex and register the doc id # Now reverse the list, and replace the doclines
The modified file_name lines
The modified file_name lines
self