Python docutils.nodes.emphasis() Examples
The following are 30
code examples of docutils.nodes.emphasis().
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: autosummary__init__.py From pyGSTi with Apache License 2.0 | 6 votes |
def autolink_role(typ, rawtext, etext, lineno, inliner, options={}, content=[]): """Smart linking role. Expands to ':obj:`text`' if `text` is an object that can be imported; otherwise expands to '*text*'. """ env = inliner.document.settings.env r = env.get_domain('py').role('obj')( 'obj', rawtext, etext, lineno, inliner, options, content) pnode = r[0][0] prefixes = get_import_prefixes_from_env(env) try: name, obj, parent, modname = import_by_name(pnode['reftarget'], prefixes) except ImportError: content = pnode[0] r[0][0] = nodes.emphasis(rawtext, content[0].astext(), classes=content['classes']) return r
Example #2
Source File: landlab_ext.py From landlab with MIT License | 6 votes |
def doctree_read(app, doctree): env = app.builder.env for node in doctree.traverse(addnodes.productionlist): for production in node: if not isinstance(production, addnodes.production): continue if not isinstance(production[-1], nodes.Text): continue parts = comment_re.split(production.pop().astext()) new_nodes = [] for s in parts: if comment_re.match(s): new_nodes.append(nodes.emphasis(s, s)) elif s: new_nodes.append(nodes.Text(s)) production += new_nodes
Example #3
Source File: diagrams_common.py From sphinxcontrib-needs with MIT License | 6 votes |
def get_filter_para(node_element): """Return paragraph containing the used filter description""" para = nodes.paragraph() filter_text = "Used filter:" filter_text += " status(%s)" % " OR ".join(node_element["status"]) if len( node_element["status"]) > 0 else "" if len(node_element["status"]) > 0 and len(node_element["tags"]) > 0: filter_text += " AND " filter_text += " tags(%s)" % " OR ".join(node_element["tags"]) if len( node_element["tags"]) > 0 else "" if (len(node_element["status"]) > 0 or len(node_element["tags"]) > 0) and len( node_element["types"]) > 0: filter_text += " AND " filter_text += " types(%s)" % " OR ".join(node_element["types"]) if len( node_element["types"]) > 0 else "" filter_node = nodes.emphasis(filter_text, filter_text) para += filter_node return para
Example #4
Source File: utils.py From sphinxcontrib-needs with MIT License | 6 votes |
def used_filter_paragraph(current_needfilter): para = nodes.paragraph() filter_text = "Used filter:" filter_text += " status(%s)" % " OR ".join(current_needfilter["status"]) if len( current_needfilter["status"]) > 0 else "" if len(current_needfilter["status"]) > 0 and len(current_needfilter["tags"]) > 0: filter_text += " AND " filter_text += " tags(%s)" % " OR ".join(current_needfilter["tags"]) if len( current_needfilter["tags"]) > 0 else "" if (len(current_needfilter["status"]) > 0 or len(current_needfilter["tags"]) > 0) and len( current_needfilter["types"]) > 0: filter_text += " AND " filter_text += " types(%s)" % " OR ".join(current_needfilter["types"]) if len( current_needfilter["types"]) > 0 else "" filter_node = nodes.emphasis(filter_text, filter_text) para += filter_node return para
Example #5
Source File: protobufdomain.py From ga4gh-schemas with Apache License 2.0 | 6 votes |
def handle_signature(self,sig,signode): sig = sig.strip() type_name, name, arglist = protobuf_sig_regex.match(sig).groups() if self.prefix: signode += addnodes.desc_annotation(self.prefix+' ', self.prefix+' ') if type_name: signode += addnodes.desc_type(type_name, type_name) if name: signode += addnodes.desc_name(name,name) if arglist: paramlist = addnodes.desc_parameterlist() for arg in arglist.split(','): argtype, argname = arg.split(None,1) param = addnodes.desc_parameter(noemph=True) param += nodes.Text(argtype,argtype) param += nodes.emphasis(' '+argname,' '+argname) paramlist += param signode += paramlist return name
Example #6
Source File: eql.py From edgedb with Apache License 2.0 | 6 votes |
def make_xref(self, rolename, domain, target, innernode=d_nodes.emphasis, contnode=None, env=None): if not rolename: return contnode or innernode(target, target) title = target if domain == 'eql' and rolename == 'type': target = EQLTypeXRef.filter_target(target) if target in EQLTypedField.ignored_types: return d_nodes.Text(title) refnode = s_nodes.pending_xref('', refdomain=domain, refexplicit=title != target, reftype=rolename, reftarget=target) refnode += contnode or innernode(title, title) if env: env.domains[domain].process_field_xref(refnode) refnode['eql-auto-link'] = True return refnode
Example #7
Source File: test_blockdiag_directives.py From blockdiag with Apache License 2.0 | 6 votes |
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 #8
Source File: __init__.py From artview with BSD 3-Clause "New" or "Revised" License | 6 votes |
def autolink_role(typ, rawtext, etext, lineno, inliner, options={}, content=[]): """Smart linking role. Expands to ':obj:`text`' if `text` is an object that can be imported; otherwise expands to '*text*'. """ env = inliner.document.settings.env r = env.get_domain('py').role('obj')( 'obj', rawtext, etext, lineno, inliner, options, content) pnode = r[0][0] prefixes = get_import_prefixes_from_env(env) try: name, obj, parent = import_by_name(pnode['reftarget'], prefixes) except ImportError: content = pnode[0] r[0][0] = nodes.emphasis(rawtext, content[0].astext(), classes=content['classes']) return r
Example #9
Source File: httpdomain.py From nltk-server with MIT License | 6 votes |
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)
Example #10
Source File: httpdomain.py From nltk-server with MIT License | 6 votes |
def result_nodes(self, document, env, node, is_ref): header = node[0][0] rawsource = node[0].rawsource config = env.domains['http'].env.config if header not in HEADER_REFS: _header = '-'.join(map(lambda i: i.title(), header.split('-'))) if _header not in HEADER_REFS: if not config['http_strict_mode']: return [nodes.emphasis(header, header)], [] _header = _header.lower() if any([_header.startswith(prefix.lower()) for prefix in config['http_headers_ignore_prefixes']]): return [nodes.emphasis(header, header)], [] reporter = document.reporter msg = reporter.error('%s is not unknown HTTP header' % header, line=node.line) prb = nodes.problematic(header, header) return [prb], [msg] url = str(HEADER_REFS[header]) node = nodes.reference(rawsource, header, refuri=url) return [node], []
Example #11
Source File: httpdomain.py From nltk-server with MIT License | 6 votes |
def result_nodes(self, document, env, node, is_ref): method = node[0][0].lower() rawsource = node[0].rawsource config = env.domains['http'].env.config if method not in METHOD_REFS: if not config['http_strict_mode']: return [nodes.emphasis(method, method)], [] reporter = document.reporter msg = reporter.error('%s is not valid HTTP method' % method, line=node.line) prb = nodes.problematic(method, method) return [prb], [msg] url = str(METHOD_REFS[method]) if not url: return [nodes.emphasis(method, method)], [] node = nodes.reference(rawsource, method.upper(), refuri=url) return [node], []
Example #12
Source File: swaggerv2_doc.py From sphinx-swaggerdoc with MIT License | 5 votes |
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 #13
Source File: httpdomain.py From couchdb-documentation with Apache License 2.0 | 5 votes |
def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): try: info = self.data[str(typ)][target] except KeyError: text = contnode.rawsource if typ == "statuscode": return http_statuscode_role(None, text, text, None, None)[0][0] elif typ == "mailheader": return http_header_role(None, text, text, None, None)[0][0] else: return nodes.emphasis(text, text) else: anchor = http_resource_anchor(typ, target) title = typ.upper() + " " + target return make_refnode(builder, fromdocname, info[0], anchor, contnode, title)
Example #14
Source File: states.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #15
Source File: states.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #16
Source File: states.py From blackmamba with MIT License | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #17
Source File: states.py From aws-extender with MIT License | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #18
Source File: states.py From cadquery-freecad-module with GNU Lesser General Public License v3.0 | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #19
Source File: parser.py From recommonmark with MIT License | 5 votes |
def visit_emph(self, _): n = nodes.emphasis() self.current_node.append(n) self.current_node = n
Example #20
Source File: resources.py From senlin with Apache License 2.0 | 5 votes |
def _build_properties(self, k, v, definition): """Build schema property documentation :returns: None """ if isinstance(v, schema.Map): newdef = self._create_section(definition, k, term=k) if v.schema is None: # if it's a map for arbritary values, only include description field = nodes.line('', v.description) newdef.append(field) return newdeflist = self._create_def_list(newdef) sorted_schema = sorted(v.schema.items(), key=cmp_to_key(self._sort_by_type)) for key, value in sorted_schema: self._build_properties(key, value, newdeflist) elif isinstance(v, schema.List): newdef = self._create_section(definition, k, term=k) # identify next section as list properties field = nodes.line() emph = nodes.emphasis('', 'List properties:') field.append(emph) newdef.append(field) newdeflist = self._create_def_list(newdef) self._build_properties('**', v.schema['*'], newdeflist) else: newdef = self._create_section(definition, k, term=k) if 'description' in v: field = nodes.line('', v['description']) newdef.append(field) else: field = nodes.line('', '++') newdef.append(field)
Example #21
Source File: csharp.py From sphinx-csharp with MIT License | 5 votes |
def append_modifiers(signode, modifiers): if not modifiers: return for modifier in modifiers: signode += nodes.emphasis(modifier, modifier) signode += nodes.Text(u' ')
Example #22
Source File: csharp.py From sphinx-csharp with MIT License | 5 votes |
def append_parameters(self, node, params): pnodes = addnodes.desc_parameterlist() for param in params: pnode = addnodes.desc_parameter('', '', noemph=True) self.append_modifiers(pnode, param.modifiers) self.append_type(pnode, param.typ) pnode += nodes.Text(u' ') pnode += nodes.emphasis(param.name, param.name) if param.default is not None: default = u' = ' + param.default pnode += nodes.emphasis(default, default) pnodes += pnode node += pnodes
Example #23
Source File: csharp.py From sphinx-csharp with MIT License | 5 votes |
def append_indexer_parameters(self, node, params): pnodes = addnodes.desc_addname() pnodes += nodes.Text('[') for param in params: if pnodes.children: pnodes += nodes.Text(u', ') self.append_type(pnodes, param.typ) pnodes += nodes.Text(u' ') pnodes += nodes.emphasis(param.name, param.name) pnodes += nodes.Text(']') node += pnodes
Example #24
Source File: states.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #25
Source File: states.py From bash-lambda-layer with MIT License | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #26
Source File: __init__.py From veros with MIT License | 5 votes |
def run(self): options= {'classes' : []} options['classes'].append('fa') for x in self.content[0].split(' '): options['classes'].append('fa-%s' % x) set_classes(options) node = emphasis(**options) return [node]
Example #27
Source File: qt_doc.py From tf-pose with Apache License 2.0 | 5 votes |
def process_todo_nodes(app, doctree, fromdocname): if not app.config.todo_include_todos: for node in doctree.traverse(Todo): node.parent.remove(node) # Replace all todolist nodes with a list of the collected todos. # Augment each todo with a backlink to the original location. env = app.builder.env for node in doctree.traverse(Todolist): if not app.config.todo_include_todos: node.replace_self([]) continue content = [] for todo_info in env.todo_all_todos: para = nodes.paragraph() filename = env.doc2path(todo_info['docname'], base=None) description = ( ('(The original entry is located in %s, line %d and can be found ') % (filename, todo_info['lineno'])) para += nodes.Text(description, description) # Create a reference newnode = nodes.reference('', '') innernode = nodes.emphasis(('here'), ('here')) newnode['refdocname'] = todo_info['docname'] newnode['refuri'] = app.builder.get_relative_uri( fromdocname, todo_info['docname']) newnode['refuri'] += '#' + todo_info['target']['refid'] newnode.append(innernode) para += newnode para += nodes.Text('.)', '.)') # Insert into the todolist content.append(todo_info['todo']) content.append(para) node.replace_self(content)
Example #28
Source File: __init__.py From veros with MIT License | 5 votes |
def fa_global(key=''): def fa(role, rawtext, text, lineno, inliner, options={}, content=[]): options.update({'classes': []}) options['classes'].append('fa') if key: options['classes'].append('fa-%s' % key) else: for x in text.split(","): options['classes'].append('fa-%s' % x) set_classes(options) node = emphasis(**options) return [node], [] return fa #add directive
Example #29
Source File: states.py From faces with GNU General Public License v2.0 | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages
Example #30
Source File: states.py From deepWordBug with Apache License 2.0 | 5 votes |
def emphasis(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.emphasis, nodes.emphasis) return before, inlines, remaining, sysmessages