px4modulesdoc: move to Python3

This commit is contained in:
TSC21 2020-01-13 18:37:11 +00:00 committed by Nuno Marques
parent 502be605fd
commit 13c0c618f3
3 changed files with 12 additions and 10 deletions

View File

@ -1,3 +1,4 @@
#! /usr/bin/env python3
"""
Class to generate Markdown documentation pages from parsed module doc strings
"""

View File

@ -1,3 +1,4 @@
#! /usr/bin/env python3
import sys
import re
import math
@ -369,9 +370,9 @@ class SourceParser(object):
failed = True
if failed:
print("Warning: documentation inconsistency in %s:" % scope)
print(" Documented options : %s" % sorted_module_options)
print(" Options found in getopt(): %s" % sorted_getopt_args)
print(("Warning: documentation inconsistency in %s:" % scope))
print((" Documented options : %s" % sorted_module_options))
print((" Options found in getopt(): %s" % sorted_getopt_args))
self._consistency_checks_failure = True
@ -393,7 +394,7 @@ class SourceParser(object):
continue # handled in the base class
if not command in doc_commands:
print("Warning: undocumented command '%s' in %s" %(command, scope))
print(("Warning: undocumented command '%s' in %s" %(command, scope)))
self._consistency_checks_failure = True
# limit the maximum line length in the module doc string
@ -409,8 +410,8 @@ class SourceParser(object):
elif not verbatim_mode:
if not 'www.' in line and not 'http' in line:
if len(line) > max_line_length:
print('Line too long (%i > %i) in %s:' % (len(line), max_line_length, scope))
print(' '+line)
print(('Line too long (%i > %i) in %s:' % (len(line), max_line_length, scope)))
print((' '+line))
self._consistency_checks_failure = True
@ -442,7 +443,7 @@ class SourceParser(object):
while next_position < len(contents):
if contents[next_position] == '\\': # escaping
if contents[next_position + 1] != '\n': # skip if continued on next line
string += contents[next_position:next_position+2].decode('string_escape')
string += contents[next_position:next_position+2].encode().decode('unicode_escape')
next_position += 2
elif contents[next_position] == '"':
next_position += 1
@ -519,4 +520,3 @@ class SourceParser(object):
for subcategory in group:
group[subcategory] = sorted(group[subcategory], key=lambda x: x.name())
return groups

View File

@ -1,3 +1,4 @@
#! /usr/bin/env python3
import os
import re
import codecs
@ -24,7 +25,7 @@ class SourceScanner(object):
if not self.ScanFile(path, parser):
return False
except:
print("Exception in file %s" % path)
print(("Exception in file %s" % path))
raise
return True
@ -44,6 +45,6 @@ class SourceScanner(object):
contents = f.read()
except:
contents = ''
print('Failed reading file: %s, skipping content.' % path)
print(('Failed reading file: %s, skipping content.' % path))
pass
return parser.Parse(scope, contents)