Rename vars to defaults

This commit is contained in:
Henning Henkel 2024-08-28 16:39:49 +02:00 committed by Henning Henkel
parent 9c77a76567
commit ac6d161a6d
10 changed files with 21 additions and 21 deletions

View File

@ -26,11 +26,11 @@ class Parser:
self.log = structlog.get_logger() self.log = structlog.get_logger()
self._files_registry = Registry() self._files_registry = Registry()
self._parse_meta_file() self._parse_meta_file()
self._parse_var_files() self._parse_defaults_files()
self._parse_task_tags() self._parse_task_tags()
self._populate_doc_data() self._populate_doc_data()
def _parse_var_files(self): def _parse_defaults_files(self):
for rfile in self._files_registry.get_files(): for rfile in self._files_registry.get_files():
if any(fnmatch.fnmatch(rfile, "*/defaults/*." + ext) for ext in YAML_EXTENSIONS): if any(fnmatch.fnmatch(rfile, "*/defaults/*." + ext) for ext in YAML_EXTENSIONS):
with open(rfile, encoding="utf8") as yamlfile: with open(rfile, encoding="utf8") as yamlfile:
@ -42,7 +42,7 @@ class Parser:
data = defaultdict(dict, raw or {}) data = defaultdict(dict, raw or {})
for key, value in data.items(): 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): def _parse_meta_file(self):
self._data["meta"]["name"] = {"value": self.config.config["role_name"]} self._data["meta"]["name"] = {"value": self.config.config["role_name"]}

View File

@ -1,4 +1,4 @@
{% set var = role.var | default({}) %} {% set var = role.defaults | default({}) %}
{% if var %} {% if var %}
## Default Variables ## Default Variables
{% for key, item in var | dictsort %} {% for key, item in var | dictsort %}

View File

@ -1,8 +1,8 @@
- [Requirements](#requirements) - [Requirements](#requirements)
{% set var = role.var | default({}) %} {% set var = role.defaults | default({}) %}
{% if var %} {% if var %}
- [Default Variables](#default-variables) - [Default Variables](#default-variables)
{% if not options.tabulate_vars %} {% if not options.tabulate_defaults %}
{% for key, item in var | dictsort %} {% for key, item in var | dictsort %}
- [{{ key }}](#{{ key }}) - [{{ key }}](#{{ key }})
{% endfor %} {% endfor %}

View File

@ -1,4 +1,4 @@
{% set var = role.var | default({}) %} {% set var = role.defaults | default({}) %}
{% if var %} {% if var %}
## Default Variables ## Default Variables

View File

@ -22,11 +22,11 @@ summary: {{ meta.summary.value | safe_join(" ") }}
{# Requirements #} {# Requirements #}
{% include '_requirements.j2' %} {% include '_requirements.j2' %}
{# Vars #} {# Defaults #}
{% if options.tabulate_vars %} {% if options.tabulate_defaults %}
{% include '_vars_tabulated.j2' %} {% include '_defaults_tabulated.j2' %}
{% else %} {% else %}
{% include '_vars.j2' %} {% include '_defaults.j2' %}
{% endif %} {% endif %}
{# Tag #} {# Tag #}

View File

@ -14,11 +14,11 @@
{# Requirements #} {# Requirements #}
{% include '_requirements.j2' %} {% include '_requirements.j2' %}
{# Vars #} {# Defaults #}
{% if options.tabulate_vars %} {% if options.tabulate_defaults %}
{% include '_vars_tabulated.j2' %} {% include '_defaults_tabulated.j2' %}
{% else %} {% else %}
{% include '_vars.j2' %} {% include '_defaults.j2' %}
{% endif %} {% endif %}
{# Tag #} {# Tag #}

View File

@ -1,4 +1,4 @@
{% set var = role.var | default({}) %} {% set var = role.defaults | default({}) %}
{% if var %} {% if var %}
## Default Variables ## Default Variables
{% for key, item in var | dictsort %} {% for key, item in var | dictsort %}

View File

@ -1,10 +1,10 @@
## Table of content ## Table of content
- [Requirements](#requirements) - [Requirements](#requirements)
{% set var = role.var | default({}) %} {% set var = role.defaults | default({}) %}
{% if var %} {% if var %}
- [Default Variables](#default-variables) - [Default Variables](#default-variables)
{% if not options.tabulate_vars %} {% if not options.tabulate_defaults %}
{% for key, item in var | dictsort %} {% for key, item in var | dictsort %}
- [{{ key }}](#{{ key }}) - [{{ key }}](#{{ key }})
{% endfor %} {% endfor %}

View File

@ -1,4 +1,4 @@
{% set var = role.var | default({}) %} {% set var = role.defaults | default({}) %}
{% if var %} {% if var %}
## Default Variables ## Default Variables

View File

@ -82,7 +82,7 @@ template:
# Configures whether to tabulate variables in the output. When set to `True`, # 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. # variables will be displayed in a tabular format intsead of plain marktdown sections.
# NOTE: This option does not support rendering multiline code blocks. # NOTE: This option does not support rendering multiline code blocks.
tabulate_vars: False tabulate_defaults: False
renderer: renderer:
# By default, double spaces, spaces before and after line breaks or tab characters, etc. # 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__NAME=readme
ANSIBLE_DOCTOR_TEMPLATE__SRC= 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__AUTOTRIM=True
ANSIBLE_DOCTOR_RENDERER__INCLUDE_HEADER= ANSIBLE_DOCTOR_RENDERER__INCLUDE_HEADER=