Skip to content

Commit 5c7c9cc

Browse files
Svetlana Karslioglufacebook-github-bot
authored andcommitted
Fix formatting and cleanup (#593)
Summary: - Added a check to the custom role to ensure sphx-gallery outputs are not affected. - Removed template tutorial custom card from index.rst - Don't generate tutorials/index.html - because sphinx autogenerates a page with all tutorials that is hard to format. - Added sys.path so we can use autodoc in .md files. Reviewed By: mergennachin Differential Revision: D49878715
1 parent 141fcf6 commit 5c7c9cc

File tree

4 files changed

+39
-14
lines changed

4 files changed

+39
-14
lines changed

docs/README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Welcome to the ExecuTorch documentation! This README.md will provide an
44
overview of the ExecuTorch docs and its features, as well as instructions on
55
how to contribute and build locally.
66

7+
All current documentation is located in the `docs/source` directory.
8+
79
<!-- toc -->
810

911
- [Toolchain Overview](#toolchain-overview)
@@ -31,7 +33,7 @@ We support both `.rst` and `.md` files but prefer the content to be authored in
3133

3234
## Building Locally
3335

34-
Documentation dependancies are stored in
36+
Documentation dependencies are stored in
3537
[.ci/docker/requirements-ci.txt](https://github.com/pytorch/executorch/blob/main/.ci/docker/requirements-ci.txt).
3638

3739
To build the documentation locally:
@@ -40,19 +42,33 @@ To build the documentation locally:
4042

4143
1. Switch to the `docs/` directory.
4244

43-
1. Start a virtual environment:
45+
1. If you don't have it already, start a conda environment:
46+
47+
```{note}
48+
The below command generates a completely new environment and resets
49+
any existing dependencies. If you have an environment already, skip
50+
this step.
51+
```
52+
53+
```bash
54+
conda create -yn executorch python=3.10.0
55+
conda activate executorch
56+
```
57+
58+
1. Install dependencies:
4459

4560
```bash
46-
virtualenv venv
47-
source venv/bin/activate
61+
pip3 install -r ./.ci/docker/requirements-ci.txt
4862
```
4963

50-
1. Install dependancies:
64+
1. Run:
5165

5266
```bash
53-
pip3 install -r ../.ci/docker/requirements-ci.txt
67+
bash install_requirements.sh
5468
```
5569

70+
1. Go to the `docs/` directory.
71+
5672
1. Build the documentation set:
5773

5874
```

docs/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272

7373
sphinx_gallery_conf = {
7474
"examples_dirs": ["tutorials_source"],
75+
"ignore_pattern": "template_tutorial.py",
7576
"gallery_dirs": ["tutorials"],
7677
"filename_pattern": "/tutorials_source/",
7778
"promote_jupyter_magic": True,
@@ -91,6 +92,8 @@
9192
# directories to ignore when looking for source files.
9293
# This pattern also affects html_static_path and html_extra_path.
9394
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
95+
exclude_patterns += sphinx_gallery_conf["examples_dirs"]
96+
exclude_patterns += ["*/index.rst"]
9497

9598
# autosectionlabel throws warnings if section names are duplicated.
9699
# The following tells autosectionlabel to not throw a warning for

docs/source/executorch_custom_versions.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,20 @@ def replace_variables(app, doctree, docname):
5656
new_text = node.astext()
5757
for var, value in variables.items():
5858
new_text = new_text.replace(var, value)
59-
node.parent.replace(node, nodes.literal_block(new_text, new_text))
59+
60+
classes = node.get("classes", [])
61+
# check if the output is generated by sphinx-gallery and if yes, keep the original
62+
# CSS classes. Otherwise, the sphinx-gallery generated outputs are
63+
# formatted as regular code blocks with gray background instead of pink.
64+
is_sphinx_gallery = any("sphx-glr" in class_ for class_ in classes)
65+
if is_sphinx_gallery:
66+
new_literal_block = nodes.literal_block(new_text, new_text, classes=classes)
67+
else:
68+
new_literal_block = nodes.literal_block(
69+
new_text, new_text, classes=["highlight-none", "notranslate"]
70+
)
71+
72+
node.parent.replace(node, new_literal_block)
6073

6174

6275
def setup(app):

docs/source/index.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,6 @@ ExecuTorch tutorials.
173173

174174
.. customcardstart::
175175

176-
.. customcarditem::
177-
:header: Template Tutorial
178-
:card_description: A template tutorial. To be deleted.
179-
:image: _static/img/generic-pytorch-logo.png
180-
:link: tutorials/template_tutorial.html
181-
:tags: Template
182-
183176
.. customcarditem::
184177
:header: Exporting to ExecuTorch Tutorial
185178
:card_description: A tutorial for exporting a model and lowering a it to be runnable on the ExecuTorch runtime.

0 commit comments

Comments
 (0)