Exemplo n.º 1
0
def language_generate():
    lang_dict = {}
    for bear in get_bears():
        for language in bear.LANGUAGES:
            if language in lang_dict:
                lang_dict[language].append(bear.name)
            else:
                lang_dict[language] = [bear.name]

    with open("README.rst", "w") as lang_file:
        lang_file.write("Documentation for coala bears\n")
        lang_file.write("=============================\n\n")
        lang_file.write("**This is repository is automatically generated. Please "
                        "make submit any changes to** "
                        "`coala-bears <https://github.com/coala/coala-bears>`_ "
                        "**instead.**\n\n")
        lang_file.write("**Note**: The ``master`` branch contains docs for the latest "
                        "stable version. If you want to view the docs for the "
                        "latest development version, see the ``pre`` branch.\n\n")
        lang_file.write("**Supported Languages ({})**\n----------------------------\n\n"
                        ".. contents::\n"
                        "    :local:\n"
                        "    :depth: 1\n"
                        "    :backlinks: none\n\n".format(len(lang_dict)))
        for language in sorted(lang_dict):
            lang_file.write(language + "\n" + "=" * len(language) + "\n")
            for bear in sorted(lang_dict[language]):
                lang_file.write("* `" + bear + " <docs/" + bear + ".rst>`_\n")
            lang_file.write("\n")
Exemplo n.º 2
0
def language_generate():
    lang_dict = {}
    for bear in get_bears():
        for language in bear.LANGUAGES:
            if language in lang_dict:
                lang_dict[language].append(bear.name)
            else:
                lang_dict[language] = [bear.name]

    with open("README.rst", "w") as lang_file:
        lang_file.write("**Supported Languages**\n-----------------------\n\n"
                        ".. contents::\n"
                        "    :local:\n"
                        "    :depth: 1\n"
                        "    :backlinks: none\n\n")
        for language in sorted(lang_dict):
            lang_file.write(language + "\n" + "=" * len(language) + "\n")
            for bear in sorted(lang_dict[language]):
                lang_file.write("* `" + bear + " <docs/" + bear + ".rst>`_\n")
            lang_file.write("\n")
Exemplo n.º 3
0
def language_generate():
    lang_dict = {}
    for bear in get_bears():
        for language in bear.LANGUAGES:
            if language in lang_dict:
                lang_dict[language].append(bear.name)
            else:
                lang_dict[language] = [bear.name]

    with open("README.rst", "w") as lang_file:
        lang_file.write("**Supported Languages**\n-----------------------\n\n"
                        ".. contents::\n"
                        "    :local:\n"
                        "    :depth: 1\n"
                        "    :backlinks: none\n\n")
        for language in sorted(lang_dict):
            lang_file.write(language + "\n" + "=" * len(language) + "\n")
            for bear in sorted(lang_dict[language]):
                lang_file.write("* `" + bear + " <docs/" + bear + ".rst>`_\n")
            lang_file.write("\n")
Exemplo n.º 4
0
def language_generate():
    lang_dict = {}
    for bear in get_bears():
        for language in bear.LANGUAGES:
            if language in lang_dict:
                lang_dict[language].append(bear.name)
            else:
                lang_dict[language] = [bear.name]

    with open("README.rst", "w") as lang_file:
        lang_file.write("Documentation for coala bears\n")
        lang_file.write("=============================\n\n")

        deprecation_notice = ("This repository has been deprecated in favor of "
                              "http://coala.io/#!/languages - please use that. Only "
                              "absolutely critical issues in this repo will be looked into.\n")
        lang_file.write(deprecation_notice)
        lang_file.write("-" * len(deprecation_notice) + "\n\n\n")

        lang_file.write("**This is repository is automatically generated. Please "
                        "make submit any changes to** "
                        "`coala-bears <https://github.com/coala/coala-bears>`_ "
                        "**instead.**\n\n")
        lang_file.write("**Note**: The ``master`` branch contains docs for the latest "
                        "stable version. If you want to view the docs for the "
                        "latest development version, see the ``pre`` branch.\n\n")
        lang_file.write("**Supported Languages ({})**\n----------------------------\n\n"
                        ".. contents::\n"
                        "    :local:\n"
                        "    :depth: 1\n"
                        "    :backlinks: none\n\n".format(len(lang_dict)))
        for language in sorted(lang_dict):
            lang_file.write(language + "\n" + "=" * len(language) + "\n")
            for bear in sorted(lang_dict[language]):
                lang_file.write("* `" + bear + " <docs/" + bear + ".rst>`_\n")
            lang_file.write("\n")
Exemplo n.º 5
0
from bear_docs_utils import get_bears

if __name__ == '__main__':
    language_can_detect = {}
    language_can_fix = {}
    can_detects = set()
    for bear in get_bears():
        can_detects |= bear.can_detect

        for language in sorted(bear.LANGUAGES):
            if language in language_can_detect:
                language_can_detect[language] |= set(bear.can_detect)
                language_can_fix[language] |= set(bear.CAN_FIX)
            else:
                language_can_detect[language] = set(bear.can_detect)
                language_can_fix[language] = set(bear.CAN_FIX)

    columns = [val for val in sorted(can_detects)]
    file = ["Languages," + ','.join(columns) + '\n']
    for language in sorted(language_can_detect):
        def get_val(val):
            if val in language_can_fix[language]:
                return 'Can fix'

            if val in language_can_detect[language]:
                return 'Can detect'

            return "Unsupported"
        detects = ','.join(get_val(val)
                           for val in sorted(can_detects))
        file.append(language + ',' + detects + '\n')
Exemplo n.º 6
0
            splitpos = curr_print[:limit].rfind(' ')
            if splitpos < 0:
                # Word too long, search for a space left from limit at least
                splitpos = curr_print.find(' ')
                if splitpos < 0:
                    break  # Break out and add the long thing in the next line

            results.append(curr_print[:splitpos])
            curr_print = curr_print[splitpos+1:]

        results.append(curr_print)

    return results

if __name__ == "__main__":
    bears = get_bears()
    for bear in bears:
        output = "**" + bear.name + "**\n"
        output += "=" * (4 + len(bear.name)) + "\n\n"
        output += bear.get_metadata().desc + "\n\n"
        output += "`Supported Languages <../README.rst>`_" + "\n-----\n\n"
        output += "\n".join(["* " + x for x in sorted(bear.LANGUAGES)])
        output += "\n\n"
        par = {}
        lmax = -1
        rmax = -1
        meta = bear.get_metadata()
        for param in meta.non_optional_params:
            key = " ``" + param + "`` "
            par[key] = text_wrap(bear.get_metadata().non_optional_params[param][0], limit=60)
            par[key] = [g.strip() for g in par[key]]
Exemplo n.º 7
0
            if splitpos < 0:
                # Word too long, search for a space left from limit at least
                splitpos = curr_print.find(' ')
                if splitpos < 0:
                    break  # Break out and add the long thing in the next line

            results.append(curr_print[:splitpos])
            curr_print = curr_print[splitpos + 1:]

        results.append(curr_print)

    return results


if __name__ == "__main__":
    bears = get_bears()
    for bear in bears:
        output = "**" + bear.name + "**\n"
        output += "=" * (4 + len(bear.name)) + "\n\n"
        output += bear.get_metadata().desc + "\n\n"
        output += "`Supported Languages <../README.rst>`_" + "\n-----\n\n"
        output += "\n".join(["* " + x for x in sorted(bear.LANGUAGES)])
        output += "\n\n"
        par = {}
        lmax = -1
        rmax = -1
        meta = bear.get_metadata()
        for param in meta.non_optional_params:
            key = " ``" + param + "`` "
            par[key] = text_wrap(
                bear.get_metadata().non_optional_params[param][0], limit=60)