Skip to content

Commit 16f3933

Browse files
svekarsfacebook-github-bot
authored andcommitted
Add ExecuTorch docs TOC (#75)
Summary: Pull Request resolved: #75 - Add the requirements.txt and Makefile for the docs - Enable sphinx 5.0, sphinx-gallery, myst-parser, sphinx-design - Create the initial toctree and placeholder files under source/ - Add custom directive for the customcards on the landing page - Configure conf.py to use sphinx-gallery, myst-parse, custom directives, etc. - Add custom.css for the sphinx-design cards - Add template_tutorial.py to demonstrate how to create tutorials Reviewed By: huydhn, dbort Differential Revision: D48374941 fbshipit-source-id: fb0e601b5d57cc8d0c8a134f7288bcdd8d9baf78
1 parent 5151eb6 commit 16f3933

40 files changed

+1004
-0
lines changed

.ci/docker/requirements-ci.txt

+10
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ ruamel.yaml==0.17.32
55
sympy==1.12
66
tomli==2.0.1
77
zstd==1.5.5.1
8+
9+
# Doc build requirements
10+
11+
sphinx==5.0.0
12+
sphinx-gallery
13+
matplotlib
14+
# PyTorch Theme
15+
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
16+
myst-parser
17+
sphinx_design

.github/workflows/doc-build.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build documentation
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- release/*
9+
tags:
10+
- v[0-9]+.[0-9]+.[0-9]
11+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
12+
workflow_dispatch:
13+
schedule:
14+
- cron: '0 0 * * *'
15+
16+
jobs:
17+
build:
18+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
19+
with:
20+
job-name: Build doc
21+
runner: linux.2xlarge
22+
docker-image: executorch-ubuntu-22.04-clang12
23+
fetch-depth: 0
24+
submodules: 'true'
25+
repository: pytorch/executorch
26+
upload-artifact: docs
27+
28+
script: |
29+
# Set up Environment Variables
30+
PYTHON_VERSION=3.10
31+
export PATH="/opt/conda/envs/py_${PYTHON_VERSION}/bin:${PATH}"
32+
33+
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
34+
export CHANNEL=test
35+
else
36+
export CHANNEL=nightly
37+
fi
38+
39+
set -ex
40+
set +u
41+
42+
# Build docset:
43+
cd docs
44+
make html
45+
cd ..
46+
47+
cp -rf docs/_build/html/* "${RUNNER_DOCS_DIR}"
48+
mv docs/_build/html "${RUNNER_ARTIFACT_DIR}"
49+
50+
# Enable preview later. Previews are available publicly
51+
#
52+
# upload-preview:
53+
# if: github.repository == 'pytorch/executorch' && github.event_name == 'push' &&
54+
# (github.ref_type == 'branch' && github.ref_name == 'main')
55+
# uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
56+
57+
upload-gh-pages:
58+
if: ${{ (github.repository == 'pytorch/executorch') && (github.ref_name == 'main') }}
59+
permissions:
60+
contents: write
61+
runs-on: ubuntu-latest
62+
needs: build
63+
steps:
64+
- uses: actions/checkout@v3
65+
with:
66+
ref: gh-pages
67+
- uses: actions/download-artifact@v3
68+
with:
69+
name: docs
70+
- name: Upload docs
71+
run: |
72+
73+
set -x
74+
git config user.name 'pytorchbot'
75+
git config user.email '[email protected]'
76+
rm -rf main
77+
mv html main
78+
git add --all main || true
79+
git commit -m "Auto-generating sphinx docs" || true
80+
git push -f

docs/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
/source/tutorials
2+
/_build
13
/sphinxbuild_py
24
/sphinxbuild_cpp

docs/Makefile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS = -WT --keep-going
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = ExecuTorch
8+
SOURCEDIR = source
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
13+
help:
14+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15+
16+
.PHONY: help Makefile
17+
18+
%: Makefile
19+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
21+
#html:
22+
# $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html

docs/source/_static/css/custom.css

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/* sphinx-design styles for cards/tabs
10+
*/
11+
:root {
12+
--sd-color-info: #ee4c2c;
13+
--sd-color-primary: #6c6c6d;
14+
--sd-color-primary-highlight: #f3f4f7;
15+
--sd-color-card-border-hover: #ee4c2c;
16+
--sd-color-card-border: #f3f4f7;
17+
--sd-color-card-background: #fff;
18+
--sd-color-card-text: inherit;
19+
--sd-color-card-header: transparent;
20+
--sd-color-card-footer: transparent;
21+
--sd-color-tabs-label-active: #ee4c2c;
22+
--sd-color-tabs-label-hover: #ee4c2c;
23+
--sd-color-tabs-label-inactive: #6c6c6d;
24+
--sd-color-tabs-underline-active: #ee4c2c;
25+
--sd-color-tabs-underline-hover: #fabdbd;
26+
--sd-color-tabs-underline-inactive: transparent;
27+
--sd-color-tabs-overline: rgb(222, 222, 222);
28+
--sd-color-tabs-underline: rgb(222, 222, 222);
29+
}
30+
31+
.sd-text-info {
32+
color: #ee4c2c;
33+
}
34+
35+
.sd-card-img-top {
36+
background: #ee4c2c;
37+
height: 5px !important;
38+
}
39+
40+
.sd-card {
41+
position: relative;
42+
background-color: #fff;
43+
opacity: 1.0;
44+
border-radius: 0px;
45+
width: 30%;
46+
border: none;
47+
padding-bottom: 0px;
48+
}
49+
50+
51+
.sd-card-img:hover {
52+
opacity: 1.0;
53+
background-color: #f3f4f7;
54+
}
55+
56+
57+
.sd-card:after {
58+
display: block;
59+
opacity: 1;
60+
content: '';
61+
border-bottom: solid 1px #ee4c2c;
62+
background-color: #fff;
63+
transform: scaleX(0);
64+
transition: transform .250s ease-in-out;
65+
transform-origin: 0% 50%;
66+
}
67+
68+
.sd-card:hover {
69+
background-color: #fff;
70+
opacity: 1;
71+
border-top: 1px solid #f3f4f7;
72+
border-left: 1px solid #f3f4f7;
73+
border-right: 1px solid #f3f4f7;
74+
}
75+
76+
.sd-card:hover:after {
77+
transform: scaleX(1);
78+
}
Loading
34.9 KB
Loading

docs/source/_templates/layout.html

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% extends "!layout.html" %}
2+
3+
{% block sidebartitle %}
4+
{% include "searchbox.html" %}
5+
{% endblock %}
6+
7+
{%- block content %}
8+
{% if 'tutorials' in pagename %}
9+
10+
<div class="pytorch-call-to-action-links">
11+
<div id="tutorial-type">{{ pagename }}</div>
12+
13+
<div id="google-colab-link">
14+
<img class="call-to-action-img" src="{{ pathto('_static/images/pytorch-colab.svg', 1) }}"/>
15+
<div class="call-to-action-desktop-view">Run in Google Colab</div>
16+
<div class="call-to-action-mobile-view">Colab</div>
17+
</div>
18+
<div id="download-notebook-link">
19+
<img class="call-to-action-notebook-img" src="{{ pathto('_static/images/pytorch-download.svg', 1) }}"/>
20+
<div class="call-to-action-desktop-view">Download Notebook</div>
21+
<div class="call-to-action-mobile-view">Notebook</div>
22+
</div>
23+
<div id="github-view-link">
24+
<img class="call-to-action-img" src="{{ pathto('_static/images/pytorch-github.svg', 1) }}"/>
25+
<div class="call-to-action-desktop-view">View on GitHub</div>
26+
<div class="call-to-action-mobile-view">GitHub</div>
27+
</div>
28+
</div>
29+
30+
{% endif %}
31+
{{ super() }}
32+
33+
{% endblock %}
34+
35+
{% block footer %}
36+
{{ super() }}
37+
<script script type="text/javascript">
38+
var collapsedSections = ['Introduction', 'Getting Started', 'Exporting to ExecuTorch', 'Intermediate Representation (IR) Specification','Compiler Entry Points', 'Runtime', 'Quantization', 'Kernel Library', 'SDK', 'Tutorials']
39+
</script>
40+
{% endblock %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Custom Compiler Passeis
2+
3+
TBA
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Delegate and Partitioner
2+
3+
TBA
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Kernel Fusion Pass
2+
3+
TBA
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Memory Planning
2+
3+
TBA

0 commit comments

Comments
 (0)