From 4a2cd09fe53d43b07c5a0f24d2e245486c278cae Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Wed, 11 Dec 2024 12:30:53 +0100 Subject: [PATCH] feat: add support for optional event warning for in-line annotation Add warning for openedx-events annotations so developers can include relevant information about the current event. As for now, these warnings have been used to indicate that the event at the time of implementation doesn't have for the event bus. --- .../contrib/config/openedx_events_annotations.yaml | 1 + code_annotations/contrib/sphinx/extensions/openedx_events.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/code_annotations/contrib/config/openedx_events_annotations.yaml b/code_annotations/contrib/config/openedx_events_annotations.yaml index 2c25ce0..af47b2c 100644 --- a/code_annotations/contrib/config/openedx_events_annotations.yaml +++ b/code_annotations/contrib/config/openedx_events_annotations.yaml @@ -12,6 +12,7 @@ annotations: - ".. event_description:": - ".. event_data:": - ".. event_key_field:": + - ".. event_warning:": extensions: python: - py diff --git a/code_annotations/contrib/sphinx/extensions/openedx_events.py b/code_annotations/contrib/sphinx/extensions/openedx_events.py index b8f839c..3256f35 100644 --- a/code_annotations/contrib/sphinx/extensions/openedx_events.py +++ b/code_annotations/contrib/sphinx/extensions/openedx_events.py @@ -118,6 +118,11 @@ def iter_nodes(self): f" {event['line_number']})" ) + if event.get(".. event_warning:") not in (None, "None", "n/a", "N/A"): + event_section += nodes.warning( + "", nodes.paragraph("", event[".. event_warning:"]), ids=[f"warning-{event_name}"] + ) + subject_header += event_section if domain_header: