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] include tooling in references #253

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docs/concepts/openedx-filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ How do Open edX Filters work?

Open edX Filters are implemented using an accumulative pipeline mechanism, which executes a series of functions in a specific order. Each function in the pipeline receives the output of the previous function as input, allowing developers to build complex processing logic by chaining multiple functions together. The pipeline ensures that the order of execution is maintained and that the result of a previous function is available to the current one in the form of a pipeline.

This pipeline mechanism is implemented by the `OpenEdxPublicFilter`_ class, which provides the necessary tools to fulfill the Open edX Filters requirements mentioned previously, such as ordered execution, configurability, interchangeable functions, argument definition, and cumulative behavior. This enables filters to modify the flow of the application dynamically during runtime based on predefined business logic or conditions.
This pipeline mechanism is implemented by the `OpenEdxPublicFilter`_ class, which provides the necessary tools to fulfill the Open edX Filters requirements mentioned previously, such as ordered execution, configurability, interchangeable functions, argument definition, and cumulative behavior. This enables filters to modify the flow of the application dynamically during runtime based on predefined business logic or conditions. You can review the :doc:`Open edX Filters Tooling <../reference/filters-tooling>` for more information on the available methods and classes.

Architectural Diagram
*********************
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
12 changes: 12 additions & 0 deletions docs/reference/filters-tooling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Open edX Filters Tooling
========================

Here we document the tooling available for working with Open edX filters as a developer.

.. autoclass:: openedx_filters.tooling.OpenEdxPublicFilter
:members:

.. autoexception:: openedx_filters.exceptions.OpenEdxFilterException

.. autoclass:: openedx_filters.filters.PipelineStep
:members:
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ References
:maxdepth: 1
:caption: Contents:

filters-tooling
glossary
filters
filters-configuration
Expand Down
4 changes: 2 additions & 2 deletions openedx_filters/course_authoring/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def run_filter(cls, url: str, org: str) -> tuple[str, str]:
Process the inputs using the configured pipeline steps to modify the URL of the page requested by the user.

Arguments:
- url (str): the URL of the page to be modified.
- org (str): Course org filter used as context data to get LMS configurations.
url (str): the URL of the page to be modified.
org (str): Course org filter used as context data to get LMS configurations.

Returns:
tuple[str, str]:
Expand Down
19 changes: 8 additions & 11 deletions openedx_filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,30 @@ class PipelineStep:

Example usage:

Let's say we want a filter step that changes enrollment modes:
Let's say we want a filter step that changes enrollment modes:

1. If the enrollment mode is honor, then changes it to no-id-professional.
2. If it's other mode, then stop pipeline execution.
1. If the enrollment mode is honor, then changes it to no-id-professional.
2. If it's other mode, then stop pipeline execution.

This pipeline step can be used in conjunction with PreEnrollmentFilter, that's
why the runner method accepts user, course_key and mode as arguments.

class MyFilterStep(PipelineStep):
This pipeline step can be used in conjunction with PreEnrollmentFilter, that's
why the runner method accepts user, course_key and mode as arguments.

>>> class MyFilterStep(PipelineStep):
def run_filter(self, user, course_key, mode):
if mode != "honor":
return

return {
"user": user,
"course_key": course_key,
"mode": "no-id-professional",
}
Another version would be:

class MyFilterStep(PipelineStep):
Another version would be:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a blank line is necessary:

Suggested change
Another version would be:
Another version would be:

Currently, the docs are displayed as follows:
image

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. Thanks!


>>> class MyFilterStep(PipelineStep):
def run_filter(self, user, course_key, mode):
if mode != "honor":
return

return {"mode": "no-id-professional"}
"""

Expand Down
Loading