Skip to content

Commit

Permalink
pythongh-113317: Move more formatting helpers into libclinic (python#…
Browse files Browse the repository at this point in the history
…113438)

Move the following global helpers into libclinic:
- format_escape()
- normalize_snippet()
- wrap_declarations()

Also move strip_leading_and_trailing_blank_lines() and make it internal to libclinic.
  • Loading branch information
erlend-aasland authored and Glyphack committed Jan 27, 2024
1 parent ada7ddb commit 1577fac
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 159 deletions.
6 changes: 3 additions & 3 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3730,7 +3730,7 @@ def test_strip_leading_and_trailing_blank_lines(self):
)
for lines, expected in dataset:
with self.subTest(lines=lines, expected=expected):
out = clinic.strip_leading_and_trailing_blank_lines(lines)
out = libclinic.normalize_snippet(lines)
self.assertEqual(out, expected)

def test_normalize_snippet(self):
Expand Down Expand Up @@ -3759,7 +3759,7 @@ def test_normalize_snippet(self):
expected_outputs = {0: zero_indent, 4: four_indent, 8: eight_indent}
for indent, expected in expected_outputs.items():
with self.subTest(indent=indent):
actual = clinic.normalize_snippet(snippet, indent=indent)
actual = libclinic.normalize_snippet(snippet, indent=indent)
self.assertEqual(actual, expected)

def test_escaped_docstring(self):
Expand All @@ -3780,7 +3780,7 @@ def test_escaped_docstring(self):
def test_format_escape(self):
line = "{}, {a}"
expected = "{{}}, {{a}}"
out = clinic.format_escape(line)
out = libclinic.format_escape(line)
self.assertEqual(out, expected)

def test_indent_all_lines(self):
Expand Down
Loading

0 comments on commit 1577fac

Please sign in to comment.