From d37906a508c1e81dc4f30d5b1db395406f50e0a8 Mon Sep 17 00:00:00 2001 From: Brett Morris Date: Fri, 1 Apr 2016 15:19:47 -0700 Subject: [PATCH] Adding note about mocking within the package-template for readthedocs --- docs/development/affiliated-packages.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/development/affiliated-packages.rst b/docs/development/affiliated-packages.rst index 23c5b86920a..3fd5534df31 100644 --- a/docs/development/affiliated-packages.rst +++ b/docs/development/affiliated-packages.rst @@ -409,6 +409,30 @@ files manually`_ section since this explains what many of the files do. All other settings can stay on their default value. + If you need to mock any Python packages or C libraries that can not be + installed and built by ReadTheDocs, you should include the following mocking + patch before the ``Project information`` section of the ``docs/conf.py`` file:: + + class Mock(object): + def __init__(self, *args, **kwargs): + pass + + def __call__(self, *args, **kwargs): + return Mock() + + @classmethod + def __getattr__(cls, name): + if name in ('__file__', '__path__'): + return '/dev/null' + elif name[0] == name[0].upper(): + return type(name, (), {}) + else: + return Mock() + + MOCK_MODULES = ['', ''] + for mod_name in MOCK_MODULES: + sys.modules[mod_name] = Mock() + #. You're now ready to start doing actual work on your affiliated package. You will probably want to read over the developer guidelines of the Astropy documentation, and if you are hosting your code in GitHub, you might also