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


Python nodes.make_id方法代码示例

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


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

示例1: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def run(self):
        set_classes(self.options)
        self.assert_has_content()
        text = '\n'.join(self.content)
        admonition_node = self.node_class(text, **self.options)
        self.add_name(admonition_node)
        if self.node_class is nodes.admonition:
            title_text = self.arguments[0]
            textnodes, messages = self.state.inline_text(title_text,
                                                         self.lineno)
            title = nodes.title(title_text, '', *textnodes)
            title.source, title.line = (
                    self.state_machine.get_source_and_line(self.lineno))
            admonition_node += title
            admonition_node += messages
            if not 'classes' in self.options:
                admonition_node['classes'] += ['admonition-' +
                                               nodes.make_id(title_text)]
        self.state.nested_parse(self.content, self.content_offset,
                                admonition_node)
        return [admonition_node] 
开发者ID:skarlekar,项目名称:faces,代码行数:23,代码来源:admonitions.py

示例2: class_option

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def class_option(argument):
    """
    Convert the argument into a list of ID-compatible strings and return it.
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    """
    if argument is None:
        raise ValueError('argument required but none supplied')
    names = argument.split()
    class_names = []
    for name in names:
        class_name = nodes.make_id(name)
        if not class_name:
            raise ValueError('cannot make "%s" into a class name' % name)
        class_names.append(class_name)
    return class_names 
开发者ID:skarlekar,项目名称:faces,代码行数:19,代码来源:__init__.py

示例3: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [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

示例4: make_admonition

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def make_admonition(node_class, name, arguments, options, content, lineno,
                    content_offset, block_text, state, state_machine):
    text = '\n'.join(content)
    admonition_node = node_class(text)
    if arguments:
        title_text = arguments[0]
        textnodes, messages = state.inline_text(title_text, lineno)
        admonition_node += nodes.title(title_text, '', *textnodes)
        admonition_node += messages
        if 'class' in options:
            classes = options['class']
        else:
            classes = ['admonition-' + nodes.make_id(title_text)]
        admonition_node['classes'] += classes
    state.nested_parse(content, content_offset, admonition_node)
    return [admonition_node] 
开发者ID:future-architect,项目名称:typescript-guide,代码行数:18,代码来源:customenv.py

示例5: _init

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def _init(self, name: str, qualified_type_name: str):
        self._node_id = nodes.make_id(nodes.fully_normalize_name(name))
        self._node = ModelElementNode(ids=[self._node_id])
        self._parse_msgs = []
        self._target = nodes.target()
        self.state.add_target(self._node_id, '', self._target, self.lineno)

        ## add node to index
        name_in_index = 'ModelElement; ' + name
        target_anchor = self._node_id

        self._indexnode = addnodes.index()
        self._indexnode['entries'] = ne = []
        self._indexnode['inline'] = False
        set_source_info(self, self._indexnode)
        ne.extend(process_index_entry(name_in_index, target_anchor))

        self._model_element_type = reflectionutil.model_element_type(
            qualified_type_name=qualified_type_name,
        ) 
开发者ID:gardener,项目名称:cc-utils,代码行数:22,代码来源:model_element.py

示例6: _create_section

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def _create_section(self, parent, sectionid, title=None, term=None):
        """Create a new section

        :returns: If term is specified, returns a definition node contained
        within the newly created section.  Otherwise return the newly created
        section node.
        """

        idb = nodes.make_id(sectionid)
        section = nodes.section(ids=[idb])
        parent.append(section)

        if term:
            if term != '**':
                section.append(nodes.term('', term))

            definition = nodes.definition()
            section.append(definition)

            return definition

        if title:
            section.append(nodes.title('', title))

        return section 
开发者ID:openstack,项目名称:senlin,代码行数:27,代码来源:resources.py

示例7: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def run(self):
        if not hasattr(self.env, 'bioconda_lint_checks'):
            self.env.bioconda_lint_checks = {str(check): check for check in get_checks()}
        # gather data
        check_name = self.arguments[0]
        if check_name not in self.env.bioconda_lint_checks:
            self.error("Duplicate lint description")
        check = self.env.bioconda_lint_checks.pop(check_name)
        _, lineno = inspect.getsourcelines(check)
        lineno += 1
        fname = inspect.getfile(check)
        doclines = inspect.getdoc(check).splitlines()
        docline_src = [(fname, i)
                       for i in range(lineno, lineno+len(doclines))]
        lines = StringList(doclines, items=docline_src)

        # create a new section with title
        section = nodes.section(ids=[nodes.make_id(check_name)])
        title_text = f'":py:class:`{check_name}`"'
        title_nodes, messages = self.state.inline_text(title_text, self.lineno)
        title = nodes.title(check_name, '', *title_nodes)
        section += title

        admonition = nodes.admonition()
        title_text = doclines[0].rstrip('.')
        title_nodes, messages = self.state.inline_text(title_text, lineno)
        title = nodes.title(title_text, '', *title_nodes)
        admonition += title
        admonition += messages
        self.state.nested_parse(lines[1:], 0, admonition)
        section += admonition

        # add remaining content of directive
        par = nodes.paragraph()
        self.state.nested_parse(self.content, self.content_offset, par)
        section += par

        return [section] 
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:40,代码来源:sphinxext.py

示例8: run

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def run(self):
        form_field = self.arguments[0]
        deonticity = validate_deonticity_choice(self.arguments[1])

        section = nodes.section(ids=nodes.make_id('formfield'))
        section += nodes.title(form_field)
        section += nodes.paragraph(self.content)

        return [section] 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:11,代码来源:formfield_extension.py

示例9: _section_block

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def _section_block(title, text=None):
        section = nodes.section(
            title,
            nodes.title(text=title),
            ids=[nodes.make_id('-'.join(title))],
        )
        if text:
            section_body = nodes.field_body()
            section_body.append(nodes.paragraph(text=text))
            section.append(section_body)

        return section 
开发者ID:openstack,项目名称:tripleo-validations,代码行数:14,代码来源:ansible-autodoc.py

示例10: _generate_nodes

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def _generate_nodes(self, name, command, parent=None, options={}):
        """Generate the relevant Sphinx nodes.
        Format a `click.Group` or `click.Command`.
        :param name: Name of command, as used on the command line
        :param command: Instance of `click.Group` or `click.Command`
        :param parent: Instance of `click.Context`, or None
        :param show_nested: Whether subcommands should be included in output
        :returns: A list of nested docutil nodes
        """

        # Title
        source_name = name
        content = [nodes.title(text=name)]
        subtitle = self.options.get('subtitle', None)
        description = self.options.get('description', None)

        if subtitle:
            content.append(nodes.subtitle(text=subtitle))
        if description:
            content.append(nodes.paragraph(text=description))

        section = nodes.section(
            '',
            *content,
            ids=[nodes.make_id(source_name)],
            names=[nodes.fully_normalize_name(source_name)])

        # Summary

        result = statemachine.ViewList()
        lines = _format_command(name, command, **options)
        for line in lines:
            result.append(line, source_name)
        self.state.nested_parse(result, 0, section)

        return [section] 
开发者ID:sdss,项目名称:marvin,代码行数:38,代码来源:docudatamodel.py

示例11: trait_node_id_from_trait_name

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def trait_node_id_from_trait_name(trait_name:str):
    return nodes.make_id(nodes.fully_normalize_name(f'trait-{trait_name}')) 
开发者ID:gardener,项目名称:cc-utils,代码行数:4,代码来源:trait.py

示例12: genindex_nodes

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def genindex_nodes(genindexentries):
    indexlabel = _('Index')
    indexunder = '=' * len(indexlabel)
    output = ['DUMMY', '=====', '.. _genindex:\n\n', indexlabel, indexunder, '']

    for key, entries in genindexentries:
        output.append('.. cssclass:: heading4\n\n%s\n\n' % key)  # initial
        for entryname, entryvalue in entries:
            links, subitems = entryvalue[0:2]
            if links:
                output.append('`%s <#%s>`_' % (entryname, nodes.make_id(links[0][1])))
                for i, link in enumerate(links[1:]):
                    output[-1] += ' `[%s] <#%s>`_ ' % (i + 1, nodes.make_id(link[1]))
                output.append('')
            else:
                output.append(entryname)
            if subitems:
                for subentryname, subentrylinks in subitems:
                    if subentrylinks:
                        output.append(
                            '    `%s <%s>`_' % (subentryname, subentrylinks[0])
                        )
                        for i, link in enumerate(subentrylinks[1:]):
                            output[-1] += ' `[%s] <%s>`_ ' % (i + 1, link)
                        output.append('')
                    else:
                        output.append(subentryname)
                        output.append('')

    doctree = docutils.core.publish_doctree('\n'.join(output))
    return doctree[1] 
开发者ID:rst2pdf,项目名称:rst2pdf,代码行数:33,代码来源:pdfbuilder.py

示例13: extract_bibliographic

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import make_id [as 别名]
def extract_bibliographic(self, field_list):
        docinfo = nodes.docinfo()
        bibliofields = self.language.bibliographic_fields
        labels = self.language.labels
        topics = {'dedication': None, 'abstract': None}
        for field in field_list:
            try:
                name = field[0][0].astext()
                normedname = nodes.make_id(name)
                if not (len(field) == 2 and normedname in bibliofields
                        and self.check_empty_biblio_field(field, name)):
                    raise TransformError
                canonical = bibliofields[normedname]
                biblioclass = self.biblio_nodes[canonical]
                if issubclass(biblioclass, nodes.TextElement):
                    if not self.check_compound_biblio_field(field, name):
                        raise TransformError
                    utils.clean_rcs_keywords(
                          field[1][0], self.rcs_keyword_substitutions)
                    docinfo.append(biblioclass('', '', *field[1][0]))
                elif issubclass(biblioclass, nodes.authors):
                    self.extract_authors(field, name, docinfo)
                elif issubclass(biblioclass, nodes.topic):
                    if topics[canonical]:
                        field[-1] += self.document.reporter.warning(
                            'There can only be one "%s" field.' % name,
                            base_node=field)
                        raise TransformError
                    title = nodes.title(name, labels[canonical])
                    topics[canonical] = biblioclass(
                        '', title, classes=[canonical], *field[1].children)
                else:
                    docinfo.append(biblioclass('', *field[1].children))
            except TransformError:
                if len(field[-1]) == 1 \
                       and isinstance(field[-1][0], nodes.paragraph):
                    utils.clean_rcs_keywords(
                        field[-1][0], self.rcs_keyword_substitutions)
                if normedname and normedname not in bibliofields:
                    field['classes'].append(normedname)
                docinfo.append(field)
        nodelist = []
        if len(docinfo) != 0:
            nodelist.append(docinfo)
        for name in ('dedication', 'abstract'):
            if topics[name]:
                nodelist.append(topics[name])
        return nodelist 
开发者ID:skarlekar,项目名称:faces,代码行数:50,代码来源:frontmatter.py


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