]> xenbits.xensource.com Git - libvirt.git/commitdiff
news: Output reStructuredText for the ASCII version
authorAndrea Bolognani <abologna@redhat.com>
Tue, 2 Jun 2020 10:24:45 +0000 (12:24 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 5 Jun 2020 14:27:33 +0000 (16:27 +0200)
The ASCII output our scripts produce is already very close to
reStructuredText, and with just a few extra tweaks we can get
almost all of the way there.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/news-ascii.xsl
scripts/reformat-news.py

index 8dacae934cbe1c70c7199da80e9698af3330a8c4..9f6c61a3c6dffcffdc034be0b447cfa85c083863 100644 (file)
@@ -8,36 +8,48 @@
 
   <!-- Document -->
   <xsl:template match="/libvirt">
-    <xsl:text>libvirt releases
+    <xsl:text>================
+libvirt releases
 ================
+
+This is the list of official releases for libvirt, along with an overview of
+the changes introduced by each of them.
+
+For a more fine-grained view, use the `git log`_.
 </xsl:text>
     <xsl:apply-templates select="release"/>
     <xsl:text>
-==============================================================================
+
 Older libvirt releases didn't have proper release notes: if you are interested
-in changes between them, you should check out docs/news-*.html or the full git
+in changes between them, you should check out docs/news-\*.html or the full git
 log (see instructions in ChangeLog).
+
+
+.. _git log: https://gitlab.com/libvirt/libvirt/-/commits/master
 </xsl:text>
   </xsl:template>
 
   <!-- Release -->
   <xsl:template match="release">
     <xsl:text>
-# </xsl:text>
+
+</xsl:text>
     <xsl:value-of select="@version"/>
     <xsl:text> (</xsl:text>
     <xsl:value-of select="@date"/>
     <xsl:text>)
+===================
 </xsl:text>
+
     <xsl:apply-templates select="section"/>
   </xsl:template>
 
   <!-- Section -->
   <xsl:template match="section">
     <xsl:text>
-* </xsl:text>
+* **</xsl:text>
     <xsl:value-of select="@title"/>
-    <xsl:text>
+    <xsl:text>**
 </xsl:text>
     <xsl:apply-templates select="change"/>
   </xsl:template>
@@ -60,10 +72,24 @@ log (see instructions in ChangeLog).
 
   <!-- Change description -->
   <xsl:template match="description">
+    <xsl:text>
+</xsl:text>
     <xsl:text>|</xsl:text> <!-- This will be removed when reformatting -->
-    <xsl:value-of select="normalize-space()"/>
+    <xsl:apply-templates/>
     <xsl:text>
 </xsl:text>
   </xsl:template>
 
+  <!-- Regular text in change description -->
+  <xsl:template match="description//text()">
+    <xsl:value-of select="normalize-space()"/>
+  </xsl:template>
+
+  <!-- <code> HTML tag in change description -->
+  <xsl:template match="description//code">
+    <xsl:text disable-output-escaping="yes"> ``</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text disable-output-escaping="yes">`` </xsl:text>
+  </xsl:template>
+
 </xsl:stylesheet>
index 7bc752d821df10ebb99a2d8970916aeda9c018f9..d1c3906bd8db69732b884703e4342e788cc83dd1 100755 (executable)
@@ -61,22 +61,22 @@ def reformat(line):
     # on the first character
     marker = line[0]
 
-    # Release
-    if marker == '#':
+    # Section
+    if marker == '*':
         initial_indent = 0
         indent = 2
-    # Section
-    elif marker == '*':
-        initial_indent = 2
-        indent = 4
     # Change summary
     elif marker == '-':
-        initial_indent = 4
-        indent = 6
+        initial_indent = 2
+        indent = 4
+        # We use different markers to be able to tell apart the various
+        # possible indentation levels, but we want to always output the
+        # same marker in the generated file
+        line = '*' + line[1:]
     # Change description
     elif marker == '|':
-        initial_indent = 8
-        indent = 8
+        initial_indent = 4
+        indent = 4
         # In this one case, the marker should not ultimately show
         # up in the output file, so we strip it before moving on
         line = line[1:]