2
2
3
3
import datetime
4
4
import itertools
5
+ import logging
5
6
import re
6
7
7
8
from pathlib import Path
@@ -132,6 +133,8 @@ def from_tokens(cls, tokens):
132
133
else :
133
134
raise ChangelogError (f"Invalid section heading: { tokens [1 ].content } " )
134
135
136
+ logging .getLogger (__name__ ).info ("Parsed new version %s" , kwargs .get ("version" ))
137
+
135
138
# The rest of the tokens should be the lists. Strip any rulers now.
136
139
tokens = [token for token in tokens [3 :] if token .type != "hr" ]
137
140
@@ -176,7 +179,6 @@ def from_tokens(cls, tokens):
176
179
kwargs .setdefault ("changed" , []).extend (items )
177
180
178
181
else :
179
- print (tokens )
180
182
raise ChangelogError ("Don't know how to handle these tokens" )
181
183
182
184
assert not tokens
@@ -251,6 +253,8 @@ def __init__(self, changelog_file: Path, repo_url: str):
251
253
self .changelog_file = changelog_file
252
254
self .repo_url = repo_url
253
255
256
+ logger = logging .getLogger (__name__ )
257
+
254
258
groups = [[]]
255
259
256
260
all_tokens = MarkdownIt ("gfm-like" ).parse (
@@ -275,6 +279,7 @@ def __init__(self, changelog_file: Path, repo_url: str):
275
279
assert nexttoken is not None
276
280
if re .match (r"^\[\d" , nexttoken .content ):
277
281
token .tag = "h2"
282
+ logger .notice ("Changing `%s` from h1 to h2" , nexttoken .content )
278
283
279
284
if token .tag == "h2" :
280
285
# A lot of our repositories have an issue where "Added",
@@ -285,6 +290,7 @@ def __init__(self, changelog_file: Path, repo_url: str):
285
290
r"Add|Fix|Change|Remove" , nexttoken .content , flags = re .IGNORECASE
286
291
):
287
292
token .tag = "h3"
293
+ logger .notice ("Changing `%s` from h2 to h3" , nexttoken .content )
288
294
else :
289
295
# Split split these tokens off into a new Version
290
296
groups .append ([])
@@ -301,7 +307,9 @@ def __init__(self, changelog_file: Path, repo_url: str):
301
307
def update_version (self , next_version : str ):
302
308
"Move all unreleased changes under the new version."
303
309
if not self .versions or self .versions [0 ].version != "Unreleased" :
304
- print ("WARNING: No Unreleased section - adding a new empty section" )
310
+ logging .getLogger (__name__ ).warning (
311
+ "No Unreleased section - adding a new empty section"
312
+ )
305
313
self .versions .insert (0 , Version .blank_unreleased ())
306
314
307
315
# Change the version and date of the unreleased section. For now
0 commit comments