diff --git a/docs/source/conf.py b/docs/source/conf.py index 5c806162..2b0a2e92 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -262,7 +262,7 @@ def _get_usd_ref_tooltip(app): @functools.cache -def _get_url_for_target(app, target): +def _get_url_for_usd_target(app, target): pxr_obj_namespace = target.removeprefix('pxr.').replace(".", "") pxr_obj_namespace = { "UsdInitialLoadSet": "UsdStage::InitialLoadSet", # there's indirection in the python bindings @@ -281,13 +281,9 @@ def _get_url_for_target(app, target): def _handle_missing_usd_reference(app, env, node, contnode): from docutils import nodes - target = node['reftarget'] - if not target.startswith('pxr.'): - return None - - reftitle, refuri = _get_url_for_target(app, target) - node = nodes.reference('', contnode.astext(), internal=False, refuri=refuri, reftitle=reftitle) - return node + if (target := node['reftarget']).startswith('pxr.'): + reftitle, refuri = _get_url_for_usd_target(app, target) + return nodes.reference('', contnode.astext(), internal=False, refuri=refuri, reftitle=reftitle) def _grill_process_signature(app, what, name, obj, options, signature, return_annotation): diff --git a/grill/usd/__init__.py b/grill/usd/__init__.py index 73814b88..fb56e69c 100644 --- a/grill/usd/__init__.py +++ b/grill/usd/__init__.py @@ -1,8 +1,7 @@ """Helpers for USD workflows which do not know anything about the pipeline.""" +from __future__ import annotations + import enum -# https://docs.python.org/3/whatsnew/3.10.html#pep-604-new-type-union-operator -# TODO: Remove when py-3.10+ is supported (for union types) -import typing import inspect import logging import functools @@ -58,7 +57,7 @@ def common_paths(paths: abc.Iterable[Sdf.Path]) -> list[Sdf.Path]: return unique -def iprims(stage: Usd.Stage, root_paths: abc.Iterable[Sdf.Path] = tuple(), prune_predicate: abc.Callable[[Usd.Prim], bool] = None, traverse_predicate: typing.Union[Usd._Term, Usd._PrimFlagsConjunction] = Usd.PrimDefaultPredicate) -> abc.Iterator[Usd.Prim]: +def iprims(stage: Usd.Stage, root_paths: abc.Iterable[Sdf.Path] = tuple(), prune_predicate: abc.Callable[[Usd.Prim], bool] = None, traverse_predicate: Usd._Term | Usd._PrimFlagsConjunction = Usd.PrimDefaultPredicate) -> abc.Iterator[Usd.Prim]: """Convenience function that creates an iterator useful for common :ref:`glossary:stage traversal`. Without keyword arguments, this is the same as calling :usdcpp:`UsdStage::Traverse`, so