Skip to content

Commit

Permalink
Fix docs (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Aug 22, 2023
1 parent f61c24e commit 8efb693
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
apt_packages:
- r-base-core
python:
install:
- method: pip
path: .
extra_requirements:
- doc
sphinx:
fail_on_warning: true
configuration: docs/conf.py
29 changes: 2 additions & 27 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,16 @@
"""Sphinx configuration."""

import sys
from abc import ABC
from datetime import datetime, timezone
from importlib.metadata import metadata
from pathlib import Path
from unittest.mock import MagicMock, patch


def mock_rpy2() -> None:
"""Can’t use autodoc_mock_imports as we import anndata2ri."""
patch('rpy2.situation.get_r_home', lambda: None).start()
sys.modules['rpy2.rinterface_lib'] = MagicMock()
submods = ['embedded', 'conversion', 'memorymanagement', 'sexp', 'bufferprotocol', 'callbacks', '_rinterface_capi']
sys.modules.update({f'rpy2.rinterface_lib.{sub}': MagicMock() for sub in submods})
sexp = sys.modules['rpy2.rinterface_lib'].sexp = sys.modules['rpy2.rinterface_lib.sexp']
sexp.Sexp = type('Sexp', (MagicMock, ABC), dict(__module__='rpy2.rinterface_lib.sexp'))
sexp.SexpEnvironment = type('SexpEnvironment', (sexp.Sexp,), dict(__module__='rpy2.rinterface_lib.sexp'))
sexp.SexpVector = sexp.StrSexpVector = MagicMock
sexp.SexpVector.from_iterable = MagicMock()

import rpy2.rinterface
import rpy2.rinterface_lib.sexp

rpy2.rinterface_lib = sys.modules['rpy2.rinterface_lib']
rpy2.rinterface._MissingArgType = object # noqa: SLF001
rpy2.rinterface.initr_simple = lambda *_, **__: None

assert rpy2.rinterface_lib.sexp is sexp


HERE = Path(__file__).parent

mock_rpy2()

# now we can anndata2ri and our extensions
sys.path[:0] = [str(HERE.parent), str(HERE / 'ext')]
# allow to import our extensions
sys.path[:0] = [str(HERE / 'ext')]


# -- General configuration ------------------------------------------------
Expand Down

0 comments on commit 8efb693

Please sign in to comment.