doxyth/gendoc.py
def read_docs(self, path, nofileprefix):
        """
        ### &doc_id gendoc:read_doc_files

        Reads the documentation files and stores each documentation text.

        This function reads the documentation files in the language directory provided, and stores all the valid
        references for further use during the replacing phase by the doxyth file_name.

        Args:
            path: The language directory path to read through.
            nofileprefix: Whether to deactivate the file_name prefix or not
        """

        files = [f for f in os.listdir(path) if isfile(join(path, f)) and f.endswith(".dthdoc")]
        final = {}

        for file in files:
            filename = ".".join(file.split(".")[0:-1])

            with open(f"{path}/{file}", encoding='utf-8') as f:
                lines = f.readlines()

            file_doc = {}
            buffer_name = None
            buffer = []
            just_read_id = False
            for line in lines:
                try:
                    stripped_line = line.strip()
                except UnicodeEncodeError:
                    stripped_line = ascii_encode(line).strip()

                if re.match(r"\s*&doc_id\s*", stripped_line):
                    buffer_name = re.split(r"\s*&doc_id\s*", stripped_line)[-1]
                    just_read_id = True
                    continue
                elif stripped_line == '"""' and just_read_id:
                    just_read_id = False
                elif stripped_line == '"""' and not just_read_id:
                    if buffer_name in final.keys():
                        raise Exception(f"ID {buffer_name} found multiple times in the same file_name.")

                    if nofileprefix:
                        file_doc[buffer_name] = buffer
                    else:
                        file_doc[f'{filename}:{buffer_name}'] = buffer
                    buffer_name, buffer = None, []
                else:
                    try:
                        stripped_line = line.rstrip()
                    except UnicodeEncodeError:
                        stripped_line = ascii_encode(line).rstrip()
                    buffer.append(stripped_line + '\n')

            if buffer or buffer_name:
                raise Exception(f"Warning: Unexpected EOF while reading ID {buffer_name} in file_name "
                                f"'{path.split('/')[-1]}'")

            for doc_id in file_doc.keys():
                if doc_id in final.keys():
                    raise Exception(f"ID {doc_id} found multiple times for the same language.")

            final = {**final, **file_doc}

        if self.verbose:
            print(f"Found {len(final)} translations")

        # We now edit all the docs to take out every empty line at the start AND end of the doclines
        for el in final.keys():
            docs = final[el]
            start = None
            end = None

            for i in range(len(docs)):
                if not docs[i].strip():
                    continue
                start = i
                break

            for i in range(len(docs)):
                if not docs[len(docs) - 1 - i].strip():
                    continue
                end = len(docs) - i
                break

            final[el] = docs[start:end]

        return final

        ### &doc_id gendoc:read_doc_files

        Reads the documentation files and stores each documentation text.

        This function reads the documentation files in the language directory provided, and stores all the valid
        references for further use during the replacing phase by the doxyth file_name.

        Args:
            path: The language directory path to read through.
            nofileprefix: Whether to deactivate the file_name prefix or not
        
&doc_id gendoc:read_doc_files
Reads the documentation files and stores each documentation text.

This function reads the documentation files in the language directory provided, and stores all the valid
references for further use during the replacing phase by the doxyth file_name.
&doc_id gendoc : read_doc_files Reads the documentation files and stores each documentation text . This function reads the documentation files in the language directory provided and stores all the valid references for further use during the replacing phase by the doxyth file_name .
def read_docs(self, path, nofileprefix):
        files = [f for f in os.listdir(path) if isfile(join(path, f)) and f.endswith(".dthdoc")]
        final = {}
        for file in files:
            filename = ".".join(file.split(".")[0:-1])
            with open(f"{path}/{file}", encoding='utf-8') as f:
                lines = f.readlines()
            file_doc = {}
            buffer_name = None
            buffer = []
            just_read_id = False
            for line in lines:
                try:
                    stripped_line = line.strip()
                except UnicodeEncodeError:
                    stripped_line = ascii_encode(line).strip()
                if re.match(r"\s*&doc_id\s*", stripped_line):
                    buffer_name = re.split(r"\s*&doc_id\s*", stripped_line)[-1]
                    just_read_id = True
                    continue
                elif stripped_line == '"""' and just_read_id:
                    just_read_id = False
                elif stripped_line == '"""' and not just_read_id:
                    if buffer_name in final.keys():
                        raise Exception(f"ID {buffer_name} found multiple times in the same file_name.")
                    if nofileprefix:
                        file_doc[buffer_name] = buffer
                    else:
                        file_doc[f'{filename}:{buffer_name}'] = buffer
                    buffer_name, buffer = None, []
                else:
                    try:
                        stripped_line = line.rstrip()
                    except UnicodeEncodeError:
                        stripped_line = ascii_encode(line).rstrip()
                    buffer.append(stripped_line + '\n')
            if buffer or buffer_name:
                raise Exception(f"Warning: Unexpected EOF while reading ID {buffer_name} in file_name "
                                f"'{path.split('/')[-1]}'")
            for doc_id in file_doc.keys():
                if doc_id in final.keys():
                    raise Exception(f"ID {doc_id} found multiple times for the same language.")
            final = {**final, **file_doc}
        if self.verbose:
            print(f"Found {len(final)} translations")
        for el in final.keys():
            docs = final[el]
            start = None
            end = None
            for i in range(len(docs)):
                if not docs[i].strip():
                    continue
                start = i
                break
            for i in range(len(docs)):
                if not docs[len(docs) - 1 - i].strip():
                    continue
                end = len(docs) - i
                break
            final[el] = docs[start:end]
        return final
def read_docs ( self , path , nofileprefix ) : files = [ f for f in os . listdir ( path ) if isfile ( join ( path , f ) ) and f . endswith ( ".dthdoc" ) ] final = { } for file in files : filename = "." . join ( file . split ( "." ) [ 0 : - 1 ] ) with open ( f"{path}/{file}" , encoding = 'utf-8' ) as f : lines = f . readlines ( ) file_doc = { } buffer_name = None buffer = [ ] just_read_id = False for line in lines : try : stripped_line = line . strip ( ) except UnicodeEncodeError : stripped_line = ascii_encode ( line ) . strip ( ) if re . match ( r"\s*&doc_id\s*" , stripped_line ) : buffer_name = re . split ( r"\s*&doc_id\s*" , stripped_line ) [ - 1 ] just_read_id = True continue elif stripped_line == '"""' and just_read_id : just_read_id = False elif stripped_line == '"""' and not just_read_id : if buffer_name in final . keys ( ) : raise Exception ( f"ID {buffer_name} found multiple times in the same file_name." ) if nofileprefix : file_doc [ buffer_name ] = buffer else : file_doc [ f'{filename}:{buffer_name}' ] = buffer buffer_name , buffer = None , [ ] else : try : stripped_line = line . rstrip ( ) except UnicodeEncodeError : stripped_line = ascii_encode ( line ) . rstrip ( ) buffer . append ( stripped_line + '\n' ) if buffer or buffer_name : raise Exception ( f"Warning: Unexpected EOF while reading ID {buffer_name} in file_name " f"'{path.split('/')[-1]}'" ) for doc_id in file_doc . keys ( ) : if doc_id in final . keys ( ) : raise Exception ( f"ID {doc_id} found multiple times for the same language." ) final = { ** final , ** file_doc } if self . verbose : print ( f"Found {len(final)} translations" ) for el in final . keys ( ) : docs = final [ el ] start = None end = None for i in range ( len ( docs ) ) : if not docs [ i ] . strip ( ) : continue start = i break for i in range ( len ( docs ) ) : if not docs [ len ( docs ) - 1 - i ] . strip ( ) : continue end = len ( docs ) - i break final [ el ] = docs [ start : end ] return final
&doc_id gendoc:read_doc_files
Reads the documentation files and stores each documentation text.
&doc_id gendoc : read_doc_files Reads the documentation files and stores each documentation text .
"""
        ### &doc_id gendoc:read_doc_files

        Reads the documentation files and stores each documentation text.

        This function reads the documentation files in the language directory provided, and stores all the valid
        references for further use during the replacing phase by the doxyth file_name.

        Args:
            path: The language directory path to read through.
            nofileprefix: Whether to deactivate the file_name prefix or not
        """ # We now edit all the docs to take out every empty line at the start AND end of the doclines
self
path
The language directory path to read through.
The language directory path to read through .
nofileprefix
Whether to deactivate the file_name prefix or not
Whether to deactivate the file_name prefix or not