Skip to content

Commit 402b0c7

Browse files
committed
Bump dict2css version.
1 parent ac5bec0 commit 402b0c7

29 files changed

+90
-132
lines changed

repo_helper/files/docs.py

Lines changed: 49 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import shutil
3434
import warnings
3535
from contextlib import suppress
36-
from typing import List
36+
from typing import Dict, List, Mapping, MutableMapping
3737

3838
# 3rd party
3939
import 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

503461
def 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"},

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ attrs>=20.2.0
33
click==7.1.2
44
configconfig>=0.4.0
55
consolekit>=0.8.0
6-
dict2css>=0.1.0
6+
dict2css>=0.2.0
77
domdf-python-tools>=2.0.1
88
dulwich>=0.19.16
99
email-validator==1.1.2

tests/test_cli/test_show_/test_requirements_3_6_.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ repo_helper==2020.12.18
9797
│ │ └── typing-extensions>=3.7.4.3
9898
│ ├── mistletoe>=0.7.2
9999
│ └── typing-extensions>=3.7.4.3
100-
├── dict2css>=0.1.0
100+
├── dict2css>=0.2.0
101101
│ ├── css-parser==1.0.6
102102
│ └── domdf-python-tools>=2.2.0
103103
│ ├── deprecation-alias>=0.1.1

tests/test_cli/test_show_/test_requirements_3_7_.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ repo_helper==2020.12.18
9191
│ │ └── typing-extensions>=3.7.4.3
9292
│ ├── mistletoe>=0.7.2
9393
│ └── typing-extensions>=3.7.4.3
94-
├── dict2css>=0.1.0
94+
├── dict2css>=0.2.0
9595
│ ├── css-parser==1.0.6
9696
│ └── domdf-python-tools>=2.2.0
9797
│ ├── deprecation-alias>=0.1.1

tests/test_cli/test_show_/test_requirements_3_8_.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ repo_helper==2020.12.18
7979
│ │ └── typing-extensions>=3.7.4.3
8080
│ ├── mistletoe>=0.7.2
8181
│ └── typing-extensions>=3.7.4.3
82-
├── dict2css>=0.1.0
82+
├── dict2css>=0.2.0
8383
│ ├── css-parser==1.0.6
8484
│ └── domdf-python-tools>=2.2.0
8585
│ ├── deprecation-alias>=0.1.1

tests/test_cli/test_show_/test_requirements_3_9__.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ repo_helper==2020.12.18
7878
│ │ └── typing-extensions>=3.7.4.3
7979
│ ├── mistletoe>=0.7.2
8080
│ └── typing-extensions>=3.7.4.3
81-
├── dict2css>=0.1.0
81+
├── dict2css>=0.2.0
8282
│ ├── css-parser==1.0.6
8383
│ └── domdf-python-tools>=2.2.0
8484
│ ├── deprecation-alias>=0.1.1

tests/test_cli/test_show_/test_requirements_concise_3_6_.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repo_helper==2020.12.18
1414
├── css-parser==1.0.6
1515
├── deprecation>=2.1.0
1616
├── deprecation-alias>=0.1.1
17-
├── dict2css>=0.1.0
17+
├── dict2css>=0.2.0
1818
├── distlib<1,>=0.3.1
1919
├── dnspython>=1.15.0
2020
├── domdf-python-tools>=2.2.0

tests/test_cli/test_show_/test_requirements_concise_3_7_.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repo_helper==2020.12.18
1414
├── css-parser==1.0.6
1515
├── deprecation>=2.1.0
1616
├── deprecation-alias>=0.1.1
17-
├── dict2css>=0.1.0
17+
├── dict2css>=0.2.0
1818
├── distlib<1,>=0.3.1
1919
├── dnspython>=1.15.0
2020
├── domdf-python-tools>=2.2.0

tests/test_cli/test_show_/test_requirements_concise_3_8_.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repo_helper==2020.12.18
1414
├── css-parser==1.0.6
1515
├── deprecation>=2.1.0
1616
├── deprecation-alias>=0.1.1
17-
├── dict2css>=0.1.0
17+
├── dict2css>=0.2.0
1818
├── distlib<1,>=0.3.1
1919
├── dnspython>=1.15.0
2020
├── domdf-python-tools>=2.2.0

tests/test_cli/test_show_/test_requirements_concise_3_9__.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repo_helper==2020.12.18
1414
├── css-parser==1.0.6
1515
├── deprecation>=2.1.0
1616
├── deprecation-alias>=0.1.1
17-
├── dict2css>=0.1.0
17+
├── dict2css>=0.2.0
1818
├── distlib<1,>=0.3.1
1919
├── dnspython>=1.15.0
2020
├── domdf-python-tools>=2.2.0

0 commit comments

Comments
 (0)