diff --git a/gio/gdbus-2.0/codegen/.flake8 b/gio/gdbus-2.0/codegen/.flake8 new file mode 100644 index 000000000..9450a2832 --- /dev/null +++ b/gio/gdbus-2.0/codegen/.flake8 @@ -0,0 +1,4 @@ +[flake8] +# We are generating long lines through templates +max-line-length = 120 +exclude = __pycache__ diff --git a/gio/gdbus-2.0/codegen/codegen_docbook.py b/gio/gdbus-2.0/codegen/codegen_docbook.py index b8d683408..b7280e306 100644 --- a/gio/gdbus-2.0/codegen/codegen_docbook.py +++ b/gio/gdbus-2.0/codegen/codegen_docbook.py @@ -25,10 +25,6 @@ from os import path from . import utils -# Disable line length warnings as wrapping the Docbook templates would be hard -# flake8: noqa: E501 - - # ---------------------------------------------------------------------------------------------------- @@ -346,7 +342,7 @@ class DocbookCodeGenerator: def expand_paras(self, s, expandParamsAndConstants): s = self.expand(s, expandParamsAndConstants).strip() res = [] - if not s.startswith(""): res.append("") for line in s.split("\n"): line = line.strip() diff --git a/gio/gdbus-2.0/codegen/parser.py b/gio/gdbus-2.0/codegen/parser.py index cf8ea5229..142754739 100644 --- a/gio/gdbus-2.0/codegen/parser.py +++ b/gio/gdbus-2.0/codegen/parser.py @@ -77,13 +77,13 @@ class DBusXMLParser: colon_index = line.find(": ") if colon_index == -1: if line.endswith(":"): - symbol = line[0 : len(line) - 1] + symbol = line[0:len(line) - 1] comment_state = DBusXMLParser.COMMENT_STATE_PARAMS else: comment_state = DBusXMLParser.COMMENT_STATE_SKIP else: symbol = line[0:colon_index] - rest_of_line = line[colon_index + 2 :].strip() + rest_of_line = line[colon_index + 2:].strip() if len(rest_of_line) > 0: body += f"{rest_of_line}\n" comment_state = DBusXMLParser.COMMENT_STATE_PARAMS @@ -98,7 +98,7 @@ class DBusXMLParser: body += f"{orig_line}\n" else: param = line[1:colon_index] - docs = line[colon_index + 2 :] + docs = line[colon_index + 2:] params[param] = docs else: comment_state = DBusXMLParser.COMMENT_STATE_BODY diff --git a/gio/tests/codegen.py b/gio/tests/codegen.py index c95736e39..93508fa62 100644 --- a/gio/tests/codegen.py +++ b/gio/tests/codegen.py @@ -27,10 +27,10 @@ import subprocess import sys import tempfile import unittest +import xml.etree.ElementTree as ET import taptestrunner - # Disable line length warnings as wrapping the C code templates would be hard # flake8: noqa: E501 @@ -625,6 +625,40 @@ G_END_DECLS self.assertEqual(result.out.strip().count("GDBusCallFlags call_flags,"), 2) self.assertEqual(result.out.strip().count("gint timeout_msec,"), 2) + def test_generate_valid_docbook(self): + """Test the basic functionality of the docbook generator.""" + xml_contents = """ + + + + + + + + + + """ + res = self.runCodegenWithInterface( + xml_contents, + "--generate-docbook", + "test", + ) + self.assertEqual("", res.err) + self.assertEqual("", res.out) + with open("test-org.project.Bar.Frobnicator.xml", "r") as f: + self.assertTrue(ET.parse(f) is not None) + if __name__ == "__main__": unittest.main(testRunner=taptestrunner.TAPTestRunner())