Skip to content

Commit

Permalink
fix light mode for pydata
Browse files Browse the repository at this point in the history
  • Loading branch information
bbielawx committed Mar 22, 2024
1 parent 40cbdfe commit ebe9c64
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import xml.etree.ElementTree as ET
import queue
from pathlib import Path
from sphinx_sitemap import setup as base_setup, get_locales, hreflang_formatter
from sphinx_sitemap import setup as base_setup, get_locales, hreflang_formatter, add_html_link, record_builder_type
from sphinx.util.logging import getLogger

logger = getLogger(__name__)

def setup(app):
app.add_config_value(
Expand All @@ -21,7 +23,9 @@ def setup(app):
for listener in app.events.listeners['build-finished']:
if listener.handler.__name__ == 'create_sitemap':
app.disconnect(listener.id)


app.connect("builder-inited", record_builder_type)
app.connect("html-page-context", add_html_link)
app.connect('build-finished', create_sitemap)
return setup

Expand All @@ -33,10 +37,14 @@ def create_sitemap(app, exception):
meta = app.builder.config.ov_sitemap_meta

site_url = app.builder.config.site_url or app.builder.config.html_baseurl
site_url = site_url.rstrip('/') + '/'
if not site_url:
print("sphinx-sitemap error: neither html_baseurl nor site_url "
"are set in conf.py. Sitemap not built.")
if site_url:
site_url.rstrip("/") + "/"
else:
logger.warning(
"sphinx-sitemap: html_baseurl is required in conf.py." "Sitemap not built.",
type="sitemap",
subtype="configuration",
)
return
if (not app.sitemap_links):
print("sphinx-sitemap warning: No pages generated for %s" %
Expand All @@ -53,20 +61,14 @@ def create_sitemap(app, exception):
for item in urlset:
root.set(*item)

locales = get_locales(app)
locales = get_locales(app, exception)

if app.builder.config.version:
version = app.builder.config.version + '/'
else:
version = ""

while True:
try:
link = app.env.app.sitemap_links.get_nowait()
print(link) # type: ignore
except queue.Empty:
break

for link in app.sitemap_links:
url = ET.SubElement(root, "url")
scheme = app.config.sitemap_url_scheme
if app.builder.config.language:
Expand All @@ -85,7 +87,7 @@ def create_sitemap(app, exception):
for tag_name, tag_value in values.items():
ET.SubElement(namespace_element, tag_name).text = tag_value

if len(locales) > 0:
if len(app.locales) > 0:
for lang in locales:
lang = lang + '/'
linktag = ET.SubElement(
Expand Down
157 changes: 157 additions & 0 deletions docs/openvino_sphinx_theme/openvino_sphinx_theme/templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{# We redefine <html/> for "basic/layout.html" to add a default `data-theme` attribute when
# a default mode has been set. This also improves compatibility when JavaScript is disabled.
#}
{% set html_tag %}
<html{% if not html5_doctype %} xmlns="http://www.w3.org/1999/xhtml"{% endif %}{% if language is not none %} lang="{{ language }}"{% endif %} {% if default_mode %}data-theme="{{ default_mode }}"{% endif %}>
{% endset %}
{%- extends "basic/layout.html" %}
{%- import "static/webpack-macros.html" as _webpack with context %}
{# Metadata and asset linking #}
{# Create the sidebar links HTML here to re-use in a few places #}
{# If we have no sidebar links, pop the links component from the sidebar list #}
{%- set sidebar_nav_html = generate_toctree_html("sidebar",
startdepth=0|int,
show_nav_level=theme_show_nav_level|int,
maxdepth=theme_navigation_depth|int,
collapse=theme_collapse_navigation|tobool,
includehidden=True,
titles_only=True)
-%}
{% if sidebar_nav_html | length == 0 %}
{% set sidebars = sidebars | reject("in", "sidebar-nav-bs.html") | list %}
{% endif %}
{# A flag for whether we include a secondary sidebar based on the page metadata #}
{% set remove_sidebar_secondary = (meta is defined and meta is not none
and 'html_theme.sidebar_secondary.remove' in meta)
or not theme_secondary_sidebar_items %}
{%- block css %}
{# The data-cfasync attribute disables CloudFlare's Rocket loader so that #}
{# mode/theme are correctly set before the browser renders the page. #}
{# https://github.com/pydata/pydata-sphinx-theme/pull/1045 #}
<script type="module" src="https://static.cloud.coveo.com/atomic/v2/atomic.esm.js"></script>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "{{ default_mode }}";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
{{ _webpack.head_pre_assets() }}
{{ _webpack.head_pre_icons() }}
{{- css() }}
{{ _webpack.head_js_preload() }}
{%- endblock css %}
{%- block extrahead %}
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="{{ language }}"/>
{%- if last_updated %}
<meta name="docbuild:last-update" content="{{ last_updated | e }}"/>
{%- endif %}
{%- endblock extrahead %}
{% block body_tag %}
{# set up with scrollspy to update the toc as we scroll #}
{# ref: https://getbootstrap.com/docs/4.0/components/scrollspy/ #}
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="{{ default_mode }}">

{# A button hidden by default to help assistive devices quickly jump to main content #}
{# ref: https://www.youtube.com/watch?v=VUR0I5mqq7I #}
<a class="skip-link" href="#main-content">{{ _("Skip to main content") }}</a>

{%- endblock %}

{%- block content %}
{# A tiny helper pixel to detect if we've scrolled #}
<div id="pst-scroll-pixel-helper"></div>

{# the scroll to top button #}
<button type="button" class="btn rounded-pill" id="pst-back-to-top">
<i class="fa-solid fa-arrow-up"></i>
{{ _("Back to top") }}
</button>

{# checkbox to toggle primary sidebar #}
<input type="checkbox"
class="sidebar-toggle"
name="__primary"
id="__primary"/>
<label class="overlay overlay-primary" for="__primary"></label>
{# Checkboxes to toggle the secondary sidebar #}
<input type="checkbox"
class="sidebar-toggle"
name="__secondary"
id="__secondary"/>
<label class="overlay overlay-secondary" for="__secondary"></label>
{# A search field pop-up that will only show when the search button is clicked #}
<div class="search-button__wrapper">
<div class="search-button__overlay"></div>
<div class="search-button__search-container">{% include "../components/search-field.html" %}</div>
</div>
{%- if theme_announcement -%}
{% include "sections/announcement.html" %}
{%- endif %}
{% block docs_navbar %}
<nav class="bd-header navbar navbar-expand-lg bd-navbar">
{%- include "sections/header.html" %}
</nav>
{% endblock docs_navbar %}
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
{# Primary sidebar #}
<div class="bd-sidebar-primary bd-sidebar{% if not sidebars %} hide-on-wide{% endif %}">
{% include "sections/sidebar-primary.html" %}
</div>
{# Using an ID here so that the skip-link works #}
<main id="main-content" class="bd-main">
{# Main content area #}
{% block docs_main %}
<div class="bd-content">
<div class="bd-article-container">
{# Article header #}
<div class="bd-header-article">{% include "sections/header-article.html" %}</div>
{# Article content #}
{% block docs_body %}
{# This is empty and only shows up if text has been highlighted by the URL #}
{% include "components/searchbox.html" %}
<article class="bd-article" role="main">
{% block body %}{% endblock %}
</article>
{% endblock docs_body %}
{# Article Footer #}
{% if theme_article_footer_items %}
<footer class="bd-footer-article">
{% include "sections/footer-article.html" %}
</footer>
{% endif %}
{# prev-next buttons #}
{% if theme_show_prev_next %}
<footer class="prev-next-footer">
{% include "components/prev-next.html" %}
</footer>
{% endif %}
</div>
{# Secondary sidebar #}
{% block docs_toc %}
{% if not remove_sidebar_secondary %}
<div class="bd-sidebar-secondary bd-toc">{% include "sections/sidebar-secondary.html" %}</div>
{% include "edit-this-page.html" %}
{% endif %}
{% endblock docs_toc %}
</div>
<footer class="bd-footer-content">
{% include "sections/footer-content.html" %}
</footer>
{% endblock docs_main %}
</main>
</div>
</div>
{# Scripts placed at the end of the page to cut down on time to first content #}
{%- block scripts_end %}{{ _webpack.body_post() }}{%- endblock scripts_end %}
{%- endblock content %}
{# Footer #}
{%- block footer %}
<footer class="bd-footer">
{%- include "sections/footer.html" %}
</footer>
{%- endblock footer %}
{# Silence the sidebars and relbars since we define our own #}
{% block header %}{% endblock %}
{% block relbar1 %}{% endblock %}
{% block relbar2 %}{% endblock %}
{% block sidebarsourcelink %}{% endblock %}
10 changes: 4 additions & 6 deletions docs/sphinx_setup/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os
import sys
import json
import shutil
from sphinx.util import logging
from sphinx.application import Sphinx
from json import JSONDecodeError
from sphinx.ext.autodoc import ClassDocumenter

project = 'OpenVINO™'
copyright = '2023, Intel®'
copyright = '2024, Intel®'
author = 'Intel®'

language = 'en'
Expand Down Expand Up @@ -101,7 +99,7 @@
"show_nav_level": 2,
"use_edit_page_button": True,
"github_url": "https://github.com/openvinotoolkit/openvino",
"footer_items": ["footer_info"],
# "footer_items": ["footer_info"],
"show_prev_next": False,
}

Expand All @@ -114,8 +112,9 @@
html_context = {
'current_language': 'English',
'languages': (('English', '/latest'), ('Chinese', '/cn/latest')),
'doxygen_mapping_file': r'C:\Users\bbielawx\OneDrive - Intel Corporation\Desktop\OpenVINO\build\mapping.json',
'doxygen_mapping_file': '@DOXYGEN_MAPPING_FILE@',
'doxygen_snippet_root': snippet_root,
'default_mode': 'light'
}

repositories = {
Expand Down Expand Up @@ -153,7 +152,6 @@

try:
doxygen_mapping_file = '@DOXYGEN_MAPPING_FILE@'
doxygen_mapping_file = r'C:\Users\bbielawx\OneDrive - Intel Corporation\Desktop\OpenVINO\build\mapping.json'
with open(doxygen_mapping_file, 'r', encoding='utf-8') as f:
doxygen_mapping_file = json.load(f)
except JSONDecodeError:
Expand Down
32 changes: 16 additions & 16 deletions docs/sphinx_setup/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
============================
OpenVINO 2023.2
OpenVINO 2024
============================

.. meta::
Expand All @@ -14,7 +14,7 @@ OpenVINO 2023.2
.. container::
:name: ov-homepage-banner

OpenVINO 2023.3
OpenVINO 2024.0

.. raw:: html

Expand All @@ -24,20 +24,20 @@ OpenVINO 2023.2
<ul class="splide__list">
<li class="splide__slide">An open-source toolkit for optimizing and deploying deep learning models.<br>Boost your AI deep-learning inference performance!</li>

<li class="splide__slide"Better OpenVINO integration with PyTorch!<br>Use PyTorch models directly, without converting them first.<br>
<a href="https://docs.openvino.ai/2023.3/openvino_docs_OV_Converter_UG_prepare_model_convert_model_Convert_Model_From_PyTorch.html">Learn more...</a>
<li class="splide__slide">Better OpenVINO integration with PyTorch!<br>Use PyTorch models directly, without converting them first.<br>
<a href="https://docs.openvino.ai/2024/openvino-workflow/model-preparation/convert-model-pytorch.html">Learn more...</a>
</li>
<li class="splide__slide">OpenVINO via PyTorch 2.0 torch.compile()<br>Use OpenVINO directly in PyTorch-native applications!<br>
<a href="https://docs.openvino.ai/2023.3/pytorch_2_0_torch_compile.html">Learn more...</a>
<a href="https://docs.openvino.ai/2024/openvino-workflow/torch-compile.html">Learn more...</a>
</li>
<li class="splide__slide">Do you like Generative AI? You will love how it performs with OpenVINO!<br>
<a href="https://docs.openvino.ai/2023.3/tutorials.html">Check out our new notebooks...</a>
<a href="https://docs.openvino.ai/2024/learn-openvino/interactive-tutorials-python.html">Check out our new notebooks...</a>
</ul>
</div>
</section>
</div>

.. button-ref:: get_started
.. button-ref:: get-started
:ref-type: doc
:class: ov-homepage-banner-btn
:color: primary
Expand All @@ -55,14 +55,14 @@ OpenVINO 2023.2
:class-container: ov-homepage-higlight-grid

.. grid-item-card:: Performance Benchmarks
:link: openvino_docs_performance_benchmarks
:link: about-openvino/performance-benchmarks
:link-alt: performance benchmarks
:link-type: doc

See latest benchmark numbers for OpenVINO and OpenVINO Model Server

.. grid-item-card:: Work with Multiple Model Formats
:link: openvino_docs_model_processing_introduction
:link: openvino-workflow/model-preparation
:link-alt: Supported Model Formats
:link-type: doc

Expand All @@ -76,21 +76,21 @@ OpenVINO 2023.2
Cloud-ready deployments for microservice applications

.. grid-item-card:: Optimize Models
:link: openvino_docs_model_optimization_guide
:link: openvino-workflow/model-optimization
:link-alt: model optimization
:link-type: doc

Boost performance using quantization and compression with NNCF

.. grid-item-card:: Use OpenVINO with PyTorch Apps with torch.compile()
:link: pytorch_2_0_torch_compile
:link: openvino-workflow/torch-compile
:link-alt: torch.compile
:link-type: doc

Optimize generation of the graph model with PyTorch 2.0 torch.compile() backend

.. grid-item-card:: Optimize and Deploy Generative AI
:link: gen_ai_guide
:link: learn-openvino/llm_inference_guide
:link-alt: gen ai
:link-type: doc

Expand Down Expand Up @@ -132,8 +132,8 @@ Feature Overview
:maxdepth: 2
:hidden:

GET STARTED <get_started>
LEARN OPENVINO <learn_openvino>
OPENVINO WORKFLOW <openvino_workflow>
GET STARTED <get-started>
LEARN OPENVINO <learn-openvino>
OPENVINO WORKFLOW <openvino-workflow>
DOCUMENTATION <documentation>
ABOUT OPENVINO <about_openvino>
ABOUT OPENVINO <about-openvino>

0 comments on commit ebe9c64

Please sign in to comment.