Exemplo n.º 1
0
def gen_impact_func_index(list_unique_identifier=None):
    """Generate impact function index
    """
    if list_unique_identifier is None:
        list_unique_identifier = []
    content_rst = ''
    title_page = 'Impact Functions Documentation'
    content_rst += '=' * len(title_page) + '\n'
    content_rst += title_page + '\n'
    content_rst += '=' * len(title_page) + '\n\n'

    content_rst += ('This document explains the purpose of impact functions '
                    'and lists the different available impact function and '
                    'the requirements each has to be used effectively.\n\n')

    content_rst += '.. toctree::\n'
    content_rst += '   :maxdepth: 2\n\n'

    # list impact function
    for ui in list_unique_identifier:
        content_rst += '   ' + impact_func_doc_dir + os.sep + \
                       ui.replace(' ', '') + '\n'

    create_rst_file(insafe_dir_path + os.sep + doc_dir, 'impact_functions_doc',
                    content_rst)
Exemplo n.º 2
0
def gen_impact_func_index(list_unique_identifier=None):
    """Generate impact function index
    """
    if list_unique_identifier is None:
        list_unique_identifier = []
    content_rst = ''
    title_page = 'Impact Functions Documentation'
    content_rst += '=' * len(title_page) + '\n'
    content_rst += title_page + '\n'
    content_rst += '=' * len(title_page) + '\n\n'

    content_rst += ('This document explains the purpose of impact functions '
                    'and lists the different available impact function and '
                    'the requirements each has to be used effectively.\n\n')

    content_rst += '.. toctree::\n'
    content_rst += '   :maxdepth: 2\n\n'

    # list impact function
    for ui in list_unique_identifier:
        content_rst += '   ' + impact_func_doc_dir + os.sep + \
                       ui.replace(' ', '') + '\n'

    create_rst_file(os.path.join(insafe_dir_path, doc_dir),
                    'impact_functions_doc',
                    content_rst)
Exemplo n.º 3
0
def main():
    create_dirs(docs_dir)
    # get all impact functions directories
    imp_func_dirs = [name for name in
                     os.listdir(impact_functions_path)
                     if (os.path.isdir(impact_functions_path + os.sep + name)
                     and ((os.listdir(impact_functions_path + os.sep +
                                     name)).count('__init__.py')) > 0)]

    # create index subtitle
    imp_func_subtitle = ['functions' + os.sep + imp_func_dir
                         for imp_func_dir in imp_func_dirs]
    index_text = create_index('impact_functions', 2, imp_func_subtitle)
    print '\n'.join(imp_func_subtitle)

    # create impact_function.rst file
    create_rst_file(docs_dir, 'impact_functions', index_header + index_text)

    for myIFD in imp_func_dirs:
        myAbsIFD = impact_functions_path + os.sep + myIFD
        generate_rst(myAbsIFD, docs_dir + os.sep + 'functions')

    impact_functions_contents = os.listdir(impact_functions_path)

    python_files = python_file_siever(impact_functions_contents,
                                      excluded_files)
    print python_files
Exemplo n.º 4
0
def gen_rst_doc(impfunc_doc, impfunc_doc_str):
    """Generate .rst file
    :param
        impfunc_doc : dictionary that contains documentation
    :return
        None
    """
    impact_func_doc_path = os.path.join(insafe_dir_path, doc_dir,
                                        impact_func_doc_dir)
    for myFuncName, myDoc in impfunc_doc.items():
        content_rst = myFuncName
        content_rst += '\n' + '=' * len(myFuncName) + '\n\n'
        # provide documentation
        content_rst += 'Overview'
        content_rst += '\n' + '-' * len('Overview') + '\n\n'
        if type(myDoc) is dict or type(myDoc) is OrderedDict:
            for mykey, myValue in myDoc.items():
                if mykey == 'detailed_description':
                    continue
                my_pretty_key = pretty_key(mykey)
                content_rst += '**' + my_pretty_key + '**' + ': \n'
                if myValue is None or len(myValue) == 0:
                    content_rst += 'No documentation found'
                else:
                    content_rst += myValue
                content_rst += '\n\n'
            content_rst += 'Details'
            content_rst += '\n' + '-' * len('Details') + '\n\n'
            if ('detailed_description' in myDoc.keys()) and \
                    (len(myDoc['detailed_description']) > 0):
                content_rst += myDoc['detailed_description']
            else:
                content_rst += 'No documentation found'
        else:
            content_rst += 'No documentation found'
        if myFuncName in impfunc_doc_str:
            my_doc_str = impfunc_doc_str[myFuncName]
            content_rst += '\n\nDocstring'
            content_rst += '\n' + '-' * len('Doc String') + '\n\n'
            content_rst += my_doc_str

        create_rst_file(impact_func_doc_path, myFuncName.replace(' ', ''),
                        content_rst)
Exemplo n.º 5
0
def gen_rst_doc(impfunc_doc):
    """Generate .rst file
    :param
        impfunc_doc : dictionary that contains documentation
    :return
        None
    """
    impact_func_doc_path = insafe_dir_path + os.sep + doc_dir + os.sep +\
                           impact_func_doc_dir
    for myFuncName, myDoc in impfunc_doc.iteritems():
        content_rst = myFuncName
        content_rst += '\n' + '=' * len(myFuncName) + '\n\n'
        # provide documentation
        content_rst += 'Overview'
        content_rst += '\n' + '-' * len('Overview') + '\n\n'
        if type(myDoc) is dict:
            for mykey, myValue in myDoc.iteritems():
                if mykey == 'detailed_description':
                    continue
                myPrettykey = pretty_key(mykey)
                content_rst += '**' + myPrettykey + '**' + ': '
                if type(myValue) is list and len(myValue) > 0:
                    content_rst += '\n\n'
                    for myVal in myValue:
                        content_rst += '* ' + myVal + '\n'
                elif myValue is None or len(myValue) == 0:
                    content_rst += 'No documentation found'
                else:
                    content_rst += myValue
                content_rst += '\n\n'
            content_rst += 'Details'
            content_rst += '\n' + '-' * len('Details') + '\n\n'
            if 'detailed_description' in myDoc.iterkeys():
                content_rst += myDoc['detailed_description']
            else:
                content_rst += 'No documentation found'
        else:
            content_rst += 'No documentation found'

        create_rst_file(impact_func_doc_path, myFuncName.replace(' ', ''),
                        content_rst)
Exemplo n.º 6
0
def gen_rst_doc(impfunc_doc):
    """Generate .rst file
    :param
        impfunc_doc : dictionary that contains documentation
    :return
        None
    """
    impact_func_doc_path = insafe_dir_path + os.sep + doc_dir + os.sep +\
                           impact_func_doc_dir
    for myFuncName, myDoc in impfunc_doc.iteritems():
        content_rst = myFuncName
        content_rst += '\n' + '=' * len(myFuncName) + '\n\n'
        # provide documentation
        content_rst += 'Overview'
        content_rst += '\n' + '-' * len('Overview') + '\n\n'
        if type(myDoc) is dict :
            for mykey, myValue in myDoc.iteritems():
                if mykey == 'detailed_description':
                    continue
                myPrettykey = pretty_key(mykey)
                content_rst += '**' + myPrettykey + '**' + ': '
                if type(myValue) is list and len(myValue) > 0:
                    content_rst += '\n\n'
                    for myVal in myValue:
                        content_rst += '* ' + myVal + '\n'
                elif myValue is None or len(myValue) == 0:
                    content_rst += 'No documentation found'
                else:
                    content_rst += myValue
                content_rst += '\n\n'
            content_rst += 'Details'
            content_rst += '\n' + '-' * len('Details') + '\n\n'
            if 'detailed_description' in myDoc.iterkeys():
                content_rst += myDoc['detailed_description']
            else:
                content_rst += 'No documentation found'
        else:
            content_rst += 'No documentation found'

        create_rst_file(impact_func_doc_path, myFuncName.replace(' ', ''),
                        content_rst)
Exemplo n.º 7
0
def gen_rst_doc(impfunc_doc):
    """Generate .rst file
    :param
        impfunc_doc : dictionary that contains documentation
    :return
        None
    """
    impact_func_doc_path = insafe_dir_path + os.sep + doc_dir + os.sep + impact_func_doc_dir
    for k, v in impfunc_doc.iteritems():
        content_rst = k
        content_rst += "\n" + "=" * len(k) + "\n\n"
        # provide documentation
        content_rst += "Overview"
        content_rst += "\n" + "-" * len("Overview") + "\n\n"
        if type(v) is dict:
            for mykey, myValue in v.iteritems():
                if mykey == "detailed_description":
                    continue
                myPrettykey = pretty_key(mykey)
                content_rst += "**" + myPrettykey + "**" + ": "
                if type(myValue) is list and len(myValue) > 0:
                    content_rst += "\n\n"
                    for myVal in myValue:
                        content_rst += "* " + myVal + "\n"
                elif myValue is None or len(myValue) == 0:
                    content_rst += "No documentation found"
                else:
                    content_rst += myValue
                content_rst += "\n\n"
            content_rst += "Details"
            content_rst += "\n" + "-" * len("Details") + "\n\n"
            if "detailed_description" in v.iterkeys():
                content_rst += v["detailed_description"]
            else:
                content_rst += "No documentation found"
        else:
            content_rst += "No documentation found"

        create_rst_file(impact_func_doc_path, k.replace(" ", ""), content_rst)
Exemplo n.º 8
0
def gen_impact_func_index(list_unique_identifier=[]):
    """Generate impact function index
    """
    content_rst = ""
    title_page = "Impact Functions Documentation"
    content_rst += "=" * len(title_page) + "\n"
    content_rst += title_page + "\n"
    content_rst += "=" * len(title_page) + "\n\n"

    content_rst += (
        "This document explains the purpose of impact functions "
        "and lists the different available impact function and "
        "the requirements each has to be used effectively.\n\n"
    )

    content_rst += ".. toctree::\n"
    content_rst += "   :maxdepth: 2\n\n"

    # list impact function
    for ui in list_unique_identifier:
        content_rst += "   " + impact_func_doc_dir + os.sep + ui.replace(" ", "") + "\n"

    create_rst_file(insafe_dir_path + os.sep + doc_dir, "impact_functions_doc", content_rst)