Skip to content

Commit

Permalink
Use autodoc_mock_imports (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilflood committed Oct 9, 2023
1 parent 78ef1bd commit c880096
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@

import sys
import os
# Set up 'mock' modules, needed to build docs if numpy, gdal etc., aren't installed
import mock
import importlib

sys.path.insert(0, os.path.abspath('../..'))
# for version info
import fmask # noqa: E402

# List of modules we will mock, but only if they are not genuinely present
MOCK_MODULES = ['numpy', 'scipy', 'scipy.ndimage', 'scipy.constants',
'scipy.stats', 'osgeo', 'gdal', 'osgeo.gdal', 'rios', 'fmask._fillminima',
'fmask._valueindexes']
# Check which ones are not present, and add them to the mock list
autodoc_mock_imports = []
for mod_name in MOCK_MODULES:
try:
importlib.import_module(mod_name)
except ImportError:
sys.modules[mod_name] = mock.Mock()
autodoc_mock_imports.append(mod_name)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down

0 comments on commit c880096

Please sign in to comment.