Skip to content

Commit

Permalink
Sphinx docs
Browse files Browse the repository at this point in the history
Summary: Added sphinx docs and github workflow to build gh-pages

Reviewed By: HapeMask

Differential Revision: D63498319

fbshipit-source-id: 401aabb6dc1624a26c2c9231ab2a1e6b98458190
  • Loading branch information
podgorskiy authored and facebook-github-bot committed Oct 1, 2024
1 parent 6ee7229 commit b6e471d
Show file tree
Hide file tree
Showing 28 changed files with 882 additions and 14 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/doc-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Doc Build

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build_docs_job:
runs-on: ubuntu-latest
# Grant write permission here so that the doc can be pushed to gh-pages branch
permissions:
contents: write
strategy:
matrix:
python-version: [3.10]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Dependencies
run: |
echo `python3 --version`
sudo apt-get install -y python-setuptools
sudo apt-get install -y python3-sphinx
sudo apt-get install -y pandoc
python3 -m pip install --upgrade pip
python3 -m pip install setuptools
python3 -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
id: build
- name: Build the docset
run: |
cd docs
pip install -r requirements.txt
make html
- name: Get output time
run: echo "The time was ${{ steps.build.outputs.time }}"
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: ./docs/build/html # The folder the action should deploy.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include src/ *.h *.cpp *.cu *.cuh
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,16 @@ img = bary * (index_img != -1)
save_image(img, "render.png")
```

![hello triangle](doc/hellow_triangle.png)
![hello triangle](docs/source/_static/hellow_triangle.png)

## Dependencies
* PyTorch >= 2.1.0

## Building
## Installing

To build a wheel and install it:
```
pip install wheel
python setup.py bdist_wheel
pip install dist/drtk-<wheel_name>.whl
pip install git+https://github.com/facebookresearch/DRTK.git
```

To build inplace, which is useful for package development:
Expand Down
16 changes: 16 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SPHINXOPTS ?=
SPHINXAPIDOC ?= sphinx-apidoc
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

autodoc:
@$(SPHINXAPIDOC) -o "$(SOURCEDIR)" "../drtk" $(SPHINXOPTS) $(O)

%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
10 changes: 10 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sphinx
sphinx_markdown_builder
sphinx-panels
sphinxcontrib-katex
pydata_sphinx_theme
accessible-pygments
myst_parser
sphinx_design
nbsphinx
ipython
71 changes: 71 additions & 0 deletions docs/source/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#rtd-footer-container {
margin-top: 0px !important;
margin-bottom: 0px !important;
}

.sig-name {
font-size: 1.0em;
color: var(--pst-color-inline-code);
}

article.bd-article .function dt.sig {
position: relative;
background: var(--sig_nkg);
padding: 0.8rem;
border-left: 3px solid #ee4c2c;
word-wrap: break-word;
padding-right: 100px;
font-weight: 400;
font-size: 0.9em;
font-family: IBMPlexMono,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New", monospace, var(--pst-font-family-monospace-system);
}

html[data-theme="dark"] {
--sig_nkg: #2b2b2b;
--pst-color-inline-code: #e16969;
--pst-color-surface: #2b2b2b;
}

html[data-theme="light"] {
--sig_nkg: #f2f2f2;
--pst-color-inline-code: #912525;
--pst-color-surface: #f2f2f2;
}

html {
--pst-color-inline-code: #912525;
--pst-font-size-icon: 2.0rem;
--bs-nav-link-font-size: 1.5rem;
--pst-color-surface: #f2f2f2;
}

a.headerlink {
font-size: 1.0em;
}

ul.bd-breadcrumbs {
font-size: 1.5rem;
li.breadcrumb-item {
&:not(.breadcrumb-home)::before {
font-size: 1.5rem;
}
}
}

.navbar-brand {
font-size: 2.5em;
}
.bd-main .bd-content .bd-article-container {
max-width: 80em;
}
.bd-page-width {
max-width: 96rem;
}

.bd-sidebar-primary {
width: 16rem;
}

p.bd-links__title {
visibility: collapse;
}
File renamed without changes
Binary file added docs/source/_static/tutorial_1_hello_triangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/tutorial_2_animation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions docs/source/api_reference/edge_grad_estimator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drtk.edge_grad_estimator
========================

.. automodule:: drtk.edge_grad_estimator
:no-index:

.. currentmodule:: drtk

.. autosummary::
:nosignatures:

edge_grad_estimator
edge_grad_estimator_ref

.. autofunction:: edge_grad_estimator

.. autofunction:: edge_grad_estimator_ref
16 changes: 16 additions & 0 deletions docs/source/api_reference/geometry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. currentmodule:: drtk.utils

Geometry utils
==============
.. automodule:: drtk.utils.geometry

.. autosummary::
:nosignatures:

face_info
vert_binormals
vert_normals

.. autofunction:: face_info
.. autofunction:: vert_binormals
.. autofunction:: vert_normals
17 changes: 17 additions & 0 deletions docs/source/api_reference/grid_scatter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drtk.grid_scatter
=================

.. automodule:: drtk.grid_scatter
:no-index:

.. currentmodule:: drtk

.. autosummary::
:nosignatures:

grid_scatter
grid_scatter_ref

.. autofunction:: grid_scatter

.. autofunction:: grid_scatter_ref
40 changes: 40 additions & 0 deletions docs/source/api_reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

:github_url: https://github.com/facebookresearch/DRTK

DRTK API
===================================

DRTK is a PyTorch library that provides functionality for differentiable rasterization.

The package consists of five main modules:

* :doc:`transform`
* :doc:`rasterize`
* :doc:`render`
* :doc:`interpolate`
* :doc:`edge_grad_estimator`


.. toctree::
:glob:
:maxdepth: 3
:caption: Main API

transform
rasterize
render
interpolate
edge_grad_estimator
mipmap_grid_sample
grid_scatter
msi


.. toctree::
:glob:
:maxdepth: 3
:caption: Utils

projection
geometry
indexing
12 changes: 12 additions & 0 deletions docs/source/api_reference/indexing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. currentmodule:: drtk.utils

Indexing utils
==============
.. automodule:: drtk.utils.indexing

.. autosummary::
:nosignatures:

index

.. autofunction:: index
17 changes: 17 additions & 0 deletions docs/source/api_reference/interpolate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drtk.interpolate
================

.. automodule:: drtk.interpolate
:no-index:

.. currentmodule:: drtk

.. autosummary::
:nosignatures:

interpolate
interpolate_ref

.. autofunction:: interpolate

.. autofunction:: interpolate_ref
17 changes: 17 additions & 0 deletions docs/source/api_reference/mipmap_grid_sample.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drtk.mipmap_grid_sample
=======================

.. automodule:: drtk.mipmap_grid_sample
:no-index:

.. currentmodule:: drtk

.. autosummary::
:nosignatures:

mipmap_grid_sample
mipmap_grid_sample_ref

.. autofunction:: mipmap_grid_sample

.. autofunction:: mipmap_grid_sample_ref
14 changes: 14 additions & 0 deletions docs/source/api_reference/msi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
drtk.msi
========

.. automodule:: drtk.msi
:no-index:

.. currentmodule:: drtk

.. .. autosummary::
.. :nosignatures:
..
.. msi
.. autofunction:: msi
14 changes: 14 additions & 0 deletions docs/source/api_reference/projection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. currentmodule:: drtk.utils

Projection functions
====================
.. automodule:: drtk.utils.projection

.. autosummary::
:nosignatures:

project_points
project_points_grad

.. autofunction:: project_points
.. autofunction:: project_points_grad
17 changes: 17 additions & 0 deletions docs/source/api_reference/rasterize.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drtk.rasterize
==============

.. automodule:: drtk.rasterize
:no-index:

.. currentmodule:: drtk

.. autosummary::
:nosignatures:

rasterize
rasterize_with_depth

.. autofunction:: rasterize

.. autofunction:: rasterize_with_depth
17 changes: 17 additions & 0 deletions docs/source/api_reference/render.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drtk.render
============

.. automodule:: drtk.render
:no-index:

.. currentmodule:: drtk

.. autosummary::
:nosignatures:

render
render_ref

.. autofunction:: render

.. autofunction:: render_ref
17 changes: 17 additions & 0 deletions docs/source/api_reference/transform.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
drtk.transform
==============

.. automodule:: drtk.transform
:no-index:

.. currentmodule:: drtk

.. autosummary::
:nosignatures:

transform
transform_with_v_cam

.. autofunction:: transform

.. autofunction:: transform_with_v_cam
Loading

0 comments on commit b6e471d

Please sign in to comment.