How to use the docutils.nodes.Text function in docutils

To help you get started, we’ve selected a few docutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trueos / sysadm / docs / api_reference / conf.py View on Github external
spans = _amp_re.split(text)  

    node = nodes.literal(rawtext=rawtext)
    for i, span in enumerate(spans):
        span = span.replace('&&', '&')
        if i == 0:
            if len(span) > 0:
                textnode = nodes.Text(span)
                node += textnode
            continue
        accel_node = nodes.inline()
        letter_node = nodes.Text(span[0])
        accel_node += letter_node
        accel_node['classes'].append('accelerator')
        node += accel_node
        textnode = nodes.Text(span[1:])
        node += textnode

    node['classes'].append(typ)
    return [node], []
github readthedocs / sphinxcontrib-dotnetdomain / sphinxcontrib / dotnetdomain.py View on Github external
prefix, target_name = target_name[0], target_name[1:]
                if prefix == '.':
                    target_alias = target_name[1:]
                elif prefix == '~':
                    target_alias = target_name.split('.')[-1]
            if target_alias is None:
                target_alias = target_name
            ref_node = addnodes.pending_xref(
                '',
                refdomain=domain,
                refexplicit=False,
                reftype=rolename,
                reftarget=target_alias,
                refspecific=True,
            )
            ref_node += nodes.Text(target_name, target_name)
            if field_node is None:
                field_node = nodes.inline()
                field_node += ref_node
            else:
                inner_node = field_node
                field_node = nodes.inline()
                field_node += [
                    ref_node,
                    nodes.Text('<', '<'),
                    inner_node,
                    nodes.Text('>', '>'),
                ]

        return innernode('', '', field_node)
github sympy / sphinx-math-dollar / sphinx_math_dollar / extension.py View on Github external
parent = node.parent
        while parent:
            if isinstance(parent, node_blacklist):
                if DEBUG and any(i == 'math' for i, _ in split_dollars(node.rawsource)):
                    print("sphinx-math-dollar: Skipping", node, "(node_blacklist = %s)" % (node_blacklist,), file=sys.stderr)
                return
            parent = parent.parent
        data = split_dollars(node.rawsource)
        nodes = []
        has_math = False
        for typ, text in data:
            if typ == "math":
                has_math = True
                nodes.append(math(text, Text(text)))
            elif typ == "text":
                nodes.append(Text(text))
            elif typ == "display math":
                has_math = True
                new_node = math_block(text, Text(text))
                new_node.attributes.setdefault('nowrap', False)
                new_node.attributes.setdefault('number', None)
                nodes.append(new_node)
            else:
                raise ValueError("Unrecognized type from split_dollars %r" % typ)
        if has_math:
            node.parent.replace(node, nodes)
github genn-team / genn / docs / sphinx / doxyrest.py View on Github external
def create_xref_node(raw_text, text, target):
    if not target:
        return nodes.Text(text, text)

    node = addnodes.pending_xref(raw_text)
    node['reftype'] = 'ref'
    node['refdomain'] = 'std'
    node['reftarget'] = target
    node['refwarn'] = True
    node['refexplicit'] = True
    node += nodes.Text(text, text)
    return node
github sqlalchemy / alembic / docs / build / ext / changelog.py View on Github external
insert_ticket = nodes.paragraph('')
        para.append(insert_ticket)

        i = 0
        for collection, render, prefix in (
                (rec['tickets'], self.env.config.changelog_render_ticket, "#%s"),
                (rec['pullreq'], self.env.config.changelog_render_pullreq,
                                            "pull request %s"),
                (rec['changeset'], self.env.config.changelog_render_changeset, "r%s"),
            ):
            for refname in collection:
                if i > 0:
                    insert_ticket.append(nodes.Text(", ", ", "))
                else:
                    insert_ticket.append(nodes.Text(" ", " "))
                i += 1
                if render is not None:
                    refuri = render % refname
                    node = nodes.reference('', '',
                            nodes.Text(prefix % refname, prefix % refname),
                            refuri=refuri
                        )
                else:
                    node = nodes.Text(prefix % refname, prefix % refname)
                insert_ticket.append(node)

        if rec['tags']:
            tag_node = nodes.strong('',
                        " ".join("[%s]" % t for t
                            in
                                [t1 for t1 in [section, cat]
github scrapinghub / python-scrapinghub / docs / conf.py View on Github external
def handle_item(fieldarg, content):
        par = nodes.paragraph()
        par += addnodes.literal_strong('', fieldarg)  # Patch: this line added
        # par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
        #                           addnodes.literal_strong))
        if fieldarg in types:
            par += nodes.Text(' (')
            # NOTE: using .pop() here to prevent a single type node to be
            # inserted twice into the doctree, which leads to
            # inconsistencies later when references are resolved
            fieldtype = types.pop(fieldarg)
            if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
                typename = u''.join(n.astext() for n in fieldtype)
                par.extend(self.make_xrefs(self.typerolename, domain, typename,
                                           addnodes.literal_emphasis))
            else:
                par += fieldtype
            par += nodes.Text(')')
        par += nodes.Text(' -- ')
        par += content
        return par
github uthcode / learntosolveit / languages / python / trackerlink.py View on Github external
#XXX: the crossref stuff is a bit bogus, needs fixed
        links = sorted(env.trackerlink_all_links,
                       key=operator.attrgetter('issue'))
        for link in links:
            if link.issue!=this:
                if para: content.append(para)
                this = link.issue
                count = 1
                para = docutils.nodes.paragraph()
                #TODO: make this strikethrough or not styling.
                para += docutils.nodes.reference(link.issue, link.issue,
                    refuri=link.ref)
                titletext = ' %s: ' % link.title
                if link.status=='2':
                    titletext += '(closed) '
                para += docutils.nodes.Text(titletext, titletext)
            if count>1:
                para += docutils.nodes.Text(', ', ', ')
            reftext = "%s %s" % (link.docname, link.lineno)
            newnode = docutils.nodes.reference(reftext, reftext)
            newnode['refdocname'] = link.docname
            newnode['refuri'] = app.builder.get_relative_uri(
                fromdocname, link.docname)
            #XXX: refid is an unknown name, so far, so the links are bogus too
            #newnode['refuri'] += '#' + link.target['refid']
            para += newnode
            count += 1
        if para: content.append(para)
        node.replace_self(content)
github useblocks / sphinxcontrib-needs / sphinxcontrib / needs / directives / utils.py View on Github external
def no_needs_found_paragraph():
    nothing_found = "No needs passed the filters"
    para = nodes.paragraph()
    nothing_found_node = nodes.Text(nothing_found, nothing_found)
    para += nothing_found_node
    return para
github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / sphinx / writers / latex.py View on Github external
def create_footnote(self, uri):
        label = nodes.label('', '#')
        para = nodes.paragraph()
        para.append(nodes.reference('', nodes.Text(uri), refuri=uri, nolinkurl=True))
        footnote = nodes.footnote(uri, label, para, auto=1)
        footnote['names'].append('#')
        self.document.note_autofootnote(footnote)

        label = nodes.Text('#')
        footnote_ref = nodes.footnote_reference('[#]_', label, auto=1,
                                                refid=footnote['ids'][0])
        self.document.note_autofootnote_ref(footnote_ref)
        footnote.add_backref(footnote_ref['ids'][0])

        return [footnote, footnote_ref]
github sqlalchemy / sqlalchemy / doc / build / builder / changelog.py View on Github external
def make_ticket_link(name, rawtext, text, lineno, inliner,
                      options={}, content=[]):
    env = inliner.document.settings.env
    render_ticket = env.config.changelog_render_ticket or "%s"
    prefix = "#%s"
    if render_ticket:
        ref = render_ticket % text
        node = nodes.reference(rawtext, prefix % text, refuri=ref, **options)
    else:
        node = nodes.Text(prefix % text, prefix % text)
    return [node], []