From 63576df1cdd5efed4e6f25f5fd5da9fc5177b5de Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Fri, 12 Aug 2022 12:49:03 -0600 Subject: [PATCH] Update doc sidebar to look better --- .gitignore | 3 ++ doc/source/_static/css/style.css | 54 ++++++++++++++++++++++++++++++++ doc/source/conf.py | 42 ++++++++++++++++++++++++- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 doc/source/_static/css/style.css diff --git a/.gitignore b/.gitignore index 894a44cc0..dee43f70b 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ venv.bak/ # mypy .mypy_cache/ + +# doc generation +doc/source/_static/logos diff --git a/doc/source/_static/css/style.css b/doc/source/_static/css/style.css new file mode 100644 index 000000000..6bccd9f49 --- /dev/null +++ b/doc/source/_static/css/style.css @@ -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; +} diff --git a/doc/source/conf.py b/doc/source/conf.py index 4e410e223..c5a8ecfe9 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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 @@ -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 @@ -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", + }, +}