From a9014e31dca7fe6fde309b4c96d3ba807c8211d8 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Sun, 10 Dec 2017 11:28:07 +0100 Subject: [PATCH] refactor(temp): Mark %temperature% token as deprecated --- doc/config.cmake | 4 ++-- src/modules/temperature.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/config.cmake b/doc/config.cmake index 6e0f26fc..fe2cc9e2 100644 --- a/doc/config.cmake +++ b/doc/config.cmake @@ -356,8 +356,8 @@ format-underline = #f50a4d format-warn = format-warn-underline = ${self.format-underline} -label = %temperature% -label-warn = %temperature% +label = %temperature-c% +label-warn = %temperature-c% label-warn-foreground = ${colors.secondary} ramp-0 =  diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index 6ed76473..642ec380 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -32,14 +32,20 @@ namespace modules { m_formatter->add(FORMAT_WARN, TAG_LABEL_WARN, {TAG_LABEL_WARN, TAG_RAMP}); if (m_formatter->has(TAG_LABEL)) { - m_label[temp_state::NORMAL] = load_optional_label(m_conf, name(), TAG_LABEL, "%temperature%"); + m_label[temp_state::NORMAL] = load_optional_label(m_conf, name(), TAG_LABEL, "%temperature-c%"); } if (m_formatter->has(TAG_LABEL_WARN)) { - m_label[temp_state::WARN] = load_optional_label(m_conf, name(), TAG_LABEL_WARN, "%temperature%"); + m_label[temp_state::WARN] = load_optional_label(m_conf, name(), TAG_LABEL_WARN, "%temperature-c%"); } if (m_formatter->has(TAG_RAMP)) { m_ramp = load_ramp(m_conf, name(), TAG_RAMP); } + + // Deprecation warning for the %temperature% token + if((m_label[temp_state::NORMAL] && m_label[temp_state::NORMAL]->has_token("%temperature%")) || + ((m_label[temp_state::WARN] && m_label[temp_state::WARN]->has_token("%temperature%")))) { + m_log.warn("%s: The token `%%temperature%%` is deprecated, use `%%temperature-c%%` instead.", name()); + } } bool temperature_module::update() { @@ -53,6 +59,8 @@ namespace modules { label->replace_token("%temperature-c%", to_string(m_temp) + "°C"); label->replace_token("%temperature-f-n%", to_string(m_temp_f)); label->replace_token("%temperature-c-n%", to_string(m_temp)); + + // DEPRECATED: Will be removed in later release label->replace_token("%temperature%", to_string(m_temp) + "°C"); };