Repository navigation
docs: explain what template patches are and how to use them - #1511
Conversation
New plugin developers had no single place explaining what a patch is: the
template patch catalog only lists the available patches, and the
ENV_PATCHES filter documentation is very brief. The only conceptual
explanation lived in the legacy v0 plugin API docs.
Add a "Template patches" page to the plugin development guide. It explains
how {{ patch(...) }} statements work, how to add content to a patch with the
ENV_PATCHES filter or with patch files, that patch content is rendered as a
Jinja2 template, how indentation is handled, how multiple items are ordered
(and how to use priorities), how to find and debug patches with
`tutor config patches list/show`, and how plugins can create their own
patches.
Link the new page from the plugin tutorial, the template patch catalog and
the ENV_PATCHES and ENV_TEMPLATE_FILTERS docstrings. The catalog stays at
reference/patches/index so that existing links to individual patches keep
working.
This completes the work started in #852.
See: openedx/wg-devops#29
Co-authored-by: Maria Fernanda Magallanes Zubillaga <maria.magallanes@edunext.co>
Faraz32123
left a comment
There was a problem hiding this comment.
Thanks, this fills a real gap for new plugin developers. I checked the content against the code (patch rendering, newline separator, priority order, tutor config patches list/show, the indent(2) example) and it's accurate; the docs also build cleanly with -n. LGTM, with a few optional nits:
- "after you modify a patch, you should run
tutor config save(ortutor local launch)": patches that go into Dockerfiles (openedx-dockerfile-*,mfe-dockerfile-*, …) also needtutor images build ...to take effect. Worth a sentence, since it's a common stumbling block. - In the indentation example, the content starts with a newline (
"""+ line break), which shows up as an empty line in the rendered file and inpatches show. Harmless in YAML, but starting with"""\(or a short note) would avoid surprises. - Optionally, add a pointer from the legacy v0 patches section to this new page, so readers who land there find the current docs.
Address review comments on the template patches page: - Explain that patches which modify a Dockerfile only take effect once the corresponding image is rebuilt with `tutor images build`: `tutor local launch` re-renders the Dockerfile but does not rebuild the image. - Start the indentation example with `"""\` so that the patch does not begin with an empty line, which showed up in `tutor config patches show` and as a whitespace-only line in docker-compose.yml. - Link the legacy v0 patches section to the new page.
Thanks @Faraz32123, all three addressed in 60a559d: Added a sentence that Dockerfile patches (e.g. openedx-dockerfile-post-python-requirements) only take effect after tutor images build .... tutor local launch re-renders the Dockerfile but doesn't rebuild the image. |
New plugin developers had no single place explaining what a patch is: the template patch catalog only lists the available patches, and the ENV_PATCHES filter documentation is very brief. The only conceptual explanation lived in the legacy v0 plugin API docs.
Add a "Template patches" page to the plugin development guide. It explains how {{ patch(...) }} statements work, how to add content to a patch with the ENV_PATCHES filter or with patch files, that patch content is rendered as a Jinja2 template, how indentation is handled, how multiple items are ordered (and how to use priorities), how to find and debug patches with
tutor config patches list/show, and how plugins can create their own patches.Link the new page from the plugin tutorial, the template patch catalog and the ENV_PATCHES and ENV_TEMPLATE_FILTERS docstrings. The catalog stays at reference/patches/index so that existing links to individual patches keep working.
This completes the work started in #852.
See: openedx/wg-devops#29