xref: /aosp_15_r20/external/executorch/docs/source/_templates/layout.html (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1{% extends "!layout.html" %}
2
3{% block extrahead %}
4{% if 'getting-started-setup' in pagename%}
5<link rel="stylesheet" href="_static/css/progress-bar.css">
6<script src="_static/js/progress-bar.js" defer></script>
7{% elif 'compiler-delegate-and-partitioner' in pagename%}
8<link rel="stylesheet" href="../_static/css/progress-bar.css">
9<script src="../_static/js/progress-bar.js" defer></script>
10{% elif 'xtensa' in pagename%}
11<link rel="stylesheet" href="../_static/css/progress-bar.css">
12<script src="../_static/js/progress-bar.js" defer></script>
13{% elif 'qualcomm-ai-engine-direct-backend' in pagename%}
14<link rel="stylesheet" href="../_static/css/progress-bar.css">
15<script src="../_static/js/progress-bar.js" defer></script>
16{% elif 'coreml' in pagename%}
17<link rel="stylesheet" href="../_static/css/progress-bar.css">
18<script src="../_static/js/progress-bar.js" defer></script>
19{% elif 'mps' in pagename%}
20<link rel="stylesheet" href="../_static/css/progress-bar.css">
21<script src="../_static/js/progress-bar.js" defer></script>
22{% endif %}
23{{ super() }}
24{% endblock %}
25
26
27{% block sidebartitle %}
28    <div class="version">
29      <a href='https://pytorch.org/executorch/versions.html'>{{ version }} &#x25BC</a>
30    </div>
31    {% include "searchbox.html" %}
32{% endblock %}
33
34{%- block content %}
35{% if 'tutorials' in pagename %}
36
37<div class="pytorch-call-to-action-links">
38  <div id="tutorial-type">{{ pagename }}</div>
39
40  <div id="google-colab-link">
41    <img class="call-to-action-img" src="{{ pathto('_static/images/pytorch-colab.svg', 1) }}" />
42    <div class="call-to-action-desktop-view">Run in Google Colab</div>
43    <div class="call-to-action-mobile-view">Colab</div>
44  </div>
45  <div id="download-notebook-link">
46    <img class="call-to-action-notebook-img" src="{{ pathto('_static/images/pytorch-download.svg', 1) }}" />
47    <div class="call-to-action-desktop-view">Download Notebook</div>
48    <div class="call-to-action-mobile-view">Notebook</div>
49  </div>
50  <div id="github-view-link">
51    <img class="call-to-action-img" src="{{ pathto('_static/images/pytorch-github.svg', 1) }}" />
52    <div class="call-to-action-desktop-view">View on GitHub</div>
53    <div class="call-to-action-mobile-view">GitHub</div>
54  </div>
55</div>
56
57{% endif %}
58{{ super() }}
59
60{% endblock %}
61
62<!-- START OF LOCAL OVERRIDE -->
63<!--  This block overrides the theme to enable third level left navigation.-->
64{% block menu %}
65    {% if 'singlehtml' not in builder %}
66         {% set global_toc = toctree(collapse=theme_collapse_navigation|tobool,
67                                     includehidden=theme_includehidden|tobool,
68                                     titles_only=theme_titles_only|tobool) %}
69         {% endif %}
70         {% if global_toc %}
71              {{ global_toc }}
72         {% else %}
73              <!-- Local TOC -->
74              <div class="local-toc">{{ toc }}</div>
75         {% endif %}
76{% endblock %}
77<!-- END OF LOCAL OVERRIDE -->
78
79{% block footer %}
80{{ super() }}
81<script script type="text/javascript">
82  var collapsedSections = ['Introduction', 'Getting Started', 'Working with LLMs', 'Exporting to ExecuTorch',  'API Reference', 'IR Specification', 'Compiler Entry Points', 'Runtime', 'Quantization', 'Kernel Library', 'Native Delegates', 'Backend Delegates', 'SDK', 'Tutorials']
83</script>
84
85{{ super() }}
86<script type="text/javascript">
87// Handle the right navigation in third level pages. Without this
88// in third level, only the last item always selected. This is a hacky
89// way and we should revise it eventually.
90// #side-scroll-highlight is disabled in .css.
91// Get all menu items
92var menuItems = document.querySelectorAll('.pytorch-right-menu a.reference.internal');
93// Add a click event listener to each menu item
94for (var i = 0; i < menuItems.length; i++) {
95  menuItems[i].addEventListener('click', function(event) {
96    // Remove the 'side-scroll-highlight-local' class from all menu items
97    for (var j = 0; j < menuItems.length; j++) {
98      menuItems[j].classList.remove('side-scroll-highlight-local');
99    }
100    // Add the 'side-scroll-highlight-local' class to the clicked item
101    event.target.classList.add('side-scroll-highlight-local');
102  });
103}
104</script>
105
106{{ super() }}
107<script type="text/javascript">
108  $(document).ready(function () {
109    // Patch links on interactive tutorial pages to point
110    // to the correct ExecuTorch URLs.
111    var downloadNote = $(".sphx-glr-download-link-note.admonition.note");
112    if (downloadNote.length >= 1) {
113      var tutorialUrl = $("#tutorial-type").text().substring($("#tutorial-type").text().indexOf("tutorials/") + 9); // 9 is the length of "tutorials/"
114      var githubLink = "https://github.com/pytorch/executorch/blob/main/docs/source/tutorials_source" + tutorialUrl + ".py",
115        notebookLink = $(".reference.download")[1].href,
116        notebookDownloadPath = notebookLink.split('_downloads')[1],
117        colabLink = "https://colab.research.google.com/github/pytorch/executorch/blob/gh-pages/main/_downloads" + notebookDownloadPath;
118
119      $(".pytorch-call-to-action-links a[data-response='Run in Google Colab']").attr("href", colabLink);
120      $(".pytorch-call-to-action-links a[data-response='View on Github']").attr("href", githubLink);
121    }
122
123    // Patch the "GitHub" link at the top of the page
124    // to point to the ExecuTorch repo.
125    var overwrite = function (_) {
126      if ($(this).length > 0) {
127        $(this)[0].href = "https://github.com/pytorch/executorch"
128      }
129    }
130    // PC
131    $(".main-menu a:contains('GitHub')").each(overwrite);
132    // Overwrite link to Tutorials and Get Started top navigation. If these sections are moved
133    // this overrides need to be updated.
134    $(".main-menu a:contains('Tutorials')").attr("href", "https://pytorch.org/executorch/stable/index.html#tutorials-and-examples");
135    $(".main-menu a:contains('Get Started')").attr("href", "https://pytorch.org/executorch/stable/getting-started-setup.html");
136    // Mobile
137    $(".mobile-menu a:contains('Github')").each(overwrite);
138    // Overwrite link to Tutorials and Get Started top navigation. If these sections are moved
139    // this overrides need to be updated.
140    $(".mobile-menu a:contains('Tutorials')").attr("href", "https://pytorch.org/executorch/stable/index.html#tutorials-and-examples");
141    $(".mobile-menu a:contains('Get Started')").attr("href", "https://pytorch.org/executorch/stable/getting-started-setup.html");
142
143  });
144</script>
145{% endblock %}
146