Skip to content

Commit

Permalink
refactor: render triggers only when trigger fields are available
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi committed Dec 30, 2024
1 parent a07eb00 commit 626d2a4
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions code_annotations/contrib/sphinx/extensions/openedx_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def iter_nodes(self):
event_key_field = event.get(".. event_key_field:", "")
event_key_literal = nodes.literal(text=event_key_field)
event_description = event[".. event_description:"]
event_trigger_repository = event.get(".. event_trigger_repository:", "").split(" ")
event_trigger_path = event.get(".. event_trigger_path:", "").split(" ")
event_trigger_repository = event.get(".. event_trigger_repository:")
event_trigger_path = event.get(".. event_trigger_path:")

event_section = nodes.section("", ids=[f"openedxevent-{event_type}"])
event_section += nodes.title(text=event_type, ids=[f"title-{event_type}"])
Expand Down Expand Up @@ -132,22 +132,25 @@ 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_trigger_path = event_trigger_path.split(" ")
event_trigger_repository = event_trigger_repository.split(" ")
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(
Expand Down

0 comments on commit 626d2a4

Please sign in to comment.