diff --git a/docs/_static/css/custom.css b/docs/_static/css/custom.css index e4832f2e6..93a95be1e 100644 --- a/docs/_static/css/custom.css +++ b/docs/_static/css/custom.css @@ -111,3 +111,23 @@ code.sig-name .lv-example-link-button:visited { color: white; } + +dl.cpp.unexpanded dd { + display: none; +} + +.lv-api-expansion-button { + padding: 4px; +} +.lv-api-expansion-button::before { + font-family: FontAwesome, "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif; + display: inline-block; + font-size: 1.1em; + cursor: pointer; +} +.unexpanded .lv-api-expansion-button::before { + content: "\f0da \00a0"; +} +.expanded .lv-api-expansion-button::before { + content: "\f0d7 \00a0"; +} \ No newline at end of file diff --git a/docs/_static/js/custom.js b/docs/_static/js/custom.js new file mode 100644 index 000000000..d16e00b02 --- /dev/null +++ b/docs/_static/js/custom.js @@ -0,0 +1,18 @@ +/* API collapsing */ +document.addEventListener('DOMContentLoaded', (event) => { + document.querySelectorAll("dl.cpp").forEach(cppListing => { + const dt = cppListing.querySelector("dt"); + let shouldBeExpanded = false; + if(dt.id == document.location.hash.substring(1)) + shouldBeExpanded = true; + cppListing.classList.add(shouldBeExpanded ? "expanded" : "unexpanded"); + const button = document.createElement("span"); + button.classList.add("lv-api-expansion-button"); + button.addEventListener("click", () => { + cppListing.classList.toggle("unexpanded"); + cppListing.classList.toggle("expanded"); + }); + + dt.insertBefore(button, dt.firstChild); + }); +}) \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 07b49715c..75d5ae3ea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,14 +18,16 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os -import sys import subprocess +import sys + sys.path.insert(0, os.path.abspath('./_ext')) +from subprocess import PIPE, Popen + import recommonmark from recommonmark.transform import AutoStructify from sphinx.builders.html import StandaloneHTMLBuilder -from subprocess import Popen, PIPE # -- General configuration ------------------------------------------------ @@ -148,6 +150,10 @@ html_sidebars = { ] } +html_js_files = [ + 'js/custom.js' +] + html_favicon = 'favicon.png' html_logo = 'logo_lvgl.png'