Skip to content

Commit 7f3fc73

Browse files
committed
Make name of doc build flag more global, explain
1 parent 3f57b8b commit 7f3fc73

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

arraycontext/impl/pytato/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
import pytato
5959
import pyopencl as cl
6060

61-
if getattr(sys, "ARRAYCONTEXT_BUILDING_SPHINX_DOCS", False):
61+
if getattr(sys, "_BUILDING_SPHINX_DOCS", False):
6262
import pyopencl as cl # noqa: F811
6363

6464

doc/conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,14 @@
2727
"https://jax.readthedocs.io/en/latest/": None,
2828
}
2929

30+
# Some modules need to import things just so that sphinx can resolve symbols in
31+
# type annotations. Often, we do not want these imports (e.g. of PyOpenCL) when
32+
# in normal use (because they would introduce unintended side effects or hard
33+
# dependencies). This flag exists so that these imports only occur during doc
34+
# build. Since sphinx appears to resolve type hints lexically (as it should),
35+
# this needs to be cross-module (since, e.g. an inherited arraycontext
36+
# docstring can be read by sphinx when building meshmode, a dependent package),
37+
# this needs a setting of the same name across all packages involved, that's
38+
# why this name is as global-sounding as it is.
3039
import sys
31-
sys.ARRAYCONTEXT_BUILDING_SPHINX_DOCS = True
40+
sys._BUILDING_SPHINX_DOCS = True

0 commit comments

Comments
 (0)