USD uses Sphinx to generate its user documentation and Doxygen for its API documentation.
Following are introductions to Sphinx, how we use it and style our documentation, and how to build it locally.
The user documentation is specified in restructured text (rst), and makes use of the following Sphinx extensions:
You will need to ensure your installation of sphinx includes these three packages for a documentation build to complete properly.
We have found the following references helpful:
- Home page for Sphinx docs
- Documentation on built-in roles in Sphinx
- Documentation on built-in roles and directives in rst
-
Use ":ref:" to link to section headers in other documents. For example, to link to the "API Schema" entry in
glossary.rst
, use::ref:`glossary:API Schema` OR :ref:`Custom Link Text <glossary:API Schema>`
For intra-page links, however, you must (and only in this case) use the "trailing underbar" syntax:
`Custom Link Text <glossary:API Schema>`_
-
Use "doc:" to link to other documents. For example, to link to the "Hello World" tutorial in
tut_helloworld.rst
, use::doc:`tut_helloworld` OR :doc:`Custom Link Text <tut_helloworld>`
-
Use the ":usdcpp:" role to link to Doxygen API docs for a specified function or class. This is a custom role created using the doxylink extension for sphinx. For example, to link to the UsdStage API docs, use:
:usdcpp:`UsdStage` OR :usdcpp:`Custom Link Text <UsdStage>`
-
Please conform the title and section headers to the following convention required by the ReadTheDocs template to work well with the navigation bar:
Use the following symbols to create headings H1 - H6:
- # with overline
- * with overline
- =
-
- ^
- "
-
The code-block directive takes a parameter to specify syntax highlighting. Commonly-used values are: python , cpp , usd , usda, none . e.g.:
.. code-block:: none
-
Formatting Quickstart
*italics*
italics**bold**
bold:bi:`bolditalics`
bolditalics:mono:`monospace`
monospace
- The
rolesAndUtils.rst
file defines a number of "roles" (e.g. like:mono:
) used in these pages for various kinds of objects, including::sdfpath:
for scene description paths, like</World/anim/chars/Bob>
:filename:
for files/assets:python:
for inline python code:cpp:
for inline C++ code that does not indicate an API method/class that can be located in the USD doxygen documentation:code:
for inline code that is ambiguous with respect to language and does not link to the USD doxygen documentation
- The
contributors.rst
file references acontributors.html
file, which is maintained by Pixar internally, and cannot receive pull requests.
build_usd.py
can be used to build the USD doxygen documentation. We may
eventually enable it to build the Sphinx documentation as well, but we currently
do not want to introduce the Sphinx (and packages) dependency. Following
are instructions for building the complete documentation manually.
If your system already has sphinx installed, you must ensure the installation
has the sphinx-rtd-theme
, sphinx_panels
, and sphinxcontrib-doxylink
extension packages installed. You can instead install sphinx locally
(instructions for linux and python3) like so:
pip3 install --user sphinx sphinx-rtd-theme sphinx_panels sphinxcontrib-doxylink
# Add to .cshrc or equivalent command in your shell's configuration file
# Make sure to run rehash or open a new shell to pick up this change.
setenv PATH $HOME/.local/bin:$PATH
# Python also needs to find your local install
setenv PYTHONPATH $HOME/.local:$PYTHONPATH
To enable links to Doxygen API documentation in the user documentation, set the following environment variables before running sphinx-build:
-
USD_DOXYGEN_TAG_FILE
This should be set to the path of the .tag file generated by the Doxygen documentation build. Sphinx will read this file to determine the HTML files containing documentation for a given class or function.
By default, the USD build installs this file to USD_INSTALL_ROOT/docs/USD.tag .
-
USD_DOXYGEN_PREFIX
This should be set to a URI for the directory containing the Doxygen HTML files. Sphinx will prepend all links to Doxygen HTML files with this prefix.
By default, the USD build installs these files to USD_INSTALL_ROOT/docs/doxy_html
For example, for a USD build installed in USD_INSTALL_ROOT that is not being served by a web-server:
setenv USD_DOXYGEN_TAG_FILE USD_INSTALL_ROOT/docs/USD.tag
setenv USD_DOXYGEN_PREFIX file://USD_INSTALL_ROOT/docs/doxy_html
If these env vars are not set, the user documentation will still build but Sphinx will issue some warnings, and links to API documentation in the user documentation will not appear.
To build the user documentation to /tmp/usddocs
, you must be in the directory
containing this README and the rst source files, and then:
sphinx-build . /tmp/usddocs
Sphinx tracks changed files, so subsequent builds will be faster than the first.