You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
Pull Request resolved: #208
Add a basic README for the documentation folder that gives a basic overview of how to build locally and contribute, as well as provide tips on how to author better pages with MyST parser.
Add a custom Sphinx directive that adds a code block with a nightly PyTorch version from the nightly.txt file.
Reviewed By: mergennachin, dbort
Differential Revision: D48757229
fbshipit-source-id: 6a83d46ae65a694bcc24bced88d4a999b998a94b
to fork that library into `fbsource/third-party` so that you can import it here.
115
+
**NOTE:** Many `README.md` files are written as placeholders with limited information
116
+
provided. Some of that content you might want to keep in the repository rather
117
+
than on the website. If you still want to add it, make sure to check
118
+
the content for accuracy, structure, and overall quality.
122
119
123
-
## Generating the documentation
120
+
## Contributing
121
+
122
+
Use the [PyTorch contributing guidelines](https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md#writing-documentation)
123
+
to contribute to the documentation.
124
+
125
+
In addition to that, see [Markdown in Sphinx Tips and Tricks](https://pytorch.org/executorch/markdown-sphinx-tips-tricks.html)
126
+
for tips on how to author high-quality markdown pages with Myst Parser.
127
+
128
+
# Auto-generated API documentation
129
+
130
+
On a high level (will go into detail later), we use Sphinx to generate both
131
+
Python and C++ documentation in the form of HTML pages.
124
132
125
133
### Python APIs
126
134
@@ -132,8 +140,9 @@ The setup for Python documentation lies within `source_py/`. To set up Sphinx, a
132
140
`conf.py` configuration file is required. We can specify ways to generate
133
141
documentation here. Specifically, the most important/relevant parts are:
134
142
135
-
* Make sure to add a path to the directory above the directory you're trying to generate documentation for. For example, since we want to generate documenation for the `executorch/` directory, the `sys.path` is `.../fbsource/fbcode/`. This tells Sphinx where to find the code to generate docs for.
136
-
*`extensions` contains extension modules. For auto-generating APIs make sure to include `sphinx.ext.autodoc`.
143
+
* Make sure to add a path to the directory above the directory you're trying to generate documentation for. For example, since we want to generate documenation for the `executorch/` directory. This tells Sphinx where to find the code to generate docs for.
144
+
145
+
*`extensions` contains extension modules. For auto-generating APIs, make sure to include `sphinx.ext.autodoc`.
137
146
*`autodoc_mock_imports` is where you put imports that Sphinx is unable to access. Sphinx runs your code in order to autogenerate the docs, so for any libraries that it unable to access due to it being outside of the directory, or containing c++ bindings, we need to specify it in the `autodoc_mock_imports` list. You can see what modules Sphinx is confused by when you run into importing errors when generating docs.
138
147
139
148
Additionally, RST files are needed in order to specify the structure of the
@@ -165,11 +174,10 @@ To view your changes on the executorch website, you can follow the same steps
165
174
listed in the "General Documentation" section.
166
175
167
176
To view just the auto-generated pages:
168
-
1.`ssh -L 8000:localhost:8000 <devserver>` from your laptop to your devserver.
169
-
2.`cd fbcode/executorch/docs/`
170
-
3.`buck2 run //executorch/docs:sphinx-build -- -M html source_py sphinxbuild_py`
177
+
1.`cd executorch/docs/`
178
+
2.`sphinx-build -M html source_py sphinxbuild_py`
171
179
to build Sphinx and generate APIs any packages.
172
-
4.`python3 -m http.server 8000 --directory sphinxbuild_py/html` to view your HTML
180
+
3.`python3 -m http.server 8000 --directory sphinxbuild_py/html` to view your HTML
173
181
files at `localhost:8000`.
174
182
175
183
### C++ APIs
@@ -203,35 +211,9 @@ structure can be found in `source_cpp/`.
203
211
A diagram of how the files work together:
204
212

205
213
206
-
To view your changes on the executorch website, you can follow the same steps
207
-
listed in the "General Documentation" section.
214
+
To view the C++ API documentation locally, run:
208
215
209
-
To view just the auto-generated pages:
210
-
1.`ssh -L 8000:localhost:8000 <devserver>` from your laptop to your devserver.
211
-
2.`cd fbcode/executorch/docs/`
212
-
3.`buck2 run //executorch/docs:sphinx-build -- -M html source_cpp sphinxbuild_cpp`
213
-
to build Sphinx and generate APIs any packages.
214
-
4.`python3 -m http.server 8000 --directory sphinxbuild_cpp/html` to view your HTML
216
+
1.`cd executorch/docs/`
217
+
2.`sphinx-build -M html source_cpp sphinxbuild_cpp`
218
+
3.`python3 -m http.server 8000 --directory sphinxbuild_py/html` to view your HTML
215
219
files at `localhost:8000`.
216
-
217
-
## Integration with Static Docs
218
-
219
-
To integrate the generated files with Static Docs, we created a `gen_docs.sh`
220
-
script under `website/`. The script contains commands to generate HTML files
221
-
into the `website/static/` folder, which are linked on the navigation bar (which
222
-
is configured in `website/docusaurus.config.js`).
223
-
224
-
To have Static Docs run this script each time the website is built, we inserted
225
-
a command to run this script into `website/package.json` under `scripts/build`:
0 commit comments