Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pep_sphinx_extensions/pep_processor/transforms/pep_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ def apply(self) -> None:
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
Expand All @@ -46,6 +52,10 @@ def apply(self) -> None:
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."""
Expand Down
25 changes: 17 additions & 8 deletions pep_sphinx_extensions/pep_theme/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -266,21 +266,30 @@ dl.rfc2822,
dl.footnote {
display: grid;
grid-template-columns: fit-content(30%) auto;
line-height: 1.875;
width: 100%;
}
dl.footnote {
border-top: 1px solid var(--colour-rule-strong);
line-height: 1.875;
}
dl.rfc2822 > dt, dl.rfc2822 > dd,
dl.footnote > dt, dl.footnote > dd {
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;
}

Expand Down