doc_src: add print media support to the Sphinx theme

Update the pydoctheme.css file to add support for print media.

The code was adapted from the existing support for screens that are less than
700px wide, with the following changes:

  - Remove the documents and sections index
  - Remove the quick search
  - Remove dead CSS code

Additionally, add section numbers and ensure that code blocks are never split
across multiple pages.
This commit is contained in:
Manlio Perillo 2024-01-06 18:11:19 +01:00 committed by Fabian Boehm
parent fdbda18418
commit a953b7984d

View File

@ -611,6 +611,68 @@ div.documentwrapper {
}
}
/* On print media remove anything non-essential. */
@media print {
.inline-search {
display: none;
}
div.sphinxsidebar {
display: none;
}
div.bodywrapper {
margin-left: 0;
}
div.sphinxsidebar ul {
flex-basis: content;
flex-wrap: wrap;
}
div.sphinxsidebarwrapper {
display: flex;
}
div#searchbox {
display: none !important;
}
div.body {
padding: 1rem;
}
div#fmain {
border-radius: 0px;
margin: 0;
box-shadow: 0;
width: 100%;
padding: 0;
/* We have some padding/margins that would overflow - just remove it */
overflow: clip;
}
div.footer {
margin: 0;
}
/* Avoid splitting code blocks across multiple pages. */
pre {
page-break-inside: avoid;
}
/* Show section numbers. */
.body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: counter(section) ". ";
font-weight: normal;
}
}
.sphinxsidebar ul.current > li.current { font-weight: bold }
.gray { color: #777 }