Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [FC-0074] add support for optional trigger information #143

Merged
merged 12 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ Change Log
Unreleased
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[2.2.0] - 2025-01-15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Add support for optional Open edX Event trigger in-line annotation.

[2.1.0] - 2024-12-12
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Add support for optional event warning for in-line annotation.
* Add support for optional Open edX Event warning for in-line annotation.

[2.0.0] - 2024-10-18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion code_annotations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Extensible tools for parsing annotations in codebases.
"""

__version__ = '2.1.0'
__version__ = '2.2.0'
9 changes: 4 additions & 5 deletions code_annotations/contrib/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"""
Expose contrib configuration file paths as Python variables, for use in 3rd-party utilities.
"""
import importlib.resources
import os

import importlib_resources

FEATURE_TOGGLE_ANNOTATIONS_CONFIG_PATH = importlib_resources.files(
FEATURE_TOGGLE_ANNOTATIONS_CONFIG_PATH = importlib.resources.files(
"code_annotations") / os.path.join("contrib", "config", "feature_toggle_annotations.yaml")

SETTING_ANNOTATIONS_CONFIG_PATH = importlib_resources.files(
SETTING_ANNOTATIONS_CONFIG_PATH = importlib.resources.files(
"code_annotations") / os.path.join("contrib", "config", "setting_annotations.yaml")

OPENEDX_EVENTS_ANNOTATIONS_CONFIG_PATH = importlib_resources.files(
OPENEDX_EVENTS_ANNOTATIONS_CONFIG_PATH = importlib.resources.files(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference: #135 (comment)

"code_annotations") / os.path.join("contrib", "config", "openedx_events_annotations.yaml")
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ annotations:
- ".. event_description:":
- ".. event_data:":
- ".. event_key_field:":
- ".. event_trigger_repository:":
- ".. event_warning:":
extensions:
python:
Expand Down
37 changes: 35 additions & 2 deletions code_annotations/contrib/sphinx/extensions/openedx_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ 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:")

event_section = nodes.section("", ids=[f"openedxevent-{event_type}"])
event_section += nodes.title(text=event_type, ids=[f"title-{event_type}"])
Expand All @@ -114,10 +115,42 @@ def iter_nodes(self):
)
event_section += nodes.paragraph("", "Event data: ", event_data_literal)
event_section += nodes.paragraph(
text=f"Defined at: {event['filename']} (line"
f" {event['line_number']})"
"",
"Defined at: ",
nodes.reference(
text="{} (line {})".format(
event["filename"], event["line_number"]
),
refuri="{}/blob/{}/{}#L{}".format(
self.env.config.openedxevents_repo_url,
self.env.config.openedxevents_repo_version,
event["filename"],
event["line_number"],
),
),
ids=[f"definition-{event_name}"],
)

if event_trigger_repository:
event_trigger_repository = event_trigger_repository.split(" ")
event_section += nodes.paragraph(text="Triggered by:", ids=[f"triggers-{event_name}"])
triggers_bullet_list = nodes.bullet_list()
for repository in event_trigger_repository:
search_url = f"https://github.com/search?q=repo:{repository}+{event_name}.send_event&type=code"
triggers_bullet_list += nodes.list_item(
"",
nodes.paragraph(
"",
"",
nodes.reference(
text=repository,
refuri=search_url,
),
),
)

event_section += triggers_bullet_list

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}"]
Expand Down
Loading