From 55550f604ead3ce9cb83c0c7419982656bd4db8e Mon Sep 17 00:00:00 2001 From: HUG0-D Date: Wed, 27 Nov 2024 09:45:23 +0100 Subject: [PATCH] Add enum wrapped_comments Signed-off-by: HUG0-D --- cimgen/cimgen.py | 7 +++++++ .../modernpython/templates/enum_template.mustache | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cimgen/cimgen.py b/cimgen/cimgen.py index 7de641a7..3f8cd797 100644 --- a/cimgen/cimgen.py +++ b/cimgen/cimgen.py @@ -414,6 +414,13 @@ def _parse_rdf(input_dic, version): # NOSONAR for instance in enum_instances: clarse = _get_rid_of_hash(instance["type"]) if clarse and clarse in classes_map: + if instance.get("comment"): + instance["wrapped_comment"] = wrap_and_clean( + instance["comment"], + width=100, + initial_indent="# ", + subsequent_indent=(" # "), + ) classes_map[clarse].add_enum_instance(instance) else: logger.info("Class {} for enum instance {} not found.".format(clarse, instance)) diff --git a/cimgen/languages/modernpython/templates/enum_template.mustache b/cimgen/languages/modernpython/templates/enum_template.mustache index d0b3826c..1c51ff62 100644 --- a/cimgen/languages/modernpython/templates/enum_template.mustache +++ b/cimgen/languages/modernpython/templates/enum_template.mustache @@ -7,9 +7,10 @@ from enum import Enum class {{class_name}}(str, Enum): """ - {{{class_comment}}} # noqa: E501 + {{{wrapped_class_comment}}} """ {{#enum_instances}} - {{label}} = "{{label}}"{{#comment}} # {{comment}}{{/comment}} # noqa: E501 + {{label}} = "{{label}}"{{#comment}} + {{wrapped_comment}}{{/comment}} {{/enum_instances}}