diff --git a/arraycontext/impl/pytato/__init__.py b/arraycontext/impl/pytato/__init__.py
index 8d87b860251fcb735684ec54b91bb40d81b6986a..0970ffb5aa9532b1d6dc9057b2adb2ae4a78fd20 100644
--- a/arraycontext/impl/pytato/__init__.py
+++ b/arraycontext/impl/pytato/__init__.py
@@ -58,7 +58,7 @@ if TYPE_CHECKING:
     import pytato
     import pyopencl as cl
 
-if getattr(sys, "ARRAYCONTEXT_BUILDING_SPHINX_DOCS", False):
+if getattr(sys, "_BUILDING_SPHINX_DOCS", False):
     import pyopencl as cl  # noqa: F811
 
 
diff --git a/doc/conf.py b/doc/conf.py
index c91572488c400ff40959254bf745ea1e7052639d..84a6d64088562c86470a9f95cdc44f76f4f8f67a 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -27,5 +27,14 @@ intersphinx_mapping = {
     "https://jax.readthedocs.io/en/latest/": None,
 }
 
+# Some modules need to import things just so that sphinx can resolve symbols in
+# type annotations. Often, we do not want these imports (e.g. of PyOpenCL) when
+# in normal use (because they would introduce unintended side effects or hard
+# dependencies). This flag exists so that these imports only occur during doc
+# build. Since sphinx appears to resolve type hints lexically (as it should),
+# this needs to be cross-module (since, e.g. an inherited arraycontext
+# docstring can be read by sphinx when building meshmode, a dependent package),
+# this needs a setting of the same name across all packages involved, that's
+# why this name is as global-sounding as it is.
 import sys
-sys.ARRAYCONTEXT_BUILDING_SPHINX_DOCS = True
+sys._BUILDING_SPHINX_DOCS = True