docstrfmt 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstrfmt
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: docstrfmt: A formatter for Sphinx flavored reStructuredText.
5
5
  Keywords: black,docutils,autoformatter,formatter,lint,restructuredtext,rst,sphinx
6
6
  Author-email: Joel Payne <lilspazjoekp@gmail.com>
@@ -9,4 +9,4 @@ from .const import (
9
9
  )
10
10
  from .docstrfmt import Manager
11
11
 
12
- __version__ = "2.0.0"
12
+ __version__ = "2.0.2"
@@ -1075,20 +1075,10 @@ class Formatters:
1075
1075
  f"Invalid doctest block: {e}",
1076
1076
  ) from None
1077
1077
  doctest_blocks = []
1078
- current_block = ""
1079
- while parsed:
1080
- example = parsed.pop(0)
1081
- if example.want:
1082
- current_block += example.source.strip()
1083
- formatted = CodeFormatters(current_block, context).python()
1084
- doctest_blocks.append((formatted, example.want.strip()))
1085
- current_block = ""
1086
- else: # pragma: no cover
1087
- current_block += example.source.strip() + "\n"
1088
- if current_block:
1089
- # If there's any remaining code, format it as well.
1090
- formatted = CodeFormatters(current_block, context).python()
1091
- doctest_blocks.append((formatted, ""))
1078
+ for example in parsed:
1079
+ formatted = CodeFormatters(example.source.strip(), context).python()
1080
+ doctest_blocks.append((formatted, example.want.strip()))
1081
+
1092
1082
  if not doctest_blocks:
1093
1083
  raise InvalidRstError(
1094
1084
  context.current_file,
@@ -1097,11 +1087,10 @@ class Formatters:
1097
1087
  "Empty doctest block.",
1098
1088
  )
1099
1089
  for formatted, want in doctest_blocks:
1100
- for line in formatted.splitlines():
1101
- if line.startswith(" "):
1102
- yield f"... {line}"
1103
- elif line:
1104
- yield f">>> {line}"
1090
+ first_line, *other_lines = formatted.splitlines()
1091
+ yield f">>> {first_line}"
1092
+ for line in other_lines:
1093
+ yield f"... {line}" if line else "..."
1105
1094
  if want:
1106
1095
  yield from want.splitlines()
1107
1096
 
@@ -387,7 +387,7 @@ def _validate_adornments(
387
387
  :raises click.BadParameter: If adornments are not unique.
388
388
 
389
389
  """
390
- actual_value = value or context.params["section_adornments"]
390
+ actual_value = context.params.pop("section_adornments", value)
391
391
 
392
392
  if len(actual_value) != len(set(actual_value)):
393
393
  msg = "Section adornments must be unique"
@@ -395,11 +395,13 @@ def _validate_adornments(
395
395
 
396
396
  if "|" in actual_value:
397
397
  with_overline, without_overline = actual_value.split("|", 1)
398
- return list(zip(with_overline, itertools.repeat(True))) + list(
398
+ adornments = list(zip(with_overline, itertools.repeat(True))) + list(
399
399
  zip(without_overline, itertools.repeat(False))
400
400
  )
401
+ else:
402
+ adornments = list(zip(actual_value, itertools.repeat(False)))
401
403
 
402
- return list(zip(actual_value, itertools.repeat(False)))
404
+ return adornments
403
405
 
404
406
 
405
407
  async def _run_formatter(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes