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


Python XRefRole.__call__方法代碼示例

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


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

示例1: __call__

# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
    def __call__(self, *args, **kwargs):
        nodes, messages = XRefRole.__call__(self, *args, **kwargs)
        for node in nodes:
            attrs = node.attributes
            target = attrs['reftarget']
            parens = ''
            if target.endswith('()'):
                # Function call, :symbol:`mongoc_init()`
                target = target[:-2]
                parens = '()'

            if ':' in target:
                # E.g., 'bson:bson_t' has domain 'bson', target 'bson_t'
                attrs['domain'], name = target.split(':', 1)
                attrs['reftarget'] = name

                old = node.children[0].children[0]
                assert isinstance(old, Text)
                new = Text(name + parens, name + parens)
                # Ensure setup_child is called.
                node.children[0].replace(old, new)

            else:
                attrs['reftarget'] = target

            attrs['reftype'] = 'doc'
            attrs['classes'].append('symbol')

            if sphinx_version_info >= (1, 6):
                # https://github.com/sphinx-doc/sphinx/issues/3698
                attrs['refdomain'] = 'std'

        return nodes, messages
開發者ID:SeisComP3,項目名稱:seiscomp3,代碼行數:35,代碼來源:__init__.py

示例2: __call__

# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
    def __call__(self, *args, **kwargs):
        nodes, messages = XRefRole.__call__(self, *args, **kwargs)
        for node in nodes:
            attrs = node.attributes
            target = attrs['reftarget']
            parens = ''
            if target.endswith('()'):
                # Function call, :symbol:`mongoc_init()`
                target = target[:-2]
                parens = '()'

            if ':' in target:
                # E.g., 'bson:bson_t' has domain 'bson', target 'bson_t'
                attrs['domain'], name = target.split(':', 1)
                attrs['reftarget'] = name

                assert isinstance(node.children[0].children[0], Text)
                node.children[0].children[0] = Text(name + parens,
                                                    name + parens)

            else:
                attrs['reftarget'] = target

            attrs['reftype'] = 'doc'
            attrs['classes'].append('symbol')
        return nodes, messages
開發者ID:ShaneHarvey,項目名稱:libbson,代碼行數:28,代碼來源:__init__.py

示例3: __call__

# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
    def __call__(self, typ, rawtext, text, lineno, inliner,
                 options={}, content=[]):

        typ = 'std:ref'
        self._reporter = inliner.document.reporter
        self._lineno = lineno
        return XRefRole.__call__(self, typ, rawtext, text, lineno,
                                 inliner, options, content)
開發者ID:lino-framework,項目名稱:lino,代碼行數:10,代碼來源:actordoc.py

示例4: __call__

# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
 def __call__(self, typ, rawtext, text, *args, **keys):
     # CMake cross-reference targets may contain '<' so escape
     # any explicit `<target>` with '<' not preceded by whitespace.
     while True:
         m = ECMXRefRole._re.match(text)
         if m and len(m.group(2)) == 0:
             text = '%s\x00<%s>' % (m.group(1), m.group(3))
         else:
             break
     return XRefRole.__call__(self, typ, rawtext, text, *args, **keys)
開發者ID:ShaheedHaque,項目名稱:extra-cmake-modules,代碼行數:12,代碼來源:ecm.py

示例5: __call__

# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
 def __call__(self, typ, rawtext, text, *args, **keys):
     # Translate CMake command cross-references of the form:
     #  `command_name(SUB_COMMAND)`
     # to have an explicit target:
     #  `command_name(SUB_COMMAND) <command_name>`
     if typ == 'cmake:command':
         m = CMakeXRefRole._re_sub.match(text)
         if m:
             text = '%s <%s>' % (text, m.group(1))
     # CMake cross-reference targets frequently contain '<' so escape
     # any explicit `<target>` with '<' not preceded by whitespace.
     while True:
         m = CMakeXRefRole._re.match(text)
         if m and len(m.group(2)) == 0:
             text = '%s\x00<%s>' % (m.group(1), m.group(3))
         else:
             break
     return XRefRole.__call__(self, typ, rawtext, text, *args, **keys)
開發者ID:dbcfd,項目名稱:CMake,代碼行數:20,代碼來源:cmake.py

示例6: __call__

# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
 def __call__(self, typ, rawtext, text, lineno, inliner,
              options={}, content=[]):
     #~ print('20130901',typ, rawtext, text, lineno, inliner,options, content)
     typ = 'std:ref'
     return XRefRole.__call__(self, typ, rawtext, text, lineno, 
         inliner, options, content)
開發者ID:MaxTyutyunnikov,項目名稱:lino,代碼行數:8,代碼來源:actordoc.py

示例7: __call__

# 需要導入模塊: from sphinx.roles import XRefRole [as 別名]
# 或者: from sphinx.roles.XRefRole import __call__ [as 別名]
 def __call__(self, *args, **kwargs):
     res = XRefRole.__call__(self, *args, **kwargs)
     return res
開發者ID:aldebaran,項目名稱:doc-tools,代碼行數:5,代碼來源:mycpp.py


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