diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 815c28921..3848f7453 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -18,6 +18,11 @@ jobs: build: runs-on: ubuntu-latest steps: + - + name: Install pagefind + uses: jaxxstorm/action-install-gh-release@v1.10.0 + with: + repo: cloudcannon/pagefind - name: Checkout source code uses: actions/checkout@v4.1.6 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index aaeb0d883..7e196cf62 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,6 +19,10 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Install pagefind + uses: jaxxstorm/action-install-gh-release@v1.10.0 + with: + repo: cloudcannon/pagefind - uses: actions/checkout@v4.1.6 - name: Set up Python 3.8 uses: actions/setup-python@v5 diff --git a/Makefile b/Makefile index a82ed47d6..ed78e5538 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,24 @@ ESPHOME_PATH = ../esphome ESPHOME_REF = 2024.5.0 +PAGEFIND_VERSION=1.1.0 +PAGEFIND=pagefind +NET_PAGEFIND=../pagefindbin/pagefind -.PHONY: html html-strict cleanhtml deploy help live-html Makefile netlify netlify-api api netlify-dependencies svg2png copy-svg2png minify +.PHONY: html html-strict cleanhtml deploy help live-html live-pagefind Makefile netlify netlify-api api netlify-dependencies svg2png copy-svg2png minify html: sphinx-build -M html . _build -j auto -n $(O) -live-html: + ${PAGEFIND} + +live-html: html sphinx-autobuild . _build -j auto -n $(O) --host 0.0.0.0 +live-pagefind: html + ${PAGEFIND} --serve + html-strict: sphinx-build -M html . _build -W -j auto -n $(O) + ${PAGEFIND} minify: minify _static/webserver-v1.js > _static/webserver-v1.min.js @@ -32,6 +41,10 @@ api: fi ESPHOME_PATH=$(ESPHOME_PATH) doxygen Doxygen +net-html: + sphinx-build -M html . _build -j auto -n $(O) + ${NET_PAGEFIND} + netlify-api: netlify-dependencies mkdir -p _build/html/api @if [ ! -d "$(ESPHOME_PATH)" ]; then \ @@ -40,15 +53,23 @@ netlify-api: netlify-dependencies fi ESPHOME_PATH=$(ESPHOME_PATH) ../doxybin/doxygen Doxygen -netlify-dependencies: +netlify-dependencies: pagefind-binary mkdir -p ../doxybin curl -L https://github.com/esphome/esphome-docs/releases/download/v1.10.1/doxygen-1.8.13.xz | xz -d >../doxybin/doxygen chmod +x ../doxybin/doxygen +pagefind-binary: + mkdir -p ../pagefindbin + curl -o pagefind-v$(PAGEFIND_VERSION)-x86_64-unknown-linux-musl.tar.gz https://github.com/CloudCannon/pagefind/releases/download/v$(PAGEFIND_VERSION)/pagefind-v$(PAGEFIND_VERSION)-x86_64-unknown-linux-musl.tar.gz -L + tar xzf pagefind-v$(PAGEFIND_VERSION)-x86_64-unknown-linux-musl.tar.gz + rm pagefind-v$(PAGEFIND_VERSION)-x86_64-unknown-linux-musl.tar.gz + mv pagefind ${NET_PAGEFIND} + + copy-svg2png: cp svg2png/*.png _build/html/_images/ -netlify: netlify-dependencies netlify-api html copy-svg2png +netlify: netlify-dependencies netlify-api net-html copy-svg2png lint: html-strict python3 lint.py diff --git a/_static/custom.css b/_static/custom.css index 182ffa4ab..e7bd6737d 100644 --- a/_static/custom.css +++ b/_static/custom.css @@ -248,6 +248,34 @@ a:has(> img:only-child) { div.body p, div.body dd, div.body li, div.body blockquote { hyphens: none; } +.pagefind-ui__form { + width: 100%; + max-width: 300px; + left: auto; + right: auto; + position: relative; +} + +.pagefind-modular-list-excerpt, .pagefind-modular-list-title { + color: #111111 !important; +} + +.search-results { + background-color: #f8f8f8; + box-shadow: 0 6px 10px rgb(0 0 0 / 0.2); + position: absolute; + z-index: 1500; + margin-top: 4px; + padding-right: 6px; + padding-left: 6px; + border-radius: 12px; + overflow: auto; + width: 0; + height: fit-content; + max-width: 650px; + transition: height, width 0.1s ease-in-out; + display: none; +} /* dark theme */ @media (prefers-color-scheme: dark) { @@ -344,4 +372,24 @@ div.body p, div.body dd, div.body li, div.body blockquote { background-color: #8e8129; } + .search-results { + background-color: #313131; + box-shadow: 0 6px 10px rgb(0 0 0 / 0.8); + } + .pagefind-modular-list-excerpt, .pagefind-modular-list-title { + color: #eeeeee !important; + } + + .pagefind-ui__form, .pagefind-modular-input, .search-results { + color: #ececec !important; + } + :root { + --pagefind-ui-primary: #eeeeee; + --pagefind-ui-text: #eeeeee; + --pagefind-ui-background: #152028; + --pagefind-ui-border: #152028; + --pagefind-ui-tag: #152028; + } + + } diff --git a/_templates/layout.html b/_templates/layout.html index b11da1a47..fe0c58b89 100644 --- a/_templates/layout.html +++ b/_templates/layout.html @@ -5,6 +5,7 @@ {% endblock %} {%- block extrahead %} + @@ -29,14 +30,16 @@ {% endblock %} {% block relbar_top %} - {% if parents|length > 0 %} + {% endif %} + +
{% endblock %} {% block footer %} diff --git a/_templates/search.html b/_templates/search.html new file mode 100644 index 000000000..04783c2dd --- /dev/null +++ b/_templates/search.html @@ -0,0 +1,36 @@ + +{% extends "page.html" %} + +{%- block htmltitle -%} +{{ _("Search") }} - {{ docstitle }} +{%- endblock htmltitle -%} + +{% block content %} +

{{ _("Search") }}

+ +{% endblock %} + +{% block scripts -%} +{{ super() }} +{%- endblock scripts %} + +{% block extra_styles -%} +{{ super() }} + +{%- endblock extra_styles %} + diff --git a/_templates/searchbox.html b/_templates/searchbox.html new file mode 100644 index 000000000..7a7de9aaa --- /dev/null +++ b/_templates/searchbox.html @@ -0,0 +1,82 @@ + + +
+ diff --git a/conf.py b/conf.py index c09e3fb82..6934ccc93 100644 --- a/conf.py +++ b/conf.py @@ -167,6 +167,7 @@ html_sidebars = { } + # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. diff --git a/pagefind.yml b/pagefind.yml new file mode 100644 index 000000000..c034230ce --- /dev/null +++ b/pagefind.yml @@ -0,0 +1,9 @@ +site: _build/html +exclude_selectors: + - "a.headerlink" + - ".toctree-wrapper" + - ".sphinxsidebar" + - ".breadcrumbs" +glob: "{components,cookbook,guides,projects,web-api}/**/*.html" +root_selector: div[role=main] +