Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename var to defaults #796

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ansibledoctor/doc_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def __init__(self):
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:
Expand All @@ -42,7 +42,7 @@ def _parse_var_files(self):
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"]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set var = role.var | default({}) %}
{% set var = role.defaults | default({}) %}
{% if var %}
## Default Variables
{% for key, item in var | dictsort %}
Expand Down
4 changes: 2 additions & 2 deletions ansibledoctor/templates/hugo-book/_toc.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set var = role.var | default({}) %}
{% set var = role.defaults | default({}) %}
{% if var %}
## Default Variables

Expand Down
8 changes: 4 additions & 4 deletions ansibledoctor/templates/hugo-book/index.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down
8 changes: 4 additions & 4 deletions ansibledoctor/templates/readme/README.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set var = role.var | default({}) %}
{% set var = role.defaults | default({}) %}
{% if var %}
## Default Variables
{% for key, item in var | dictsort %}
Expand Down
4 changes: 2 additions & 2 deletions ansibledoctor/templates/readme/_toc.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set var = role.var | default({}) %}
{% set var = role.defaults | default({}) %}
{% if var %}
## Default Variables

Expand Down
4 changes: 2 additions & 2 deletions docs/content/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@xoxys xoxys Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, a dedicated setting for tabulation of variables is a bit overkill. If someone wants to use a table to display vars it should be used for defaults and vars.


renderer:
# By default, double spaces, spaces before and after line breaks or tab characters, etc.
Expand Down Expand Up @@ -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=
Expand Down