Skip to content

Commit

Permalink
Update doc sidebar to look better
Browse files Browse the repository at this point in the history
  • Loading branch information
tfcollins committed Aug 12, 2022
1 parent 0cb5bb5 commit 63576df
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

# doc generation
doc/source/_static/logos
54 changes: 54 additions & 0 deletions doc/source/_static/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[data-theme=light] {
--sidebar-highligh-color-hover: black;
--sidebar-highligh-color: white;
}

[data-theme=dark] {
--sidebar-highligh-color-hover: white;
--sidebar-highligh-color: black;
}

/* Pad sidebar entries so radius does not touch content or browser*/
body > div > aside > div > div > div.sidebar-scroll > div > ul {
padding-right: 10px;
padding-left: 10px;
}

/* Disable sidebar title */
.sidebar-brand-text {
display: none;
}

/* Add better highlighting on selected sidebar entry */
.sidebar-tree .current>.reference {
border-radius: 25px;
color: var(--sidebar-highligh-color);
padding-bottom: 5px;
padding-top: 5px;
}

/* Add better highlighting on selected second level sidebar entry */
.toctree-l2 .current.reference.internal {
border-radius: 25px;
color: var(--sidebar-highligh-color);
padding-bottom: 1px;
padding-top: 1px;
margin: 2px;
}

/* Add better highlighting on selected hovered sidebar entry */
.sidebar-tree .current>.reference:hover {
color: var(--sidebar-highligh-color-hover);
border: 1px solid var(--sidebar-highligh-color-hover);
padding-bottom: 4px;
padding-top: 4px;
}

/* Add better highlighting on selected second level hovered sidebar entry */
.toctree-l2 .current.reference.internal:hover {
color: var(--sidebar-highligh-color-hover);
border: 1px solid var(--sidebar-highligh-color-hover);
padding-bottom: 1px;
padding-top: 1px;
margin: 2px;
}
42 changes: 41 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import shutil
import sys
from typing import List

Expand All @@ -19,12 +20,32 @@
sys.path.insert(0, os.path.abspath("../.."))
sys.setrecursionlimit(1500)

# Move logos over to doc directory
p = os.path.join("_static", "logos")
if not os.path.exists(p):
os.mkdir("_static/logos")

for filename in os.listdir(os.path.join("..", "..", "images")):
if filename.endswith(".png"):
shutil.copy(
os.path.join("..", "..", "images", filename),
os.path.join("_static", "logos", filename),
)
fn = os.path.join("_static", "logos", filename)
from PIL import Image

im = Image.open(fn)
# Remove left 30% of image
im = im.crop((int(im.size[0] * 0.45), 0, int(im.size[0] * 1), im.size[1]))
im.save(fn)


import adi # isort:skip

# -- Project information -----------------------------------------------------

project = "Analog Devices Hardware Python Interfaces"
copyright = "2019-2021, Analog Devices, Inc"
copyright = "2019-2022, Analog Devices, Inc"
author = "Travis Collins"

# The full version, including alpha/beta/rc tags
Expand Down Expand Up @@ -76,3 +97,22 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_css_files = [
"css/style.css",
]

html_theme_options = {
"light_logo": os.path.join("logos", "PyADI-IIO_Logo_300.png"),
"dark_logo": os.path.join("logos", "PyADI-IIO_Logo_w_300.png"),
"dark_css_variables": {
"color-sidebar-item-background--current": "white",
"color-sidebar-link-text": "white",
"color-sidebar-link-text--top-level": "white",
},
"light_css_variables": {
"color-sidebar-item-background--current": "black",
"color-sidebar-link-text": "black",
"color-sidebar-link-text--top-level": "black",
},
}

0 comments on commit 63576df

Please sign in to comment.