Skip to content

Commit f471e44

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: dbort Differential Revision: D48374941 fbshipit-source-id: 656e1af34e11df9d138e170b23dce436f2cc5036
1 parent e05bf2a commit f471e44

40 files changed

+1012
-0
lines changed

.github/workflows/doc-build.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
repository: pytorch/executorch
23+
gpu-arch-type: cpu
24+
upload-artifact: docs
25+
26+
script: |
27+
# Set up Environment Variables
28+
export PYTHON_VERSION=3.9
29+
30+
# Set CHANNEL
31+
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
32+
export CHANNEL=test
33+
else
34+
export CHANNEL=nightly
35+
fi
36+
37+
# Create Conda Env
38+
conda create --quiet -y --prefix executorch-env python="${PYTHON_VERSION}"
39+
conda activate ./executorch-env
40+
conda install -c conda-forge flatbuffers
41+
TORCH_VERSION=2.1.0.dev20230813
42+
43+
44+
# Install PyTorch
45+
set -ex
46+
set +u
47+
pip install --force-reinstall --pre torch=="${TORCH_VERSION}" -i https://download.pytorch.org/whl/nightly/cpu # will need to be updated.
48+
49+
# Install ExecuTorch - TBA
50+
51+
# Install doc requirements:
52+
53+
cd docs
54+
pip3 install --quiet -r requirements.txt
55+
56+
# Build docset:
57+
58+
make html
59+
60+
if [[ ${{ github.event_name == 'pull_request' }} ]]; then
61+
cp -r _build/html/* "${RUNNER_DOCS_DIR}"
62+
fi
63+
64+
upload-preview:
65+
if: ${{ steps.check-artifacts.outputs.upload-docs == 1 && github.event.pull_request.number != '' }}
66+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
67+
68+
upload-gh-pages:
69+
if: ${{ (github.repository == 'pytorch/executorch') && (github.ref_name == 'main') }}
70+
permissions:
71+
contents: write
72+
runs-on: ubuntu-latest
73+
needs: build
74+
steps:
75+
- uses: actions/checkout@v3
76+
with:
77+
ref: gh-pages
78+
- uses: actions/download-artifact@v3
79+
with:
80+
name: docs
81+
- name: Upload docs
82+
run: |
83+
84+
set -x
85+
git config user.name 'pytorchbot'
86+
git config user.email '[email protected]'
87+
rm -rf main
88+
mv html main
89+
git add --all main || true
90+
git commit -m "Auto-generating sphinx docs" || true
91+
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/requirements.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sphinx==5.0.0
2+
sphinx-gallery
3+
matplotlib
4+
# PyTorch Theme
5+
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
6+
myst-parser
7+
sphinx_design

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)