mirror of
https://github.com/thegeeklab/ansible-doctor.git
synced 2024-11-22 04:40:43 +00:00
fix: allow line-breaks in multiline annotations (#243)
This commit is contained in:
parent
9bb31ca293
commit
aac0ef5f20
@ -4,6 +4,7 @@
|
|||||||
import glob
|
import glob
|
||||||
import ntpath
|
import ntpath
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
import jinja2.exceptions
|
import jinja2.exceptions
|
||||||
@ -158,7 +159,10 @@ class Generator:
|
|||||||
def _save_join(self, eval_ctx, value, d=u"", attribute=None):
|
def _save_join(self, eval_ctx, value, d=u"", attribute=None):
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
value = [value]
|
value = [value]
|
||||||
return jinja2.filters.do_join(eval_ctx, value, d, attribute=None)
|
|
||||||
|
joined = jinja2.filters.do_join(eval_ctx, value, d, attribute=None)
|
||||||
|
nornalized = re.sub(r" +(\n|\t| )", "\\1", joined)
|
||||||
|
return nornalized
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
self.logger.info("Using output dir: " + self.config.config.get("output_dir"))
|
self.logger.info("Using output dir: " + self.config.config.get("output_dir"))
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
{% set deps = meta.dependencies.value %}
|
{% set deps = meta.dependencies.value %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for item in deps %}
|
{% for item in deps %}
|
||||||
* {{ item }}
|
- {{ item }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
None.
|
None.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{% set var = role.var | default({}) %}
|
{% set var = role.var | default({}) %}
|
||||||
{% if var %}
|
{% if var %}
|
||||||
* [Default Variables](#default-variables)
|
- [Default Variables](#default-variables)
|
||||||
{% for key, item in var | dictsort %}
|
{% for key, item in var | dictsort %}
|
||||||
* [{{ key }}](#{{ key }})
|
- [{{ key }}](#{{ key }})
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
* [Dependencies](#dependencies)
|
- [Dependencies](#dependencies)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
### {{ key }}
|
### {{ key }}
|
||||||
{% if item.description is defined and item.description %}
|
{% if item.description is defined and item.description %}
|
||||||
|
|
||||||
{{ item.description | save_join(" ") | striptags }}
|
{{ item.description | save_join(" ") }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.value is defined and item.value %}
|
{% if item.value is defined and item.value %}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
{{ item.value | to_nice_yaml(indent=2) }}
|
{{ item.value | to_nice_yaml(indent=2) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for ve_line in item.value %}
|
{% for ve_line in item.value %}
|
||||||
{{ ve_line }}
|
{{ ve_line | replace("\n\n", "\n") }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
```
|
```
|
||||||
@ -32,7 +32,7 @@
|
|||||||
{{ item.example | to_nice_yaml(indent=2) }}
|
{{ item.example | to_nice_yaml(indent=2) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for ex_line in item.example %}
|
{% for ex_line in item.example %}
|
||||||
{{ ex_line }}
|
{{ ex_line | replace("\n\n", "\n") }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
```
|
```
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
{% set deps = meta.dependencies.value %}
|
{% set deps = meta.dependencies.value %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for item in deps %}
|
{% for item in deps %}
|
||||||
* {{ item }}
|
- {{ item }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
None.
|
None.
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
{% set var = role.var | default({}) %}
|
{% set var = role.var | default({}) %}
|
||||||
{% if var %}
|
{% if var %}
|
||||||
* [Default Variables](#default-variables)
|
- [Default Variables](#default-variables)
|
||||||
{% for key, item in var | dictsort %}
|
{% for key, item in var | dictsort %}
|
||||||
* [{{ key }}](#{{ key }})
|
- [{{ key }}](#{{ key }})
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
* [Dependencies](#dependencies)
|
- [Dependencies](#dependencies)
|
||||||
* [License](#license)
|
- [License](#license)
|
||||||
* [Author](#author)
|
- [Author](#author)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
### {{ key }}
|
### {{ key }}
|
||||||
{% if item.description is defined and item.description %}
|
{% if item.description is defined and item.description %}
|
||||||
|
|
||||||
{{ item.description | save_join(" ") | striptags }}
|
{{ item.description | save_join(" ") }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.value is defined and item.value %}
|
{% if item.value is defined and item.value %}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
{{ item.value | to_nice_yaml(indent=2) }}
|
{{ item.value | to_nice_yaml(indent=2) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for ve_line in item.value %}
|
{% for ve_line in item.value %}
|
||||||
{{ ve_line }}
|
{{ ve_line | replace("\n\n", "\n") }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
```
|
```
|
||||||
@ -32,7 +32,7 @@
|
|||||||
{{ item.example | to_nice_yaml(indent=2) }}
|
{{ item.example | to_nice_yaml(indent=2) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for ex_line in item.example %}
|
{% for ex_line in item.example %}
|
||||||
{{ ex_line }}
|
{{ ex_line | replace("\n\n", "\n") }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
```
|
```
|
||||||
|
@ -39,6 +39,8 @@ demo_role_dict:
|
|||||||
demo_role_dict:
|
demo_role_dict:
|
||||||
key1:
|
key1:
|
||||||
sub: some value
|
sub: some value
|
||||||
|
|
||||||
|
# Inline description
|
||||||
key2:
|
key2:
|
||||||
sublist:
|
sublist:
|
||||||
- subval1
|
- subval1
|
||||||
@ -105,6 +107,8 @@ demo_role_single: b
|
|||||||
|
|
||||||
If you want to add an explicit notice, that a var is not set by default, this is one option. Make sure to flag it as json value: `@var demo_role_undefined_var: $ "_unset_"`
|
If you want to add an explicit notice, that a var is not set by default, this is one option. Make sure to flag it as json value: `@var demo_role_undefined_var: $ "_unset_"`
|
||||||
|
|
||||||
|
Test paragarph
|
||||||
|
|
||||||
#### Default value
|
#### Default value
|
||||||
|
|
||||||
```YAML
|
```YAML
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
demo_role_unset:
|
demo_role_unset:
|
||||||
|
|
||||||
demo_role_empty: ""
|
demo_role_empty: ""
|
||||||
demo_role_single: 'b'
|
demo_role_single: "b"
|
||||||
|
|
||||||
# @var demo_role_empty_dict:description: >
|
# @var demo_role_empty_dict:description: >
|
||||||
# ... or you can use a valid json. In this case,
|
# ... or you can use a valid json. In this case,
|
||||||
@ -19,6 +19,8 @@ demo_role_empty_dict: {}
|
|||||||
# demo_role_dict:
|
# demo_role_dict:
|
||||||
# key1:
|
# key1:
|
||||||
# sub: some value
|
# sub: some value
|
||||||
|
#
|
||||||
|
# # Inline description
|
||||||
# key2:
|
# key2:
|
||||||
# sublist:
|
# sublist:
|
||||||
# - subval1
|
# - subval1
|
||||||
@ -39,9 +41,10 @@ demo_role_dict:
|
|||||||
# ]
|
# ]
|
||||||
# @end
|
# @end
|
||||||
demo_role_other_tags: []
|
demo_role_other_tags: []
|
||||||
|
|
||||||
# @var demo_role_undefined_var:description: >
|
# @var demo_role_undefined_var:description: >
|
||||||
# If you want to add an explicit notice, that a var is not set by default, this is one option.
|
# If you want to add an explicit notice, that a var is not set by default, this is one option.
|
||||||
# Make sure to flag it as json value: `@var demo_role_undefined_var: $ "_unset_"`
|
# Make sure to flag it as json value: `@var demo_role_undefined_var: $ "_unset_"`
|
||||||
|
#
|
||||||
|
# Test paragarph
|
||||||
# @end
|
# @end
|
||||||
# @var demo_role_undefined_var: $ "_unset_"
|
# @var demo_role_undefined_var: $ "_unset_"
|
||||||
|
Loading…
Reference in New Issue
Block a user