Skip to content

Commit 4a5751f

Browse files
authored
Style: Reduce space consumed by headers and improve alignment (#2533)
1 parent 0806d52 commit 4a5751f

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

pep_sphinx_extensions/pep_processor/transforms/pep_title.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@ def apply(self) -> None:
2222
pep_header_details = {}
2323

2424
# Iterate through the header fields, which are the first section of the document
25+
desired_fields = {"PEP", "Title"}
26+
fields_to_remove = []
2527
for field in self.document[0]:
2628
# Hold details of the attribute's tag against its details
2729
row_attributes = {sub.tagname: sub.rawsource for sub in field}
2830
pep_header_details[row_attributes["field_name"]] = row_attributes["field_body"]
2931

32+
# Store the redundant fields in the table for removal
33+
if row_attributes["field_name"] in desired_fields:
34+
fields_to_remove.append(field)
35+
3036
# We only need the PEP number and title
31-
if pep_header_details.keys() >= {"PEP", "Title"}:
37+
if pep_header_details.keys() >= desired_fields:
3238
break
3339

3440
# Create the title string for the PEP
@@ -46,6 +52,10 @@ def apply(self) -> None:
4652
pep_title_node.extend(document_children)
4753
self.document.note_implicit_target(pep_title_node, pep_title_node)
4854

55+
# Remove the now-redundant fields
56+
for field in fields_to_remove:
57+
field.parent.remove(field)
58+
4959

5060
def _line_to_nodes(text: str) -> list[nodes.Node]:
5161
"""Parse RST string to nodes."""

pep_sphinx_extensions/pep_theme/static/style.css

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ p {margin: .5rem 0}
4141
h1 {
4242
font-size: 2rem;
4343
font-weight: bold;
44-
margin-top: 2rem;
45-
margin-bottom: 1.5rem;
44+
margin-top: 1.25rem;
45+
margin-bottom: 1rem;
4646
}
4747
h2 {
4848
font-size: 1.6rem;
@@ -145,7 +145,7 @@ dl dd {
145145
hr {
146146
border: 0;
147147
border-top: 1px solid var(--colour-rule-light);
148-
margin: 1.75rem 0;
148+
margin: 0;
149149
}
150150
/*Image rules */
151151
img {
@@ -266,21 +266,30 @@ dl.rfc2822,
266266
dl.footnote {
267267
display: grid;
268268
grid-template-columns: fit-content(30%) auto;
269-
line-height: 1.875;
270269
width: 100%;
270+
}
271+
dl.footnote {
271272
border-top: 1px solid var(--colour-rule-strong);
273+
line-height: 1.875;
272274
}
273-
dl.rfc2822 > dt, dl.rfc2822 > dd,
274-
dl.footnote > dt, dl.footnote > dd {
275+
dl.rfc2822 > dt,
276+
dl.rfc2822 > dd {
277+
padding: .1rem .3rem .1rem;
278+
}
279+
dl.footnote > dt,
280+
dl.footnote > dd {
275281
padding: .25rem .5rem .2rem;
276282
border-bottom: 1px solid var(--colour-rule-strong);
277283
}
284+
dl.rfc2822 > dt {
285+
text-align: right;
286+
}
278287
dl.footnote > dt {
279288
font-weight: normal;
280289
border-right: 1px solid var(--colour-background);
281290
}
282-
dl.rfc2822 dd,
283-
dl.footnote dd {
291+
dl.rfc2822 > dd,
292+
dl.footnote > dd {
284293
margin: 0;
285294
}
286295

0 commit comments

Comments
 (0)