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 Class to generate Markdown documentation pages from parsed module doc strings
""" """

View File

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

View File

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