| <!-- |
| Copyright 2024 The Pigweed Authors |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License. You may obtain a copy of |
| the License at |
| |
| https://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| License for the specific language governing permissions and limitations under |
| the License. |
| --> |
| |
| {% extends "pydata_sphinx_theme/layout.html" %} |
| |
| {# htmltitle controls the HTML title node. On some pages we customize |
| the title to make it more usable. #} |
| {% block htmltitle %} |
| {# Override the title for some module pages. #} |
| {% if pagename.startswith('pw_') %} |
| {% set tokens = pagename.split('/') %} |
| {% set module_name = tokens[0] %} |
| {% set maybe_doc_name = tokens[1] %} |
| {% if maybe_doc_name == 'docs' %} |
| {# It's the homepage for a module. Use the normal title. #} |
| <title>{{ title|striptags|e }}{{ titlesuffix }}</title> |
| {% else %} |
| {# It's a subpage of the module's docs, e.g. the API reference. |
| Prepend the module's name so that it's easier to see what module |
| this doc is related to. E.g. before our change the default title |
| just says "API reference - Pigweed" and after our change it says |
| "pw_string: API reference - Pigweed". #} |
| <title>{{ module_name }}: {{ title|striptags|e }}{{ titlesuffix }}</title> |
| {% endif %} |
| {# It's a non-module page. Use the normal title. #} |
| {% else %} |
| <title>{{ title|striptags|e }}{{ titlesuffix }}</title> |
| {% endif %} |
| {% endblock %} |
| |
| {% block extrahead %} |
| {{ super() }} |
| <!-- Preconnect with Google Fonts to speed up font loading. --> |
| <link rel="preconnect" href="https://fonts.googleapis.com"> |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| {% endblock extrahead %} |
| |
| {% block docs_main %} |
| {{ super() }} |
| {# The following scripts are loaded after the main content in order to |
| improve load performance. Background: |
| https://developer.chrome.com/docs/lighthouse/performance/render-blocking-resources #} |
| {% if pagename == 'search' %} |
| {# Search tools are already loaded on search page. Don't load them twice. #} |
| {% else %} |
| {# Load Sphinx's built-in search tools so that our custom inline search |
| experience (see pigweed.js) can work on all pages. #} |
| <script src="{{ pathto('_static/searchtools.js', 1) | e }}"></script> |
| <script src="{{ pathto('_static/language_data.js', 1) | e }}"></script> |
| <script src="{{ pathto('searchindex.js', 1) | e }}"></script> |
| {% endif %} |
| {# Always load pigweed.js after Sphinx's search scripts because pigweed.js |
| relies on classes and data from Sphinx's scripts. #} |
| <script src="{{ pathto('_static/js/pigweed.js', 1) | e }}"></script> |
| {% endblock docs_main %} |