Automatic documentation generation#18152
Conversation
|
@nijel, can you share your thoughts on this approach for automating documentation generation ? |
Codecov Report❌ Patch coverage is
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nijel
left a comment
There was a problem hiding this comment.
I think it's a reasonable approach. See a few comments I've made on the implementation. I will also trigger copilot review to comment on this.
There was a problem hiding this comment.
Pull request overview
Adds scaffolding for automatic documentation generation by introducing version metadata markers for add-ons and updating the list_addons management command to emit/insert auto-generated RST blocks.
Changes:
- Introduced RST “versionadded/versionchanged” metadata helper classes and attached version metadata to various add-ons.
- Extended
./manage.py list_addonsto write generated docs either to stdout or into a file section delimited by markers. - Added human-readable descriptions for add-on events to improve generated documentation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| weblate/utils/docs.py | Adds RST version metadata helpers for embedding versionadded/versionchanged directives. |
| weblate/addons/base.py | Introduces doc_versions on add-on base class for documentation metadata. |
| weblate/addons/webhooks.py | Adds doc_versions metadata to webhook add-ons. |
| weblate/addons/gettext.py | Updates add-on description formatting and adds versionchanged metadata. |
| weblate/addons/generate.py | Adds versionadded metadata for locale-generation add-ons. |
| weblate/addons/fedora_messaging.py | Adds versionadded metadata for Fedora Messaging add-on. |
| weblate/addons/cleanup.py | Adds versionadded metadata for Remove Blank add-on. |
| weblate/addons/cdn.py | Adds versionadded metadata for CDNJS add-on. |
| weblate/addons/events.py | Adds event description strings used in generated docs. |
| weblate/addons/management/commands/list_addons.py | Adds marker-based insertion into an output file and restructures doc generation output. |
dc20e72 to
f315457
Compare
f315457 to
52ada99
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 51 out of 51 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (7)
weblate/utils/management/base.py:1
sectionsis a mutableClassVar, so it is shared across all instances and subclasses. This can leak sections between differentcall_command(...)invocations (and even across different commands inheritingDocGeneratorCommand), producing incorrect docs output. Makesectionsan instance attribute (initializeself.sections = []in__init__or at the start ofhandle) and remove theClassVar.
weblate/utils/management/base.py:1sectionsis a mutableClassVar, so it is shared across all instances and subclasses. This can leak sections between differentcall_command(...)invocations (and even across different commands inheritingDocGeneratorCommand), producing incorrect docs output. Makesectionsan instance attribute (initializeself.sections = []in__init__or at the start ofhandle) and remove theClassVar.
weblate/utils/management/base.py:1- If both markers exist multiple times, or if
end_markerappears beforestart_marker, this will splice the wrong range (possibly deleting unrelated content). Consider locatingend_markerstarting fromstart_index + 1(e.g.,lines.index(end_marker, start_index + 1)) and, if the ordering is invalid, either raise an error or fall back to appending at EOF.
weblate/utils/docs.py:1 - The docstring references
get_versions_output(), but the implemented API isget_versions_rst_lines(). Update the docstring to match the actual method name to avoid confusing API consumers.
weblate/utils/docs.py:1 bodycan contain embedded newlines, but downstream code treats each list element as a single RST line (later doing\"\\n\".join(...)). Returning multi-line strings makes line-based insertion harder to reason about and can create subtle formatting issues. Prefer splitting into individual lines (e.g., indent each line andextendthem) soget_versions_rst_lines()always returns a truelist[str]of lines.
weblate/checks/management/commands/list_checks.py:1- This stores a trailing newline inside a single 'line' element. Because output is later assembled with
\"\\n\".join(lines), embedding newline characters inside one element can lead to inconsistent spacing and makes marker replacement logic harder to keep stable. Use separate list elements instead (anchor line without\\n, followed by an explicit empty string when you need a blank line).
weblate/checks/management/commands/list_checks.py:1 enable_flagsis annotated aslist[str]but is assigned a set literal. This is a concrete type mismatch and will trip static type checking. Either change the annotation toset[str]or build a list explicitly (and preserve ordering expectations if needed).
|
@gersona Can you check copilot comments? At least the type annotations ones seem legit to me. |
…ocumentation, # Conflicts: # weblate/addons/management/commands/list_addons.py
The approach is to use markers in the target document in order to combine automatically generated content (within the markers) and custom/handwritten content.
This has is drawbacks, but it allows to keep a minimal number of files to maintain, and reduces mix of concern between documentation code and actual logic code.