diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f3b361..dfc2888 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,3 +40,11 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + + - repo: local + hooks: + - id: readme.py + name: readme.py + language: system + entry: python .tools/readme.py + files: "README.md|src/changelist/default_config.toml|.tools/readme.py" diff --git a/.tools/readme.py b/.tools/readme.py new file mode 100644 index 0000000..aef9040 --- /dev/null +++ b/.tools/readme.py @@ -0,0 +1,20 @@ +import re + +with open("README.md") as fh: + readme = fh.read() + +with open("src/changelist/default_config.toml") as fh: + default_config = fh.read() + +config_begin = r"\n" +config_end = r"\n" +config_section = ( + config_begin + r"\n````toml\n" + default_config + r"````\n\n" + config_end +) + +rx = re.compile(config_begin + ".*?" + config_end, re.DOTALL) +readme = rx.sub(config_section, readme) + + +with open("README.md", "w") as fh: + fh.write(readme) diff --git a/README.md b/README.md index 111d658..707c6ab 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ changelist can be configured from two sources, in order of precedence: If a configuration option is not specified in either file above, changelist falls back to the following configuration: + + ````toml # Default changelist configuration as supported in pyproject.toml [tool.changelist] @@ -109,6 +111,8 @@ pr_summary_regex = "^```release-note\\s*(?P[\\s\\S]*?\\w[\\s\\S]*?)\\s* ".*Maintenance.*" = "Maintenance" ```` + + ## Set up your repository To categorize merged PRs in the changelist with the default configuration, each