From 03aa4be0355bdbdf10aafc6cc1211673c76726cc Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 26 Oct 2023 08:56:11 +0100 Subject: [PATCH] feat: generate private addon readmes with markdown fragments Adds support for the latest changes found in maintainer tools. Now, readmes will have a source digest, resulting in fewer rebuilds, and markdown portions are supported. Because of that, the readme generation is moved to be the last hook. This way, the digest will include all changes from above hooks. --- .module-readme.rst.j2 | 16 ++++++++++------ .pre-commit-config.yaml.jinja | 25 +++++++++++++------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.module-readme.rst.j2 b/.module-readme.rst.j2 index 808676cf..df2b84c9 100644 --- a/.module-readme.rst.j2 +++ b/.module-readme.rst.j2 @@ -11,10 +11,13 @@ {{ manifest.name }} {{ '=' * manifest.name|length }} -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: {{ source_digest }} + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge_devstat| image:: https://img.shields.io/badge/maturity-{{ development_status | replace("-", "--") | urlencode }}-brightgreen.png :target: https://odoo-community.org/page/development-status @@ -40,7 +43,8 @@ .. contents:: :local: -{{ fragment('INSTALL', 'Installation') }} +{{ fragment('CONTEXT', 'Use Cases / Context') }} +{{- fragment('INSTALL', 'Installation') }} {{- fragment('CONFIGURE', 'Configuration') }} {{- fragment('USAGE', 'Usage') }} {{- fragment('DEVELOP', 'Development') }} @@ -52,17 +56,17 @@ Credits {% if authors -%} Authors -~~~~~~~ +{{ level3_underline * 7 }} {% for author in authors if author -%} * {{ author }} {% endfor %} {% endif -%} -{{ fragment('CONTRIBUTORS', 'Contributors', sub='~') }} -{{- fragment('CREDITS', 'Other credits', sub='~') -}} +{{ fragment('CONTRIBUTORS', 'Contributors', sub=level3_underline) }} +{{- fragment('CREDITS', 'Other credits', sub=level3_underline) -}} Maintainers -~~~~~~~~~~~ +{{ level3_underline * 11 }} This module is maintained by {{ org_name }}. diff --git a/.pre-commit-config.yaml.jinja b/.pre-commit-config.yaml.jinja index 96dc4865..3da28f97 100644 --- a/.pre-commit-config.yaml.jinja +++ b/.pre-commit-config.yaml.jinja @@ -34,7 +34,8 @@ repos: entry: found forbidden files; remove them language: fail files: "\\.rej$" - - repo: https://github.com/oca/maintainer-tools + - &maintainer_tools + repo: https://github.com/oca/maintainer-tools rev: 1070863d1298b1bf373a0e69458dd8a88ab91578 hooks: # update the NOT INSTALLABLE ADDONS section above @@ -42,17 +43,6 @@ repos: args: - --addons-dir - odoo/custom/src/private - - repo: https://github.com/oca/maintainer-tools - rev: 1070863d1298b1bf373a0e69458dd8a88ab91578 - hooks: - - id: oca-gen-addon-readme - args: - - --addons-dir=odoo/custom/src/private - - --org-name={{ project_author }} - - --repo-name={{ project_name }} - - --gen-html - - --branch={{ odoo_version }} - - --template-filename=.module-readme.rst.j2 - repo: https://github.com/myint/autoflake rev: v2.2.0 hooks: @@ -148,3 +138,14 @@ repos: args: - --color - --fix + - <<: *maintainer_tools + hooks: + # Generate readme is last, so its digest includes changes from above + - id: oca-gen-addon-readme + args: + - --addons-dir=odoo/custom/src/private + - --org-name={{ project_author }} + - --repo-name={{ project_name }} + - --gen-html + - --branch={{ odoo_version }} + - --template-filename=.module-readme.rst.j2