Skip to content

Commit

Permalink
Ensure README is synched with code
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman committed Oct 3, 2023
1 parent d9ac1e4 commit 4ce41b3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
20 changes: 20 additions & 0 deletions .tools/readme.py
Original file line number Diff line number Diff line change
@@ -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"<!--- begin default_config.toml --->\n"
config_end = r"<!--- end default_config.toml --->\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)
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<!--- begin default_config.toml --->

````toml
# Default changelist configuration as supported in pyproject.toml
[tool.changelist]
Expand Down Expand Up @@ -109,6 +111,8 @@ pr_summary_regex = "^```release-note\\s*(?P<summary>[\\s\\S]*?\\w[\\s\\S]*?)\\s*
".*Maintenance.*" = "Maintenance"
````

<!--- end default_config.toml --->

## Set up your repository

To categorize merged PRs in the changelist with the default configuration, each
Expand Down

0 comments on commit 4ce41b3

Please sign in to comment.