• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ws_re.sub函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sphinx.util.ws_re.sub函数的典型用法代码示例。如果您正苦于以下问题:Python sub函数的具体用法?Python sub怎么用?Python sub使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sub函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: process_link

 def process_link(self, env, refnode, has_explicit_title, title, target):
     program = env.temp_data.get("std:program")
     if not has_explicit_title:
         if " " in title and not (title.startswith("/") or title.startswith("-")):
             program, target = re.split(" (?=-|--|/)", title, 1)
             program = ws_re.sub("-", program)
             target = target.strip()
     elif " " in target:
         program, target = re.split(" (?=-|--|/)", target, 1)
         program = ws_re.sub("-", program)
     refnode["refprogram"] = program
     return title, target
开发者ID:cumtjie,项目名称:commcarehq-venv,代码行数:12,代码来源:std.py


示例2: process_link

 def process_link(self, env, refnode, has_explicit_title, title, target):
     program = env.temp_data.get('std:program')
     if not has_explicit_title:
         if ' ' in title and not (title.startswith('/') or
                                  title.startswith('-')):
             program, target = re.split(' (?=-|--|/)', title, 1)
             program = ws_re.sub('-', program)
             target = target.strip()
     elif ' ' in target:
         program, target = re.split(' (?=-|--|/)', target, 1)
         program = ws_re.sub('-', program)
     refnode['refprogram'] = program
     return title, target
开发者ID:qsnake,项目名称:sphinx,代码行数:13,代码来源:std.py


示例3: handle_signature

    def handle_signature(self, sig, signode):
        name = self.options["name"]
        parameters = json.loads(self.options["parameters"]) if "parameters" in self.options else []
        return_v = json.loads(self.options["return"]) if "return" in self.options else ("", "")
        prefix = self.options["prefix"] if "prefix" in self.options else ""

        if not ("parameters" in self.options) or not ("return" in self.options):
            print("WARNING: No parameters or return set for '" + name + "'")

        signode += nodes.Text(prefix + " ", prefix + u"\xa0")
        xref = addnodes.pending_xref(
            ":ref:`" + return_v[1] + "`",
            refdomain="std",
            reftype="ref",
            reftarget=ws_re.sub(" ", return_v[1].lower()),
            refexplicit=False,
        )
        xref += nodes.Text(return_v[0], return_v[0])
        signode += xref
        signode += nodes.Text(" ", u"\xa0")

        signode += addnodes.desc_name(name, name)
        paramlist = addnodes.desc_parameterlist()
        for tn in parameters:
            param = addnodes.desc_parameter("", "", noemph=True)
            prefix = ""
            if len(tn) > 3 and tn[3] == "True":
                prefix += "ref "
            if len(tn) > 4 and tn[4] == "True":
                prefix += "out "

            if prefix != "":
                param += nodes.Text(prefix + " ", prefix + u"\xa0")

            xref = addnodes.pending_xref(
                ":ref:`" + tn[2] + "`",
                refdomain="std",
                reftype="ref",
                reftarget=ws_re.sub(" ", tn[2].lower()),
                refexplicit=False,
            )
            xref += nodes.Text(tn[0], tn[0])
            param += xref
            param += nodes.emphasis(" " + tn[1], u"\xa0" + tn[1])
            paramlist += param
        signode += paramlist

        return name, ""
开发者ID:hach-que,项目名称:Protogame.Docs,代码行数:48,代码来源:netxml.py


示例4: resolve_info_references

def resolve_info_references(app, _env, refnode, contnode):
    """Resolve Info references.

    Process all :class:`~sphinx.addnodes.pending_xref` nodes whose ``reftype``
    is ``infonode``.

    Replace the pending reference with a :class:`~docutils.nodes.reference`
    node, which references the corresponding web URL, as stored in the database
    referred to by :data:`HTMLXREF_URL`.

    """
    if refnode["reftype"] != "infonode":
        return None

    target = ws_re.sub(" ", refnode["reftarget"])
    match = INFO_RE.match(target)
    if not match:
        app.env.warn(refnode.source, "Invalid info target: {0}".format(target), refnode.line)
        return contnode

    manual = match.group("manual")
    node = match.group("node")

    xrefdb = app.env.info_htmlxref
    uri = xrefdb.resolve(manual, node)
    if not uri:
        message = "Cannot resolve info manual {0}".format(manual)
        app.env.warn(refnode.source, message, refnode.line)
        return contnode
    else:
        reference = nodes.reference("", "", internal=False, refuri=uri, reftitle=target)
        reference += contnode
        return reference
开发者ID:nordlow,项目名称:flycheck,代码行数:33,代码来源:info.py


示例5: process_link

 def process_link(self, env, refnode, has_explicit_title, title, target):
     """Called after parsing title and target text, and creating the
     reference node (given in *refnode*).  This method can alter the
     reference node and must return a new (or the same) ``(title, target)``
     tuple.
     """
     return title, ws_re.sub(' ', target)
开发者ID:QuLogic,项目名称:sphinx,代码行数:7,代码来源:roles.py


示例6: run

    def run(self):
        env = self.state.document.settings.env
        # normalize whitespace in fullname like XRefRole does
        fullname = ws_re.sub(' ', self.arguments[0].strip())
        targetname = '%s-%s' % (self.ref_type, fullname)

        # keep the target; this may be used to generate a BBIndex later
        targets = env.domaindata['bb']['targets'].setdefault(self.ref_type, {})
        targets[fullname] = env.docname, targetname

        # make up the descriptor: a target and potentially an index descriptor
        node = nodes.target('', '', ids=[targetname])
        ret = [node]

        # add the target to the document
        self.state.document.note_explicit_target(node)

        # append the index node if necessary
        entries = []
        for tpl in self.indextemplates:
            colon = tpl.find(':')
            if colon != -1:
                indextype = tpl[:colon].strip()
                indexentry = tpl[colon+1:].strip() % (fullname,)
            else:
                indextype = 'single'
                indexentry = tpl % (fullname,)
            entries.append((indextype, indexentry, targetname, targetname))

        if entries:
            inode = addnodes.index(entries=entries)
            ret.insert(0, inode)

        return ret 
开发者ID:bobbyi,项目名称:buildbot,代码行数:34,代码来源:ext.py


示例7: run

    def run(self):
        # type: () -> List[nodes.Node]
        # normalize whitespace in fullname like XRefRole does
        fullname = ws_re.sub(' ', self.arguments[0].strip())
        targetname = '%s-%s' % (self.name, fullname)
        node = nodes.target('', '', ids=[targetname])
        self.state.document.note_explicit_target(node)
        ret = [node]  # type: List[nodes.Node]
        if self.indextemplate:
            indexentry = self.indextemplate % (fullname,)
            indextype = 'single'
            colon = indexentry.find(':')
            if colon != -1:
                indextype = indexentry[:colon].strip()
                indexentry = indexentry[colon + 1:].strip()
            inode = addnodes.index(entries=[(indextype, indexentry,
                                             targetname, '', None)])
            ret.insert(0, inode)
        name = self.name
        if ':' in self.name:
            _, name = self.name.split(':', 1)

        std = cast(StandardDomain, self.env.get_domain('std'))
        std.add_object(name, fullname, self.env.docname, targetname)

        return ret
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:26,代码来源:std.py


示例8: process_link

 def process_link(self, env, refnode, has_explicit_title, title, target):
   paren_start = target.index("(")
   dot_start = target.rindex(".", 0, paren_start)
   dot_start = target.rindex(".", 0, dot_start)
   refnode['refdomain']='std'
   refnode['reftype']='ref'
   refnode['refexplicit']=True
   return (target[dot_start+1:paren_start], ws_re.sub(' ', target.lower()))
开发者ID:RedpointGames,项目名称:Protogame,代码行数:8,代码来源:netxml.py


示例9: process_link

 def process_link(self, env, refnode, has_explicit_title, title, target):
     paren_start = target.index("(")
     dot_start = target.rindex(".", 0, paren_start)
     dot_start = target.rindex(".", 0, dot_start)
     refnode["refdomain"] = "std"
     refnode["reftype"] = "ref"
     refnode["refexplicit"] = True
     return (target[dot_start + 1 : paren_start], ws_re.sub(" ", target.lower()))
开发者ID:hach-que,项目名称:Protogame.Docs,代码行数:8,代码来源:netxml.py


示例10: run

 def run(self):
     env = self.state.document.settings.env
     program = ws_re.sub("-", self.arguments[0].strip())
     if program == "None":
         env.temp_data["std:program"] = None
     else:
         env.temp_data["std:program"] = program
     return []
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:8,代码来源:std.py


示例11: run

 def run(self):
     env = self.state.document.settings.env
     program = ws_re.sub('-', self.arguments[0].strip())
     if program == 'None':
         env.ref_context.pop('std:program', None)
     else:
         env.ref_context['std:program'] = program
     return []
开发者ID:861008761,项目名称:standard_flask_web,代码行数:8,代码来源:std.py


示例12: handle_signature

 def handle_signature(self, sig, signode):
     directive = get_config_directive(sig)
     signode.clear()
     # only show the directive (not daemon and resource type)
     signode += addnodes.desc_name(sig, directive['shortid'])
     # normalize whitespace like XRefRole does
     name = ws_re.sub('', sig)
     return name
开发者ID:bareos,项目名称:bareos,代码行数:8,代码来源:bareos-ext.py


示例13: run

 def run(self):
     env = self.state.document.settings.env
     program = ws_re.sub('-', self.arguments[0].strip())
     if program == 'None':
         env.currprogram = None
     else:
         env.currprogram = program
     return []
开发者ID:ericmjonas,项目名称:sphinxdev,代码行数:8,代码来源:other.py


示例14: handle_signature

 def handle_signature(self, sig, signode):
   name = self.options['name']
   parameters = json.loads(self.options['parameters']) if 'parameters' in self.options else []
   return_v = json.loads(self.options['return']) if 'return' in self.options else ("","")
   prefix = self.options['prefix'] if 'prefix' in self.options else ""
 
   if not ('parameters' in self.options) or not ('return' in self.options):
     print("WARNING: No parameters or return set for '" + name + "'")
   
   signode += nodes.Text(prefix + ' ', prefix + u'\xa0')
   xref = addnodes.pending_xref(
     ':ref:`' + return_v[1] + '`',
     refdomain='std',
     reftype='ref',
     reftarget=ws_re.sub(' ', return_v[1].lower()),
     refexplicit=False)
   xref += nodes.Text(return_v[0], return_v[0])
   signode += xref
   signode += nodes.Text(' ', u'\xa0')
     
   signode += addnodes.desc_name(name, name)
   paramlist = addnodes.desc_parameterlist()
   for tn in parameters:
     param = addnodes.desc_parameter('', '', noemph=True)
     prefix = ''
     if len(tn) > 3 and tn[3] == "True":
       prefix += "ref "
     if len(tn) > 4 and tn[4] == "True":
       prefix += "out "
     
     if prefix != "":
       param += nodes.Text(prefix + ' ', prefix + u'\xa0')
       
     xref = addnodes.pending_xref(
       ':ref:`' + tn[2] + '`',
       refdomain='std',
       reftype='ref',
       reftarget=ws_re.sub(' ', tn[2].lower()),
       refexplicit=False)
     xref += nodes.Text(tn[0], tn[0])
     param += xref
     param += nodes.emphasis(' '+tn[1], u'\xa0'+tn[1])
     paramlist += param
   signode += paramlist
   
   return name, ""
开发者ID:RedpointGames,项目名称:Protogame,代码行数:46,代码来源:netxml.py


示例15: _split

 def _split(self, text, refnode, env):
     try:
         program, target = re.split(" (?=-|--|/)", text, 1)
     except ValueError:
         env.warn_node("Malformed :option: %r, does not contain option " "marker - or -- or /" % text, refnode)
         return None, text
     else:
         program = ws_re.sub("-", program)
         return program, target
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:9,代码来源:std.py


示例16: handle_signature

 def handle_signature(self, sig, signode):
     if self.parse_node:
         name = self.parse_node(self.env, sig, signode)
     else:
         signode.clear()
         signode += addnodes.desc_name(sig, sig)
         # normalize whitespace like XRefRole does
         name = ws_re.sub('', sig)
     return name
开发者ID:861008761,项目名称:standard_flask_web,代码行数:9,代码来源:std.py


示例17: program_directive

def program_directive(name, arguments, options, content, lineno,
                      content_offset, block_text, state, state_machine):
    env = state.document.settings.env
    program = ws_re.sub('-', arguments[0].strip())
    if program == 'None':
        env.currprogram = None
    else:
        env.currprogram = program
    return []
开发者ID:fedor4ever,项目名称:linux_build,代码行数:9,代码来源:other.py


示例18: run

    def run(self):
        self.env = env = self.state.document.settings.env
        # normalize whitespace in fullname like XRefRole does
        fullname = ws_re.sub(' ', self.arguments[0].strip())
        targetname = '%s-%s' % (self.ref_type, fullname)

        # keep the target; this may be used to generate a BBIndex later
        targets = env.domaindata['bb']['targets'].setdefault(self.ref_type, {})
        targets[fullname] = env.docname, targetname

        # make up the descriptor: a target and potentially an index descriptor
        node = nodes.target('', '', ids=[targetname])
        ret = [node]

        # add the target to the document
        self.state.document.note_explicit_target(node)

        # append the index node if necessary
        entries = []
        for tpl in self.indextemplates:
            colon = tpl.find(':')
            if colon != -1:
                indextype = tpl[:colon].strip()
                indexentry = tpl[colon + 1:].strip() % (fullname,)
            else:
                indextype = 'single'
                indexentry = tpl % (fullname,)
            entries.append(
                (indextype, indexentry, targetname, targetname, None))

        if entries:
            inode = addnodes.index(entries=entries)
            ret.insert(0, inode)

        # if the node has content, set up a signature and parse the content
        if self.has_content:
            descnode = addnodes.desc()
            descnode['domain'] = 'bb'
            descnode['objtype'] = self.ref_type
            descnode['noindex'] = True
            signode = addnodes.desc_signature(fullname, '')

            if self.name_annotation:
                annotation = "%s " % self.name_annotation
                signode += addnodes.desc_annotation(annotation, annotation)
            signode += addnodes.desc_name(fullname, fullname)
            descnode += signode

            contentnode = addnodes.desc_content()
            self.state.nested_parse(self.content, 0, contentnode)
            DocFieldTransformer(self).transform_all(contentnode)
            descnode += contentnode

            ret.append(descnode)

        return ret
开发者ID:Cray,项目名称:buildbot,代码行数:56,代码来源:ext.py


示例19: parse_signature

 def parse_signature(self, sig, signode):
     parse_node = additional_xref_types[self.desctype][2]
     if parse_node:
         name = parse_node(self.env, sig, signode)
     else:
         signode.clear()
         signode += addnodes.desc_name(sig, sig)
         # normalize whitespace like xfileref_role does
         name = ws_re.sub('', sig)
     return name
开发者ID:89sos98,项目名称:main,代码行数:10,代码来源:desc.py


示例20: process_link

    def process_link(self, env, refnode, has_explicit_title, title, target):
        """Called after parsing title and target text, and creating the
        reference node (given in *refnode*).  This method can alter the
        reference node and must return a new (or the same) ``(title, target)``
        tuple.
        """

        #~ print(20130901, refnode, has_explicit_title, title, target)
        #~ 20130901 <pending_xref refdomain="" refexplicit="False" reftype="ddref"/> False cal.Event cal.Event

        target = ws_re.sub(' ', target)  # replace newlines or tabs by spaces
        # ~ target = ' '.join(target.split()) # replace newlines or tabs by spaces

        level, x = resolve_name(target)
        if x is None:
            msg = "Could not resolve name %r" % target
            return [self._reporter.warning(msg, line=self._lineno), target]
            # raise Exception(msg)
        # lng = env.temp_data.get('language', env.config.language)
        lng = CurrentLanguage.get_current_value(env)
        with translation.override(lng):
            if isinstance(x, models.Field):
                text = utils.unescape(str(x.verbose_name))
                target = model_name(x.model) + '.' + x.name
                # print(target)
            elif isinstance(x, Plugin):
                text = utils.unescape(str(x.verbose_name))
                target = settings.SITE.userdocs_prefix + target

            elif isinstance(x, type) and issubclass(x, models.Model):
                text = utils.unescape(str(x._meta.verbose_name))
                target = model_name(x)
            elif isinstance(x, type) and issubclass(x, actors.Actor):
                text = utils.unescape(str(x.title or x.label))
                target = actor_name(x)
            elif isinstance(x, actions.Action):
                text = utils.unescape(str(x.label))
                target = actor_name(x)
            else:
                raise Exception("Don't know how to handle %r" % x)

        if not has_explicit_title:
            # avoid replacing title by the heading text
            refnode['refexplicit'] = True
            title = text

        refnode['refwarn'] = False  # never warn

        #~ refnode['reftype'] = 'ref'

        #~ title = "[%s]" % title
        #~ if target == 'welfare.reception.waitingvisitors':
        #~ print("20130907 ddref to %s : title=%r" % (target,title))

        return title, target
开发者ID:lino-framework,项目名称:lino,代码行数:55,代码来源:actordoc.py



注:本文中的sphinx.util.ws_re.sub函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python versioning.merge_doctrees函数代码示例发布时间:2022-05-27
下一篇:
Python url_re.match函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap