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

docs: [FC-0074] add documentation for in-line code annotations #432

Merged
merged 1 commit into from
Dec 12, 2024
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
22 changes: 5 additions & 17 deletions docs/how-tos/creating-new-events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,13 @@ specifies:

The definition created in this step must comply with:

- It should be created in the `signals.py` file in the corresponding subdomain. Refer to Naming Conventions ADR for more
- It should be created in the ``signals.py`` file in the corresponding subdomain. Refer to Naming Conventions ADR for more
on events subdomains.
- It should follow the naming conventions specified in Naming Conventions ADR.
- It must be documented using in-line documentation with at least: `event_type`, `event_name`, `event_description` and
`event_data`:
- It should follow the naming conventions specified in :doc:`../decisions/0002-events-naming-and-versioning`.
- It must be documented using in-line documentation with at least: ``event_type``, ``event_name``, ``event_description`` and
``event_data``. See :doc:`../reference/in-line-code-annotations-for-an-event` for more information.

+-------------------+----------------------------------------------------------------------------------------------------+
| Annotation | Description |
+===================+====================================================================================================+
| event_type | Identifier across services of the event. Should follow the events naming conventions. |
+-------------------+----------------------------------------------------------------------------------------------------+
| event_name | Name of the variable storing the event instance. |
+-------------------+----------------------------------------------------------------------------------------------------+
| event_description | General description which includes when the event should be emitted. |
+-------------------+----------------------------------------------------------------------------------------------------+
| event_data | What type of class attribute the event sends. |
+-------------------+----------------------------------------------------------------------------------------------------+

Consider the following example:
Consider the course enrollment created event as an example:

.. code-block:: python

Expand Down
34 changes: 34 additions & 0 deletions docs/reference/in-line-code-annotations-for-an-event.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
In-line Code Annotations for An Open edX Event
==============================================

When creating a new Open edX Event, you must document the event definition using in-line code annotations. These annotations provide a structured way to document the event's metadata, making it easier for developers to understand the event's purpose and how it should be used.

+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
| Annotation | Description |
+==================================+==================================================================================================================================+
| event_type (Required) | Identifier across services of the event. Should follow the :doc:`../decisions/0002-events-naming-and-versioning` standard. |
+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
| event_name (Required) | Name of the variable storing the event instance. |
+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
| event_description (Required) | General description which includes when the event should be emitted. |
+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
| event_data (Required) | What type of class attribute the event sends. |
+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------+
| event_warnings (Optional) | Any warnings or considerations that should be taken into account when using the event. |
+----------------------------------+----------------------------------------------------------------------------------------------------------------------------------+

Consider the following example:

.. code-block:: python

# Location openedx_events/learning/signals.py
# .. event_type: org.openedx.learning.course.enrollment.created.v1
# .. event_name: COURSE_ENROLLMENT_CREATED
# .. event_description: emitted when the user's enrollment process is completed.
# .. event_data: CourseEnrollmentData
COURSE_ENROLLMENT_CREATED = OpenEdxPublicSignal(
event_type="org.openedx.learning.course.enrollment.created.v1",
data={
"enrollment": CourseEnrollmentData,
}
)
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ References
:caption: Contents:

events
in-line-code-annotations-for-an-event
glossary
event-bus-configurations
oeps
Expand Down
Loading