From 5392d8697d645b23f1abb56a125f4b399fef8d7a Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 17 Jul 2019 12:01:07 -0700 Subject: [PATCH] Docs scripts cleanup (#59169) * Fix dump_keywords to require attribute docs * Change the documentation commands to make definition files positional Since the definition files are mandatory, make them positional parameters instead of options. --- docs/docsite/Makefile | 4 ++-- .../build_ansible/command_plugins/dump_config.py | 12 ++++-------- .../build_ansible/command_plugins/dump_keywords.py | 10 +++------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/docs/docsite/Makefile b/docs/docsite/Makefile index 386998be149..988dc08f589 100644 --- a/docs/docsite/Makefile +++ b/docs/docsite/Makefile @@ -84,10 +84,10 @@ cli: PYTHONPATH=../../lib $(GENERATE_CLI) --template-file=../templates/cli_rst.j2 --output-dir=rst/cli/ --output-format rst ../../lib/ansible/cli/*.py keywords: ../templates/playbooks_keywords.rst.j2 - PYTHONPATH=../../lib $(KEYWORD_DUMPER) --template-dir=../templates --output-dir=rst/reference_appendices/ -d ./keyword_desc.yml + PYTHONPATH=../../lib $(KEYWORD_DUMPER) --template-dir=../templates --output-dir=rst/reference_appendices/ ./keyword_desc.yml config: ../templates/config.rst.j2 - PYTHONPATH=../../lib $(CONFIG_DUMPER) --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/ -d ../../lib/ansible/config/base.yml + PYTHONPATH=../../lib $(CONFIG_DUMPER) --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/ ../../lib/ansible/config/base.yml modules: ../templates/plugin.rst.j2 PYTHONPATH=../../lib $(PLUGIN_FORMATTER) -t rst --template-dir=../templates --module-dir=../../lib/ansible/modules -o rst/modules/ $(MODULE_ARGS) diff --git a/hacking/build_library/build_ansible/command_plugins/dump_config.py b/hacking/build_library/build_ansible/command_plugins/dump_config.py index 51db0f2a994..d1822d20e8d 100644 --- a/hacking/build_library/build_ansible/command_plugins/dump_config.py +++ b/hacking/build_library/build_ansible/command_plugins/dump_config.py @@ -50,8 +50,8 @@ class DocumentConfig(Command): help="directory containing Jinja2 templates") parser.add_argument("-o", "--output-dir", action="store", dest="output_dir", default='/tmp/', help="Output directory for rst files") - parser.add_argument("-d", "--docs-source", action="store", dest="docs", default=None, - help="Source for attribute docs") + parser.add_argument("config_defs", metavar="CONFIG-OPTION-DEFINITIONS.yml", type=str, + help="Source for config option docs") @staticmethod def main(args): @@ -60,13 +60,9 @@ class DocumentConfig(Command): template_file = os.path.basename(template_file_full_path) template_dir = os.path.dirname(template_file_full_path) - if args.docs: - with open(args.docs) as f: - docs = yaml.safe_load(f) - else: - docs = {} + with open(args.config_defs) as f: + config_options = yaml.safe_load(f) - config_options = docs config_options = fix_description(config_options) env = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True,) diff --git a/hacking/build_library/build_ansible/command_plugins/dump_keywords.py b/hacking/build_library/build_ansible/command_plugins/dump_keywords.py index ff1d52d33c2..2fc6e5d259f 100644 --- a/hacking/build_library/build_ansible/command_plugins/dump_keywords.py +++ b/hacking/build_library/build_ansible/command_plugins/dump_keywords.py @@ -106,16 +106,12 @@ class DocumentKeywords(Command): help="directory containing Jinja2 templates") parser.add_argument("-o", "--output-dir", action="store", dest="output_dir", default='/tmp/', help="Output directory for rst files") - parser.add_argument("-d", "--docs-source", action="store", dest="docs", default=None, - help="Source for attribute docs") + parser.add_argument("keyword_defs", metavar="KEYWORD-DEFINITIONS.yml", type=str, + help="Source for playbook keyword docs") @staticmethod def main(args): - if not args.docs: - print('Definitions for keywords must be specified via `--docs-source FILENAME`') - return 1 - - keyword_definitions = load_definitions(args.docs) + keyword_definitions = load_definitions(args.keyword_defs) pb_keywords = extract_keywords(keyword_definitions) keyword_page = generate_page(pb_keywords, args.template_dir)