Module READMEs#
odl readme builds a module’s documentation from the Markdown fragments in
its readme/ folder, the way the OBS client template does:
README.md: the fragments joined, each under a heading;static/description/index.html: that README rendered, the page Odoo shows for the module.
odl readme modules/custom # every module with a readme/ folder
odl readme modules/custom/acme_sale/readme/USAGE.md # the module of a file
odl readme --check modules/custom # write nothing; exit 1 when out of date
Only modules with a readme/ folder are touched, and a file is only written
when it changes.
Fragments#
File |
Heading |
|---|---|
|
Introduction |
|
Features |
|
Installation |
|
Configuration |
|
Usage |
|
Context |
|
History |
|
Roadmap |
|
Contributors |
|
Credits |
Empty or missing fragments are left out.
Same output, much faster#
The output is byte for byte what the template’s Python generator
(convert_readme2html.py) writes. It uses the same Markdown engine
(comrak 0.54, with GitHub tables,
task lists, footnotes, strikethrough, superscript, description lists and
smart punctuation) and the same page. On the 86 documented modules of a
client repository it takes 0.06 seconds; the Python generator starts a uv run per module.
Mermaid diagrams (```mermaid blocks) become <div class="mermaid">,
which the page renders with mermaid.js. The Python generator switches to
another Markdown engine for documents with a diagram; odl readme renders
them like every other document, so moving over changes their punctuation
once ('quotes' become typographic quotes, ... becomes …).
The obs style#
OBSNL/obs-modules writes one README.md per addon in another layout: an
HTML comment with a digest of the sources, the title, badges (maturity,
license, GitHub), the description, a table of contents, the sections
(“Use Cases / Context”, “Installation”, “Configuration”, “Usage”,
“Development”, “Known issues / Roadmap”, “Changelog”), “Bug Tracker” and
“Credits” (authors, contributors, other credits, maintainers). Relative
images point at raw.githubusercontent.com, and the fragments’ own headings
move below their section. It is the output of the repository’s former
tools/obs_gen_addon_readme.py, byte for byte:
[tool.odoo-lint.readme]
style = "obs"
org = "OBSNL" # the default
repo = "obs-modules"
branch = "19.0" # default: target-version
remove-rst = true # delete a README.rst next to the README.md
An addon without readme/DESCRIPTION.md keeps its README; an .rst
fragment is an error, as this style writes Markdown.
As a hook#
With pre-commit, the odoo-lint-readme hook of
odoo-lint-pre-commit runs odl readme on the
staged readme/*.md fragments and manifests:
- repo: https://github.com/GetFluvo/odoo-lint-pre-commit
rev: v0.1.0a21
hooks:
- id: odoo-lint-readme
In hk, as a step next to the odoo-lint step:
["readme"] {
glob = "modules/custom/**/readme/**/*.md"
fix = "odl readme {{files}}"
}