MaterialX
MaterialX copied to clipboard
Sphinx Python Documentation
Add support for the generation of Sphinx documentation for MaterialX Python, using the approach described here:
https://pybind11.readthedocs.io/en/stable/advanced/misc.html#generating-documentation-using-sphinx
I'd like to take a stab at this for the ASWF Dev Days 2023.
If I’m understanding this right, the work here roughly consists of two parts:
- Integrating a Sphinx build of the MaterialX Python API documentation into the MaterialX CMake build
- Adding/extending docstrings for MaterialX Python bindings using pybind11
While it may not be possible/feasible to add/curate docstrings for all MaterialX Python bindings during Dev Days, it should be possible to lay the foundation for building API documentation using Sphinx on the day.
Proposed approach/outcome:
- An optional extra build target similar to the existing
cmake --build . --target MaterialXDocs
(which usesdoxygen
to generate C++ API documentation), possibly namedMaterialXDocsPython
. - Documentation in HTML format that is generated in a sibling folder next to the existing C++ API documentation (as opposed to living in the same
html
folder).
Proposed artifacts:
- A new CMake module at
cmake/modules/FindSphinx.cmake
to be able to find thesphinx-build
executable (Windows:sphinx-build.exe
) fromdocuments/CMakeLists.txt
usingfind_package(Sphinx)
.- cf. https://eb2.co/blog/2012/03/sphinx-and-cmake-beautiful-documentation-for-c-projects/
- cf. https://www.vortech.nl/en/integrating-sphinx-in-cmake/
- Modifications to
documents/CMakeLists.txt
to create a new build target namedMaterialXDocsPython
, which would runsphinx-build
to generate Python API developer documentation, in a directory that is separate to the existingdoxygen
-generatedhtml
documentation, e.g. namedhtml-sphinx
.- https://www.sphinx-doc.org/en/master/tutorial/getting-started.html
- A Sphinx configuration template file (e.g.
documents/sphinx-conf.py.in
) that would be filled with values of configuration variables likeMATERIALX_LIBRARY_VERSION
as part of the build, in order to generate theconf.py
file thatsphinx-build
uses.- This would be similar to the existing
developer/Doxyfile.in
from whichdocuments/CMakeLists.txt
generatesDoxyfile
for configuring thedoxygen
run. - https://www.sphinx-doc.org/en/master/usage/configuration.html
- This would be similar to the existing
- Integration of existing developer guide contents in Markdown format from
documents/DeveloperGuide/
into the Sphinx-generated Python API documentation, e.g. using themyst_parser
extension:- https://www.sphinx-doc.org/en/master/usage/markdown.html
-
GraphEditor.md
-
MainPage.md
-
ShaderGeneration.md
-
Viewer.md
- A new paragraph in the Building API Documentation section in
documents/DeveloperGuide/MainPage.md
to describe how to build the Python API documentation using Sphinx. - Integration of docstrings from MaterialX Python bindings that are defined in
source/PyMaterialX/
from compiled Python C extensions, e.g. fromlib/PyMaterialXCore.cpython-312-darwin.so
etc.