3333import shutil
3434import warnings
3535from contextlib import suppress
36- from typing import List
36+ from typing import Dict , List , Mapping , MutableMapping
3737
3838# 3rd party
3939import dict2css
@@ -384,120 +384,78 @@ def make_alabaster_theming() -> str:
384384 :return: The custom stylesheet.
385385 """
386386
387- sheet = dict2css .StyleSheet ()
388-
389387 # Common options
390388 solid_border = {"border-style" : "solid" }
391389 docs_bottom_margin = {"margin-bottom" : (dict2css .px (17 ), dict2css .IMPORTANT )}
392390
393- sheet .add_style ("li p:last-child" , {"margin-bottom" : dict2css .px (12 )})
394-
395- # Smooth scrolling between sections
396- sheet .add_style ("html" , {"scroll-behavior" : "smooth" })
397-
398- # Border around classes
399- sheet .add_style (
400- "dl.class" ,
401- {
402- "padding" : "3px 3px 3px 5px" ,
403- "margin-top" : ("7px" , dict2css .IMPORTANT ),
404- ** docs_bottom_margin ,
405- "border-color" : "rgba(240, 128, 128, 0.5)" ,
406- ** solid_border ,
407- }
408- )
391+ object_border = {"padding" : "3px 3px 3px 5px" , ** docs_bottom_margin , ** solid_border }
409392
410- # Border around functions
411- sheet .add_style (
412- "dl.function" ,
413- {
414- "padding" : "3px 3px 3px 5px" ,
415- "margin-top" : ("7px" , dict2css .IMPORTANT ),
416- ** docs_bottom_margin ,
417- "border-color" : "lightskyblue" ,
418- ** solid_border ,
419- }
420- )
393+ class_border = {
394+ ** object_border ,
395+ "margin-top" : ("7px" , dict2css .IMPORTANT ),
396+ "border-color" : "rgba(240, 128, 128, 0.5)" ,
397+ }
421398
422- sheet .add_style ("dl.function dt" , {"margin-bottom" : (dict2css .px (10 ), dict2css .IMPORTANT )})
423-
424- # Border around attributes
425- sheet .add_style (
426- "dl.attribute" ,
427- {
428- "padding" : "3px 3px 3px 5px" ,
429- ** docs_bottom_margin ,
430- "border-color" : "rgba(119, 136, 153, 0.5)" ,
431- ** solid_border
432- }
433- )
399+ function_border = {
400+ ** object_border ,
401+ "margin-top" : ("7px" , dict2css .IMPORTANT ),
402+ "border-color" : "lightskyblue" ,
403+ }
434404
435- # Border around Methods
436- sheet .add_style (
437- "dl.method" ,
438- {
439- "padding" : "3px 3px 3px 5px" ,
440- ** docs_bottom_margin ,
441- "border-color" : "rgba(32, 178, 170, 0.5)" ,
442- ** solid_border
443- }
444- )
405+ attribute_border = {** object_border , "border-color" : "rgba(119, 136, 153, 0.5)" }
406+ method_border = {** object_border , "border-color" : "rgba(32, 178, 170, 0.5)" }
445407
446- sheet .add_style ("div.sphinxsidebar" , {"font-size" : dict2css .px (14 ), "line-height" : "1.5" })
447- sheet .add_style ("div.sphinxsidebar h3" , {"font-weight" : "bold" })
448- sheet .add_style ("div.sphinxsidebar p.caption" , {"font-size" : dict2css .px (20 )})
449- sheet .add_style (
450- "div.sphinxsidebar div.sphinxsidebarwrapper" , {"padding-right" : (dict2css .px (20 ), dict2css .IMPORTANT )}
451- )
408+ table_vertical_margins = {
409+ "margin-bottom" : (dict2css .px (20 ), "important" ),
410+ "margin-top" : (dict2css .px (- 15 ), dict2css .IMPORTANT ),
411+ }
452412
453- # Margin above and below table
454- sheet .add_style (
455- "table.longtable" , {
456- "margin-bottom" : (dict2css .px (20 ), "important" ),
457- "margin-top" : (dict2css .px (- 15 ), dict2css .IMPORTANT )
458- }
459- )
413+ style : Dict [str , MutableMapping ] = {
414+ "li p:last-child" : {"margin-bottom" : dict2css .px (12 )},
415+ "html" : {"scroll-behavior" : "smooth" }, # Smooth scrolling between sections
416+ "dl.class" : class_border ,
417+ "dl.function" : function_border ,
418+ "dl.function dt" : {"margin-bottom" : (dict2css .px (10 ), dict2css .IMPORTANT )},
419+ "dl.attribute" : attribute_border ,
420+ "dl.method" : method_border ,
421+ "div.sphinxsidebar" : {"font-size" : dict2css .px (14 ), "line-height" : "1.5" },
422+ "div.sphinxsidebar h3" : {"font-weight" : "bold" },
423+ "div.sphinxsidebar p.caption" : {"font-size" : dict2css .px (20 )},
424+ "div.sphinxsidebar div.sphinxsidebarwrapper" : {"padding-right" : (dict2css .px (20 ), dict2css .IMPORTANT )},
425+ "table.longtable" : table_vertical_margins ,
426+ }
460427
461- # The following styling from Tox" s documentation
428+ # The following styling from Tox' s documentation
462429 # https://github.com/tox-dev/tox/blob/master/docs/_static/custom.css
463430 # MIT Licensed
464431
465432 # Page width
466- sheet . add_style ( "div.document" , {"width" : "100%" , "max-width" : dict2css .px (1400 )})
467- sheet . add_style ( "div.body" , {"max-width" : dict2css .px (1100 )})
433+ style [ "div.document" ] = {"width" : "100%" , "max-width" : dict2css .px (1400 )}
434+ style [ "div.body" ] = {"max-width" : dict2css .px (1100 )}
468435
469436 # No end-of-line hyphenation
470- sheet . add_style ( "div.body p, ol > li, div.body td" , {"hyphens" : None })
471-
472- sheet . add_style ( "img, div.figure" , {"margin" : ('0' , dict2css .IMPORTANT )})
473- sheet . add_style ( "ul > li" , {"text-align" : "justify" })
474- sheet . add_style ( "ul > li > p" , {"margin-bottom" : '0' })
475- sheet . add_style ( "ol > li > p" , {"margin-bottom" : '0' })
476- sheet . add_style ( "div.body code.descclassname" , {"display" : None })
477- sheet . add_style ( ".wy-table-responsive table td" , {"white-space" : ("normal" , dict2css .IMPORTANT )})
478- sheet . add_style ( ".wy-table-responsive" , {"overflow" : ("visible" , dict2css .IMPORTANT )})
479- sheet . add_style ( "div.toctree-wrapper.compound > ul > li" , {
437+ style [ "div.body p, ol > li, div.body td" ] = {"hyphens" : None }
438+
439+ style [ "img, div.figure" ] = {"margin" : ('0' , dict2css .IMPORTANT )}
440+ style [ "ul > li" ] = {"text-align" : "justify" }
441+ style [ "ul > li > p" ] = {"margin-bottom" : '0' }
442+ style [ "ol > li > p" ] = {"margin-bottom" : '0' }
443+ style [ "div.body code.descclassname" ] = {"display" : None }
444+ style [ ".wy-table-responsive table td" ] = {"white-space" : ("normal" , dict2css .IMPORTANT )}
445+ style [ ".wy-table-responsive" ] = {"overflow" : ("visible" , dict2css .IMPORTANT )}
446+ style [ "div.toctree-wrapper.compound > ul > li" ] = {
480447 "margin" : '0' ,
481448 "padding" : '0' ,
482- })
449+ }
483450 # TODO
484451 # code.docutils.literal {{
485452 # background-color: #ECF0F3;
486453 # padding: 0 1px;
487454 # }}
488455
489- with dict2css .CSSSerializer (trailing_semicolon = True ).use ():
490- stylesheet = sheet .tostring ().replace ('}' , "}\n " )
456+ style ["@media screen and (min-width: 870px)" ] = {"div.sphinxsidebar" : {"width" : "250px" }}
491457
492- return f"""\
493- { stylesheet }
494-
495- @media screen and (min-width: 870px) {{
496- div.sphinxsidebar {{
497- width: 250px;
498- }}
499- }}
500- """
458+ return dict2css .dumps (style , trailing_semicolon = True )
501459
502460
503461def make_readthedocs_theming () -> str :
@@ -507,7 +465,7 @@ def make_readthedocs_theming() -> str:
507465 :return: The custom stylesheet.
508466 """
509467
510- style = {
468+ style : Dict [ str , Mapping ] = {
511469 ".wy-nav-content" : {"max-width" : (dict2css .px (1200 ), dict2css .IMPORTANT )},
512470 "li p:last-child" : {"margin-bottom" : (dict2css .px (12 ), dict2css .IMPORTANT )},
513471 "html" : {"scroll-behavior" : "smooth" },
0 commit comments