summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAndrea Bolognani <abologna@redhat.com>2020-06-02 13:44:21 +0200
committerAndrea Bolognani <abologna@redhat.com>2020-06-05 16:27:33 +0200
commitdcd14c88a1e18820c4d8b4e002dc18dd8505f044 (patch)
tree90cbf805ae9c54b0ce2b70f54b010daf57641b3f /scripts
parent0ccfcd0361cd630b9daaf0f19062fe546ce9ddad (diff)
downloadlibvirt-dcd14c88a1e18820c4d8b4e002dc18dd8505f044.tar.gz
news: Convert to reStructuredText
Instead of storing release notes as XML and then converting them to HTML and ASCII at build time using XSLT and a custom script, we can use reStructuredText as both the source and ASCII representation and generate HTML from it using the same tooling we already use for the rest of the documentation. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/reformat-news.py102
1 files changed, 0 insertions, 102 deletions
diff --git a/scripts/reformat-news.py b/scripts/reformat-news.py
deleted file mode 100755
index d1c3906bd8..0000000000
--- a/scripts/reformat-news.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/env python3
-
-# reformat-news.py: Reformat the NEWS file properly
-#
-# Copyright (C) 2017 Red Hat, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see
-# <http://www.gnu.org/licenses/>.
-
-import sys
-
-COLUMNS = 80
-
-
-def reformat_with_indent(text, initial_indent, indent):
-
- res = ""
- line = initial_indent
-
- for word in text.split():
-
- # If adding one more word (plus a whitespace, plus a newline)
- # to the current line would push us over the desired number
- # of columns we start a new line instead
- if len(line) + len(word) > (COLUMNS - 2):
- res = res + line + "\n"
- line = indent
-
- # We need to take care when we've just started a new line,
- # as we don't want to add any additional leading whitespace
- # in that case
- if line == indent or line == initial_indent:
- line = line + word
- else:
- line = line + " " + word
-
- # Append whatever's left
- res = res + line
-
- return res
-
-
-def reformat(line):
-
- # Empty lines don't need to be reformatted or even inspected
- if len(line) == 0:
- return line
-
- # For all non-empty lines, we decide the indentation level based
- # on the first character
- marker = line[0]
-
- # Section
- if marker == '*':
- initial_indent = 0
- indent = 2
- # Change summary
- elif marker == '-':
- 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 = 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:]
- # Anything else should be left as-is
- else:
- return line
-
- return reformat_with_indent(line, " " * initial_indent, " " * indent)
-
-
-def main(args):
-
- if len(args) < 2:
- sys.stdout.write("Usage: " + args[0] + " FILE\n")
- sys.exit(1)
-
- with open(args[1], 'r') as f:
- for line in f:
- print(reformat(line.strip()))
-
-
-if __name__ == "__main__":
- main(sys.argv)