當前位置: 首頁>>代碼示例>>Python>>正文


Python autosummary.get_documenter方法代碼示例

本文整理匯總了Python中sphinx.ext.autosummary.get_documenter方法的典型用法代碼示例。如果您正苦於以下問題:Python autosummary.get_documenter方法的具體用法?Python autosummary.get_documenter怎麽用?Python autosummary.get_documenter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sphinx.ext.autosummary的用法示例。


在下文中一共展示了autosummary.get_documenter方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_members

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def _get_members(self, class_obj, member_type, include_in_public=None):
        """
        Return class members of the specified type.

        class_obj: Class object.

        member_type: Member type ('method' or 'attribute').

        include_in_public: set/list/tuple with member names that should be
          included in public members in addition to the public names (those
          starting without underscore).

        Returns:
          tuple(public_members, all_members): Names of the class members of
            the specified member type (public / all).
        """
        try:
            app = self.state.document.settings.env.app
        except AttributeError:
            app = None
        if not include_in_public:
            include_in_public = []
        all_members = []
        for member_name in dir(class_obj):
            try:
                documenter = get_documenter(
                    app,
                    safe_getattr(class_obj, member_name),
                    class_obj)
            except AttributeError:
                continue
            if documenter.objtype == member_type:
                all_members.append(member_name)
        public_members = [x for x in all_members
                  if x in include_in_public or not x.startswith('_')]
        return public_members, all_members 
開發者ID:zhmcclient,項目名稱:python-zhmcclient,代碼行數:38,代碼來源:conf.py

示例2: get_members

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def get_members(doc, obj, typ, include_public=None, signal=False, enum=False):
        try:
            if not include_public:
                include_public = []
            items = []

            for name in dir(obj):
                if name not in obj.__dict__.keys():
                    continue
                try:
                    chobj = safe_getattr(obj, name)
                    documenter = get_documenter(doc.settings.env.app, chobj, obj)
                    #cl = get_class_that_defined_method(chobj)
                    #print(name, chobj.__qualname__, type(chobj), issubclass(chobj, Enum), documenter.objtype)
                    if documenter.objtype == typ:
                        if typ == 'attribute':
                            if signal and type(chobj) != PyQt5.QtCore.pyqtSignal:
                                continue
                            if not signal and type(chobj) == PyQt5.QtCore.pyqtSignal:
                                continue
                        elif typ == 'class':
                            if enum and not issubclass(chobj, Enum):
                                continue
                            if not enum and issubclass(chobj, Enum):
                                continue
                        items.append(name)
                except AttributeError:
                    continue
            public = [x for x in items if x in include_public or not x.startswith('_')]
            return public, items
        except BaseException as e:
            print(str(e))
            raise e 
開發者ID:qgis,項目名稱:pyqgis,代碼行數:35,代碼來源:autoautosummary.py

示例3: get_members

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def get_members(clazz, obj, typ):
        names = set()
        items = []

        # the default dir
        for name in dir(obj):
            try:
                documenter = get_documenter(safe_getattr(obj, name), obj)
            except AttributeError:
                continue
            if documenter.objtype == typ and not name.startswith('_'):
                if name not in AutoCosmoSummary.exclude:
                    items.append((clazz,name))
                    names.add(name) # keep track of method/attribute conflicts

        # the delegate dro
        for n in obj.dro:
            for name in dir(n):
                try:
                    documenter = get_documenter(safe_getattr(n, name), n)
                except AttributeError:
                    continue

                # dont do conflicts
                if name not in names:
                    if documenter.objtype == typ and not name.startswith('_'):
                        if name not in AutoCosmoSummary.exclude:
                            x = "%s.%s" %(n.__module__, n.__name__)
                            items.append((x,name))
                            names.add(name)

        return ['~%s.%s' %item for item in sorted(items, key=lambda x: x[1])] 
開發者ID:bccp,項目名稱:nbodykit,代碼行數:34,代碼來源:conf.py

示例4: get_members

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def get_members(obj, typ, public_only=True):
        items = []
        for name in dir(obj):
            if public_only and name.startswith('_'):
                continue
            try:
                documenter = get_documenter(None, safe_getattr(obj, name), obj)
            except AttributeError:
                continue
            if documenter.objtype == typ:
                items.append(name)
        return items 
開發者ID:civisanalytics,項目名稱:civis-python,代碼行數:14,代碼來源:conf.py

示例5: get_members

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def get_members(obj, typ, include_public=None):
        if not include_public:
            include_public = []
        items = []
        for name in sorted(obj.__dict__.keys()):#dir(obj):
            try:
                documenter = get_documenter(AutoAutoSummary.app, safe_getattr(obj, name), obj)
            except AttributeError:
                continue
            if documenter.objtype in typ:
                items.append(name)
        public = [x for x in items if x in include_public or not x.startswith('_')]
        return public, items 
開發者ID:pyvista,項目名稱:pyvista,代碼行數:15,代碼來源:conf.py

示例6: get_members

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def get_members(app, obj, typ, include_public=(), imported=False):
    items = []
    for name in dir(obj):
        try:
            obj_name = safe_getattr(obj, name)
            try:
                documenter = get_documenter(app, obj_name, obj)
            except TypeError:
                documenter = get_documenter(obj_name, obj)

        except AttributeError:
            continue
        if documenter.objtype == typ:
            try:
                cond = imported or (obj_name.__module__ == obj.__name__)
            except AttributeError:
                cond = True

            if cond:
                items.append(name)
    skip = set(app.config.autosummary_skip_members)
    _n = '{}.%s'.format(obj.__name__)

    public = [
        x for x in items
        if (x in include_public or not x.startswith('_')) and _n % x not in skip
    ]
    return public, items 
開發者ID:vinci1it2000,項目名稱:schedula,代碼行數:30,代碼來源:autosummary.py

示例7: get_members

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def get_members(obj, typ, include_public=None):
        if not include_public:
            include_public = []
        items = []
        for name in dir(obj):
            try:
                documenter = get_documenter(safe_getattr(obj, name), obj)
            except AttributeError:
                continue
            if documenter.objtype == typ:
                items.append(name)
        public = [x for x in items if x in include_public or not x.startswith('_')]
        return public, items 
開發者ID:lucasrodes,項目名稱:whatstk,代碼行數:15,代碼來源:conf.py

示例8: setup

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def setup(app):
    app.connect('autodoc-skip-member', skip_deprecated)
    try:
        from sphinx.ext.autosummary import Autosummary
        from sphinx.ext.autosummary import get_documenter
        from docutils.parsers.rst import directives
        from sphinx.util.inspect import safe_getattr

        class AutoAutoSummary(Autosummary):

            option_spec = {
                'methods': directives.unchanged,
                'attributes': directives.unchanged
            }

            required_arguments = 1

            @staticmethod
            def get_members(obj, typ, include_public=None):
                if not include_public:
                    include_public = []
                items = []
                for name in dir(obj):
                    try:
                        documenter = get_documenter(safe_getattr(obj, name),
                                                    obj)
                    except AttributeError:
                        continue
                    if documenter.objtype == typ:
                        items.append(name)
                public = [x for x in items
                          if x in include_public or not x.startswith('_')]
                return public, items

            def run(self):
                clazz = str(self.arguments[0])
                try:
                    (module_name, class_name) = clazz.rsplit('.', 1)
                    m = __import__(module_name, globals(), locals(),
                                   [class_name])
                    c = getattr(m, class_name)
                    if 'methods' in self.options:
                        _, methods = self.get_members(c,
                                                      'method', ['__init__'])

                        self.content = ["~%s.%s" % (clazz, method)
                                        for method in methods
                                        if not method.startswith('_')]
                    if 'attributes' in self.options:
                        _, attribs = self.get_members(c, 'attribute')
                        self.content = ["~%s.%s" % (clazz, attrib)
                                        for attrib in attribs
                                        if not attrib.startswith('_')]
                finally:
                    return super(AutoAutoSummary, self).run()

        app.add_directive('autoautosummary', AutoAutoSummary)
    except BaseException as e:
        raise e 
開發者ID:libvips,項目名稱:pyvips,代碼行數:61,代碼來源:conf.py

示例9: run

# 需要導入模塊: from sphinx.ext import autosummary [as 別名]
# 或者: from sphinx.ext.autosummary import get_documenter [as 別名]
def run(self):
        module_name = str(self.arguments[0])
        module = importlib.import_module(module_name)

        analyzer = ModuleAnalyzer.for_module(module_name)
        attr_docs = analyzer.find_attr_docs()

        with open(module.__file__) as module_file:
            symbols = symtable.symtable(module_file.read(), module.__file__, "exec")

        members = []

        for name in dir(module):
            member = getattr(module, name)

            # Ignore private members
            if name.startswith("_"):
                continue

            # Ignore imported modules
            if isinstance(member, types.ModuleType):
                continue

            # Ignore members imported from other modules
            member_module_name = getattr(member, "__module__", None)
            if member_module_name is None:
                try:
                    if symbols.lookup(name).is_imported():
                        continue
                except KeyError:
                    continue
            else:
                if member_module_name != module_name:
                    continue

            documenter = get_documenter(self.env.app, member, module)

            # Ignore data items that do not have docstrings
            if documenter.objtype == "data" and ("", name) not in attr_docs:
                continue

            members.append(name)

        # Sort members in the order they appear in source code
        tagorder = analyzer.tagorder
        members.sort(key=lambda name: tagorder.get(name, len(tagorder)))

        self.content = [f"{module_name}.{member}" for member in members]

        return super().run() 
開發者ID:broadinstitute,項目名稱:gnomad_methods,代碼行數:52,代碼來源:directives.py


注:本文中的sphinx.ext.autosummary.get_documenter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。