From 779e572e1d580004f0704474a6ba657e44b35eb3 Mon Sep 17 00:00:00 2001 From: Christopher Arndt Date: Mon, 25 Nov 2024 09:33:26 +0100 Subject: [PATCH] feat: add getter for parameter tooltip/description Also collapse consecutive whitespace in parameter description into single space Signed-off-by: Christopher Arndt --- faustdoctor/architectures/generic.cpp | 12 ++++++++++++ faustdoctor/architectures/generic.hpp | 1 + faustdoctor/metadata.py | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/faustdoctor/architectures/generic.cpp b/faustdoctor/architectures/generic.cpp index 3ae6fb0..a1cff51 100644 --- a/faustdoctor/architectures/generic.cpp +++ b/faustdoctor/architectures/generic.cpp @@ -225,6 +225,18 @@ const char *{{Identifier}}::parameter_short_label(unsigned index) noexcept } } +const char *{{Identifier}}::parameter_description(unsigned index) noexcept +{ + switch (index) { + {% for w in active + passive %}{% if w.tooltip %} + case {{loop.index0}}: + return {{cstr(w.tooltip)}}; + {%- endif %}{% endfor %} + default: + return 0; + } +} + const char *{{Identifier}}::parameter_style(unsigned index) noexcept { switch (index) { diff --git a/faustdoctor/architectures/generic.hpp b/faustdoctor/architectures/generic.hpp index ae006c6..e706f1d 100644 --- a/faustdoctor/architectures/generic.hpp +++ b/faustdoctor/architectures/generic.hpp @@ -69,6 +69,7 @@ class {{Identifier}} { static const char *parameter_group_symbol(unsigned group_id) noexcept; static const char *parameter_label(unsigned index) noexcept; static const char *parameter_short_label(unsigned index) noexcept; + static const char *parameter_description(unsigned index) noexcept; static const char *parameter_style(unsigned index) noexcept; static const char *parameter_symbol(unsigned index) noexcept; static const char *parameter_unit(unsigned index) noexcept; diff --git a/faustdoctor/metadata.py b/faustdoctor/metadata.py index df36770..b061e28 100644 --- a/faustdoctor/metadata.py +++ b/faustdoctor/metadata.py @@ -194,7 +194,7 @@ def extract_widget(node: ET.Element, is_active: bool, md: Metadata) -> Widget: elif key == "symbol": w.symbol = mangle(value) elif key == "tooltip": - w.tooltip = value + w.tooltip = re.sub(r'\s+', ' ', value) elif key == "unit": w.unit = value