X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fdoc_gen%2Fgen_rst.py;h=898f215b1b17c380f26986dcfaaaf8fc0b779018;hb=be82f49dda573dfc7010a56d6f76f8e161beac16;hp=8f239d0951be4280773719e2fb48638f39e59830;hpb=4dadc7a005ca99aa5a14ac650e9aa187cea10619;p=csit.git diff --git a/resources/tools/doc_gen/gen_rst.py b/resources/tools/doc_gen/gen_rst.py index 8f239d0951..898f215b1b 100755 --- a/resources/tools/doc_gen/gen_rst.py +++ b/resources/tools/doc_gen/gen_rst.py @@ -163,13 +163,15 @@ def write_module_title(fh, module_name): :type fh: file :type module_name: str """ - title = "{} module".format(module_name) + title = "{} suite".format(module_name) fh.write("\n{}\n{}\n".format(title, '-' * len(title))) def generate_py_rst_files(): """Generate all rst files for all python modules.""" + dirs_ignore_list = ["__pycache__", ] + py_libs = get_files(PATH_PY_LIBS, PY_EXT) file_names = create_rst_file_names_set(py_libs, RESOURCES_DIR) @@ -177,19 +179,27 @@ def generate_py_rst_files(): path = join(WORKING_DIR, *file_name.split('.')[:-1]) dirs, files = scan_dir(path) + for item in dirs_ignore_list: + while True: + try: + dirs.remove(item) + except ValueError: + break + full_path = join(WORKING_DIR, file_name) with open(full_path, mode='a') as fh: if getsize(full_path) == 0: package = file_name.split('.')[-2] - fh.write("{} package\n".format(package)) - fh.write('=' * len("{} package".format(package))) + fh.write("{}\n".format(package)) + fh.write('=' * len("{}".format(package))) module_path = file_name.split('.')[:-1] if dirs: write_toc(fh, module_path, dirs) for file in files: module_name = file.split('.')[0] write_module_title(fh, module_name) - fh.write(rst_py_module.format('.'.join(module_path), module_name)) + fh.write(rst_py_module.format('.'.join(module_path), + module_name)) def generate_rf_rst_files(file_names, incl_tests=True, incl_keywords=True): @@ -213,8 +223,8 @@ def generate_rf_rst_files(file_names, incl_tests=True, incl_keywords=True): with open(full_path, mode='a') as fh: if getsize(full_path) == 0: package = file_name.split('.')[-2] - fh.write("{} package\n".format(package)) - fh.write('=' * len("{} package".format(package)) + '\n') + fh.write("{}\n".format(package)) + fh.write('=' * len("{}".format(package)) + '\n') module_path = file_name.split('.')[:-1] if dirs: write_toc(fh, module_path, dirs)