From f3d16ec76fa8c2556e5cd20a5d41044e900bf12c Mon Sep 17 00:00:00 2001 From: Mark Saroufim Date: Tue, 26 Nov 2024 21:56:52 +0000 Subject: [PATCH] Add doc preview command (#141590) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convenience, when we build pytorch docs 1. Docs for build weren't clear that `make html` is the main command intended to be ran 2. Once you run `make html` you need to visualize the work, opening up a simple http server seems like the simplest solution so adding a `make serve command` Usage ```shell numpy ❯ make serve PORT=8080 # Add port optionally Serving HTTP on :: port 8080 (http://[::]:8080/) ... ::1 - - [26/Nov/2024 10:05:41] "GET / HTTP/1.1" 200 - ::1 - - [26/Nov/2024 10:05:41] "GET /_static/copybutton.css HTTP/1.1" 200 - ::1 - - [26/Nov/2024 10:05:41] "GET /_static/katex-math.css HTTP/1.1" 200 - ``` ![Screenshot 2024-11-26 at 10 05 46 AM](https://github.com/user-attachments/assets/3b275c33-1515-4e21-b540-f5a68c8a8e55) Pull Request resolved: https://github.com/pytorch/pytorch/pull/141590 Approved by: https://github.com/svekars, https://github.com/malfet --- README.md | 6 ++++-- docs/Makefile | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 314bc007f37..c62b07ebd6c 100644 --- a/README.md +++ b/README.md @@ -417,9 +417,11 @@ readthedocs theme. ```bash cd docs/ pip install -r requirements.txt +make html +make serve ``` -You can then build the documentation by running `make ` from the -`docs/` folder. Run `make` to get a list of all available output formats. + +Run `make` to get a list of all available output formats. If you get a katex error run `npm install katex`. If it persists, try `npm install -g katex` diff --git a/docs/Makefile b/docs/Makefile index c6df057d8a6..36e428cf4de 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -41,7 +41,10 @@ html-stable: # See conf.py for more details. RELEASE=1 make html -.PHONY: help Makefile docset onnx exportdb +.PHONY: help Makefile docset onnx exportdb serve + +serve: + @cd $(BUILDDIR)/html && $(PYCMD) -m http.server $(PORT) # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).