Ejemplo n.º 1
0
    if not fname.endswith('.py'):
        f = io.open(fname, encoding='utf-8')
        filetext = f.read()
        f.close()
        # Multiline matching to find codeblock
        items = re.findall(dcs, filetext, re.DOTALL)

        for item in items:
            # remove paragraph if this keyword is to be ignored
            for kw in keywords_ignore:
                item = re.sub(r"(" + kw + ".+?\n\n|" + kw + ".+?$)",
                              "",
                              item,
                              flags=re.DOTALL)
            # Check the ifdef in code
            require = check_ifdef(item, filetext, dcs)
            if require:
                item = '\n\nRequire: ' + require + item
            alllines = []
            s = " ######\n"
            for line in item.splitlines():
                name_line = re.findall(r"([\s*]?Name[\s*]?\:)(.*)", line)
                if name_line:
                    # Clean the Name: line
                    name_line_0 = name_line[0][0].strip()
                    name_line_1 = name_line[0][1].strip()
                    line = name_line_0 + ' ' + name_line_1
                line = textwrap.dedent(line).strip()
                # Tricks for the blanks
                line = html.escape(line)
                line = re.sub(r'^(\s)*- ', ' • ', line)
Ejemplo n.º 2
0
                        sliname = cut_it(' - ', name_line_1)[0]
                        sli_command_list.append(sliname)

# Now begin to collect the data for the help files and start generating.
dcs = r'\/\*[\s?]*[\n?]*BeginDocumentation[\s?]*\:?[\s?]*[.?]*\n(.*?)\n*?\*\/'
for fname in allfiles:
    # .py is for future use
    if not fname.endswith('.py'):
        f = open(fname, 'r')
        filetext = f.read()
        f.close()
        # Multiline matching to find codeblock
        items = re.findall(dcs, filetext, re.DOTALL)
        for item in items:
            # Check the ifdef in code
            require = check_ifdef(item, filetext, dcs)
            if require:
                item = '\n\nRequire: ' + require + item
            alllines = []
            s = " ######\n"
            for line in item.splitlines():
                name_line = re.findall(r"([\s*]?Name[\s*]?\:)(.*)", line)
                if name_line:
                    # Clean the Name: line!
                    name_line_0 = name_line[0][0].strip()
                    name_line_1 = name_line[0][1].strip()
                    line = name_line_0 + ' ' + name_line_1
                line = textwrap.dedent(line).strip()
                # Tricks for the blanks
                line = re.sub(r"(\s){5,}", '~~~ ', line)
                line = re.sub(r"(\s){3,4}", '~~ ', line)