X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fdoc_gen%2Fgen_rst.py;h=3d04568de21dffc5ae656f501e7da4f527ef884a;hb=8c34e2945809ce12dd2795bb4e76c2a6b30e1be7;hp=c79ffc07bbebef5d83aeb0530e68c5feaf10f042;hpb=a9da1b4ca1e8cccef22a6e2b8bfa859a9ed04555;p=csit.git diff --git a/resources/tools/doc_gen/gen_rst.py b/resources/tools/doc_gen/gen_rst.py index c79ffc07bb..3d04568de2 100755 --- a/resources/tools/doc_gen/gen_rst.py +++ b/resources/tools/doc_gen/gen_rst.py @@ -1,6 +1,4 @@ -#!/usr/bin/python - -# Copyright (c) 2016 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -48,6 +46,16 @@ rst_py_module = """ :show-inheritance: """ +rst_rf_suite_setup = """ +.. robot-settings:: + :source: {} +""" + +rst_rf_variables = """ +.. robot-variables:: + :source: {} +""" + rst_rf_keywords = """ .. robot-keywords:: :source: {} @@ -145,7 +153,7 @@ def write_toc(fh, path, dirs): :param fh: File handler of the rst file. :param path: Path to package. :param dirs: List of directories to be included in ToC. - :type fh: file + :type fh: BinaryIO :type path: str :type dirs: list """ @@ -160,7 +168,7 @@ def write_module_title(fh, module_name): :param fh: File handler of the rst file. :param module_name: The name of module used for title. - :type fh: file + :type fh: BinaryIO :type module_name: str """ title = "{} suite".format(module_name) @@ -198,20 +206,28 @@ def generate_py_rst_files(): 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): +def generate_rf_rst_files(file_names, incl_tests=True, incl_keywords=True, + incl_suite_setup=False, incl_variables=False): """Generate rst files for the given robot modules. :param file_names: List of file names to be included in the documentation (rst files). - :param incl_tests: If true, tests will be included in the documentation. - :param incl_keywords: If true, keywords will be included in the + :param incl_tests: If True, tests will be included in the documentation. + :param incl_keywords: If True, keywords will be included in the + documentation. + :param incl_suite_setup: If True, the suite setup will be included in the + documentation. + :param incl_variables: If True, the variables will be included in the documentation. :type file_names: set :type incl_tests: bool :type incl_keywords: bool + :type incl_suite_setup: bool + :type incl_variables: bool """ for file_name in file_names: @@ -231,10 +247,14 @@ def generate_rf_rst_files(file_names, incl_tests=True, incl_keywords=True): module_name = file.split('.')[0] write_module_title(fh, module_name) path = join(join(*module_path), module_name + RF_EXT) - if incl_tests: - fh.write(rst_rf_tests.format(path)) + if incl_suite_setup: + fh.write(rst_rf_suite_setup.format(path)) + if incl_variables: + fh.write(rst_rf_variables.format(path)) if incl_keywords: fh.write(rst_rf_keywords.format(path)) + if incl_tests: + fh.write(rst_rf_tests.format(path)) def generate_kw_rst_files(): @@ -254,7 +274,9 @@ def generate_tests_rst_files(): tests = get_files(PATH_TESTS, RF_EXT) file_names = create_rst_file_names_set(tests, TESTS_DIR) - generate_rf_rst_files(file_names) + generate_rf_rst_files(file_names, + incl_suite_setup=True, + incl_variables=True) if __name__ == '__main__':