From 6be773de3c0dda4c0a48cad59c75055174d78218 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 8 May 2025 22:10:28 +0200 Subject: [PATCH] fix: tiramisu_display_name could display only description --- src/rougail/__init__.py | 30 +++++++++++++++++++++--------- src/rougail/config.py | 19 ++++++++++++------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/rougail/__init__.py b/src/rougail/__init__.py index f7888ec56..c4fda63e0 100644 --- a/src/rougail/__init__.py +++ b/src/rougail/__init__.py @@ -42,17 +42,29 @@ def tiramisu_display_name( with_quote: bool = False, ) -> str: """Replace the Tiramisu display_name function to display path + description""" - doc = kls._get_information(subconfig, "doc", None) - comment = f" ({doc})" if doc and doc != kls.impl_getname() else "" + config_bag = subconfig.config_bag + context = config_bag.context + values = context.get_values() + context_subconfig = context.get_root(config_bag) + doc = values.get_information(subconfig, "doc", None) + comment = doc if doc and doc != kls.impl_getname() else "" if "{{ identifier }}" in comment and subconfig.identifiers: comment = comment.replace("{{ identifier }}", str(subconfig.identifiers[-1])) - path = kls.impl_getpath() - if "{{ identifier }}" in path and subconfig.identifiers: - path = path.replace( - "{{ identifier }}", normalize_family(str(subconfig.identifiers[-1])) - ) - if with_quote: - return f'"{path}"{comment}' + path_in_description = values.get_information(context_subconfig, 'path_in_description', True) + if path_in_description or not comment: + comment = f" ({comment})" if comment else "" + if path_in_description is False: + path = kls.impl_getname() + else: + path = kls.impl_getpath() + if "{{ identifier }}" in path and subconfig.identifiers: + path = path.replace( + "{{ identifier }}", normalize_family(str(subconfig.identifiers[-1])) + ) + if with_quote and not path_in_description: + return f'"{path}"{comment}' + else: + path = "" return f"{path}{comment}" diff --git a/src/rougail/config.py b/src/rougail/config.py index e7693b7b4..d11d4ae53 100644 --- a/src/rougail/config.py +++ b/src/rougail/config.py @@ -223,7 +223,7 @@ def _rougail_config( add_extra_options: bool = True, ) -> "OptionDescription": rougail_options = f"""default_dictionary_format_version: - description: Dictionary format version by default, if not specified in dictionary file + description: {_('Structure format version by default, if not specified in structure file')} alternative_name: v choices: - '1.0' @@ -370,13 +370,13 @@ secret_manager: for process in processes: if processes[process]: objects = processes[process] - rougail_process += """ + process_name = normalize_family(process) + tr_process_name = _(process_name) + rougail_process += f""" - {NAME}: - description: Select for {NAME} -""".format( - NAME=normalize_family(process), - ) + {process_name}: + description: {_('Select for {0}').format(tr_process_name)} +""" if process != "structural": rougail_process += """ alternative_name: {NAME[0]} @@ -454,8 +454,13 @@ secret_manager: PROP=prop, ) rougail_process += f""" +define_default_params: false # {_('Override default parameters for option type')} + default_params: description: {_("Default parameters for option type")} + disabled: + variable: _.define_default_params + when: false """ for typ, params in get_convert_option_types():