From ac6d161a6dbfcb8a488c8a9f11ae898aea4ade3a Mon Sep 17 00:00:00 2001 From: Henning Henkel Date: Wed, 28 Aug 2024 16:39:49 +0200 Subject: [PATCH] Rename vars to defaults --- ansibledoctor/doc_parser.py | 6 +++--- .../templates/hugo-book/{_vars.j2 => _defaults.j2} | 2 +- ansibledoctor/templates/hugo-book/_toc.j2 | 4 ++-- .../{_vars_tabulated.j2 => defaults_tabulated.j2} | 2 +- ansibledoctor/templates/hugo-book/index.md.j2 | 8 ++++---- ansibledoctor/templates/readme/README.md.j2 | 8 ++++---- ansibledoctor/templates/readme/{_vars.j2 => _defaults.j2} | 2 +- ansibledoctor/templates/readme/_toc.j2 | 4 ++-- .../readme/{_vars_tabulated.j2 => defaults_tabulated.j2} | 2 +- docs/content/usage/configuration.md | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) rename ansibledoctor/templates/hugo-book/{_vars.j2 => _defaults.j2} (97%) rename ansibledoctor/templates/hugo-book/{_vars_tabulated.j2 => defaults_tabulated.j2} (97%) rename ansibledoctor/templates/readme/{_vars.j2 => _defaults.j2} (97%) rename ansibledoctor/templates/readme/{_vars_tabulated.j2 => defaults_tabulated.j2} (97%) diff --git a/ansibledoctor/doc_parser.py b/ansibledoctor/doc_parser.py index 382ad13..c67719e 100644 --- a/ansibledoctor/doc_parser.py +++ b/ansibledoctor/doc_parser.py @@ -26,11 +26,11 @@ class Parser: self.log = structlog.get_logger() self._files_registry = Registry() self._parse_meta_file() - self._parse_var_files() + self._parse_defaults_files() self._parse_task_tags() self._populate_doc_data() - def _parse_var_files(self): + def _parse_defaults_files(self): for rfile in self._files_registry.get_files(): if any(fnmatch.fnmatch(rfile, "*/defaults/*." + ext) for ext in YAML_EXTENSIONS): with open(rfile, encoding="utf8") as yamlfile: @@ -42,7 +42,7 @@ class Parser: data = defaultdict(dict, raw or {}) for key, value in data.items(): - self._data["var"][key] = {"value": {key: value}} + self._data["defaults"][key] = {"value": {key: value}} def _parse_meta_file(self): self._data["meta"]["name"] = {"value": self.config.config["role_name"]} diff --git a/ansibledoctor/templates/hugo-book/_vars.j2 b/ansibledoctor/templates/hugo-book/_defaults.j2 similarity index 97% rename from ansibledoctor/templates/hugo-book/_vars.j2 rename to ansibledoctor/templates/hugo-book/_defaults.j2 index e2c453b..0ccf65c 100644 --- a/ansibledoctor/templates/hugo-book/_vars.j2 +++ b/ansibledoctor/templates/hugo-book/_defaults.j2 @@ -1,4 +1,4 @@ -{% set var = role.var | default({}) %} +{% set var = role.defaults | default({}) %} {% if var %} ## Default Variables {% for key, item in var | dictsort %} diff --git a/ansibledoctor/templates/hugo-book/_toc.j2 b/ansibledoctor/templates/hugo-book/_toc.j2 index 3a39f40..7296b96 100644 --- a/ansibledoctor/templates/hugo-book/_toc.j2 +++ b/ansibledoctor/templates/hugo-book/_toc.j2 @@ -1,8 +1,8 @@ - [Requirements](#requirements) -{% set var = role.var | default({}) %} +{% set var = role.defaults | default({}) %} {% if var %} - [Default Variables](#default-variables) -{% if not options.tabulate_vars %} +{% if not options.tabulate_defaults %} {% for key, item in var | dictsort %} - [{{ key }}](#{{ key }}) {% endfor %} diff --git a/ansibledoctor/templates/hugo-book/_vars_tabulated.j2 b/ansibledoctor/templates/hugo-book/defaults_tabulated.j2 similarity index 97% rename from ansibledoctor/templates/hugo-book/_vars_tabulated.j2 rename to ansibledoctor/templates/hugo-book/defaults_tabulated.j2 index 96339e8..6dbefb3 100644 --- a/ansibledoctor/templates/hugo-book/_vars_tabulated.j2 +++ b/ansibledoctor/templates/hugo-book/defaults_tabulated.j2 @@ -1,4 +1,4 @@ -{% set var = role.var | default({}) %} +{% set var = role.defaults | default({}) %} {% if var %} ## Default Variables diff --git a/ansibledoctor/templates/hugo-book/index.md.j2 b/ansibledoctor/templates/hugo-book/index.md.j2 index 71cc24d..e0af0d8 100644 --- a/ansibledoctor/templates/hugo-book/index.md.j2 +++ b/ansibledoctor/templates/hugo-book/index.md.j2 @@ -22,11 +22,11 @@ summary: {{ meta.summary.value | safe_join(" ") }} {# Requirements #} {% include '_requirements.j2' %} -{# Vars #} -{% if options.tabulate_vars %} -{% include '_vars_tabulated.j2' %} +{# Defaults #} +{% if options.tabulate_defaults %} +{% include '_defaults_tabulated.j2' %} {% else %} -{% include '_vars.j2' %} +{% include '_defaults.j2' %} {% endif %} {# Tag #} diff --git a/ansibledoctor/templates/readme/README.md.j2 b/ansibledoctor/templates/readme/README.md.j2 index ebc1aaa..00d6e8e 100644 --- a/ansibledoctor/templates/readme/README.md.j2 +++ b/ansibledoctor/templates/readme/README.md.j2 @@ -14,11 +14,11 @@ {# Requirements #} {% include '_requirements.j2' %} -{# Vars #} -{% if options.tabulate_vars %} -{% include '_vars_tabulated.j2' %} +{# Defaults #} +{% if options.tabulate_defaults %} +{% include '_defaults_tabulated.j2' %} {% else %} -{% include '_vars.j2' %} +{% include '_defaults.j2' %} {% endif %} {# Tag #} diff --git a/ansibledoctor/templates/readme/_vars.j2 b/ansibledoctor/templates/readme/_defaults.j2 similarity index 97% rename from ansibledoctor/templates/readme/_vars.j2 rename to ansibledoctor/templates/readme/_defaults.j2 index e2c453b..0ccf65c 100644 --- a/ansibledoctor/templates/readme/_vars.j2 +++ b/ansibledoctor/templates/readme/_defaults.j2 @@ -1,4 +1,4 @@ -{% set var = role.var | default({}) %} +{% set var = role.defaults | default({}) %} {% if var %} ## Default Variables {% for key, item in var | dictsort %} diff --git a/ansibledoctor/templates/readme/_toc.j2 b/ansibledoctor/templates/readme/_toc.j2 index ef22289..7348e20 100644 --- a/ansibledoctor/templates/readme/_toc.j2 +++ b/ansibledoctor/templates/readme/_toc.j2 @@ -1,10 +1,10 @@ ## Table of content - [Requirements](#requirements) -{% set var = role.var | default({}) %} +{% set var = role.defaults | default({}) %} {% if var %} - [Default Variables](#default-variables) -{% if not options.tabulate_vars %} +{% if not options.tabulate_defaults %} {% for key, item in var | dictsort %} - [{{ key }}](#{{ key }}) {% endfor %} diff --git a/ansibledoctor/templates/readme/_vars_tabulated.j2 b/ansibledoctor/templates/readme/defaults_tabulated.j2 similarity index 97% rename from ansibledoctor/templates/readme/_vars_tabulated.j2 rename to ansibledoctor/templates/readme/defaults_tabulated.j2 index 72d03c1..782ae93 100644 --- a/ansibledoctor/templates/readme/_vars_tabulated.j2 +++ b/ansibledoctor/templates/readme/defaults_tabulated.j2 @@ -1,4 +1,4 @@ -{% set var = role.var | default({}) %} +{% set var = role.defaults | default({}) %} {% if var %} ## Default Variables diff --git a/docs/content/usage/configuration.md b/docs/content/usage/configuration.md index 6a7a4df..d56c40a 100644 --- a/docs/content/usage/configuration.md +++ b/docs/content/usage/configuration.md @@ -82,7 +82,7 @@ template: # Configures whether to tabulate variables in the output. When set to `True`, # variables will be displayed in a tabular format intsead of plain marktdown sections. # NOTE: This option does not support rendering multiline code blocks. - tabulate_vars: False + tabulate_defaults: False renderer: # By default, double spaces, spaces before and after line breaks or tab characters, etc. @@ -145,7 +145,7 @@ ANSIBLE_DOCTOR_LOGGING__JSON=False ANSIBLE_DOCTOR_TEMPLATE__NAME=readme ANSIBLE_DOCTOR_TEMPLATE__SRC= -ANSIBLE_DOCTOR_TEMPLATE__OPTIONS__TABULATE_VARS=False +ANSIBLE_DOCTOR_TEMPLATE__OPTIONS__TABULATE_DEFAULTS=False ANSIBLE_DOCTOR_RENDERER__AUTOTRIM=True ANSIBLE_DOCTOR_RENDERER__INCLUDE_HEADER=