From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 964E93857C53; Mon, 24 Aug 2020 16:36:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 964E93857C53 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jon TURNEY To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] doc: Various fixes to makedocbook for python3.8 X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/master X-Git-Oldrev: c1f177d6a9e0b86f9ad22c49891fd2d60433e472 X-Git-Newrev: c2d6e6f7f6e4cee5db023fa299d5c39d348805ca Message-Id: <20200824163638.964E93857C53@sourceware.org> Date: Mon, 24 Aug 2020 16:36:38 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib GIT logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 16:36:38 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c2d6e6f7f6e4cee5db023fa299d5c39d348805ca commit c2d6e6f7f6e4cee5db023fa299d5c39d348805ca Author: Jon Turney Date: Sat Aug 22 17:15:24 2020 +0100 doc: Various fixes to makedocbook for python3.8 Also update shebang to explicitly use python3, since python2 is EOL and (per PEP 0394) 'python' may not exist at all. Diff: --- newlib/doc/makedocbook.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py index 92d0f279d..66481a672 100755 --- a/newlib/doc/makedocbook.py +++ b/newlib/doc/makedocbook.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # python script to process makedoc instructions in a source file and produce # DocBook XML output @@ -199,6 +199,8 @@ def function(c, l): namelist = map(lambda v: re.sub('^and ', '', v.strip(), 1), namelist) # strip off << >> surrounding name namelist = map(lambda v: v.strip().lstrip('<').rstrip('>'), namelist) + # instantiate list to make it subscriptable + namelist = list(namelist) if verbose: print(namelist, file=sys.stderr) @@ -262,7 +264,7 @@ def index(c, l): primary.text = l # to validate, it seems we need to maintain refentry elements in a certain order - refentry[:] = sorted(refentry, key = lambda x: x.tag) + refentry[:] = sorted(refentry, key = lambda x: x.tag if isinstance(x.tag, str) else '') # adds another alternate refname refnamediv = refentry.find('refnamediv') @@ -807,7 +809,7 @@ def main(file): perform(processed) # output the XML tree - s = lxml.etree.tostring(rootelement, pretty_print=True) + s = lxml.etree.tostring(rootelement, pretty_print=True, encoding='unicode') if not s: print('No output produced (perhaps the input has no makedoc markup?)', file=sys.stderr) @@ -826,7 +828,7 @@ def main(file): if __name__ == '__main__' : options = OptionParser() - options.add_option('-v', '--verbose', action='count', dest = 'verbose') + options.add_option('-v', '--verbose', action='count', dest = 'verbose', default = 0) options.add_option('-c', '--cache', action='store_true', dest = 'cache', help="just ensure PLY cache is up to date") (opts, args) = options.parse_args()