How to use the docutils.nodes.emphasis 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 sphinx-doc / sphinx / tests / test_ext_intersphinx.py View on Github external
def fake_node(domain, type, target, content, **attrs):
    contnode = nodes.emphasis(content, content)
    node = addnodes.pending_xref('')
    node['reftarget'] = target
    node['reftype'] = type
    node['refdomain'] = domain
    node.attributes.update(attrs)
    node += contnode
    return node, contnode
github project-fifo / docs / _extensions / httpdomain.py View on Github external
def resolve_xref(self, env, fromdocname, builder, typ, target,
                     node, contnode):
        try:
            info = self.data[str(typ)][target]
        except KeyError:
            text = contnode.rawsource
            role = self.roles.get(typ)
            if role is None:
                return nodes.emphasis(text, text)
            resnode = role.result_nodes(env.get_doctree(fromdocname),
                                        env, node, None)[0][0]
            if isinstance(resnode, addnodes.pending_xref):
                text = node[0][0]
                reporter = env.get_doctree(fromdocname).reporter
                reporter.error('Cannot resolve reference to %r' % text,
                               line=node.line)
                return nodes.problematic(text, text)
            return resnode
        else:
            anchor = http_resource_anchor(typ, target)
            title = typ.upper() + ' ' + target
            return make_refnode(builder, fromdocname, info[0], anchor,
                                contnode, title)
github RedpointGames / Protogame / Protogame.Docs / _ext / netxml.py View on Github external
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, ""
github zopefoundation / Zope / lib / python / docutils / parsers / rst / states.py View on Github external
'rfc-reference': 'rfc_reference_role',
        'footnote-reference': None,
        'citation-reference': None,
        'substitution-reference': None,
        'target': None,
        'restructuredtext-unimplemented-role': None}
    """Mapping of canonical interpreted text role name to method name.
    Initializes a name to bound-method mapping in `__init__`."""

    default_interpreted_role = 'title-reference'
    """The role to use when no explicit role is given.
    Override in subclasses."""

    generic_roles = {'abbreviation': nodes.abbreviation,
                     'acronym': nodes.acronym,
                     'emphasis': nodes.emphasis,
                     'literal': nodes.literal,
                     'strong': nodes.strong,
                     'subscript': nodes.subscript,
                     'superscript': nodes.superscript,
                     'title-reference': nodes.title_reference,}
    """Mapping of canonical interpreted text role name to node class.
    Used by the `generic_interpreted_role` method for simple, straightforward
    roles (simple wrapping; no extra processing)."""

    def __init__(self, roles=None):
        """
        `roles` is a mapping of canonical role name to role function or bound
        method, which enables additional interpreted text roles.
        """

        self.implicit_dispatch = [(self.patterns.uri, self.standalone_uri),]
github DLR-SC / F2x / doc / contrib / ext / sphinxfortran / fortran_domain.py View on Github external
    def make_xref(self, rolename, domain, target, innernode=nodes.emphasis,
        modname=None, typename=None):
        if not rolename:
            return innernode(target, target)
        refnode = addnodes.pending_xref('', refdomain=domain, refexplicit=False,
                                        reftype=rolename, reftarget=target,
                                        modname=modname, typename=typename)
        refnode += innernode(target, target)
        return refnode
github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / sphinx / builders / latex.py View on Github external
largetree = inline_all_toctrees(self, self.docnames, indexfile, tree,
                                        darkgreen, [indexfile])
        largetree['docname'] = indexfile
        for docname in appendices:
            appendix = self.env.get_doctree(docname)
            appendix['docname'] = docname
            largetree.append(appendix)
        self.info()
        self.info("resolving references...")
        self.env.resolve_references(largetree, indexfile, self)
        # resolve :ref:s to distant tex files -- we can't add a cross-reference,
        # but append the document name
        for pendingnode in largetree.traverse(addnodes.pending_xref):
            docname = pendingnode['refdocname']
            sectname = pendingnode['refsectname']
            newnodes = [nodes.emphasis(sectname, sectname)]
            for subdir, title in self.titles:
                if docname.startswith(subdir):
                    newnodes.append(nodes.Text(_(' (in '), _(' (in ')))
                    newnodes.append(nodes.emphasis(title, title))
                    newnodes.append(nodes.Text(')', ')'))
                    break
            else:
                pass
            pendingnode.replace_self(newnodes)
        return largetree
github genn-team / genn / docs / sphinx / doxyrest.py View on Github external
self.state.document.settings.env.config.doxyrest_tab_width
        return Include.run(self)


#...............................................................................
#
#  Sphinx transforms
#

class RefTransform(Transform):
    default_priority = 100

    node_classes = {
        nodes.literal,
        nodes.strong,
        nodes.emphasis
    }

    def __init__(self, document, startnode=None):
        Transform.__init__(self, document, startnode)

        re_src = '(:c?ref:)'
        if document.settings.env.config.default_role == 'cref':
            re_src += '?' # explicit role is optional

        re_src += '`(.+?)(\s*<([^<>]*)>)?`'
        self.re_prog = re.compile(re_src)

    @staticmethod
    def node_filter(node):
        for node_class in RefTransform.node_classes:
            if isinstance (node, node_class):
github jschementi / iron-websites / docutils / build / lib / docutils / parsers / rst / roles.py View on Github external
""""""
    # Once nested inline markup is implemented, this and other methods should
    # recursively call inliner.nested_parse().
    set_classes(options)
    return [nodes.inline(rawtext, utils.unescape(text), **options)], []

generic_custom_role.options = {'class': directives.class_option}


######################################################################
# Define and register the standard roles:
######################################################################

register_generic_role('abbreviation', nodes.abbreviation)
register_generic_role('acronym', nodes.acronym)
register_generic_role('emphasis', nodes.emphasis)
register_generic_role('literal', nodes.literal)
register_generic_role('strong', nodes.strong)
register_generic_role('subscript', nodes.subscript)
register_generic_role('superscript', nodes.superscript)
register_generic_role('title-reference', nodes.title_reference)

def pep_reference_role(role, rawtext, text, lineno, inliner,
                       options={}, content=[]):
    try:
        pepnum = int(text)
        if pepnum < 0 or pepnum > 9999:
            raise ValueError
    except ValueError:
        msg = inliner.reporter.error(
            'PEP number must be a number from 0 to 9999; "%s" is invalid.'
            % text, line=lineno)
github VACUMM / sphinx-fortran / sphinxfortran / fortran_domain.py View on Github external
domain,
                                  fieldarg,
                                  self.namefmt,
                                  modname=modname,
                                  typename=typename)
            #par += self.namefmt(fieldarg, fieldarg)

            fieldtype = types.pop(fieldarg, None)
            fieldshape = shapes and shapes.pop(fieldarg, None)
            fieldattrs = attrs and attrs.pop(fieldarg, None)
            if fieldshape:
                shape = parse_shape(fieldshape[0].astext())
                #par += nodes.Text(' %s'%shape)
                add_shape(par, shape, modname=modname)
            if fieldtype or fieldattrs:
                par += nodes.emphasis(' [', ' [')
            if fieldtype:
                if len(fieldtype) == 1 and isinstance(
                        fieldtype[0], nodes.Text):
                    thistypename = fieldtype[0].astext()
                    #typename = u''.join(n.astext() for n in fieldtype)
                    par += self.make_xref(self.typerolename,
                                          domain,
                                          thistypename,
                                          modname=modname,
                                          typename=typename)
                else:
                    par += fieldtype
            if fieldattrs:
                if fieldtype:
                    par += nodes.emphasis(',', ',')
                par += fieldattrs
github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / sphinx / addnodes.py View on Github external
information about all documents.

    These nodes are resolved before writing output, in
    BuildEnvironment.resolve_references.
    """


class number_reference(nodes.reference):
    """Node for number references, similar to pending_xref."""


class download_reference(nodes.reference):
    """Node for download references, similar to pending_xref."""


class literal_emphasis(nodes.emphasis):
    """Node that behaves like `emphasis`, but further text processors are not
    applied (e.g. smartypants for HTML output).
    """


class literal_strong(nodes.strong):
    """Node that behaves like `strong`, but further text processors are not
    applied (e.g. smartypants for HTML output).
    """


class abbreviation(nodes.Inline, nodes.TextElement):
    """Node for abbreviations with explanations."""


class termsep(nodes.Structural, nodes.Element):