cps.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:cps 作者: mwoehlke 项目源码 文件源码
def apply(self, **kwargs):
        for ref in self.document.traverse(nodes.reference):
            # Skip inter-document links
            if 'refname' in ref:
                if self.document.nameids.get(ref['refname']):
                    continue

            # Convert remaining non-external links to intra-document references
            refuri = ref['refuri'] if 'refuri' in ref else None
            if not refuri or not '://' in refuri:
                # Get the raw text (strip ``s and _)
                rawtext = re.sub('^`(.*)`_?$', '\\1', ref.rawsource)

                # Create xref node
                xref = addnodes.pending_xref(
                    rawtext, reftype='ref', refdomain='std',
                    refexplicit=(refuri is not None))

                # Rewrite section links
                if not refuri:
                    refuri = ref['name']

                # Fill target information
                xref['reftarget'] = refuri.lower()
                xref['refwarn'] = True
                xref['refdoc'] = self.document.settings.env.docname

                # Add ref text
                xref += nodes.inline(rawtext, ref['name'],
                                     classes=ref['classes'])

                # Replace the old node
                ref.replace_self(xref)

#==============================================================================
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号