I am currently trying to generate sphinx documentation for scripts which use the ArcGIS arcpy library.
I am running into an issue when sphinx tries to run the scrip
I do something like this. In my conf.py
I add a new variable to the builtins
module like:
# anywhere in conf.py before any of your modules are imported
import builtins
builtins.__sphinx_build__ = True
Then in my module code I can write a check like:
try:
from some_dependency import SomeClass
except ImportError:
try:
if __sphinx_build__:
class SomeClass:
"""Mock the class"""
except NameError:
raise ImportError('some_dependency')