diff --git a/code_annotations/contrib/sphinx/extensions/openedx_events.py b/code_annotations/contrib/sphinx/extensions/openedx_events.py index 9a9f05d..99e695d 100644 --- a/code_annotations/contrib/sphinx/extensions/openedx_events.py +++ b/code_annotations/contrib/sphinx/extensions/openedx_events.py @@ -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:"] @@ -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: