Compare commits
No commits in common. "1abdf419e67d18b34b2196d882f2d10544152aae" and "b2f2aa440665a1a459c7a10fcf9dc4fb54621812" have entirely different histories.
1abdf419e6
...
b2f2aa4406
7 changed files with 5 additions and 70 deletions
|
|
@ -1,9 +1,3 @@
|
||||||
## 0.1.0a7 (2025-03-30)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- support multi lines for help
|
|
||||||
|
|
||||||
## 0.1.0a6 (2025-03-28)
|
## 0.1.0a6 (2025-03-28)
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rougail.output_formatter"
|
name = "rougail.output_formatter"
|
||||||
version = "0.1.0a7"
|
version = "0.1.0a6"
|
||||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
description = "Rougail output formatter"
|
description = "Rougail output formatter"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ from ruamel.yaml import YAML, CommentedMap
|
||||||
from ruamel.yaml.tokens import CommentToken
|
from ruamel.yaml.tokens import CommentToken
|
||||||
from ruamel.yaml.error import CommentMark
|
from ruamel.yaml.error import CommentMark
|
||||||
from ruamel.yaml.comments import CommentedSeq
|
from ruamel.yaml.comments import CommentedSeq
|
||||||
from ruamel.yaml.scalarstring import LiteralScalarString, FoldedScalarString, ScalarString
|
from ruamel.yaml.scalarstring import LiteralScalarString, FoldedScalarString
|
||||||
|
|
||||||
from djlint.settings import Config
|
from djlint.settings import Config
|
||||||
from djlint.reformat import formatter
|
from djlint.reformat import formatter
|
||||||
|
|
@ -285,16 +285,12 @@ class RougailOutputFormatter:
|
||||||
return _get_last_obj(o[param], o, param, 'seq')
|
return _get_last_obj(o[param], o, param, 'seq')
|
||||||
return typ, parent, param
|
return typ, parent, param
|
||||||
param = list(obj)[-1]
|
param = list(obj)[-1]
|
||||||
if isinstance(obj[param], ScalarString):
|
|
||||||
enter = '\n'
|
|
||||||
else:
|
|
||||||
enter = '\n\n'
|
|
||||||
typ, parent, param = _get_last_obj(obj[param], obj, param, 'map')
|
typ, parent, param = _get_last_obj(obj[param], obj, param, 'map')
|
||||||
if typ == 'seq':
|
if typ == 'seq':
|
||||||
func = parent.yaml_key_comment_extend
|
func = parent.yaml_key_comment_extend
|
||||||
else:
|
else:
|
||||||
func = parent.yaml_value_comment_extend
|
func = parent.yaml_value_comment_extend
|
||||||
func(param, [CommentToken(enter, CommentMark(0)), None])
|
func(param, [CommentToken('\n\n', CommentMark(0)), None])
|
||||||
|
|
||||||
def object_to_yaml(self, key, type_, value, multi, object_path):
|
def object_to_yaml(self, key, type_, value, multi, object_path):
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
|
|
@ -311,6 +307,7 @@ class RougailOutputFormatter:
|
||||||
return new_values
|
return new_values
|
||||||
if isinstance(value, JinjaCalculation):
|
if isinstance(value, JinjaCalculation):
|
||||||
jinja = CommentedMap()
|
jinja = CommentedMap()
|
||||||
|
# replace \n to space a add index of \n (now a space) to fold_pos
|
||||||
jinja_values = formatter(self.config, value.jinja.strip())[:-1]
|
jinja_values = formatter(self.config, value.jinja.strip())[:-1]
|
||||||
if key == 'default' and not multi:
|
if key == 'default' and not multi:
|
||||||
jinja["jinja"] = FoldedScalarString(jinja_values)
|
jinja["jinja"] = FoldedScalarString(jinja_values)
|
||||||
|
|
@ -373,8 +370,6 @@ class RougailOutputFormatter:
|
||||||
return {value.key: variable}
|
return {value.key: variable}
|
||||||
elif type_ == 'port' and isinstance(value, str) and value.isnumeric():
|
elif type_ == 'port' and isinstance(value, str) and value.isnumeric():
|
||||||
return int(value)
|
return int(value)
|
||||||
elif key == 'help' and '\n' in value:
|
|
||||||
return LiteralScalarString(value)
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def calc_variable_path(self, object_path, variable_path):
|
def calc_variable_path(self, object_path, variable_path):
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
secret1:
|
|
||||||
description: the first variable
|
|
||||||
type: secret
|
|
||||||
params:
|
|
||||||
min_len: 10
|
|
||||||
|
|
||||||
secret2:
|
|
||||||
description: the second variable
|
|
||||||
type: secret
|
|
||||||
params:
|
|
||||||
max_len: 10
|
|
||||||
forbidden_char:
|
|
||||||
- $
|
|
||||||
- ^
|
|
||||||
default: value
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
var1:
|
|
||||||
description: the first variable
|
|
||||||
help: |-
|
|
||||||
Multi line
|
|
||||||
|
|
||||||
Help
|
|
||||||
|
|
||||||
With useful information
|
|
||||||
|
|
||||||
var2:
|
|
||||||
description: the second variable
|
|
||||||
help: |-
|
|
||||||
Multi line
|
|
||||||
Help
|
|
||||||
With useful information
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
version: 1.1
|
|
||||||
|
|
||||||
var1:
|
|
||||||
description: the first <variable>
|
|
||||||
help: |-
|
|
||||||
Multi line
|
|
||||||
|
|
||||||
<Help>
|
|
||||||
|
|
||||||
With useful information
|
|
||||||
|
|
||||||
var2:
|
|
||||||
description: the second <variable>
|
|
||||||
help: |-
|
|
||||||
Multi line
|
|
||||||
<Help>
|
|
||||||
With useful information
|
|
||||||
|
|
@ -11,7 +11,7 @@ excludes = [
|
||||||
]
|
]
|
||||||
|
|
||||||
test_ok = get_structures_list(excludes)
|
test_ok = get_structures_list(excludes)
|
||||||
# test_ok = [Path('../rougail-tests/structures/00_7help')]
|
# test_ok = [Path('../rougail-tests/structures/00_9default_calculation_param_optional')]
|
||||||
|
|
||||||
|
|
||||||
def idfn(fixture_value):
|
def idfn(fixture_value):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue