Python docutils.nodes 模块,citation() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用docutils.nodes.citation()

项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def depart_citation_reference(self, node):
        if self._use_latex_citations:
            followup_citation = False
            # check for a following citation separated by a space or newline
            next_siblings = node.traverse(descend=False, siblings=True,
                                          include_self=False)
            if len(next_siblings) > 1:
                next = next_siblings[0]
                if (isinstance(next, nodes.Text) and
                    next.astext() in (' ', '\n')):
                    if next_siblings[1].__class__ == node.__class__:
                        followup_citation = True
            if followup_citation:
                self.out.append(',')
            else:
                self.out.append('}')
                self.inside_citation_reference_label = False
        else:
            self.out.append(']}')
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def citation(self, match):
        src, srcline = self.state_machine.get_source_and_line()
        indented, indent, offset, blank_finish = \
              self.state_machine.get_first_known_indented(match.end())
        label = match.group(1)
        name = normalize_name(label)
        citation = nodes.citation('\n'.join(indented))
        citation.source = src
        citation.line = srcline
        citation += nodes.label('', label)
        citation['names'].append(name)
        self.document.note_citation(citation)
        self.document.note_explicit_target(citation, citation)
        if indented:
            self.nested_parse(indented, input_offset=offset, node=citation)
        return [citation], blank_finish
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def depart_citation_reference(self, node):
        if self._use_latex_citations:
            followup_citation = False
            # check for a following citation separated by a space or newline
            next_siblings = node.traverse(descend=False, siblings=True,
                                          include_self=False)
            if len(next_siblings) > 1:
                next = next_siblings[0]
                if (isinstance(next, nodes.Text) and
                    next.astext() in (' ', '\n')):
                    if next_siblings[1].__class__ == node.__class__:
                        followup_citation = True
            if followup_citation:
                self.out.append(',')
            else:
                self.out.append('}')
                self.inside_citation_reference_label = False
        else:
            self.out.append(']}')
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def citation(self, match):
        src, srcline = self.state_machine.get_source_and_line()
        indented, indent, offset, blank_finish = \
              self.state_machine.get_first_known_indented(match.end())
        label = match.group(1)
        name = normalize_name(label)
        citation = nodes.citation('\n'.join(indented))
        citation.source = src
        citation.line = srcline
        citation += nodes.label('', label)
        citation['names'].append(name)
        self.document.note_citation(citation)
        self.document.note_explicit_target(citation, citation)
        if indented:
            self.nested_parse(indented, input_offset=offset, node=citation)
        return [citation], blank_finish
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def depart_citation_reference(self, node):
        if self._use_latex_citations:
            followup_citation = False
            # check for a following citation separated by a space or newline
            next_siblings = node.traverse(descend=False, siblings=True,
                                          include_self=False)
            if len(next_siblings) > 1:
                next = next_siblings[0]
                if (isinstance(next, nodes.Text) and
                    next.astext() in (' ', '\n')):
                    if next_siblings[1].__class__ == node.__class__:
                        followup_citation = True
            if followup_citation:
                self.out.append(',')
            else:
                self.out.append('}')
                self.inside_citation_reference_label = False
        else:
            self.out.append(']}')
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def citation(self, match):
        src, srcline = self.state_machine.get_source_and_line()
        indented, indent, offset, blank_finish = \
              self.state_machine.get_first_known_indented(match.end())
        label = match.group(1)
        name = normalize_name(label)
        citation = nodes.citation('\n'.join(indented))
        citation.source = src
        citation.line = srcline
        citation += nodes.label('', label)
        citation['names'].append(name)
        self.document.note_citation(citation)
        self.document.note_explicit_target(citation, citation)
        if indented:
            self.nested_parse(indented, input_offset=offset, node=citation)
        return [citation], blank_finish
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def depart_citation_reference(self, node):
        if self._use_latex_citations:
            followup_citation = False
            # check for a following citation separated by a space or newline
            next_siblings = node.traverse(descend=False, siblings=True,
                                          include_self=False)
            if len(next_siblings) > 1:
                next = next_siblings[0]
                if (isinstance(next, nodes.Text) and
                    next.astext() in (' ', '\n')):
                    if next_siblings[1].__class__ == node.__class__:
                        followup_citation = True
            if followup_citation:
                self.out.append(',')
            else:
                self.out.append('}')
                self.inside_citation_reference_label = False
        else:
            self.out.append(']}')
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def citation(self, match):
        src, srcline = self.state_machine.get_source_and_line()
        indented, indent, offset, blank_finish = \
              self.state_machine.get_first_known_indented(match.end())
        label = match.group(1)
        name = normalize_name(label)
        citation = nodes.citation('\n'.join(indented))
        citation.source = src
        citation.line = srcline
        citation += nodes.label('', label)
        citation['names'].append(name)
        self.document.note_citation(citation)
        self.document.note_explicit_target(citation, citation)
        if indented:
            self.nested_parse(indented, input_offset=offset, node=citation)
        return [citation], blank_finish
项目:RST-vscode    作者:tht13    | 项目源码 | 文件源码
def depart_citation_reference(self, node):
        if self._use_latex_citations:
            followup_citation = False
            # check for a following citation separated by a space or newline
            next_siblings = node.traverse(descend=False, siblings=True,
                                          include_self=False)
            if len(next_siblings) > 1:
                next = next_siblings[0]
                if (isinstance(next, nodes.Text) and
                    next.astext() in (' ', '\n')):
                    if next_siblings[1].__class__ == node.__class__:
                        followup_citation = True
            if followup_citation:
                self.out.append(',')
            else:
                self.out.append('}')
                self.inside_citation_reference_label = False
        else:
            self.out.append(']}')
项目:RST-vscode    作者:tht13    | 项目源码 | 文件源码
def citation(self, match):
        src, srcline = self.state_machine.get_source_and_line()
        indented, indent, offset, blank_finish = \
              self.state_machine.get_first_known_indented(match.end())
        label = match.group(1)
        name = normalize_name(label)
        citation = nodes.citation('\n'.join(indented))
        citation.source = src
        citation.line = srcline
        citation += nodes.label('', label)
        citation['names'].append(name)
        self.document.note_citation(citation)
        self.document.note_explicit_target(citation, citation)
        if indented:
            self.nested_parse(indented, input_offset=offset, node=citation)
        return [citation], blank_finish
项目:tf_aws_ecs_instance_draining_on_scale_in    作者:terraform-community-modules    | 项目源码 | 文件源码
def depart_citation_reference(self, node):
        if self._use_latex_citations:
            followup_citation = False
            # check for a following citation separated by a space or newline
            next_siblings = node.traverse(descend=False, siblings=True,
                                          include_self=False)
            if len(next_siblings) > 1:
                next = next_siblings[0]
                if (isinstance(next, nodes.Text) and
                    next.astext() in (' ', '\n')):
                    if next_siblings[1].__class__ == node.__class__:
                        followup_citation = True
            if followup_citation:
                self.out.append(',')
            else:
                self.out.append('}')
                self.inside_citation_reference_label = False
        else:
            self.out.append(']}')
项目:tf_aws_ecs_instance_draining_on_scale_in    作者:terraform-community-modules    | 项目源码 | 文件源码
def citation(self, match):
        src, srcline = self.state_machine.get_source_and_line()
        indented, indent, offset, blank_finish = \
              self.state_machine.get_first_known_indented(match.end())
        label = match.group(1)
        name = normalize_name(label)
        citation = nodes.citation('\n'.join(indented))
        citation.source = src
        citation.line = srcline
        citation += nodes.label('', label)
        citation['names'].append(name)
        self.document.note_citation(citation)
        self.document.note_explicit_target(citation, citation)
        if indented:
            self.nested_parse(indented, input_offset=offset, node=citation)
        return [citation], blank_finish
项目:pymotw3    作者:reingart    | 项目源码 | 文件源码
def visit_label(self, node):
        if isinstance(node.parent, nodes.citation):
            self.bibitems[-1][0] = node.astext()
            self.bibitems[-1][2] = self.curfilestack[-1]
            self.bibitems[-1][3] = node.parent['ids'][0]
        raise nodes.SkipNode
项目:sphinxcontrib-confluencebuilder    作者:tonybaloney    | 项目源码 | 文件源码
def depart_footnote(self, node):
        self.add_text('|%s' % self.nl)

        next_sibling = node.traverse(None, False, False, True)
        if not next_sibling or not isinstance(
                next_sibling[0], (nodes.citation, nodes.footnote)):
            self.end_state()
        else:
            self.end_state(end=None)
项目:sphinxcontrib-confluencebuilder    作者:tonybaloney    | 项目源码 | 文件源码
def visit_paragraph(self, node):
        if not isinstance(node.parent, (
                    nodes.Admonition,
                    nodes.citation,
                    nodes.entry,
                    nodes.footnote,
                    nodes.list_item,
                    addnodes.seealso,
                )):
            self.new_state(0)
项目:sphinxcontrib-confluencebuilder    作者:tonybaloney    | 项目源码 | 文件源码
def depart_paragraph(self, node):
        if isinstance(node.parent, nodes.list_item):
            self.add_text(self.nl)

        elif not isinstance(node.parent, (
                    nodes.Admonition,
                    nodes.citation,
                    nodes.entry,
                    nodes.footnote,
                    addnodes.seealso,
                )):
            self.end_state()
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def visit_label(self, node):
        # footnote and citation
        if (isinstance(node.parent, nodes.footnote)
            or isinstance(node.parent, nodes.citation)):
            raise nodes.SkipNode
        self.document.reporter.warning('"unsupported "label"',
                base_node=node)
        self.body.append('[')
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def visit_title_reference(self, node):
        """inline citation reference"""
        self.body.append(self.defs['title_reference'][0])
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def depart_caption(self, node):
        self.body.append('</p>\n')

    # citations
    # ---------
    # Use definition list instead of table for bibliographic references.
    # Join adjacent citation entries.
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def visit_citation(self, node):
        if not self.in_footnote_list:
            self.body.append('<dl class="citation">\n')
            self.in_footnote_list = True
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def depart_citation(self, node):
        self.body.append('</dd>\n')
        if not isinstance(node.next_node(descend=False, siblings=True),
                          nodes.citation):
            self.body.append('</dl>\n')
            self.in_footnote_list = False
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def depart_inline(self, node):
        self.body.append('</span>')

    # footnote and citation labels:
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def visit_label(self, node):
        if (isinstance(node.parent, nodes.footnote)):
            classes = self.settings.footnote_references
        else:
            classes = 'brackets'
        # pass parent node to get id into starttag:
        self.body.append(self.starttag(node.parent, 'dt', '', CLASS='label'))
        self.body.append(self.starttag(node, 'span', '', CLASS=classes))
        # footnote/citation backrefs:
        if self.settings.footnote_backlinks:
            backrefs = node.parent['backrefs']
            if len(backrefs) == 1:
                self.body.append('<a class="fn-backref" href="#%s">'
                                 % backrefs[0])
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def depart_footnote_reference(self, node):
        self.out.append(self.context.pop())

    # footnote/citation label
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def label_delim(self, node, bracket, superscript):
        if isinstance(node.parent, nodes.footnote):
            raise nodes.SkipNode
        else:
            assert isinstance(node.parent, nodes.citation)
            if not self._use_latex_citations:
                self.out.append(bracket)
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def visit_label(self, node):
        # footnote and citation
        if (isinstance(node.parent, nodes.footnote)
            or isinstance(node.parent, nodes.citation)):
            raise nodes.SkipNode
        self.document.reporter.warning('"unsupported "label"',
                base_node=node)
        self.body.append('[')
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def visit_title_reference(self, node):
        """inline citation reference"""
        self.body.append(self.defs['title_reference'][0])
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def depart_caption(self, node):
        self.body.append('</p>\n')

    # citations
    # ---------
    # Use definition list instead of table for bibliographic references.
    # Join adjacent citation entries.
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def visit_citation(self, node):
        if not self.in_footnote_list:
            self.body.append('<dl class="citation">\n')
            self.in_footnote_list = True
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def depart_citation(self, node):
        self.body.append('</dd>\n')
        if not isinstance(node.next_node(descend=False, siblings=True),
                          nodes.citation):
            self.body.append('</dl>\n')
            self.in_footnote_list = False
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def depart_inline(self, node):
        self.body.append('</span>')

    # footnote and citation labels:
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def visit_label(self, node):
        if (isinstance(node.parent, nodes.footnote)):
            classes = self.settings.footnote_references
        else:
            classes = 'brackets'
        # pass parent node to get id into starttag:
        self.body.append(self.starttag(node.parent, 'dt', '', CLASS='label'))
        self.body.append(self.starttag(node, 'span', '', CLASS=classes))
        # footnote/citation backrefs:
        if self.settings.footnote_backlinks:
            backrefs = node.parent['backrefs']
            if len(backrefs) == 1:
                self.body.append('<a class="fn-backref" href="#%s">'
                                 % backrefs[0])
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def depart_footnote_reference(self, node):
        self.out.append(self.context.pop())

    # footnote/citation label
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def label_delim(self, node, bracket, superscript):
        if isinstance(node.parent, nodes.footnote):
            raise nodes.SkipNode
        else:
            assert isinstance(node.parent, nodes.citation)
            if not self._use_latex_citations:
                self.out.append(bracket)
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def visit_label(self, node):
        # footnote and citation
        if (isinstance(node.parent, nodes.footnote)
            or isinstance(node.parent, nodes.citation)):
            raise nodes.SkipNode
        self.document.reporter.warning('"unsupported "label"',
                base_node=node)
        self.body.append('[')
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def visit_title_reference(self, node):
        """inline citation reference"""
        self.body.append(self.defs['title_reference'][0])
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def depart_footnote_reference(self, node):
        self.out.append(self.context.pop())

    # footnote/citation label
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def label_delim(self, node, bracket, superscript):
        if isinstance(node.parent, nodes.footnote):
            if not self.figure_footnotes:
                raise nodes.SkipNode
            if self.settings.footnote_references == 'brackets':
                self.out.append(bracket)
            else:
                self.out.append(superscript)
        else:
            assert isinstance(node.parent, nodes.citation)
            if not self._use_latex_citations:
                self.out.append(bracket)
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def note_citations_from(self, docname, document):
        for node in document.traverse(nodes.citation):
            label = node[0].astext()
            if label in self.citations:
                self.warn_node('duplicate citation %s, ' % label +
                               'other instance in %s' % self.doc2path(
                                   self.citations[label][0]), node)
            self.citations[label] = (docname, node['ids'][0])
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def _warn_missing_reference(self, refdoc, typ, target, node, domain):
        warn = node.get('refwarn')
        if self.config.nitpicky:
            warn = True
            if self._nitpick_ignore:
                dtype = domain and '%s:%s' % (domain.name, typ) or typ
                if (dtype, target) in self._nitpick_ignore:
                    warn = False
                # for "std" types also try without domain name
                if (not domain or domain.name == 'std') and \
                   (typ, target) in self._nitpick_ignore:
                    warn = False
        if not warn:
            return
        if domain and typ in domain.dangling_warnings:
            msg = domain.dangling_warnings[typ]
        elif typ == 'doc':
            msg = 'unknown document: %(target)s'
        elif typ == 'citation':
            msg = 'citation not found: %(target)s'
        elif node.get('refdomain', 'std') not in ('', 'std'):
            msg = '%s:%s reference target not found: %%(target)s' % \
                  (node['refdomain'], typ)
        else:
            msg = '%r reference target not found: %%(target)s' % typ
        self.warn_node(msg % {'target': target}, node)
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def visit_label(self, node):
        if isinstance(node.parent, nodes.citation):
            self.bibitems[-1][0] = node.astext()
            self.bibitems[-1][2] = self.curfilestack[-1]
            self.bibitems[-1][3] = node.parent['ids'][0]
        raise nodes.SkipNode
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def visit_label(self, node):
        # footnote and citation
        if (isinstance(node.parent, nodes.footnote)
            or isinstance(node.parent, nodes.citation)):
            raise nodes.SkipNode
        self.document.reporter.warning('"unsupported "label"',
                base_node=node)
        self.body.append('[')
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def visit_title_reference(self, node):
        """inline citation reference"""
        self.body.append(self.defs['title_reference'][0])
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def depart_caption(self, node):
        self.body.append('</p>\n')

    # citations
    # ---------
    # Use definition list instead of table for bibliographic references.
    # Join adjacent citation entries.
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def visit_citation(self, node):
        if not self.in_footnote_list:
            self.body.append('<dl class="citation">\n')
            self.in_footnote_list = True
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def depart_citation(self, node):
        self.body.append('</dd>\n')
        if not isinstance(node.next_node(descend=False, siblings=True),
                          nodes.citation):
            self.body.append('</dl>\n')
            self.in_footnote_list = False
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def depart_inline(self, node):
        self.body.append('</span>')

    # footnote and citation labels:
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def visit_label(self, node):
        if (isinstance(node.parent, nodes.footnote)):
            classes = self.settings.footnote_references
        else:
            classes = 'brackets'
        # pass parent node to get id into starttag:
        self.body.append(self.starttag(node.parent, 'dt', '', CLASS='label'))
        self.body.append(self.starttag(node, 'span', '', CLASS=classes))
        # footnote/citation backrefs:
        if self.settings.footnote_backlinks:
            backrefs = node.parent['backrefs']
            if len(backrefs) == 1:
                self.body.append('<a class="fn-backref" href="#%s">'
                                 % backrefs[0])
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def depart_footnote_reference(self, node):
        self.out.append(self.context.pop())

    # footnote/citation label
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def label_delim(self, node, bracket, superscript):
        if isinstance(node.parent, nodes.footnote):
            raise nodes.SkipNode
        else:
            assert isinstance(node.parent, nodes.citation)
            if not self._use_latex_citations:
                self.out.append(bracket)