Skip to content

Commit b9cfa4e

Browse files
Bordatchaton
authored andcommitted
fix mock pkgs in docs (#4591)
* fix mock pkgs in docs * sphinx * CI Co-authored-by: chaton <[email protected]>
1 parent b6c73b4 commit b9cfa4e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

.github/workflows/docs-checks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on: # Trigger the workflow on push or pull request, but only for the master bra
88
branches: [master, "release/*"]
99

1010
jobs:
11-
check-docs:
11+
sphinx-check:
1212
runs-on: ubuntu-20.04
1313
steps:
1414
- uses: actions/checkout@v2
@@ -48,6 +48,7 @@ jobs:
4848
# python -m pip install --upgrade --user pip
4949
pip install --requirement requirements.txt --upgrade-strategy only-if-needed --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --quiet
5050
pip install --requirement requirements/extra.txt
51+
pip install --requirement requirements/loggers.txt
5152
pip install --requirement requirements/docs.txt
5253
python --version
5354
pip --version

docs/source/conf.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,22 +304,23 @@ def package_list_from_file(file):
304304
return mocked_packages
305305

306306

307+
# define mapping from PyPI names to python imports
308+
PACKAGE_MAPPING = {
309+
'Pillow': 'PIL',
310+
'opencv-python': 'cv2',
311+
'PyYAML': 'yaml',
312+
'comet-ml': 'comet_ml',
313+
'neptune-client': 'neptune',
314+
}
307315
MOCK_PACKAGES = []
308316
if SPHINX_MOCK_REQUIREMENTS:
309317
# mock also base packages when we are on RTD since we don't install them there
310318
MOCK_PACKAGES += package_list_from_file(os.path.join(PATH_ROOT, 'requirements.txt'))
311319
MOCK_PACKAGES += package_list_from_file(os.path.join(PATH_ROOT, 'requirements/extra.txt'))
312320
MOCK_PACKAGES += package_list_from_file(os.path.join(PATH_ROOT, 'requirements/loggers.txt'))
321+
MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES]
313322

314-
MOCK_MANUAL_PACKAGES = [
315-
'torchvision',
316-
'PIL',
317-
# packages with different package name compare to import name
318-
'yaml',
319-
'comet_ml',
320-
'neptune',
321-
]
322-
autodoc_mock_imports = MOCK_PACKAGES + MOCK_MANUAL_PACKAGES
323+
autodoc_mock_imports = MOCK_PACKAGES
323324

324325
autosummary_generate = True
325326

0 commit comments

Comments
 (0)