コード例 #1
0
def test_get_module_source():
    assert get_module_source('sphinx') == ('file', sphinx.__file__)

    # failed to obtain source information from builtin modules
    with pytest.raises(PycodeError):
        get_module_source('builtins')
    with pytest.raises(PycodeError):
        get_module_source('itertools')
コード例 #2
0
ファイル: test_util.py プロジェクト: olivier-heurtier/sphinx
def test_get_module_source():
    assert get_module_source('sphinx') == ('file', sphinx.__file__)

    # failed to obtain source information from builtin modules
    with pytest.raises(PycodeError):
        get_module_source('builtins')
    with pytest.raises(PycodeError):
        get_module_source('itertools')
コード例 #3
0
    def is_importable(self, modname):
        """Determine whether members of the given module can be documented with
        sphinx by using the :func:`sphinx.util.get_module_source` function

        Parameters
        ----------
        modname: str
            The __name__ attribute of the module to import

        Returns
        -------
        bool
            True if sphinx can import the module"""
        try:
            get_module_source(modname)
            return True
        except Exception:
            return False
コード例 #4
0
ファイル: help_explorer.py プロジェクト: Chilipp/psyplot_gui
    def is_importable(self, modname):
        """Determine whether members of the given module can be documented with
        sphinx by using the :func:`sphinx.util.get_module_source` function

        Parameters
        ----------
        modname: str
            The __name__ attribute of the module to import

        Returns
        -------
        bool
            True if sphinx can import the module"""
        try:
            get_module_source(modname)
            return True
        except Exception:
            return False
コード例 #5
0
    def for_module(cls, modname):
        if ('module', modname) in cls.cache:
            entry = cls.cache['module', modname]
            if isinstance(entry, PycodeError):
                raise entry
            return entry

        try:
            type, source = get_module_source(modname)
            if type == 'string':
                obj = cls.for_string(source, modname)
            else:
                obj = cls.for_file(source, modname)
        except PycodeError, err:
            cls.cache['module', modname] = err
            raise
コード例 #6
0
    def for_module(cls, modname):
        if ('module', modname) in cls.cache:
            entry = cls.cache['module', modname]
            if isinstance(entry, PycodeError):
                raise entry
            return entry

        try:
            type, source = get_module_source(modname)
            if type == 'string':
                obj = cls.for_string(source, modname)
            else:
                obj = cls.for_file(source, modname)
        except PycodeError, err:
            cls.cache['module', modname] = err
            raise