From 2395da9128991fff2ce330c6ed837f23e3941b62 Mon Sep 17 00:00:00 2001 From: Tarun Karuturi <58826100+tarun292@users.noreply.github.com> Date: Fri, 3 Jan 2025 16:35:06 -0800 Subject: [PATCH] Build executorch Sphinx docs internally and link to static docs Differential Revision: D58986545 Pull Request resolved: https://github.com/pytorch/executorch/pull/7481 --- docs/TARGETS | 46 +++++++++++++++++++++++++++++++++++++++++++++ docs/source/conf.py | 8 +++++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 docs/TARGETS diff --git a/docs/TARGETS b/docs/TARGETS new file mode 100644 index 0000000000..867ed107dd --- /dev/null +++ b/docs/TARGETS @@ -0,0 +1,46 @@ +load("@fbcode_macros//build_defs:native_rules.bzl", "buck_filegroup", "buck_sh_test") +load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") + +oncall("pytorch_r2p") + +python_binary( + name = "sphinx", + main_module = "sphinx.cmd.build", + par_style = "xar", + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/devtools:lib", + "//executorch/exir/backend/test:backend_with_compiler_demo", + "//executorch/exir/backend/test:op_partitioner_demo", + "//executorch/devtools/bundled_program/serialize:lib", + "fbsource//third-party/pypi/ipykernel:ipykernel", + "fbsource//third-party/pypi/jupyter-client:jupyter-client", + "fbsource//third-party/pypi/jupytext:jupytext", + "fbsource//third-party/pypi/nbsphinx:nbsphinx", + "fbsource//third-party/pypi/pytorch-sphinx-theme:pytorch-sphinx-theme", + "fbsource//third-party/pypi/sphinx:sphinx", + "fbsource//third-party/pypi/breathe:breathe", + "fbsource//third-party/pypi/sphinx-copybutton:sphinx-copybutton", + "fbsource//third-party/pypi/sphinx-design:sphinx-design", + "fbsource//third-party/pypi/sphinx-gallery:sphinx-gallery", + "fbsource//third-party/pypi/matplotlib:matplotlib", + "fbsource//third-party/pypi/myst-parser:myst-parser", + ], +) + +buck_filegroup( + name = "source", + srcs = glob(["source/**/*"]), +) + +buck_sh_test( + name = "doctest", + args = [ + "-M", + "doctest", + "$(location :source)/source/", + "/tmp/sphinxbuild", + ], + test = ":sphinx", +) diff --git a/docs/source/conf.py b/docs/source/conf.py index 12453dbfd2..c497c4d023 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -44,6 +44,8 @@ import os import sys +FBCODE = "fbcode" in os.getcwd() + extensions = [ "breathe", "sphinx.ext.autodoc", @@ -60,9 +62,13 @@ "myst_parser", "sphinx_design", "sphinx_gallery.gen_gallery", - "executorch_custom_versions", ] +if not FBCODE: + extensions += [ + "executorch_custom_versions", + ] + this_file_dir = os.path.abspath(os.path.dirname(__file__)) doxygen_xml_dir = os.path.join( os.path.dirname(this_file_dir), # {repo_root}/docs/