From 38024081b54b9982d0a12ed21d4a92398b2e665d Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Mon, 30 Dec 2024 12:13:58 +0100 Subject: [PATCH] refactor: render triggers only when trigger fields are available --- .../sphinx/extensions/openedx_events.py | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/code_annotations/contrib/sphinx/extensions/openedx_events.py b/code_annotations/contrib/sphinx/extensions/openedx_events.py index 2e2e7ec..7e4ecd3 100644 --- a/code_annotations/contrib/sphinx/extensions/openedx_events.py +++ b/code_annotations/contrib/sphinx/extensions/openedx_events.py @@ -132,22 +132,23 @@ def iter_nodes(self): ids=[f"definition-{event_name}"], ) - event_section += nodes.paragraph(text="Triggers", ids=[f"triggers-{event_name}"]) - triggers_bullet_list = nodes.bullet_list() - for repository, path in zip(event_trigger_repository, event_trigger_path): - triggers_bullet_list += nodes.list_item( - "", - nodes.paragraph( + if event_trigger_path and event_trigger_repository: + event_section += nodes.paragraph(text="Triggers", ids=[f"triggers-{event_name}"]) + triggers_bullet_list = nodes.bullet_list() + for repository, path in zip(event_trigger_repository, event_trigger_path): + triggers_bullet_list += nodes.list_item( "", - "Path: ", - nodes.reference( - text=path, - refuri=f"https://github.com/search?q=repo:{repository}+{event_name}+path:{path}" + nodes.paragraph( + "", + "Path: ", + nodes.reference( + text=path, + refuri=f"https://github.com/search?q=repo:{repository}+{event_name}+path:{path}" + ), ), - ), - ) + ) - event_section += triggers_bullet_list + event_section += triggers_bullet_list if event.get(".. event_warning:") not in (None, "None", "n/a", "N/A"): event_section += nodes.warning(