Python sphinx.addnodes.desc_name() Examples
The following are 28
code examples of sphinx.addnodes.desc_name().
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
sphinx.addnodes
, or try the search function
.
Example #1
Source File: configdomain.py From couchdb-documentation with Apache License 2.0 | 6 votes |
def handle_signature(self, sig, signode): if "::" in sig: name, descr = map(lambda i: i.strip(), sig.split("::")) else: name, descr = sig.strip(), "" signode["name"] = name signode["descr"] = descr domain, objtype = self.name.split(":") if objtype == "section": self.env.temp_data["section"] = signode["name"] name = "[%s]" % signode["name"] signode += addnodes.desc_name(name, name) return signode["name"]
Example #2
Source File: pbDomain.py From opbasm with MIT License | 6 votes |
def handle_signature(self, sig, signode): """Transform a PicoBlaze signature into RST nodes.""" m = pb_sig_re.match(sig) if m is None: raise ValueError('no match') name, arglist = m.groups() signode += addnodes.desc_name(name, name) if not arglist: if self.objtype in ('function', 'macro'): # for functions and macros, add an empty parameter list signode += addnodes.desc_parameterlist() self.env.domains['pb'].data['has_params'][name] = False return name _parse_arglist(signode, arglist) self.env.domains['pb'].data['has_params'][name] = True return name
Example #3
Source File: rpc.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def handle_signature(self, sig, signode): m = re.match(r'([a-zA-Z0-9_/\(\):]+)\(([a-zA-Z0-9,\'"_= ]*)\)', sig) if not m: signode += addnodes.desc_name(sig, sig) return sig uri_path, args = m.groups() signode += addnodes.desc_name(uri_path, uri_path) plist = DescRPCArgumentList() args = args.split(',') for pos, arg in enumerate(args): arg = arg.strip() if pos < len(args) - 1: arg += ',' x = DescRPCArgument() x += addnodes.desc_parameter(arg, arg) plist += x signode += plist return uri_path
Example #4
Source File: graphql.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def handle_signature(self, sig, signode): match = re.match(r'(?P<name>[a-zA-Z0-9]+)(\((?P<arguments>[a-z_0-9]+(, +[a-z_0-9]+)*)\))?', sig) field_name = match.group('name') if 'gql:object' in self.env.ref_context: full_name = self.env.ref_context['gql:object'] + '.' + field_name else: full_name = field_name signode += addnodes.desc_name(field_name, field_name) arguments = match.group('arguments') if arguments: plist = DescGraphQLFieldArgumentList() arguments = arguments.split(',') for pos, arg in enumerate(arguments): arg = arg.strip() if pos < len(arguments) - 1: arg += ',' x = DescGraphQLFieldArgument() x += addnodes.desc_parameter(arg, arg) plist += x signode += plist return full_name
Example #5
Source File: database.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def handle_signature(self, sig, signode): match = re.match(r'(?P<name>[a-z0-9_]+)(\((?P<arguments>[a-z_0-9]+(, +[a-z_0-9]+)*)\))?', sig) field_name = match.group('name') if 'db:table' in self.env.ref_context: full_name = self.env.ref_context['db:table'] + '.' + field_name else: full_name = field_name signode += addnodes.desc_name(field_name, field_name) arguments = match.group('arguments') if arguments: plist = DescDatabaseFieldArgumentList() arguments = arguments.split(',') for pos, arg in enumerate(arguments): arg = arg.strip() if pos < len(arguments) - 1: arg += ',' x = DescDatabaseFieldArgument() x += addnodes.desc_parameter(arg, arg) plist += x signode += plist return full_name
Example #6
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 #7
Source File: eql.py From edgedb with Apache License 2.0 | 6 votes |
def handle_signature(self, sig, signode): if '::' in sig: mod, name = sig.strip().split('::') else: name = sig.strip() mod = 'std' display = name.replace('-', ' ') if mod != 'std': display = f'{mod}::{display}' signode['eql-module'] = mod signode['eql-name'] = name signode['eql-fullname'] = fullname = f'{mod}::{name}' signode += s_nodes.desc_annotation('type', 'type') signode += d_nodes.Text(' ') signode += s_nodes.desc_name(display, display) return fullname
Example #8
Source File: csharp.py From sphinx-csharp with MIT License | 6 votes |
def handle_signature(self, sig, signode): modifiers, typ, name, getter, setter = parse_property_signature(sig) self.append_modifiers(signode, modifiers) self.append_type(signode, typ) signode += nodes.Text(' ') signode += addnodes.desc_name(name, name) signode += nodes.Text(' { ') extra = [] if getter: extra.append('get;') if setter: extra.append('set;') extra_str = ' '.join(extra) signode += addnodes.desc_annotation(extra_str, extra_str) signode += nodes.Text(' }') return self.get_fullname(name)
Example #9
Source File: csharp.py From sphinx-csharp with MIT License | 6 votes |
def handle_signature(self, sig, signode): modifiers, typ, params, getter, setter = parse_indexer_signature(sig) self.append_modifiers(signode, modifiers) self.append_type(signode, typ) signode += nodes.Text(' ') signode += addnodes.desc_name('this[]', 'this') self.append_indexer_parameters(signode, params) signode += nodes.Text(' { ') extra = [] if getter: extra.append('get;') if setter: extra.append('set;') extra_str = ' '.join(extra) signode += addnodes.desc_annotation(extra_str, extra_str) signode += nodes.Text(' }') return self.get_fullname('this[]')
Example #10
Source File: csharp.py From sphinx-csharp with MIT License | 5 votes |
def handle_signature(self, sig, signode): name, params = parse_attr_signature(sig) signode += addnodes.desc_name(name, name) if params: signode += nodes.Text(' ') self.append_parameters(signode, params) return self.get_fullname(name)
Example #11
Source File: csharp.py From sphinx-csharp with MIT License | 5 votes |
def handle_signature(self, sig, signode): typ, _, _ = parse_type_signature(sig) desc_name = 'class %s' % sig signode += addnodes.desc_name(desc_name, desc_name) return self.get_fullname(typ)
Example #12
Source File: csharp.py From sphinx-csharp with MIT License | 5 votes |
def handle_signature(self, sig, signode): modifiers, typ, name, \ generic_types, params = parse_method_signature(sig) self.append_modifiers(signode, modifiers) if typ is not None: self.append_type(signode, typ) signode += nodes.Text(' ') signode += addnodes.desc_name(name, name) if generic_types is not None: signode += nodes.Text(generic_types) signode += nodes.Text(' ') self.append_parameters(signode, params) return self.get_fullname(name)
Example #13
Source File: csharp.py From sphinx-csharp with MIT License | 5 votes |
def handle_signature(self, sig, signode): desc_name = 'enum %s' % sig signode += addnodes.desc_name(desc_name, desc_name) return self.get_fullname(sig)
Example #14
Source File: httpdomain.py From nltk-server with MIT License | 5 votes |
def handle_signature(self, sig, signode): method = self.method.upper() + ' ' signode += addnodes.desc_name(method, method) offset = 0 path = None for match in http_sig_param_re.finditer(sig): path = sig[offset:match.start()] signode += addnodes.desc_name(path, path) params = addnodes.desc_parameterlist() typ = match.group('type') if typ: typ += ': ' params += addnodes.desc_annotation(typ, typ) name = match.group('name') params += addnodes.desc_parameter(name, name) signode += params offset = match.end() if offset < len(sig): path = sig[offset:len(sig)] signode += addnodes.desc_name(path, path) assert path is not None, 'no matches for sig: %s' % sig fullname = self.method.upper() + ' ' + path signode['method'] = self.method signode['path'] = sig signode['fullname'] = fullname return (fullname, self.method, sig)
Example #15
Source File: djangodocs.py From django-cas-server with GNU General Public License v3.0 | 5 votes |
def parse_django_admin_node(env, sig, signode): command = sig.split(' ')[0] env.ref_context['std:program'] = command title = "django-admin %s" % sig signode += addnodes.desc_name(title, title) return command
Example #16
Source File: apidoc.py From build-relengapi with Mozilla Public License 2.0 | 5 votes |
def handle_signature(self, sig, signode): signode += addnodes.desc_annotation('REST type ', 'REST type ') signode += addnodes.desc_name(sig, sig)
Example #17
Source File: apidoc.py From build-relengapi with Mozilla Public License 2.0 | 5 votes |
def handle_signature(self, sig, signode): methods, path = sig signode += addnodes.desc_annotation('endpoint ', 'endpoint ') signode += addnodes.desc_addname(methods + ' ', methods + ' ') signode += addnodes.desc_name(path, path)
Example #18
Source File: httpdomain.py From couchdb-documentation with Apache License 2.0 | 5 votes |
def handle_signature(self, sig, signode): method = self.method.upper() + " " signode += addnodes.desc_name(method, method) offset = 0 path = None for match in http_sig_param_re.finditer(sig): path = sig[offset : match.start()] signode += addnodes.desc_name(path, path) params = addnodes.desc_parameterlist() typ = match.group("type") if typ: typ += ": " params += addnodes.desc_annotation(typ, typ) name = match.group("name") params += addnodes.desc_parameter(name, name) signode += params offset = match.end() if offset < len(sig): path = sig[offset : len(sig)] signode += addnodes.desc_name(path, path) if path is None: assert False, "no matches for sig: %s" % sig fullname = self.method.upper() + " " + path signode["method"] = self.method signode["path"] = sig signode["fullname"] = fullname return (fullname, self.method, sig)
Example #19
Source File: need.py From sphinxcontrib-needs with MIT License | 5 votes |
def get_sections_and_signature(need_info): """Gets the hierarchy of the section nodes as a list starting at the section of the current need and then its parent sections""" sections = [] signature = None current_node = need_info['target_node'] while current_node: if isinstance(current_node, nodes.section): title = current_node.children[0].astext() # If using auto-section numbering, then Sphinx inserts # multiple non-breaking space unicode characters into the title # we'll replace those with a simple space to make them easier to # use in filters title = NON_BREAKING_SPACE.sub(' ', title) sections.append(title) # Checking for a signature defined "above" the need. # Used and set normally by directives like automodule. # Only check as long as we haven't found a signature if signature is None and current_node.parent is not None and current_node.parent.children is not None: for sibling in current_node.parent.children: # We want to check only "above" current node, so no need to check sibling after current_node. if sibling == current_node: break if isinstance(sibling, desc_signature): # Check the child of the found signature for the text content/node. for desc_child in sibling.children: if isinstance(desc_child, desc_name) and \ isinstance(desc_child.children[0], nodes.Text): signature = desc_child.children[0] if signature is not None: break current_node = getattr(current_node, 'parent', None) return sections, signature
Example #20
Source File: sphinx_cfg_options.py From tenpy with GNU General Public License v3.0 | 5 votes |
def handle_signature(self, sig, signode): fullname = sig signode += addnodes.desc_annotation('config ', 'config ') signode += addnodes.desc_name(sig, '', nodes.Text(sig)) return fullname
Example #21
Source File: eql.py From edgedb with Apache License 2.0 | 5 votes |
def handle_signature(self, sig, signode): if self.names: name = self.names[0] else: try: name, sig = sig.split(':', 1) except Exception as ex: raise shared.DirectiveParseError( self, f':eql:operator signature must match "NAME: SIGNATURE" ' f'template', cause=ex) name = name.strip() sig = sig.strip() if not name or not sig: raise shared.DirectiveParseError( self, f'invalid :eql:operator: signature') signode['eql-name'] = name signode['eql-fullname'] = name signode['eql-signature'] = sig signode += s_nodes.desc_annotation('operator', 'operator') signode += d_nodes.Text(' ') signode += s_nodes.desc_name(sig, sig) return name
Example #22
Source File: eql.py From edgedb with Apache License 2.0 | 5 votes |
def handle_signature(self, sig, signode): signode['eql-name'] = sig signode['eql-fullname'] = sig display = sig.replace('-', ' ') signode += s_nodes.desc_annotation('keyword', 'keyword') signode += d_nodes.Text(' ') signode += s_nodes.desc_name(display, display) return sig
Example #23
Source File: sphinxext.py From bioconda-utils with MIT License | 5 votes |
def handle_signature(self, sig: str, signode: addnodes.desc) -> str: """Transform signature into RST nodes""" signode += addnodes.desc_annotation(self.typename, self.typename + " ") signode += addnodes.desc_name(sig, sig) if 'badges' in self.options: badges = addnodes.desc_annotation() badges['classes'] += ['badges'] content = StringList([self.options['badges']]) self.state.nested_parse(content, 0, badges) signode += badges if 'replaces_section_title' in self.options: section = self.state.parent if isinstance(section, nodes.section): title = section[-1] if isinstance(title, nodes.title): section.remove(title) else: signode += self.state.document.reporter.warning( "%s:%s:: must follow section directly to replace section title" % (self.domain, self.objtype), line = self.lineno ) else: signode += self.state.document.reporter.warning( "%s:%s:: must be in section to replace section title" % (self.domain, self.objtype), line = self.lineno ) return sig
Example #24
Source File: _exttools.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
def handle_signature(self, sig, signode): signode.clear() signode += addnodes.desc_name(sig, sig) return ws_re.sub('', sig)
Example #25
Source File: sphinx_cfg_options.py From tenpy with GNU General Public License v3.0 | 5 votes |
def handle_signature(self, sig, signode): name = sig config = self.options.get('config', self.env.ref_context.get('cfg:config', "")) if not config: logger.warning("config option with unknown config", location=signode) config = "UNKNOWN" fullname = config + '.' + name signode += addnodes.desc_annotation('option ', 'option ') if not self.env.ref_context.get('cfg:in-config', False): signode += addnodes.pending_xref(sig, addnodes.desc_addname(config, config), refdomain='cfg', reftype='config', reftarget=config) signode += addnodes.desc_addname('', '.') signode += addnodes.desc_name(sig, '', nodes.Text(sig)) typ = self.options.get('type') if typ: type_node = addnodes.desc_annotation(': ', ': ') info = self.content.parent.info(1) # might be off by a few lines... type_node.extend(_parse_inline(self.state, typ, info)) signode += type_node defaultvalue = self.options.get('default') if defaultvalue: val_node = addnodes.desc_annotation(' = ', ' = ') val_node += nodes.literal(defaultvalue, defaultvalue) signode += val_node return fullname, config
Example #26
Source File: eql.py From edgedb with Apache License 2.0 | 4 votes |
def handle_signature(self, sig, signode): parser = edgeql_parser.EdgeQLBlockParser() try: astnode = parser.parse( f'CREATE ABSTRACT CONSTRAINT {sig};')[0] except Exception as ex: raise shared.DirectiveParseError( self, f'could not parse constraint signature {sig!r}', cause=ex) if (not isinstance(astnode, ql_ast.CreateConstraint) or not isinstance(astnode.name, ql_ast.ObjectRef)): raise shared.DirectiveParseError( self, f'EdgeQL parser returned unsupported AST') modname = astnode.name.module constr_name = astnode.name.name if not modname: raise shared.DirectiveParseError( self, f'Missing module in EdgeQL constraint declaration') constr_repr = ql_gen.EdgeQLSourceGenerator.to_source(astnode) m = re.match(r'''(?xs) ^ CREATE\sABSTRACT\sCONSTRAINT\s (?P<f>.*?)(?:\s*ON(?P<subj>.*))? $ ''', constr_repr) if not m or not m.group('f'): raise shared.DirectiveParseError( self, f'could not recreate constraint signature from AST') constr_repr = m.group('f') signode['eql-module'] = modname signode['eql-name'] = constr_name signode['eql-fullname'] = fullname = f'{modname}::{constr_name}' signode['eql-signature'] = constr_repr subject = m.group('subj') if subject: subject = subject.strip()[1:-1] signode['eql-subjexpr'] = subject signode['eql-signature'] += f' ON ({subject})' signode += s_nodes.desc_annotation('constraint', 'constraint') signode += d_nodes.Text(' ') signode += s_nodes.desc_name(fullname, fullname) return fullname
Example #27
Source File: eql.py From edgedb with Apache License 2.0 | 4 votes |
def handle_signature(self, sig, signode): parser = edgeql_parser.EdgeQLBlockParser() try: astnode = parser.parse( f'CREATE FUNCTION {sig} USING SQL FUNCTION "xxx";')[0] except Exception as ex: raise shared.DirectiveParseError( self, f'could not parse function signature {sig!r}', cause=ex) if (not isinstance(astnode, ql_ast.CreateFunction) or not isinstance(astnode.name, ql_ast.ObjectRef)): raise shared.DirectiveParseError( self, f'EdgeQL parser returned unsupported AST') modname = astnode.name.module funcname = astnode.name.name if not modname: raise shared.DirectiveParseError( self, f'EdgeQL function declaration is missing namespace') func_repr = ql_gen.EdgeQLSourceGenerator.to_source(astnode) m = re.match(r'''(?xs) ^ CREATE\sFUNCTION\s (?P<f>.*?) \sUSING\sSQL\sFUNCTION .*$ ''', func_repr) if not m or not m.group('f'): raise shared.DirectiveParseError( self, f'could not recreate function signature from AST') func_repr = m.group('f') signode['eql-module'] = modname signode['eql-name'] = funcname signode['eql-fullname'] = fullname = f'{modname}::{funcname}' signode['eql-signature'] = func_repr signode += s_nodes.desc_annotation('function', 'function') signode += d_nodes.Text(' ') signode += s_nodes.desc_name(fullname, fullname) ret_repr = ql_gen.EdgeQLSourceGenerator.to_source(astnode.returning) if astnode.returning_typemod is qltypes.TypeModifier.SET_OF: ret_repr = f'SET OF {ret_repr}' elif astnode.returning_typemod is qltypes.TypeModifier.OPTIONAL: ret_repr = f'OPTIONAL {ret_repr}' signode += s_nodes.desc_returns(ret_repr, ret_repr) return fullname
Example #28
Source File: autoprocess.py From resolwe with Apache License 2.0 | 4 votes |
def make_process_header(self, slug, typ, version, source_uri, description, inputs): """Generate a process definition header. :param str slug: process' slug :param str typ: process' type :param str version: process' version :param str source_uri: url to the process definition :param str description: process' description :param dict inputs: process' inputs """ node = addnodes.desc() signode = addnodes.desc_signature(slug, "") node.append(signode) node["objtype"] = node["desctype"] = typ signode += addnodes.desc_annotation(typ, typ, classes=["process-type"]) signode += addnodes.desc_addname("", "") signode += addnodes.desc_name(slug + " ", slug + " ") paramlist = addnodes.desc_parameterlist() for field_schema, _, _ in iterate_schema({}, inputs, ""): field_type = field_schema["type"] field_name = field_schema["name"] field_default = field_schema.get("default", None) field_default = "" if field_default is None else "={}".format(field_default) param = addnodes.desc_parameter("", "", noemph=True) param += nodes.emphasis(field_type, field_type, classes=["process-type"]) # separate by non-breaking space in the output param += nodes.strong(text="\xa0\xa0" + field_name) paramlist += param signode += paramlist signode += nodes.reference( "", nodes.Text("[Source: v{}]".format(version)), refuri=source_uri, classes=["viewcode-link"], ) desc = nodes.paragraph() desc += nodes.Text(description, description) return [node, desc]