Style: Reduce space consumed by headers and improve alignment (#2533)

This commit is contained in:
CAM Gerlach 2022-04-19 01:24:27 -05:00 committed by GitHub
parent 0806d5200b
commit 4a5751f0d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 10 deletions

View File

@ -22,13 +22,19 @@ class PEPTitle(transforms.Transform):
pep_header_details = {}
# Iterate through the header fields, which are the first section of the document
desired_fields = {"PEP", "Title"}
fields_to_remove = []
for field in self.document[0]:
# Hold details of the attribute's tag against its details
row_attributes = {sub.tagname: sub.rawsource for sub in field}
pep_header_details[row_attributes["field_name"]] = row_attributes["field_body"]
# Store the redundant fields in the table for removal
if row_attributes["field_name"] in desired_fields:
fields_to_remove.append(field)
# We only need the PEP number and title
if pep_header_details.keys() >= {"PEP", "Title"}:
if pep_header_details.keys() >= desired_fields:
break
# Create the title string for the PEP
@ -46,6 +52,10 @@ class PEPTitle(transforms.Transform):
pep_title_node.extend(document_children)
self.document.note_implicit_target(pep_title_node, pep_title_node)
# Remove the now-redundant fields
for field in fields_to_remove:
field.parent.remove(field)
def _line_to_nodes(text: str) -> list[nodes.Node]:
"""Parse RST string to nodes."""

View File

@ -41,8 +41,8 @@ p {margin: .5rem 0}
h1 {
font-size: 2rem;
font-weight: bold;
margin-top: 2rem;
margin-bottom: 1.5rem;
margin-top: 1.25rem;
margin-bottom: 1rem;
}
h2 {
font-size: 1.6rem;
@ -145,7 +145,7 @@ dl dd {
hr {
border: 0;
border-top: 1px solid var(--colour-rule-light);
margin: 1.75rem 0;
margin: 0;
}
/*Image rules */
img {
@ -266,21 +266,30 @@ dl.rfc2822,
dl.footnote {
display: grid;
grid-template-columns: fit-content(30%) auto;
line-height: 1.875;
width: 100%;
border-top: 1px solid var(--colour-rule-strong);
}
dl.rfc2822 > dt, dl.rfc2822 > dd,
dl.footnote > dt, dl.footnote > dd {
dl.footnote {
border-top: 1px solid var(--colour-rule-strong);
line-height: 1.875;
}
dl.rfc2822 > dt,
dl.rfc2822 > dd {
padding: .1rem .3rem .1rem;
}
dl.footnote > dt,
dl.footnote > dd {
padding: .25rem .5rem .2rem;
border-bottom: 1px solid var(--colour-rule-strong);
}
dl.rfc2822 > dt {
text-align: right;
}
dl.footnote > dt {
font-weight: normal;
border-right: 1px solid var(--colour-background);
}
dl.rfc2822 dd,
dl.footnote dd {
dl.rfc2822 > dd,
dl.footnote > dd {
margin: 0;
}