Skip to content

Commit

Permalink
Infra: Automatically trim trailing commas & whitespace in header values
Browse files Browse the repository at this point in the history
  • Loading branch information
CAM-Gerlach committed Apr 17, 2022
1 parent ebed4ce commit a0bc50f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ def apply(self) -> None:
# Mark unneeded fields
fields_to_remove.append(field)

# Remove any trailing commas and whitespace in the headers
if para and isinstance(para[-1], nodes.Text):
last_node = para[-1]
if last_node.astext().strip() == ",":
last_node.parent.remove(last_node)
else:
para[-1] = last_node.rstrip().rstrip(",")

# Remove unneeded fields
for field in fields_to_remove:
field.parent.remove(field)
Expand Down

0 comments on commit a0bc50f

Please sign in to comment.