[PATCH] Mock non-standard modules so we can generate API docs on readthedocs.
Vratislav Podzimek
vpodzime at redhat.com
Fri Jul 18 05:21:56 UTC 2014
On Thu, 2014-07-17 at 15:44 -0500, David Lehman wrote:
> ---
> doc/conf.py | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/doc/conf.py b/doc/conf.py
> index 4b16a97..05594fd 100644
> --- a/doc/conf.py
> +++ b/doc/conf.py
> @@ -289,3 +289,32 @@ epub_copyright = u'2013, David Lehman'
>
> # Example configuration for intersphinx: refer to the Python standard library.
> intersphinx_mapping = {'https://docs.python.org/2': None}
> +
> +class Mock(object):
> +
> + __all__ = []
> +
> + 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():
> + mockType = type(name, (), {})
> + mockType.__module__ = __name__
> + return mockType
> + else:
> + return Mock()
> +
> + @classmethod
> + def __getitem__(cls, key):
> + return cls.__getattr__(key)
> +
> +MOCK_MODULES = ['parted', 'block', 'pycryptsetup', 'pykickstart', 'pykickstart.constants', '_ped']
> +for mod_name in MOCK_MODULES:
> + sys.modules[mod_name] = Mock()
Interesting, but looks good to me as well.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list