mirror of
https://github.com/thegeeklab/ansible-doctor.git
synced 2024-11-24 05:40:40 +00:00
feat: add support for indentation with spaces (#508)
This commit is contained in:
parent
b6001fe81d
commit
588f41a3ea
@ -87,6 +87,12 @@ class Config():
|
||||
"file": True,
|
||||
"type": environs.Env().str
|
||||
},
|
||||
"template_autotrim": {
|
||||
"default": True,
|
||||
"env": "TEMPLATE_AUTOTRIM",
|
||||
"file": True,
|
||||
"type": environs.Env().bool
|
||||
},
|
||||
"force_overwrite": {
|
||||
"default": False,
|
||||
"env": "FORCE_OVERWRITE",
|
||||
|
@ -166,10 +166,12 @@ class Generator:
|
||||
value = [value]
|
||||
|
||||
normalized = jinja2.filters.do_join(eval_ctx, value, d, attribute=None)
|
||||
|
||||
if self.config.config["template_autotrim"]:
|
||||
for s in [r" +(\n|\t| )", r"(\n|\t) +"]:
|
||||
normalized = re.sub(s, "\\1", normalized)
|
||||
|
||||
return normalized
|
||||
return jinja2.filters.do_mark_safe(normalized)
|
||||
|
||||
def render(self):
|
||||
self.logger.info(f"Using output dir: {self.config.config.get('output_dir')}")
|
||||
|
@ -39,6 +39,11 @@ output_dir:
|
||||
# Default is built-in templates directory.
|
||||
template_dir:
|
||||
template: readme
|
||||
# By default, double spaces, spaces before and after line breaks or tab characters, etc.
|
||||
# are automatically removed before the template is rendered. As a result, indenting
|
||||
# with spaces does not work. If you want to use spaces to indent text, you must disable
|
||||
# this option.
|
||||
template_autotrim: True
|
||||
|
||||
# Don't ask to overwrite if output file exists.
|
||||
force_overwrite: False
|
||||
@ -97,6 +102,7 @@ ANSIBLE_DOCTOR_LOG_JSON=false
|
||||
ANSIBLE_DOCTOR_OUTPUT_DIR=
|
||||
ANSIBLE_DOCTOR_TEMPLATE_DIR=
|
||||
ANSIBLE_DOCTOR_TEMPLATE=readme
|
||||
ANSIBLE_DOCTOR_TEMPLATE_AUTOTRIM=true
|
||||
ANSIBLE_DOCTOR_FORCE_OVERWRITE=false
|
||||
ANSIBLE_DOCTOR_CUSTOM_HEADER=
|
||||
ANSIBLE_DOCTOR_EXCLUDE_FILES=
|
||||
|
@ -8,6 +8,7 @@ the default description with an annotation.
|
||||
|
||||
## Table of content
|
||||
|
||||
- [Requirements](#requirements)
|
||||
- [Default Variables](#default-variables)
|
||||
- [demo_role_dict](#demo_role_dict)
|
||||
- [demo_role_empty](#demo_role_empty)
|
||||
@ -26,6 +27,11 @@ the default description with an annotation.
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- Minimum Ansible version: `2.4`
|
||||
|
||||
|
||||
## Default Variables
|
||||
|
||||
### demo_role_dict
|
||||
|
Loading…
Reference in New Issue
Block a user