From 317af481f8530fcba709c0c874524506923955d5 Mon Sep 17 00:00:00 2001 From: Andrei Pavel Date: Thu, 22 Aug 2024 12:49:03 +0300 Subject: [#1945] address review - generate kea-messages.rst automatically on make -C doc/sphinx - add disclaimer header that debug-messages.rst and kea-messages.rst are generated - minor changes to debug level variable names - do not write section "Messages printed" in tools/check-messages.py if there are no messages --- tools/check-messages.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/check-messages.py b/tools/check-messages.py index 63d7149e40..aaa1773c5b 100755 --- a/tools/check-messages.py +++ b/tools/check-messages.py @@ -149,16 +149,22 @@ def check_placeholder_ids(messages): def generate_page_with_messages_printed_on_each_debug_level(messages, debug_levels): content = [] for log_level in sorted(set(debug_levels.values())): + messages_at_this_log_level = [(message_id, message) for message_id, message in sorted(messages.items()) + if message['debug_log_level_line'] == f'Logged at debug log level {log_level}.'] + if len(messages_at_this_log_level) == 0: + # Do not write "Messages printed" subtitle if there are no messages. + continue subtitle = f'Messages printed on debuglevel {log_level}' content.append(subtitle) content.append('=' * len(subtitle)) content.append('\n') - for message_id, message in sorted(messages.items()): - if message['debug_log_level_line'] == f'Logged at debug log level {log_level}.': - content.append(f'- {message_id}') + for message_id, message in messages_at_this_log_level: + content.append(f'- {message_id}') content.append('\n') parent_dir = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) with open(f'{parent_dir}/../doc/sphinx/debug-messages.rst', 'w', encoding='utf-8') as f: + f.write('..\n') + f.write(' File generated by "./tools/check-messages.py -a". Do not edit by hand.\n\n') for i in content: f.write(i) f.write('\n') -- cgit v1.2.3