Skip to content

Commit

Permalink
feat: Add a config for openedx-events annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
bmtcril committed Feb 20, 2024
1 parent d99bb11 commit 2e6fd96
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions code_annotations/contrib/sphinx/extensions/openedx_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def iter_nodes(self):
event_name = event[".. event_name:"]
event_name_literal = nodes.literal(text=quote_value(event_name))
event_data = event[".. event_data:"]
event_key_field = event.get(".. event_key_field:", None)
event_key_field = event.get(".. event_key_field:", "")
event_key_literal = nodes.literal(text=quote_value(event_key_field))
event_description = event[".. event_description:"]

Expand All @@ -103,11 +103,16 @@ def iter_nodes(self):
event_section += nodes.paragraph(text=f"Description:"
f" {event_description}")
event_section += nodes.paragraph(text=f"Event data: {event_data}")
event_section += nodes.paragraph(
text=f"Defined at: {event['filename']} (line"
f" {event['line_number']})"
source = nodes.reference(
text=f"{event['filename']} (line {event['line_number']})",
refuri="{}/blob/{}/{}#L{}".format(
self.env.config.openedxevents_repo_url,
self.env.config.openedxevents_repo_version,
event['filename'],
event['line_number'],
),
)

event_section += nodes.paragraph("", "Defined at:", source)
domain_header += event_section

if domain_header:
Expand Down

0 comments on commit 2e6fd96

Please sign in to comment.