]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Adjust gitchangelog whitespace
authorNicki Křížek <nicki@isc.org>
Wed, 17 Jul 2024 12:58:01 +0000 (14:58 +0200)
committerNicki Křížek <nicki@isc.org>
Wed, 24 Jul 2024 15:43:11 +0000 (17:43 +0200)
Format the output to produce a nicer looking rst output, similar to the
former CHANGES file.

contrib/gitchangelog/gitchangelog.py

index cc347bccd0a953c76882cb8f9c3989909af9e75f..ebb283db39e92d27ce3a1da932bdbb10b2694fa3 100755 (executable)
@@ -545,7 +545,7 @@ def indent(text, chars="  ", first=None):
     return "\n".join([(chars + line).rstrip() for line in text.split("\n")])
 
 
-def paragraph_wrap(text, regexp="\n\n"):
+def paragraph_wrap(text, regexp="\n\n", separator="\n"):
     r"""Wrap text by making sure that paragraph are separated correctly
 
         >>> string = 'This is first paragraph which is quite long don\'t you \
@@ -560,7 +560,7 @@ def paragraph_wrap(text, regexp="\n\n"):
 
     """
     regexp = re.compile(regexp, re.MULTILINE)
-    return "\n".join(
+    return separator.join(
         "\n".join(textwrap.wrap(paragraph.strip())) for paragraph in regexp.split(text)
     ).strip()
 
@@ -1483,7 +1483,7 @@ def rest_py(data, opts={}):
     """Returns ReStructured Text changelog content from data"""
 
     def rest_title(label, char="="):
-        return (label.strip() + "\n") + (char * len(label) + "\n")
+        return (label.strip() + "\n") + (char * len(label) + "\n\n")
 
     def render_version(version):
         title = (
@@ -1500,7 +1500,7 @@ def rest_py(data, opts={}):
             section_label = section["label"] if section.get("label", None) else "Other"
 
             if not (section_label == "Other" and nb_sections == 1):
-                s += "\n" + rest_title(section_label, "~")
+                s += rest_title(section_label, "~")
 
             for commit in section["commits"]:
                 s += render_commit(commit, opts)
@@ -1518,14 +1518,16 @@ def rest_py(data, opts={}):
             entry += "\n" + indent(commit["body"])
             entry += "\n"
 
+        entry += "\n"
+
         return entry
 
     if data["title"]:
-        yield rest_title(data["title"], char="=") + "\n\n"
+        yield rest_title(data["title"], char="=") + "\n"
 
     for version in data["versions"]:
         if len(version["sections"]) > 0:
-            yield render_version(version) + "\n\n"
+            yield render_version(version) + "\n"
 
 
 ## formatter engines