Python docutils.nodes.strong() Examples

The following are 30 code examples of docutils.nodes.strong(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module docutils.nodes , or try the search function .
Example #1
Source File: pdfbuilder.py    From rst2pdf with MIT License 6 votes vote down vote up
def visit_productionlist(self, node):
        replacement = nodes.literal_block(classes=["code"])
        names = []
        for production in node:
            names.append(production['tokenname'])
        maxlen = max(len(name) for name in names)
        for production in node:
            if production['tokenname']:
                lastname = production['tokenname'].ljust(maxlen)
                n = nodes.strong()
                n += nodes.Text(lastname)
                replacement += n
                replacement += nodes.Text(' ::= ')
            else:
                replacement += nodes.Text('%s     ' % (' ' * len(lastname)))
            production.walkabout(self)
            replacement.children.extend(production.children)
            replacement += nodes.Text('\n')
        node.parent.replace(node, replacement)
        raise nodes.SkipNode 
Example #2
Source File: ext.py    From rucio with Apache License 2.0 6 votes vote down vote up
def _format_subcommands(self, parser_info):
        assert 'children' in parser_info
        items = []
        for subcmd in parser_info['children']:
            subcmd_items = []
            if subcmd['help']:
                subcmd_items.append(nodes.paragraph(text=subcmd['help']))
            else:
                subcmd_items.append(nodes.paragraph(text='Undocumented'))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(
                        text=subcmd['bare_usage'])),
                    nodes.definition('', *subcmd_items)))
        return nodes.definition_list('', *items) 
Example #3
Source File: swaggerv2_doc.py    From sphinx-swaggerdoc with MIT License 6 votes vote down vote up
def make_parameters(self, parameters):
        entries = []

        head = ['Name', 'Position', 'Description', 'Type']
        body = []
        for param in parameters:
            row = []
            row.append(param.get('name', ''))
            row.append(param.get('in', ''))
            row.append(param.get('description', ''))
            row.append(param.get('type', ''))

            body.append(row)

        table = self.create_table(head, body)

        paragraph = nodes.paragraph()
        paragraph += nodes.strong('', 'Parameters')

        entries.append(paragraph)
        entries.append(table)

        return entries 
Example #4
Source File: httpdomain.py    From couchdb-documentation with Apache License 2.0 6 votes vote down vote up
def http_header_role(name, rawtext, text, lineno, inliner, options=None, content=None):
    if options is None:
        options = {}
    if content is None:
        content = []
    header = str(text)
    if header not in HEADER_REFS:
        header = header.title()
    if header not in HEADER_REFS:
        if header.startswith(("X-Couch-", "Couch-")):
            return [nodes.strong(header, header)], []
        msg = inliner.reporter.error(
            "%s is not unknown HTTP header" % header, lineno=lineno
        )
        prb = inliner.problematic(rawtext, rawtext, msg)
        return [prb], [msg]
    url = str(HEADER_REFS[header])
    node = nodes.reference(rawtext, header, refuri=url, **options)
    return [node], [] 
Example #5
Source File: ext.py    From safekit with MIT License 6 votes vote down vote up
def _format_subcommands(self, parser_info):
        assert 'children' in parser_info
        items = []
        for subcmd in parser_info['children']:
            subcmd_items = []
            if subcmd['help']:
                subcmd_items.append(nodes.paragraph(text=subcmd['help']))
            else:
                subcmd_items.append(nodes.paragraph(text='Undocumented'))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(
                        text=subcmd['bare_usage'])),
                    nodes.definition('', *subcmd_items)))
        return nodes.definition_list('', *items) 
Example #6
Source File: test_blockdiag_directives.py    From blockdiag with Apache License 2.0 6 votes vote down vote up
def test_caption_option2(self):
        directives.setup(format='SVG', outputdir=self.tmpdir)
        text = (".. blockdiag::\n"
                "   :caption: **hello** *world*\n"
                "\n"
                "   A -> B")
        doctree = publish_doctree(text)
        self.assertEqual(1, len(doctree))
        self.assertEqual(nodes.figure, type(doctree[0]))
        self.assertEqual(2, len(doctree[0]))
        self.assertEqual(nodes.image, type(doctree[0][0]))
        self.assertEqual(nodes.caption, type(doctree[0][1]))
        self.assertEqual(3, len(doctree[0][1]))
        self.assertEqual(nodes.strong, type(doctree[0][1][0]))
        self.assertEqual('hello', doctree[0][1][0][0])
        self.assertEqual(nodes.Text, type(doctree[0][1][1]))
        self.assertEqual(' ', doctree[0][1][1][0])
        self.assertEqual(nodes.emphasis, type(doctree[0][1][2]))
        self.assertEqual('world', doctree[0][1][2][0]) 
Example #7
Source File: ext.py    From safekit with MIT License 6 votes vote down vote up
def _format_subcommands(self, parser_info):
        assert 'children' in parser_info
        items = []
        for subcmd in parser_info['children']:
            subcmd_items = []
            if subcmd['help']:
                subcmd_items.append(nodes.paragraph(text=subcmd['help']))
            else:
                subcmd_items.append(nodes.paragraph(text='Undocumented'))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(
                        text=subcmd['bare_usage'])),
                    nodes.definition('', *subcmd_items)))
        return nodes.definition_list('', *items) 
Example #8
Source File: sphinx_directives.py    From emva1288 with GNU General Public License v3.0 6 votes vote down vote up
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] 
Example #9
Source File: states.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #10
Source File: swagger_doc.py    From sphinx-swaggerdoc with MIT License 5 votes vote down vote up
def create_item(self, key, value):
        para = nodes.paragraph()
        para += nodes.strong('', key)
        para += nodes.Text(value)

        item = nodes.list_item()
        item += para

        return item 
Example #11
Source File: states.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #12
Source File: states.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #13
Source File: exercise.py    From sphinxcontrib-jupyter with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def run(self):
        self.assert_has_content()

        num = self.env.new_serialno(self.node_class_str)
        target_id = f"{self.node_class_str}-{num:d}"
        targetnode = nodes.target('', '', ids=[target_id])
        _path = self.env.docname.replace("/", "-")
        node_id = f"{_path}-{num}"

        node = self.node_class("\n".join(self.content))
        node["_id"] = node_id
        node["classes"] = [self.options.get("class", None)]
        node["label"] = self.options.get("label", None)
        title_root = self.options.get("title", self.title_root)
        node["title_root"] = title_root

        title = _(f"{title_root} {num + 1}")

        para = nodes.paragraph()
        para += nodes.strong(title, title)
        node += para

        self.state.nested_parse(self.content, self.content_offset, node)

        if not hasattr(self.env, self.env_attr):
            setattr(self.env, self.env_attr, dict())

        getattr(self.env, self.env_attr)[node_id] = {
            'docname': self.env.docname,
            'lineno': self.lineno,
            'node_copy': node.deepcopy(),
            'target': targetnode,
            "number": num,
            "label": node["label"],
            "title_root": title_root,
        }
        return [targetnode, node] 
Example #14
Source File: states.py    From blackmamba with MIT License 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #15
Source File: states.py    From aws-extender with MIT License 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #16
Source File: swaggerv2_doc.py    From sphinx-swaggerdoc with MIT License 5 votes vote down vote up
def create_item(self, key, value):
        para = nodes.paragraph()
        para += nodes.strong('', key)
        para += nodes.Text(value)

        item = nodes.list_item()
        item += para

        return item 
Example #17
Source File: swaggerv2_doc.py    From sphinx-swaggerdoc with MIT License 5 votes vote down vote up
def make_responses(self, responses):
        # Create an entry with swagger responses and a table of the response properties
        entries = []
        paragraph = nodes.paragraph()
        paragraph += nodes.strong('', 'Responses')

        entries.append(paragraph)

        head = ['Name', 'Description', 'Type']
        for response_name, response in responses.items():
            paragraph = nodes.paragraph()
            paragraph += nodes.emphasis('', '%s - %s' % (response_name,
                                                         response.get('description', '')))
            entries.append(paragraph)

            body = []

            # if the optional field properties is in the schema, display the properties
            if isinstance(response.get('schema'), dict) and 'properties' in response.get('schema'):
                for property_name, property in response.get('schema').get('properties', {}).items():
                    row = []
                    row.append(property_name)
                    row.append(property.get('description', ''))
                    row.append(property.get('type', ''))

                    body.append(row)

                table = self.create_table(head, body)
                entries.append(table)
        return entries 
Example #18
Source File: swaggerv2_doc.py    From sphinx-swaggerdoc with MIT License 5 votes vote down vote up
def run(self):
        self.reporter = self.state.document.reporter

        api_url = self.content[0]

        if len(self.content) > 1:
            selected_tags = self.content[1:]
        else:
            selected_tags = []

        try:
            api_desc = self.processSwaggerURL(api_url)

            groups = self.group_tags(api_desc)

            self.check_tags(selected_tags, groups.keys(), api_url)

            entries = []
            for tag_name, methods in groups.items():
                if tag_name in selected_tags or len(selected_tags) == 0:
                    section = self.create_section(tag_name)

                    for path, method_type, method in methods:
                        section += self.make_method(path, method_type, method)

                    entries.append(section)

            return entries
        except Exception as e:
            error_message = 'Unable to process URL: %s' % api_url
            print(error_message)
            traceback.print_exc()

            error = nodes.error('')
            para_error = nodes.paragraph()
            para_error += nodes.Text(error_message + '. Please check that the URL is a valid Swagger api-docs URL and it is accesible')
            para_error_detailed = nodes.paragraph()
            para_error_detailed = nodes.strong('Processing error. See console output for a more detailed error')
            error += para_error
            error += para_error_detailed
            return [error] 
Example #19
Source File: parser.py    From recommonmark with MIT License 5 votes vote down vote up
def visit_strong(self, _):
        n = nodes.strong()
        self.current_node.append(n)
        self.current_node = n 
Example #20
Source File: states.py    From bash-lambda-layer with MIT License 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #21
Source File: resources.py    From senlin with Apache License 2.0 5 votes vote down vote up
def _create_list_item(self, str):
        """Creates a new list item

        :returns: List item node
        """
        para = nodes.paragraph()
        para += nodes.strong('', str)

        item = nodes.list_item()
        item += para

        return item 
Example #22
Source File: ext.py    From safekit with MIT License 5 votes vote down vote up
def print_subcommand_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    items = []
    if 'children' in data:
        for child in data['children']:
            my_def = [nodes.paragraph(
                text=child['help'])] if child['help'] else []
            name = child['name']
            my_def = apply_definition(definitions, my_def, name)
            if len(my_def) == 0:
                my_def.append(nodes.paragraph(text='Undocumented'))
            if 'description' in child:
                my_def.append(nodes.paragraph(text=child['description']))
            my_def.append(nodes.literal_block(text=child['usage']))
            my_def.append(print_command_args_and_opts(
                print_arg_list(child, nested_content),
                print_opt_list(child, nested_content),
                print_subcommand_list(child, nested_content)
            ))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(text=name)),
                    nodes.definition('', *my_def)
                )
            )
    return nodes.definition_list('', *items) 
Example #23
Source File: ext.py    From safekit with MIT License 5 votes vote down vote up
def print_subcommand_list(data, nested_content):
    definitions = map_nested_definitions(nested_content)
    items = []
    if 'children' in data:
        for child in data['children']:
            my_def = [nodes.paragraph(
                text=child['help'])] if child['help'] else []
            name = child['name']
            my_def = apply_definition(definitions, my_def, name)
            if len(my_def) == 0:
                my_def.append(nodes.paragraph(text='Undocumented'))
            if 'description' in child:
                my_def.append(nodes.paragraph(text=child['description']))
            my_def.append(nodes.literal_block(text=child['usage']))
            my_def.append(print_command_args_and_opts(
                print_arg_list(child, nested_content),
                print_opt_list(child, nested_content),
                print_subcommand_list(child, nested_content)
            ))
            items.append(
                nodes.definition_list_item(
                    '',
                    nodes.term('', '', nodes.strong(text=name)),
                    nodes.definition('', *my_def)
                )
            )
    return nodes.definition_list('', *items) 
Example #24
Source File: states.py    From deepWordBug with Apache License 2.0 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #25
Source File: landlab_ext.py    From landlab with MIT License 5 votes vote down vote up
def role_ftype(name, rawtext, text, lineno, inliner, options=None, content=()):
    options = options or {}
    node = nodes.strong(text, text)
    assert text.count('(') in (0, 1)
    assert text.count('(') == text.count(')')
    assert ')' not in text or text.endswith(')')
    match = re.search(r'\((.*?)\)', text)
    node['ids'] = [match.group(1) if match else text]
    return [node], [] 
Example #26
Source File: states.py    From faces with GNU General Public License v2.0 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #27
Source File: states.py    From faces with GNU General Public License v2.0 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #28
Source File: states.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def strong(self, match, lineno):
        before, inlines, remaining, sysmessages, endstring = self.inline_obj(
              match, lineno, self.patterns.strong, nodes.strong)
        return before, inlines, remaining, sysmessages 
Example #29
Source File: test_blockdiag_directives.py    From blockdiag with Apache License 2.0 4 votes vote down vote up
def test_desctable_option_with_rest_markups(self):
        directives.setup(format='SVG', outputdir=self.tmpdir)
        text = (".. blockdiag::\n"
                "   :desctable:\n"
                "\n"
                "   A [description = \"foo *bar* **baz**\"]"
                "   B [description = \"**foo** *bar* baz\"]")
        doctree = publish_doctree(text)
        self.assertEqual(2, len(doctree))
        self.assertEqual(nodes.image, type(doctree[0]))
        self.assertEqual(nodes.table, type(doctree[1]))

        # tgroup
        self.assertEqual(4, len(doctree[1][0]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][0]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][1]))
        self.assertEqual(nodes.thead, type(doctree[1][0][2]))
        self.assertEqual(nodes.tbody, type(doctree[1][0][3]))

        # colspec
        self.assertEqual(50, doctree[1][0][0]['colwidth'])
        self.assertEqual(50, doctree[1][0][1]['colwidth'])

        # thead
        thead = doctree[1][0][2]
        self.assertEqual(2, len(thead[0]))
        self.assertEqual('Name', thead[0][0][0][0])
        self.assertEqual('Description', thead[0][1][0][0])

        # tbody
        tbody = doctree[1][0][3]
        self.assertEqual(2, len(tbody))
        self.assertEqual('A', tbody[0][0][0][0])
        self.assertEqual(4, len(tbody[0][1][0]))
        self.assertEqual(nodes.Text, type(tbody[0][1][0][0]))
        self.assertEqual('foo ', str(tbody[0][1][0][0]))
        self.assertEqual(nodes.emphasis, type(tbody[0][1][0][1]))
        self.assertEqual(nodes.Text, type(tbody[0][1][0][1][0]))
        self.assertEqual('bar', tbody[0][1][0][1][0])
        self.assertEqual(nodes.Text, type(tbody[0][1][0][2]))
        self.assertEqual(' ', str(tbody[0][1][0][2]))
        self.assertEqual(nodes.strong, type(tbody[0][1][0][3]))
        self.assertEqual(nodes.Text, type(tbody[0][1][0][3][0]))
        self.assertEqual('baz', str(tbody[0][1][0][3][0]))

        self.assertEqual('B', tbody[1][0][0][0])
        self.assertEqual(4, len(tbody[1][1][0]))
        self.assertEqual(nodes.strong, type(tbody[1][1][0][0]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][0][0]))
        self.assertEqual('foo', str(tbody[1][1][0][0][0]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][1]))
        self.assertEqual(' ', str(tbody[1][1][0][1]))
        self.assertEqual(nodes.emphasis, type(tbody[1][1][0][2]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][2][0]))
        self.assertEqual('bar', str(tbody[1][1][0][2][0]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][3]))
        self.assertEqual(' baz', str(tbody[1][1][0][3])) 
Example #30
Source File: test_rst_directives.py    From seqdiag with Apache License 2.0 4 votes vote down vote up
def test_desctable_option_with_rest_markups(self):
        directives.setup(format='SVG', outputdir=self.tmpdir)
        text = (".. seqdiag::\n"
                "   :desctable:\n"
                "\n"
                "   A [description = \"foo *bar* **baz**\"]"
                "   B [description = \"**foo** *bar* baz\"]")
        doctree = publish_doctree(text)
        self.assertEqual(2, len(doctree))
        self.assertEqual(nodes.image, type(doctree[0]))
        self.assertEqual(nodes.table, type(doctree[1]))

        # tgroup
        self.assertEqual(4, len(doctree[1][0]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][0]))
        self.assertEqual(nodes.colspec, type(doctree[1][0][1]))
        self.assertEqual(nodes.thead, type(doctree[1][0][2]))
        self.assertEqual(nodes.tbody, type(doctree[1][0][3]))

        # colspec
        self.assertEqual(50, doctree[1][0][0]['colwidth'])
        self.assertEqual(50, doctree[1][0][1]['colwidth'])

        # thead
        thead = doctree[1][0][2]
        self.assertEqual(2, len(thead[0]))
        self.assertEqual('Name', thead[0][0][0][0])
        self.assertEqual('Description', thead[0][1][0][0])

        # tbody
        tbody = doctree[1][0][3]
        self.assertEqual(2, len(tbody))
        self.assertEqual('A', tbody[0][0][0][0])
        self.assertEqual(4, len(tbody[0][1][0]))
        self.assertEqual(nodes.Text, type(tbody[0][1][0][0]))
        self.assertEqual('foo ', str(tbody[0][1][0][0]))
        self.assertEqual(nodes.emphasis, type(tbody[0][1][0][1]))
        self.assertEqual(nodes.Text, type(tbody[0][1][0][1][0]))
        self.assertEqual('bar', tbody[0][1][0][1][0])
        self.assertEqual(nodes.Text, type(tbody[0][1][0][2]))
        self.assertEqual(' ', str(tbody[0][1][0][2]))
        self.assertEqual(nodes.strong, type(tbody[0][1][0][3]))
        self.assertEqual(nodes.Text, type(tbody[0][1][0][3][0]))
        self.assertEqual('baz', str(tbody[0][1][0][3][0]))

        self.assertEqual('B', tbody[1][0][0][0])
        self.assertEqual(4, len(tbody[1][1][0]))
        self.assertEqual(nodes.strong, type(tbody[1][1][0][0]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][0][0]))
        self.assertEqual('foo', str(tbody[1][1][0][0][0]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][1]))
        self.assertEqual(' ', str(tbody[1][1][0][1]))
        self.assertEqual(nodes.emphasis, type(tbody[1][1][0][2]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][2][0]))
        self.assertEqual('bar', str(tbody[1][1][0][2][0]))
        self.assertEqual(nodes.Text, type(tbody[1][1][0][3]))
        self.assertEqual(' baz', str(tbody[1][1][0][3]))