当前位置: 首页>>代码示例>>Python>>正文


Python nodes.inline方法代码示例

本文整理汇总了Python中docutils.nodes.inline方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.inline方法的具体用法?Python nodes.inline怎么用?Python nodes.inline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docutils.nodes的用法示例。


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

示例1: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def run(self):
        idb = nodes.make_id("emva1288-" + self.options['section'])
        section = nodes.section(ids=[idb])
        section += nodes.rubric(text='Emva1288')
        lst = nodes.bullet_list()

        for k in self.option_spec.keys():
            if k not in self.options:
                continue

            item = nodes.list_item()
            item += nodes.strong(text=k + ':')
            item += nodes.inline(text=' ' + self.options[k])
            lst += item
        section += lst
        return [section] 
开发者ID:EMVA1288,项目名称:emva1288,代码行数:18,代码来源:sphinx_directives.py

示例2: label_ref_node

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def label_ref_node(docname, ref_to, title):
    """Generate a node that references a label"""
    txt = Text(title, rawsource=title)
    newchild = inline(
        ':ref:`%s`' % ref_to,
        '',
        txt,
        classes=['xref', 'std', 'std-ref']
    )
    newnode = pending_xref(
        ':ref:`%s`' % ref_to,
        newchild,
        reftype='ref',
        refwarn='True',
        reftarget=ref_to,
        refexplicit='False',
        refdomain='std',
        refdoc=docname
    )
    return newnode 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:22,代码来源:conf.py

示例3: meta_id

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def meta_id(self):
        """
        Returns the current need id as clickable and linked reference.

        Usage::

            <<meta_id()>>

        :return: docutils node
        """
        from sphinx.util.nodes import make_refnode
        id_container = nodes.inline(classes=["needs-id"])

        nodes_id_text = nodes.Text(self.need['id'], self.need['id'])
        id_ref = make_refnode(self.app.builder,
                              # fromdocname=self.need['docname'],
                              fromdocname=self.fromdocname,
                              todocname=self.need['docname'],
                              targetid=self.need['id'],
                              child=nodes_id_text.deepcopy(),
                              title=self.need['id'])
        id_container += id_ref
        return id_container 
开发者ID:useblocks,项目名称:sphinxcontrib-needs,代码行数:25,代码来源:layout.py

示例4: pmid_reference_role

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def pmid_reference_role(role, rawtext, text, lineno, inliner,
                        options={}, content=[]):
    try:
        pmid = int(text)
        if pmid <= 0:
            raise ValueError
    except ValueError:
        msg = inliner.reporter.error(
            'pmid number must be a number greater than or equal to 1; '
            '"%s" is invalid.' % text, line=lineno)
        prb = inliner.problematic(rawtext, rawtext, msg)
        return [prb], [msg]
    ref = pubmed_uri_pattern % pmid
    nodelist = []
    nodelist.append(nodes.inline(text='PMID:'))
    nodelist.append(nodes.reference(rawtext, utils.unescape(text), refuri=ref,
                                    **options))
    return nodelist, [] 
开发者ID:sorgerlab,项目名称:indra,代码行数:20,代码来源:citations.py

示例5: make_target_footnote

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def make_target_footnote(self, refuri, refs, notes):
        if refuri in notes:  # duplicate?
            footnote = notes[refuri]
            assert len(footnote['names']) == 1
            footnote_name = footnote['names'][0]
        else:                           # original
            footnote = nodes.footnote()
            footnote_id = self.document.set_id(footnote)
            # Use uppercase letters and a colon; they can't be
            # produced inside names by the parser.
            footnote_name = 'TARGET_NOTE: ' + footnote_id
            footnote['auto'] = 1
            footnote['names'] = [footnote_name]
            footnote_paragraph = nodes.paragraph()
            footnote_paragraph += nodes.reference('', refuri, refuri=refuri)
            footnote += footnote_paragraph
            self.document.note_autofootnote(footnote)
            self.document.note_explicit_target(footnote, footnote)
        for ref in refs:
            if isinstance(ref, nodes.target):
                continue
            refnode = nodes.footnote_reference(refname=footnote_name, auto=1)
            refnode['classes'] += self.classes
            self.document.note_autofootnote_ref(refnode)
            self.document.note_footnote_ref(refnode)
            index = ref.parent.index(ref) + 1
            reflist = [refnode]
            if not utils.get_trim_footnote_ref_space(self.document.settings):
                if self.classes:
                    reflist.insert(0, nodes.inline(text=' ', Classes=self.classes))
                else:
                    reflist.insert(0, nodes.Text(' '))
            ref.parent.insert(index, reflist)
        return footnote 
开发者ID:skarlekar,项目名称:faces,代码行数:36,代码来源:references.py

示例6: generic_custom_role

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def generic_custom_role(role, rawtext, text, lineno, inliner,
                        options={}, content=[]):
    """"""
    # 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)], [] 
开发者ID:skarlekar,项目名称:faces,代码行数:9,代码来源:roles.py

示例7: code_role

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def code_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
    set_classes(options)
    language = options.get('language', '')
    classes = ['code']
    if 'classes' in options:
        classes.extend(options['classes'])
    if language and language not in classes:
        classes.append(language)
    try:
        tokens = Lexer(utils.unescape(text, 1), language,
                       inliner.document.settings.syntax_highlight)
    except LexerError as error:
        msg = inliner.reporter.warning(error)
        prb = inliner.problematic(rawtext, rawtext, msg)
        return [prb], [msg]

    node = nodes.literal(rawtext, '', classes=classes)

    # analyse content and add nodes for every token
    for classes, value in tokens:
        # print (classes, value)
        if classes:
            node += nodes.inline(value, value, classes=classes)
        else:
            # insert as Text to decrease the verbosity of the output
            node += nodes.Text(value, value)

    return [node], [] 
开发者ID:skarlekar,项目名称:faces,代码行数:30,代码来源:roles.py

示例8: make_field

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def make_field(self, types, domain, item, env=None):
        fieldname = nodes.field_name('', self.label)
        backref = addnodes.pending_xref(
            '',
            refdomain="conda",
            reftype='requiredby', refexplicit=False,
            reftarget=env.ref_context['conda:package'],
            refdoc=env.docname
        )
        backref += nodes.inline('', '')
        fieldbody = nodes.field_body('', backref)
        return nodes.field('', fieldname, fieldbody) 
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:14,代码来源:sphinxext.py

示例9: create_node

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def create_node(env, relative_path, show_button):
    """
    Creates documentation node for example include.

    :param env: environment of the documentation
    :param relative_path: path of the code
    :param show_button: whether to show "view code" button
    :return paragraph with the node
    """
    pagename = "_modules/" + relative_path[:-3]

    header_classes = ["example-header"]
    if show_button:
        header_classes += ["example-header--with-button"]
    paragraph = nodes.paragraph(relative_path, classes=header_classes)
    paragraph += nodes.inline("", relative_path, classes=["example-title"])
    if show_button:
        pending_ref = addnodes.pending_xref(
            "",
            reftype="viewcode",
            refdomain="std",
            refexplicit=False,
            reftarget=pagename,
            refid="",
            refdoc=env.docname,
            classes=["example-header-button viewcode-button"],
        )
        pending_ref += nodes.inline("", _("View Source"))
        paragraph += pending_ref

    return paragraph


# noinspection PyProtectedMember
# pylint: disable=protected-access 
开发者ID:apache,项目名称:airflow,代码行数:37,代码来源:exampleinclude.py

示例10: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def run(self):
        head = nodes.paragraph()
        head.append(nodes.inline("Wraps API:", "Wraps API: "))

        source = '\n'.join(self.content.data)
        literal_node = nodes.literal_block(source, source)
        literal_node['laguage'] = 'C++'

        return [head, literal_node] 
开发者ID:swistakm,项目名称:pyimgui,代码行数:11,代码来源:custom_directives.py

示例11: _parse

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def _parse(self, line):
        """
        Parses a single line/string for inline rst statements, like strong, emphasis, literal, ...

        :param line: string to parse
        :return: nodes
        """
        inline_parser = Inliner()
        inline_parser.init_customizations(self.doc_settings)
        result, message = inline_parser.parse(line, 0, self.doc_memo, self.dummy_doc)
        if message:
            raise SphinxNeedLayoutException(message)
        return result 
开发者ID:useblocks,项目名称:sphinxcontrib-needs,代码行数:15,代码来源:layout.py

示例12: numdoc_role

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def numdoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    """Role for making latex ref to the doc head."""
    env = inliner.document.settings.env
    
    text = utils.unescape(text)
    has_explicit, title, target = split_explicit_title(text)
    
    pnode = nodes.inline(rawtext, title, classes=['xref','doc'])
    pnode['reftarget'] = target

    return [pnode], [] 
开发者ID:future-architect,项目名称:typescript-guide,代码行数:13,代码来源:numdoc.py

示例13: doi_reference_role

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import inline [as 别名]
def doi_reference_role(role, rawtext, text, lineno, inliner,
                       options={}, content=[]):
    ref = doi_uri_pattern % text
    nodelist = []
    nodelist.append(nodes.inline(text='doi:'))
    nodelist.append(nodes.reference(rawtext, utils.unescape(text), refuri=ref,
                                    **options))
    return nodelist, [] 
开发者ID:sorgerlab,项目名称:indra,代码行数:10,代码来源:citations.py


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