@@ -19,10 +19,11 @@ class Changelogs:
1919 def __init__ (self , changes_path : Path , root_path : Path , version : Version ) -> None :
2020 """
2121 Args:
22- changes_path: directory containing the changelog, e.g. `doc/changes/`
22+ changes_path: directory containing the changelog & changes files , e.g. `doc/changes/`
2323 root_path: root directory of the current project, containing file
2424 `pyproject.toml`
25- version: the version to be used in the `changes_{version}.md` and listed in the `changelog.md`.
25+ version: the version to be used in the versioned changes file and listed in
26+ the `changelog.md`, which contains the index of the change log
2627 """
2728
2829 self .version = version
@@ -39,23 +40,22 @@ def _create_new_unreleased(self):
3940
4041 def _create_versioned_changelog (self , unreleased_content : str ) -> None :
4142 """
42- Create a changelog entry for a specific version .
43+ Create a versioned changes file .
4344
4445 Args:
45- unreleased_content: The content of the changelog entry.
46-
46+ unreleased_content: the content of the (not yet versioned) changes
4747 """
4848 template = f"# { self .version } - { datetime .today ().strftime ('%Y-%m-%d' )} "
4949 template += f"\n { unreleased_content } "
5050
51- if dependency_content := self ._prepare_dependency_update ():
51+ if dependency_content := self ._describe_dependency_changes ():
5252 template += f"\n ## Dependency Updates\n { dependency_content } "
5353
5454 self .versioned_changelog_md .write_text (cleandoc (template ))
5555
5656 def _extract_unreleased_notes (self ) -> str :
5757 """
58- Extract release notes from `unreleased.md`.
58+ Extract (not yet versioned) changes from `unreleased.md`.
5959 """
6060 with self .unreleased_md .open (mode = "r" , encoding = "utf-8" ) as f :
6161 # skip header when reading in file, as contains # Unreleased
@@ -64,13 +64,17 @@ def _extract_unreleased_notes(self) -> str:
6464 unreleased_content += "\n "
6565 return unreleased_content
6666
67- def _prepare_dependency_update (self ) -> str :
67+ def _describe_dependency_changes (self ) -> str :
68+ """
69+ Describe the dependency changes between the latest tag and the current version
70+ for use in the versioned changes file.
71+ """
6872 previous_dependencies_in_groups = get_dependencies_from_latest_tag ()
6973 current_dependencies_in_groups = get_dependencies (
7074 working_directory = self .root_path
7175 )
7276
73- content = ""
77+ changes_by_group : list [ str ] = []
7478 # preserve order of keys from old group
7579 groups = list (
7680 dict .fromkeys (
@@ -88,10 +92,9 @@ def _prepare_dependency_update(self) -> str:
8892 current_dependencies = current_dependencies ,
8993 ).changes
9094 if changes :
91- content += f"\n ### `{ group } `\n "
92- content += "\n " .join (str (change ) for change in changes )
93- content += "\n "
94- return content
95+ changes_str = "\n " .join (str (change ) for change in changes )
96+ changes_by_group .append (f"\n ### `{ group } `\n { changes_str } \n " )
97+ return "" .join (changes_by_group )
9598
9699 def _update_changelog_table_of_contents (self ) -> None :
97100 """
@@ -119,7 +122,7 @@ def update_changelogs_for_release(self) -> None:
119122 """
120123 Rotates the changelogs as is needed for a release.
121124
122- 1. Moves the contents of the `unreleased.md` to the `changes_<version>.md`
125+ 1. Moves the changes from the `unreleased.md` to the `changes_<version>.md`
123126 2. Create a new file `unreleased.md`
124127 3. Updates the table of contents in the `changelog.md` with the new `changes_<version>.md`
125128 """
0 commit comments