Skip to content

Commit fee20a0

Browse files
authored
Add pybind11 docs (#2657)
## Purpose - Add in Python docs into the MaterialX package for all modules - This allows for standard Python help and the ability to integrate this with things like type stubs (pyi) An example of this integrated into VSCode and PyCharm is shown - Tooling used to create html docs via tools like Sphinx but does not add any reliance on such tools. ## Changes - The existing build flag `MATERIALX_BUILD_DOCS` is used to: - Build docs with XML `Doxygen` output as extracted from C++ code. - Run a utility script to parse the XML to insert into PyMaterialX module files. - The flag is enabled when building Python wheels.
1 parent 9aacd43 commit fee20a0

File tree

6 files changed

+564
-6
lines changed

6 files changed

+564
-6
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ jobs:
476476
CIBW_SKIP: '*musllinux*'
477477
CIBW_ARCHS: 'auto64'
478478
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
479-
CIBW_BEFORE_ALL_LINUX: yum install -y libXt-devel
479+
CIBW_BEFORE_ALL_LINUX: yum install -y libXt-devel doxygen
480+
CIBW_BEFORE_ALL_MACOS: brew install doxygen
481+
CIBW_BEFORE_ALL_WINDOWS: choco install doxygen.install -y
480482
CIBW_BUILD_VERBOSITY: 1
481483
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
482484
MACOSX_DEPLOYMENT_TARGET: '11.0'

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ set(MATERIALX_PYTHON_EXECUTABLE "" CACHE FILEPATH
135135
"Python executable to be used in building the MaterialX Python package (e.g. 'C:/Python39/python.exe').")
136136
set(MATERIALX_PYTHON_PYBIND11_DIR "" CACHE PATH
137137
"Path to a folder containing the PyBind11 source to be used in building MaterialX Python.")
138+
option(MATERIALX_PYTHON_FORCE_REPLACE_DOCS "Force replace existing docstrings when generating Python binding documentation from Doxygen." OFF)
138139

139140
# Settings to define installation layout
140141
set(MATERIALX_INSTALL_INCLUDE_PATH "include" CACHE STRING "Install header include path (e.g. 'inc', 'include').")
@@ -210,6 +211,7 @@ mark_as_advanced(MATERIALX_DYNAMIC_ANALYSIS)
210211
mark_as_advanced(MATERIALX_PYTHON_VERSION)
211212
mark_as_advanced(MATERIALX_PYTHON_EXECUTABLE)
212213
mark_as_advanced(MATERIALX_PYTHON_PYBIND11_DIR)
214+
mark_as_advanced(MATERIALX_PYTHON_FORCE_REPLACE_DOCS)
213215
mark_as_advanced(MATERIALX_OSL_BINARY_OSLC)
214216
mark_as_advanced(MATERIALX_OSL_BINARY_TESTRENDER)
215217
mark_as_advanced(MATERIALX_OSL_INCLUDE_PATH)
@@ -548,16 +550,16 @@ if(MATERIALX_BUILD_TESTS)
548550
add_subdirectory(source/MaterialXTest)
549551
endif()
550552

553+
if (MATERIALX_BUILD_DOCS)
554+
add_subdirectory(documents)
555+
endif()
556+
551557
# Add Python subdirectories
552558
if(MATERIALX_BUILD_PYTHON)
553559
add_subdirectory(source/PyMaterialX)
554560
add_subdirectory(python)
555561
endif()
556562

557-
if(MATERIALX_BUILD_DOCS)
558-
add_subdirectory(documents)
559-
endif()
560-
561563
if(MATERIALX_BUILD_JS)
562564
add_subdirectory(source/JsMaterialX)
563565
endif()

documents/Doxyfile.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ FULL_SIDEBAR = NO
2323

2424
QUIET = YES
2525
WARN_IF_UNDOCUMENTED = NO
26+
27+
GENERATE_XML = YES
28+
XML_OUTPUT = doxygen_xml

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,25 @@ logging.level = "DEBUG"
5656
# where the package is.
5757
wheel.packages = ["python/MaterialX"]
5858

59+
sdist.include = [
60+
"/documents",
61+
]
62+
5963
sdist.exclude = [
6064
"/build",
6165
"/dist",
6266
"/resources",
6367
"/javascript",
64-
"/documents",
6568
"/.github",
6669
"MANIFEST.in",
6770
"/source/JsMaterialX",
6871
]
6972

73+
wheel.exclude = [
74+
"/documents",
75+
"documents/",
76+
]
77+
7078
[tool.scikit-build.metadata.version]
7179
# https://scikit-build-core.readthedocs.io/en/latest/configuration.html#dynamic-metadata
7280
provider = "scikit_build_core.metadata.regex"
@@ -81,6 +89,8 @@ result = "{major}.{minor}.{build}"
8189
[tool.scikit-build.cmake.define]
8290
MATERIALX_BUILD_SHARED_LIBS = 'OFF' # Be explicit
8391
MATERIALX_BUILD_PYTHON = 'ON'
92+
MATERIALX_BUILD_DOCS = 'ON'
93+
MATERIALX_PYTHON_FORCE_REPLACE_DOCS = 'ON'
8494
MATERIALX_TEST_RENDER = 'OFF'
8595
MATERIALX_WARNINGS_AS_ERRORS = 'ON'
8696
MATERIALX_BUILD_TESTS = 'OFF'

0 commit comments

Comments
 (0)