Debian Codegraph @

src/sass/_theme_rst.sass

raw
1 // -------------------------------------------------------------------------------------------------------------------
2 // CONTRIBUTORS, PLEASE READ THIS!
3 // -------------------------------------------------------------------------------------------------------------------
4 // Couple things...
5 // 1. Lots of this @extends from wyrm_core/_type.sass (http://www.github.com/snide/wyrm/.
6 // * Try not to replace any @extends code. It's pretty generic stuff meant to work together.
7 // * That said, know that I'm very unlikely to accept PRs from wyrm just to change style here.
8 // 2. I plan to remove the !importants in here. Part of it is due to laziness, part to sphinx's fondness for nesting.
9 // 3. Try to use variables from wyrm_core/wy_variables.sass. Notable are...
10 // * $base-line-height // All margins, padding and line-height should use this in .25 increments.
11 // * $text-color, $text-light, $text-dark...etc
12 // * $base-font-family, $custom-font-family, $code-font-family
13 // 4. If you have changes for mobile/tablet, put them at the bottom of the sass file.
14 // --------------------------------------------------------------------------------------------------------------------
15
16 .rst-content
17 // Some browsers like to give arbitrary margins :( make them all consistent.
18 h1, h2, h3, h4, h5, h6
19 margin-bottom: $base-line-height
20
21 // Sphinx by default applies HxW style attributes to images. This fixes that oversite.
22 img
23 max-width: 100%
24 height: auto
25
26 div.figure, figure
27 margin-bottom: $base-line-height
28 .caption-text
29 font-style: italic
30 p:last-child.caption
31 margin-bottom: 0px
32 &.align-center
33 text-align: center
34
35 // Usually it's a good idea to give images some space.
36 .section >, section >
37 img, a > img
38 margin-bottom: $base-line-height
39
40 // normalize browser styling
41 abbr[title]
42 text-decoration: none
43
44 // Style external links
45 &.style-external-links a.reference.external:after
46 font-family: FontAwesome
47 content: "\f08e"
48 color: $text-light
49 vertical-align: super
50 font-size: 60%
51 margin: 0 0.2em
52
53 // For the most part, its safe to assume that sphinx wants you to use a blockquote as an indent. It gets
54 // used in many different ways, so don't assume you can apply some fancy style, just leave it be.
55 blockquote
56 margin-left: $base-line-height
57 line-height: $base-line-height
58 margin-bottom: $base-line-height
59
60 pre.literal-block
61 white-space: pre
62 margin: 0
63 padding: ($base-line-height / 2) ($base-line-height / 2)
64 font-family: $code-font-family
65 display: block
66 overflow: auto
67 pre.literal-block, div[class^='highlight']
68 border: 1px solid $table-border-color
69 overflow-x: auto
70 // 1px hack otherwise border won't show. lame
71 margin: 1px 0 $base-line-height 0
72 div[class^='highlight']
73 padding: 0px
74 border: none
75 margin: 0
76 // Needs 100% width for line highlighting to work properly
77 div[class^='highlight'] td.code
78 width: 100%
79 .linenodiv pre
80 border-right: solid 1px lighten($table-border-color, 2%)
81 margin: 0
82 padding: ($base-line-height / 2) ($base-line-height / 2)
83 font-family: $code-font-family
84 user-select: none
85 pointer-events: none
86 div[class^='highlight'] pre
87 white-space: pre
88 margin: 0
89 padding: ($base-line-height / 2) ($base-line-height / 2)
90 display: block
91 overflow: auto
92 & .hll
93 // Line emphasis spans full width
94 display: block
95 margin: 0 (-1 * $base-line-height / 2)
96 padding: 0 ($base-line-height / 2)
97 pre.literal-block, div[class^='highlight'] pre, .linenodiv pre
98 font-family: $code-font-family
99 font-size: 12px
100 line-height: 1.4
101
102 // Do not allow selection of code block prompts and line numbers
103 div.highlight
104 span.linenos, .gp
105 user-select: none
106 pointer-events: none
107
108 span.linenos
109 display: inline-block
110 padding-left: 0px
111 padding-right: ($base-line-height / 2)
112 margin-right: ($base-line-height / 2)
113 border-right: 1px solid lighten($table-border-color, 2%)
114
115 .code-block-caption
116 font-style: italic
117 font-size: 85%
118 line-height: 1
119 padding: 1em 0
120 text-align: center
121
122 @media print
123 .codeblock, div[class^='highlight'], div[class^='highlight'] pre
124 white-space: pre-wrap
125
126 // These are the various note pullouts that sphinx applies
127 .note, .attention, .caution, .danger, .error, .hint, .important, .tip, .warning, .seealso, .admonition-todo, .admonition
128 @extend .wy-alert
129 // These block elements are unsuitable for having floating objects next
130 // to them
131 clear: both
132 .last, > *:last-child
133 margin-bottom: 0
134 .admonition-title
135 @extend .wy-alert-title
136 @extend .fa
137 @extend .fa-exclamation-circle
138 &:before
139 margin-right: 4px
140 .note, .seealso
141 @extend .wy-alert.wy-alert-info
142 .hint, .tip, .important
143 @extend .wy-alert.wy-alert-success
144 .error, .danger
145 @extend .wy-alert.wy-alert-danger
146 .warning, .caution, .attention, .admonition-todo
147 @extend .wy-alert.wy-alert-warning
148 // Some people put tables in notes. Let's give them very basic support.
149 .admonition table
150 border-color: rgba(0, 0, 0, 0.1)
151 td, th
152 background: transparent !important
153 border-color: rgba(0, 0, 0, 0.1) !important
154
155 .section, section, .toctree-wrapper
156 ul
157 @extend .wy-plain-list-disc
158 ol.loweralpha, ol.loweralpha > li
159 list-style: lower-alpha
160 ol.upperalpha, ol.upperalpha > li
161 list-style: upper-alpha
162 ol, ol.arabic
163 @extend .wy-plain-list-decimal
164 // Complex bullet lists, they have more item margins than simple lists
165 ol li, ul li
166 > *
167 margin-top: $base-line-height / 2
168 margin-bottom: $base-line-height / 2
169 &:first-child
170 margin-top: 0rem
171 > p
172 &, &:last-child
173 margin-bottom: $base-line-height / 2
174 &:only-child, &:only-child:last-child
175 margin-bottom: 0rem
176 > ul, > ol
177 margin-bottom: $base-line-height / 2
178 // Simple lists, no item margins
179 ol.simple li, ul.simple li
180 > *
181 margin-top: 0rem
182 margin-bottom: 0rem
183 ul, ol
184 margin-top: 0rem
185 margin-bottom: 0rem
186
187 .line-block
188 margin-left: 0px
189 margin-bottom: $base-line-height
190 line-height: $base-line-height
191 .line-block .line-block
192 margin-left: $base-line-height
193 margin-bottom: 0px
194
195 // Generics handling of headings and toc stuff.
196 .topic-title
197 font-weight: bold
198 margin-bottom: $base-line-height / 2
199 .toc-backref
200 color: $text-color
201 .align-right
202 float: right
203 margin: 0px 0px $base-line-height $base-line-height
204 .align-left
205 float: left
206 margin: 0px $base-line-height $base-line-height 0px
207 .align-center
208 margin: auto
209 // Do not override display:table for tables
210 &:not(table)
211 display: block
212 .toctree-wrapper > p.caption
213 @extend h2
214
215 // This is the #href that shows up on hover. Sphinx's is terrible so I hack it away.
216 h1, h2, h3, h4, h5, h6, dl dt, p, p.caption, table > caption, .code-block-caption, .eqno
217 .headerlink
218 opacity: 0
219 font-size: 14px
220 font-family: FontAwesome
221 margin-left: 0.5em
222 @extend .fa
223 &:focus
224 opacity: 1
225 &:hover .headerlink
226 opacity: 1
227
228 // Make links inside paragraphs wrap when they are too long
229 p a
230 overflow-wrap: anywhere
231 // Consistent font sizing for table typography
232 .wy-table
233 th, td
234 p, ul
235 font-size: inherit
236
237 // override the Wyrm accessibility anti-pattern of hiding button focus
238 .btn:focus
239 outline: 2px solid
240
241 table > caption .headerlink:after
242 font-size: 12px
243
244 .centered
245 text-align: center
246
247 // Sidebar content. You'll see at the bottom of this file I change it in mobile.
248 .sidebar
249 float: right
250 width: 40%
251 display: block
252 margin: 0 0 $base-line-height $base-line-height
253 padding: $base-line-height
254 background: $sidebar-background-color
255 border: solid 1px $sidebar-border-color
256 // Sidebar content is usually less relevant, so adjust the margins and sizes.
257 p, ul, dl
258 font-size: 90%
259 .last, > *:last-child
260 margin-bottom: 0
261 .sidebar-title
262 display: block
263 font-family: $custom-font-family
264 font-weight: bold
265 background: $table-border-color
266 padding: ($base-line-height / 4) ($base-line-height / 2)
267 margin: -$base-line-height
268 margin-bottom: $base-line-height
269 font-size: 100%
270 // Sphinx can highlight searched text with ?highlighted=searchterm
271 .highlighted
272 background: $highlight-color
273 box-shadow: 0 0 0 ($base-line-height / 12) $highlight-color
274 display: inline
275 font-weight: bold
276
277 // These are the little citation links [1] that show up within paragraphs.
278 .footnote-reference, .citation-reference
279 vertical-align: baseline
280 position: relative
281 top: -0.4em
282 line-height: 0
283 font-size: 90%
284 > span.fn-bracket
285 display: none
286
287 // Horizontal lists have multiple columns; use full width
288 .hlist
289 width: 100%
290
291 // Definition lists term/classifier separator
292 // Adds a separator for Sphinx > 1.x as a pseudo-element
293 // and hides the hardcoded separator from Sphinx 1.x
294 dl dt span.classifier
295 &:before
296 content: " : "
297 dl dt span.classifier-delimiter
298 display: none !important
299
300 // The html4 writer outputs the citation and footnotes as a table, and the
301 // html5 writer outputs these as a definition list (docutils < 0.18) or an
302 // aside/div (docutils 0.18+). We will use the fairly well supported css
303 // `grid` attributes to make these back into a table
304 // HTML4 writer
305 html.writer-html4 &
306 table.docutils.citation, table.docutils.footnote
307 background: none
308 border: none
309 td, tr
310 border: none
311 background-color: transparent !important
312 white-space: normal
313 td.label
314 padding-left: 0
315 padding-right: 0
316 vertical-align: top
317 // HTML5 writer
318 html.writer-html5 &
319 // docutils < 0.18 grid layout. Some spacing is the dl/dt/dd margins
320 dl.footnote, dl.citation, dl.field-list
321 display: grid
322 grid-template-columns: auto minmax(80%, 95%)
323 > dt
324 display: inline-grid
325 grid-template-columns: max-content auto
326 // docutils => 0.18 grid layout
327 aside.footnote, aside.citation, div.citation
328 display: grid
329 // Two any width columns for label and backrefs, a noop column to expand
330 // to fill the width allocated to the first two columns, and then the
331 // content column for the paragraphs.
332 grid-template-columns: auto auto minmax(0.65rem, auto) minmax(40%, 95%)
333 & > span.label
334 grid-column-start: 1
335 grid-column-end: 2
336 & > span.backrefs
337 grid-column-start: 2
338 grid-column-end: 3
339 grid-row-start: 1
340 grid-row-end: 3
341 & > p
342 grid-column-start: 4
343 grid-column-end: 5
344
345 // Shared backrefs styling for docutils versions
346 @mixin footnote-backrefs
347 text-align: left
348 font-style: italic
349 margin-left: .65rem
350 word-break: break-word
351 word-spacing: -0.1rem
352 max-width: 5rem
353
354 > a
355 &:not(:first-child)::before
356 content: " "
357 word-break: keep-all
358
359 // docutils < 0.18 html5 writer styling
360 dl.footnote, dl.citation, dl.field-list,
361 margin-bottom: $base-line-height
362 > dt
363 padding-left: 1rem
364 > dt, > dd
365 margin-bottom: 0rem
366 dl.footnote, dl.citation
367 font-size: .9rem
368 > dt
369 margin: 0rem 0.5rem 0.5rem 0rem
370 line-height: 1.2rem
371 word-break: break-all
372 font-weight: normal
373 > span.brackets
374 &:before
375 content: "["
376 &:after
377 content: "]"
378 > span.fn-backref
379 @include footnote-backrefs
380 > dd
381 margin: 0rem 0rem 0.5rem 0rem
382 line-height: 1.2rem
383 p
384 font-size: 0.9rem
385
386 // docutils => 0.18 html5 writer styling
387 aside.footnote, aside.citation, div.citation
388 padding-left: 1rem
389 padding-right: 1rem
390 font-size: 0.9rem
391 line-height: 1.2rem
392 p
393 font-size: 0.9rem
394 line-height: 1.2rem
395 margin-bottom: $base-line-height / 2
396 span.backrefs
397 @include footnote-backrefs
398 span.label
399 line-height: 1.2rem
400 aside.footnote-list, aside.citation-list, div.citation-list
401 margin-bottom: $base-line-height
402
403 dl.option-list
404 kbd
405 font-size: 0.9rem
406 // Both
407 html.writer-html4 & table.docutils.citation, table.docutils.footnote,
408 html.writer-html5 & dl.footnote,
409 html.writer-html5 & dl.citation,
410 html.writer-html5 & aside.footnote,
411 html.writer-html5 & aside.footnote-list aside.footnote,
412 html.writer-html5 & div.citation-list > div.citation
413 color: $text-medium
414 code
415 color: $gray
416
417 // Remove the large vertical space between citations and footnotes
418 .wy-table-responsive.citation, .wy-table-responsive.footnote
419 margin-bottom: 0
420 // Re-add vertical space to element directly following citation and footnotes,
421 // if the following element is of a different type
422 .wy-table-responsive.citation + :not(.citation),
423 .wy-table-responsive.footnote + :not(.footnote)
424 margin-top: $base-line-height
425 // Re-add vertical space after citation and footnotes if it is the last child of a parent
426 .wy-table-responsive.citation:last-child, .wy-table-responsive.footnote:last-child
427 margin-bottom: $base-line-height
428 table.docutils
429 @extend .wy-table
430 @extend .wy-table-bordered-all
431 th
432 border-color: $table-border-color
433 html.writer-html5 &
434 border: 1px solid $table-border-color
435 html.writer-html5 &
436 th > p, td > p
437 line-height: 1rem
438 margin-bottom: 0rem
439 font-size: 0.9rem
440 &:not(.field-list)
441 @extend .wy-table-striped
442 // Remove bottom margin for the last element (and it's last child)
443 td .last, td .last > *:last-child
444 margin-bottom: 0
445 // This table is what gets spit out for auto-generated API stuff. I style it smaller bits of padding.
446 table.field-list
447 @extend .wy-table
448 border: none
449 td
450 border: none
451 p
452 line-height: inherit
453 td > strong
454 display: inline-block
455 .field-name
456 padding-right: 10px
457 text-align: left
458 white-space: nowrap
459 .field-body
460 text-align: left
461
462 // These are the "literals" that get spit out when you mark stuff as ``code`` as your write.
463 tt, code
464 @extend code
465 color: $black
466 font-family: $code-font-family
467 padding: 2px 5px
468 big, em
469 font-size: 100% !important
470 line-height: normal
471
472 &.literal
473 color: $text-code-color
474 white-space: normal
475 &.xref, a &
476 font-weight: bold
477 color: $text-codexref-color
478 // https://github.com/readthedocs/sphinx_rtd_theme/issues/1368
479 overflow-wrap: normal
480 pre, kbd, samp
481 font-family: $code-font-family
482 // If the literal is inside an a tag, let's color it like a link
483 a tt, a code
484 color: $link-color
485 dl
486 margin-bottom: $base-line-height
487 dt
488 font-weight: bold
489 margin-bottom: $base-line-height / 2
490 // Most of the content within these dls are one liners, so I halve the normal margins.
491 p, table, ul, ol
492 margin-bottom: $base-line-height / 2
493 // rST seems to want dds to be treated as the browser would, indented.
494 dd
495 margin: 0 0 ($base-line-height / 2) $base-line-height
496 line-height: $base-line-height
497 > p:last-child,
498 > ol:last-child,
499 > ul:last-child,
500 > table:last-child
501 margin-bottom: 0
502 html.writer-html4 & dl:not(.docutils),
503 html.writer-html5 & dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple)
504 margin-bottom: $base-line-height
505 > dt
506 display: table
507 margin: ($base-line-height / 4) 0
508 font-size: 90%
509 line-height: normal
510 background: lighten($class-color, 50%)
511 color: $class-color
512 border-top: solid 3px lighten($class-color, 20%)
513 padding: $base-line-height / 4
514 position: relative
515 &:before
516 color: lighten($class-color, 20%)
517 .headerlink
518 color: $text-color
519 font-size: 100% !important
520 // In the html4 writer, parameters is a table. In html5 writer, parameters
521 // is a nested dl.field-list
522 dl:not(.option-list):not(.field-list):not(.footnote):not(.citation):not(.glossary):not(.simple) > dt
523 margin-bottom: $base-line-height / 4
524 border: none
525 border-left: solid 3px hsl(0, 0%, 80%)
526 background: hsl(0, 0%, 94%)
527 color: $method-color
528 .headerlink
529 color: $headerlink-color
530 font-size: 100% !important
531 > dt:first-child
532 margin-top: 0
533 // Since dts get the callout style, we treat this less as callouts.
534 tt, code
535 &.descname, &.descclassname
536 background-color: transparent
537 border: none
538 padding: 0
539 font-size: 100% !important
540 &.descname
541 font-weight: bold
542 // This is for more advanced parameter control
543 .optional
544 display: inline-block
545 padding: 0 4px
546 color: $black
547 font-weight: bold
548 .property
549 display: inline-block
550 padding-right: 8px
551 max-width: 100%
552 // This is keywords such as "const"
553 .k
554 font-style: italic
555 .sig-name, .descname, .descclassname
556 font-family: $code-font-family
557 color: $black
558 // Doc links to sourcecode
559 .viewcode-link, .viewcode-back
560 display: inline-block
561 color: $text-viewcode-color
562 font-size: 80%
563 padding-left: $base-line-height
564 .viewcode-back
565 display: block
566 float: right
567 p.rubric
568 margin-bottom: 12px
569 font-weight: bold
570 //Download link
571 code.download
572 background: inherit
573 padding: inherit
574 font-weight: normal
575 font-family: inherit
576 font-size: inherit
577 color: inherit
578 border: inherit
579 white-space: inherit
580 span:first-child
581 -webkit-font-smoothing: subpixel-antialiased
582 @extend .fa
583 @extend .fa-download
584 &:before
585 margin-right: 4px
586 .guilabel,
587 .menuselection
588 font-size: 80%
589 font-weight: 700
590 border-radius: $base-line-height / 6
591 padding: ($base-line-height / 10) ($base-line-height / 4)
592 margin: auto ($base-line-height / 12)
593 .guilabel,
594 border: 1px solid lighten($guilabel-color, 25%)
595 background: lighten($guilabel-color, 50%)
596 .menuselection
597 border: 1px solid lighten($menuselection-color, 25%)
598 background: lighten($menuselection-color, 50%)
599 *:not(dl.option-list) > :not(dt):not(kbd):not(.kbd) > kbd,
600 *:not(dl.option-list) > :not(dt):not(kbd):not(.kbd) > .kbd
601 color: inherit
602 font-size: 80%
603 background-color: lighten($text-light, 30%)
604 border: 1px solid darken($text-light, 5%)
605 border-radius: $base-line-height / 6
606 box-shadow: grey 0px $base-line-height / 12
607 padding: $base-line-height / 10 $base-line-height / 4
608 margin: auto 0
609 .versionmodified
610 font-style: italic
611
612
613 // Mobile specific
614 +media($mobile)
615 .rst-content
616 .sidebar
617 width: 100%
618 float: none
619 margin-left: 0