Skip to content

Commit d5306a2

Browse files
committed
docs: Update docstrings to valid rst syntax.
1 parent 1b92a31 commit d5306a2

File tree

3 files changed

+42
-45
lines changed

3 files changed

+42
-45
lines changed

backend/sample_plugin/apps.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ class SamplePluginConfig(AppConfig):
3333
- Add custom business logic
3434
3535
Entry Point Configuration:
36-
This plugin is registered in setup.py as:
37-
```python
38-
entry_points={
39-
"lms.djangoapp": ["sample_plugin = sample_plugin.apps:SamplePluginConfig"],
40-
"cms.djangoapp": ["sample_plugin = sample_plugin.apps:SamplePluginConfig"],
41-
}
42-
```
36+
This plugin is registered in setup.py as::
37+
38+
entry_points={
39+
"lms.djangoapp": ["sample_plugin = sample_plugin.apps:SamplePluginConfig"],
40+
"cms.djangoapp": ["sample_plugin = sample_plugin.apps:SamplePluginConfig"],
41+
}
4342
4443
The platform automatically discovers and loads plugins registered in these entry points.
4544
""" # noqa:

backend/sample_plugin/pipeline.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
Key Concepts:
1414
- Filters receive data and return modified data
15-
- They run at specific pipeline steps during platform operations
15+
- They run at specific pipeline steps during platform operations
1616
- Filters can halt execution by raising exceptions
1717
- Multiple filters can be chained together in a pipeline
1818
- Filters should be lightweight and handle errors gracefully
@@ -56,18 +56,17 @@ class ChangeCourseAboutPageUrl(PipelineStep):
5656
This filter hooks into the course about page URL rendering process.
5757
Register it for the filter: org.openedx.learning.course.about.render.started.v1
5858
59-
Registration Example (in settings/common.py):
60-
```python
61-
def plugin_settings(settings):
62-
settings.OPEN_EDX_FILTERS_CONFIG = {
63-
"org.openedx.learning.course.about.render.started.v1": {
64-
"pipeline": [
65-
"sample_plugin.pipeline.ChangeCourseAboutPageUrl"
66-
],
67-
"fail_silently": False,
59+
Registration Example (in settings/common.py)::
60+
61+
def plugin_settings(settings):
62+
settings.OPEN_EDX_FILTERS_CONFIG = {
63+
"org.openedx.learning.course.about.render.started.v1": {
64+
"pipeline": [
65+
"sample_plugin.pipeline.ChangeCourseAboutPageUrl"
66+
],
67+
"fail_silently": False,
68+
}
6869
}
69-
}
70-
```
7170
7271
Filter Documentation:
7372
- Available Filters: https://docs.openedx.org/projects/openedx-filters/en/latest/reference/filters.html
@@ -100,7 +99,7 @@ def run_filter(self, url, org, **kwargs):
10099
101100
Raises:
102101
FilterException: If processing should be halted
103-
102+
104103
Filter Requirements:
105104
- Must return dictionary with keys matching input parameters
106105
- Return None to skip this filter (let other filters run)
@@ -121,14 +120,14 @@ def run_filter(self, url, org, **kwargs):
121120
match = re.search(pattern, url)
122121
if match:
123122
course_id = match.group('course_id')
124-
123+
125124
# Example: Redirect to external marketing site
126125
new_url = f"https://example.com/new_about_page/{course_id}"
127-
126+
128127
logger.debug(
129128
f"Redirecting course about page for {course_id} from {url} to {new_url}"
130129
)
131-
130+
132131
# Return modified data
133132
return {"url": new_url, "org": org}
134133

@@ -137,17 +136,17 @@ def run_filter(self, url, org, **kwargs):
137136
return {"url": url, "org": org}
138137

139138
# Alternative patterns for different business logic:
140-
139+
141140
# Organization-based routing:
142141
# if org == "special_org":
143142
# new_url = f"https://special-site.com/courses/{course_id}"
144143
# return {"url": new_url, "org": org}
145-
144+
146145
# Course type-based routing:
147146
# if "MicroMasters" in course_id:
148147
# new_url = f"https://micromasters.example.com/{course_id}"
149148
# return {"url": new_url, "org": org}
150-
149+
151150
# A/B testing implementation:
152151
# import random
153152
# if random.choice([True, False]):

backend/sample_plugin/signals.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,33 @@ def log_course_info_changed(signal, sender, catalog_info: CourseCatalogData, **k
8585
- Log changes for audit and compliance
8686
- Update analytics dashboards with new course information
8787
88-
Example Implementation:
89-
```python
90-
# Send to external CRM system
91-
external_api.update_course(
92-
course_id=str(catalog_info.course_key),
93-
name=catalog_info.name,
94-
is_hidden=catalog_info.hidden
95-
)
96-
97-
# Update internal tracking
98-
CourseChangeLog.objects.create(
99-
course_key=catalog_info.course_key,
100-
change_type='catalog_updated',
101-
timestamp=timezone.now()
102-
)
103-
```
88+
Example Implementation::
89+
90+
# Send to external CRM system
91+
external_api.update_course(
92+
course_id=str(catalog_info.course_key),
93+
name=catalog_info.name,
94+
is_hidden=catalog_info.hidden
95+
)
96+
97+
# Update internal tracking
98+
CourseChangeLog.objects.create(
99+
course_key=catalog_info.course_key,
100+
change_type='catalog_updated',
101+
timestamp=timezone.now()
102+
)
104103
105104
Performance Considerations:
106105
- Keep processing lightweight (events should not block platform operations)
107106
- Use asynchronous tasks for heavy processing (Celery, etc.)
108107
- Handle exceptions gracefully to prevent platform disruption
109108
"""
110109
logging.info(f"Course catalog updated: {catalog_info.course_key}")
111-
110+
112111
# Access available data from the event
113112
logging.debug(f"Course name: {catalog_info.name}")
114113
logging.debug(f"Course hidden: {catalog_info.hidden}")
115-
114+
116115
# Example: Integrate with external systems
117116
# try:
118117
# # Send to external system
@@ -123,7 +122,7 @@ def log_course_info_changed(signal, sender, catalog_info: CourseCatalogData, **k
123122
# )
124123
# except Exception as e:
125124
# logging.error(f"Failed to notify external system: {e}")
126-
125+
127126
# Example: Update internal tracking
128127
# from .models import CourseArchiveStatus
129128
# CourseArchiveStatus.objects.filter(

0 commit comments

Comments
 (0)