|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
import sys |
|
|
|
import unittest.mock as mock |
|
|
|
from recommonmark.parser import CommonMarkParser |
|
from recommonmark.states import DummyStateMachine |
|
from sphinx.builders.html import StandaloneHTMLBuilder |
|
from sphinx.ext.autodoc import between |
|
|
|
|
|
|
|
orig_run_role = DummyStateMachine.run_role |
|
|
|
|
|
def run_role(self, name, options=None, content=None): |
|
if name == "doc": |
|
name = "any" |
|
return orig_run_role(self, name, options, content) |
|
|
|
|
|
DummyStateMachine.run_role = run_role |
|
|
|
|
|
StandaloneHTMLBuilder.supported_image_types = [ |
|
"image/svg+xml", |
|
"image/gif", |
|
"image/png", |
|
"image/jpeg", |
|
] |
|
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.abspath("../")) |
|
sys.path.insert(0, os.path.abspath("../pytorch3d")) |
|
sys.path.insert(0, os.path.abspath("../../")) |
|
|
|
DEPLOY = os.environ.get("READTHEDOCS") == "True" |
|
needs_sphinx = "1.7" |
|
|
|
|
|
try: |
|
import torch |
|
except ImportError: |
|
for m in [ |
|
"torch", |
|
"torchvision", |
|
"torch.nn", |
|
"torch.autograd", |
|
"torch.autograd.function", |
|
"torch.nn.modules", |
|
"torch.nn.modules.utils", |
|
"torch.utils", |
|
"torch.utils.data", |
|
"torchvision", |
|
"torchvision.ops", |
|
]: |
|
sys.modules[m] = mock.Mock(name=m) |
|
|
|
for m in ["cv2", "scipy", "numpy", "pytorch3d._C", "np.eye", "np.zeros"]: |
|
sys.modules[m] = mock.Mock(name=m) |
|
|
|
|
|
|
|
project = "PyTorch3D" |
|
copyright = "Meta Platforms, Inc" |
|
author = "facebookresearch" |
|
|
|
|
|
version = "" |
|
|
|
|
|
release = version |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extensions = [ |
|
"sphinx_markdown_tables", |
|
"sphinx.ext.autodoc", |
|
"sphinx.ext.mathjax", |
|
"sphinx.ext.napoleon", |
|
"sphinx.ext.intersphinx", |
|
"sphinx.ext.todo", |
|
"sphinx.ext.coverage", |
|
"sphinx.ext.viewcode", |
|
"sphinx.ext.githubpages", |
|
] |
|
|
|
|
|
napoleon_google_docstring = True |
|
napoleon_include_init_with_doc = True |
|
napoleon_include_special_with_doc = True |
|
napoleon_numpy_docstring = False |
|
|
|
napoleon_use_rtype = False |
|
autodoc_inherit_docstrings = False |
|
autodoc_member_order = "bysource" |
|
|
|
source_parsers = {".md": CommonMarkParser} |
|
|
|
|
|
|
|
|
|
|
|
source_suffix = [".rst", ".md"] |
|
|
|
|
|
master_doc = "index" |
|
|
|
|
|
templates_path = ["_templates"] |
|
|
|
|
|
|
|
|
|
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "build", "README.md"] |
|
|
|
|
|
pygments_style = "sphinx" |
|
|
|
|
|
|
|
|
|
|
|
|
|
html_theme = "sphinx_rtd_theme" |
|
|
|
|
|
|
|
|
|
html_static_path = ["_static"] |
|
|
|
html_theme_options = {"collapse_navigation": True} |
|
|
|
|
|
def url_resolver(url): |
|
if ".html" not in url: |
|
url = url.replace("../", "") |
|
return "https://github.com/facebookresearch/pytorch3d/blob/main/" + url |
|
else: |
|
if DEPLOY: |
|
return "http://pytorch3d.readthedocs.io/" + url |
|
else: |
|
return "/" + url |
|
|
|
|
|
def setup(app): |
|
|
|
if DEPLOY: |
|
import subprocess |
|
|
|
subprocess.call(["ln", "-s", "../README.md", "overview.md"]) |
|
|
|
from recommonmark.transform import AutoStructify |
|
|
|
app.add_config_value( |
|
"recommonmark_config", |
|
{ |
|
"url_resolver": url_resolver, |
|
"auto_toc_tree_section": "Contents", |
|
"enable_math": True, |
|
"enable_inline_math": True, |
|
"enable_eval_rst": True, |
|
"enable_auto_toc_tree": True, |
|
}, |
|
True, |
|
) |
|
|
|
|
|
|
|
app.connect("autodoc-process-docstring", between("^.*IGNORE.*$", exclude=True)) |
|
app.add_transform(AutoStructify) |
|
|
|
return app |
|
|