• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!--
2Copyright 2024 The Pigweed Authors
3
4Licensed under the Apache License, Version 2.0 (the "License"); you may not
5use this file except in compliance with the License. You may obtain a copy of
6the License at
7
8    https://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13License for the specific language governing permissions and limitations under
14the License.
15-->
16
17{% extends "pydata_sphinx_theme/layout.html" %}
18
19{# htmltitle controls the HTML title node. On some pages we customize
20   the title to make it more usable. #}
21{% block htmltitle %}
22  {# Override the title for some module pages. #}
23  {% if pagename.startswith('pw_') %}
24    {% set tokens = pagename.split('/') %}
25    {% set module_name = tokens[0] %}
26    {% set maybe_doc_name = tokens[1] %}
27    {% if maybe_doc_name == 'docs' %}
28      {# It's the homepage for a module. Use the normal title. #}
29      <title>{{ title|striptags|e }}{{ titlesuffix }}</title>
30    {% else %}
31      {# It's a subpage of the module's docs, e.g. the API reference.
32         Prepend the module's name so that it's easier to see what module
33         this doc is related to. E.g. before our change the default title
34         just says "API reference - Pigweed" and after our change it says
35         "pw_string: API reference - Pigweed". #}
36      <title>{{ module_name }}: {{ title|striptags|e }}{{ titlesuffix }}</title>
37    {% endif %}
38  {# It's a non-module page. Use the normal title. #}
39  {% else %}
40    <title>{{ title|striptags|e }}{{ titlesuffix }}</title>
41  {% endif %}
42{% endblock %}
43
44{% block extrahead %}
45  {{ super() }}
46  <!-- Preconnect with Google Fonts to speed up font loading. -->
47  <link rel="preconnect" href="https://fonts.googleapis.com">
48  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
49{% endblock extrahead %}
50
51{% block docs_main %}
52  {{ super() }}
53  {# The following scripts are loaded after the main content in order to
54     improve load performance. Background:
55     https://developer.chrome.com/docs/lighthouse/performance/render-blocking-resources #}
56  {% if pagename == 'search' %}
57    {# Search tools are already loaded on search page. Don't load them twice. #}
58  {% else %}
59    {# Load Sphinx's built-in search tools so that our custom inline search
60       experience (see pigweed.js) can work on all pages. #}
61    <script src="{{ pathto('_static/searchtools.js', 1) | e }}"></script>
62    <script src="{{ pathto('_static/language_data.js', 1) | e }}"></script>
63    <script src="{{ pathto('searchindex.js', 1) | e }}"></script>
64  {% endif %}
65  {# Always load pigweed.js after Sphinx's search scripts because pigweed.js
66     relies on classes and data from Sphinx's scripts. #}
67  <script src="{{ pathto('_static/js/pigweed.js', 1) | e }}"></script>
68{% endblock docs_main %}
69