Beispiel #1
0
    def handle_signature(self, sig, signode):
        mod, typ, name, generic, inherits = self.parse_signature(sig)
        signode += addnodes.desc_type(
            text='{}'.format(mod if mod else 'private'))
        signode += nodes.Text(' ')
        signode += addnodes.desc_type(text='{}'.format(typ))
        signode += nodes.Text(' ')
        signode += addnodes.desc_name(text=name)
        if generic:
            signode += nodes.Text('<{}>'.format(generic))
        if inherits:
            signode += nodes.Text(' : ')

            inherit_types = split_sig(inherits)
            i = 1
            for t in inherit_types:
                self.append_ref_signature(t, signode)
                if i < len(inherit_types):
                    signode += nodes.Text(', ')
                    i += 1

        opt_parent = self.options[
            'parent'] if 'parent' in self.options else None
        form = '{}.{}' if self.has_parent() and opt_parent else '{}{}'
        parent = form.format(self.get_parent() if self.has_parent() else '',
                             opt_parent if opt_parent else '')
        self.env.ref_context[CSharpObject.PARENT_TYPE_NAME] = self.ParentType(
            parent=parent, name=name, type=typ, override=opt_parent)
        if opt_parent:
            self.env.ref_context[self.PARENT_ATTR_NAME] = parent
        return self.get_fullname(name)
    def handle_subprogram_decl(self, decl, node, signode, annotations):
        # type: (lal.BasicSubpDecl, N.desc, N.desc_signature) -> None

        subp_spec = decl.p_subp_spec_or_null().cast(lal.SubpSpec)
        ret_type = subp_spec.p_returns
        kind = 'function' if ret_type else 'procedure'
        name = decl.p_defining_name.text

        node['objtype'] = node['desctype'] = kind
        signode += N.desc_annotation(kind + ' ', kind + ' ')
        signode += N.desc_name(name, name)

        params = subp_spec.p_params

        if params:
            signode += nodes.Text(' ')
            param_list = N.desc_parameterlist()
            param_list.child_text_separator = ''
            signode += param_list
            for i, param in enumerate(params):
                assert isinstance(param, lal.ParamSpec)
                if i > 0:
                    param_list += nodes.Text('; ')
                name = param.f_ids.text
                ptype = param.f_type_expr.text
                param_list += N.desc_parameter(name, name)
                param_list += nodes.Text(' : ')
                param_list += N.desc_type(ptype, ptype)

        if ret_type:
            signode += N.desc_annotation(' return ', ' return ')
            signode += N.desc_type(ret_type.text, ret_type.text)

        if isinstance(decl, lal.AbstractSubpDecl):
            signode += N.desc_annotation(' is abstract', ' is abstract')
Beispiel #3
0
 def handle_signature(self, sig, signode):
     mod, typ, name, generic, params = self.parse_signature(sig)
     signode += addnodes.desc_type(
         text='{}'.format(mod.strip() if mod else 'private'))
     signode += nodes.Text(' ')
     self.append_ref_signature(typ if typ else name, signode)
     signode += nodes.inline(text=' ')
     if typ:
         signode += addnodes.desc_addname(text='{}'.format(name))
     if generic:
         signode += nodes.Text('<{}>'.format(generic))
     param_node = addnodes.desc_parameterlist()
     if params:
         self._params_list = self._get_params(params)
         for (pmod, ptyp, pname, pvalue) in self._params_list:
             pnode = addnodes.desc_parameter()
             if pmod:
                 pnode += addnodes.desc_type(text='{}'.format(pmod))
                 pnode += nodes.Text(' ')
             self.append_ref_signature(ptyp, pnode)
             pnode += nodes.Text(' ')
             pnode += addnodes.desc_addname(text='{}'.format(pname))
             if pvalue:
                 pnode += nodes.Text(' = ')
                 self.append_ref_signature(pvalue, pnode)
             param_node += pnode
     signode += param_node
     return self.get_fullname(name)
Beispiel #4
0
 def handle_signature(self, sig, signode):
     mod, name = self.parse_signature(sig)
     if mod:
         signode += addnodes.desc_type(text='{}'.format(mod.strip()))
         signode += nodes.Text(' ')
     signode += addnodes.desc_type(text='enum')
     signode += nodes.Text(' ')
     signode += addnodes.desc_name(text='{}'.format(name.strip()))
     return self.get_fullname(name)
Beispiel #5
0
    def foobar(argument, is_last, param):
        parts = argument.replace('[]', '()').split(' ')

        if len(parts) != 4:
            raise ValueError("Argument '{0}' has unexpected format".format(argument))

        param += addnodes.desc_type(parts[0] + ' ', parts[0] + ' ')
        param += nodes.emphasis(parts[1] + ' ', parts[1] + ' ')
        param += addnodes.desc_type(' '.join(parts[2:]), ' '.join(parts[2:]))

        if not is_last:
            param += nodes.emphasis(', ', ', ')
Beispiel #6
0
    def handle_signature(self, sig, signode):
        signode += addnodes.desc_annotation("relation", "relation ")
        typ, name, mult = sig.split(" ")
        signode += addnodes.desc_type(typ, typ + " ")

        show_name = name
        if "." in name:
            _, show_name = name.split(".")
        signode += addnodes.desc_addname(name, show_name)

        signode += addnodes.desc_type(mult, " " + mult)
        return name
Beispiel #7
0
 def append_ref_signature(self, typname, signode, append_generic=True):
     match = REF_TYPE_RE.match(typname.strip())
     if not match:
         raise Exception(
             'Invalid reference type signature. Got: {}'.format(typname))
     is_new, name, generic, is_array, constr = match.groups()
     if is_new:
         signode += addnodes.desc_type(text='new')
         signode += nodes.Text(' ')
     types = name.split('.')
     explicit_path = []
     i = 1
     for t in types:
         styp = t.strip()
         explicit_path.append(styp)
         refnode = addnodes.pending_xref('',
                                         refdomain='sphinxsharp',
                                         reftype=None,
                                         reftarget=styp,
                                         modname=None,
                                         classname=None)
         if not self.has_parent():
             refnode[self.PARENT_ATTR_NAME] = None
         else:
             refnode[self.PARENT_ATTR_NAME] = self.get_parent()
         if len(explicit_path) > 1:
             target_path = '.'.join(explicit_path[:-1])
             type_par = self.get_type_parent() if self.has_parent_type(
             ) else None
             refnode[self.PARENT_ATTR_NAME] = (type_par.parent + '.' \
                                                 if type_par and type_par.parent \
                                                 else '') + target_path
         refnode += addnodes.desc_type(text=styp)
         signode += refnode
         if i < len(types):
             signode += nodes.Text('.')
             i += 1
     if append_generic and generic:
         signode += nodes.Text('<')
         gen_groups = split_sig(generic)
         i = 1
         for g in gen_groups:
             self.append_ref_signature(g, signode, append_generic)
             if i < len(gen_groups):
                 signode += nodes.Text(', ')
                 i += 1
         signode += nodes.Text('>')
     if is_array:
         signode += nodes.Text('[]')
     if constr is not None:
         signode += nodes.Text('()')
Beispiel #8
0
    def foobar(argument, is_last, param):
        parts = argument.split(':')
        name = parts[0].split(' ')

        if len(name) > 1:
            param += addnodes.desc_type(name[0] + ' ', name[0] + ' ')
            param += nodes.emphasis(' '.join(name[1:]) + ': ', ' '.join(name[1:]) + ': ')
        else:
            param += nodes.emphasis(name[0] + ': ', name[0] + ': ')

        param += addnodes.desc_type(parts[-1], parts[-1])

        if not is_last:
            param += nodes.emphasis('; ', '; ')
Beispiel #9
0
 def _make_index_section(self, obj, title, id):
     section = self._make_section(title)
     subobjs = obj.filter_by_id(id)
     kwargs = {
         'refdomain': 'cpp',
         'refexplicit': False,
     }
     if subobjs:
         lst = addnodes.desc()
         lst['objtype'] = 'function function-index'
         for obj in subobjs:
             desc = addnodes.desc_signature()
             span = nodes.inline()
             try:
                 kwargs['reftype'] = 'func'
                 if obj.rv is not None:
                     span += addnodes.desc_type(text=str(obj.rv))
             except AttributeError:
                 kwargs['reftype'] = 'member'
                 span += addnodes.desc_type(text=str(obj.typename))
             desc += span
             desc += nodes.Text(u' ')
             name = unicode(obj.name)
             kwargs['reftarget'] = unicode(obj.get_name())
             name = name.split('::')[-1]
             desc_name = addnodes.desc_name()
             refnode = addnodes.pending_xref('', **kwargs)
             innernode = nodes.literal(text=name)
             innernode.attributes['classes'].extend(['xref', 'cpp', 'cpp-func'])
             refnode += innernode
             desc_name += refnode
             desc += desc_name
             try:
                 paramlist = addnodes.desc_parameterlist()
                 for param_obj in obj.signature:
                     param = addnodes.desc_parameter('', '', noemph=True)
                     if param_obj.type is not None:
                         param += nodes.Text(str(param_obj.type) + ' ')
                     param += nodes.emphasis(text=str(param_obj.name))
                     paramlist += param
                 desc += paramlist
                 if obj.const:
                     desc += nodes.Text(u' const')
             except AttributeError:
                 pass
             lst += desc
         section += lst
         return section
     return None
Beispiel #10
0
 def handle_signature(self, sig: str, signode: desc_signature) -> Signature:
     signode += desc_annotation(self.objtype, self.objtype)
     module_name = self.options['module'] + '.'
     signode += desc_name(sig, sig)
     signode += desc_type(' = ', ' = ')
     signode.extend(parse_type(self.options['target'], make_desc_type))
     return Signature(self.objtype, sig, self.options['module'])
Beispiel #11
0
 def handle_signature(self, sig: str, signode: desc_signature) -> Signature:
     if 'oneway' in self.options:
         signode += desc_annotation('oneway', 'oneway')
     signode += desc_type(self.options['return_type'] + ' ',
                          self.options['return_type'] + ' ')
     service_name = self.options['service'] + '.'
     signode += desc_name(sig, sig)
     signode += desc_addname('(', '(')
     first = True
     for name, type_ in self.options['parameters']:
         if first:
             first = False
         else:
             signode += desc_addname(', ', ', ')
         signode.extend(parse_type(type_, make_desc_type))
         signode += make_desc_type(' ')
         signode += desc_addname(name, name)
     signode += desc_addname(')', ')')
     first = True
     if self.options['exceptions']:
         signode += desc_addname(' throws (', ' throws (')
     for name, type_ in self.options['exceptions']:
         if first:
             first = False
         else:
             signode += desc_addname(', ', ', ')
         signode.extend(parse_type(type_, make_desc_type))
         signode += make_desc_type(' ')
         signode += desc_addname(name, name)
     if self.options['exceptions']:
         signode += desc_addname(')', ')')
     return Signature(self.objtype, service_name + sig,
                      self.options['module'])
Beispiel #12
0
    def _handle_object_signature(self, sig, signode, m):
        "Transform a Nim object into RST nodes."
        name = m.groups()[0]

        signode += addnodes.desc_type('object', 'object')
        signode += addnodes.desc_name(name, name)
        return name
Beispiel #13
0
def _pseudo_parse_arglist(signode, arglist):
    paramlist = desc_parameterlist()
    param = addnodes.desc_type()

    def foobar(argument, is_last, param):
        parts = argument.split(':')
        name = parts[0].split(' ')

        if len(name) > 1:
            param += addnodes.desc_type(name[0] + ' ', name[0] + ' ')
            param += nodes.emphasis(' '.join(name[1:]) + ': ', ' '.join(name[1:]) + ': ')
        else:
            param += nodes.emphasis(name[0] + ': ', name[0] + ': ')

        param += addnodes.desc_type(parts[-1], parts[-1])

        if not is_last:
            param += nodes.emphasis('; ', '; ')

    arguments = arglist.split(';')
    for argument in arguments[:-1]:
        foobar(argument.strip(), False, param)
    foobar(arguments[-1].strip(), True, param)

    paramlist += param
    signode += paramlist
Beispiel #14
0
    def handle_signature(self, sig, signode):
        m = ks_sig_re.match(sig)
        name = m.group('object')

        current_struct = self.env.temp_data.get('ks:structure')
        if m.group('prefix') is None:
            if current_struct is not None:
                fullname = current_struct + ':' + name
        else:
            struct = m.group('prefix').split(':')[-1]
            fullname = struct + ':' + name

        if struct is not None:
            if struct != '':
                signode += addnodes.desc_type(struct, struct + ':')

        signode += addnodes.desc_name(fullname, name)

        args = m.group('args')
        if args:
            signode += addnodes.desc_parameterlist(args, args)
        else:
            signode += addnodes.desc_parameterlist()

        return fullname
Beispiel #15
0
    def render(self):

        title = self.title()
        rettype, name, arglist, const, signature = self.directive.parse_title(title)
        target = self.directive.create_target(name)

        # add a signature node 
        signode = addnodes.desc_signature(signature, '')
        signode['first'] = False

        signode += addnodes.desc_type('', '')
        
        self.directive.add_return_type(signode[-1] , rettype)
        name = self.directive.add_sig_name(signode, name)
        self.directive.set_name(name)
        self.directive.add_sig_args(signode, arglist, const)


        self.directive.before_content()
        description_nodes = self.description()
        content_node = addnodes.desc_content('')
        content_node += description_nodes
        self.directive.after_content()

        target.extend(signode)
        term = self.node_factory.term("","", ids=[name], *target )
        entry = self.node_factory.definition_list_item("",term, content_node)

        
        return [entry]
Beispiel #16
0
    def render(self):
        title = self.title()
        rettype, name, arglist, const, signature = self.directive.parse_title(title)
        fullname = self.directive.get_full_name(name)

        if self.data_object.kind == "function":
            # set True that this might be a structure method
            self.directive.sphinx_directive.typemethod_set = True
        
        target = self.directive.create_target(fullname)

        if self.data_object.kind == "function":
            self.directive.sphinx_directive.typemethod_set = False
      
        # add a signature node 
        signode = addnodes.desc_signature(signature, '')
        signode['first'] = False

        signode += addnodes.desc_type('', '')
        
        self.directive.add_return_type(signode[-1] , rettype)
        name = self.directive.add_sig_name(signode, name)
        self.directive.add_sig_args(signode, arglist, const)

        description_nodes = self.description()
        content_node = addnodes.desc_content('')
        content_node += description_nodes
        

        target.extend(signode)
        term = self.node_factory.term("","", ids=[name], *target )
        entry = self.node_factory.definition_list_item("",term, content_node)

        return [entry]
Beispiel #17
0
    def handle_signature(self, sig, signode):
        container_class_name = self.env.temp_data.get('kotlin:class')
        enum_case = None
        assoc_value = None
        raw_value = None

        # split on ( -> first part is case name
        parts = [x.strip() for x in sig.split('(', 1)]
        enum_case = parts[0].strip()
        if len(parts) > 1:
            parts = parts[1].rsplit('=', 1)
            assoc_value = parts[0].strip()
            if len(parts) > 1:
                raw_value = parts[1].strip()
            if assoc_value == "":
                assoc_value = None
            else:
                assoc_value = "(" + assoc_value
        else:
            parts = [x.strip() for x in sig.split('=', 1)]
            enum_case = parts[0].strip()
            if len(parts) > 1:
                raw_value = parts[1].strip()

        # Add class name
        signode += addnodes.desc_name(enum_case, enum_case)
        if assoc_value:
            signode += addnodes.desc_type(assoc_value, assoc_value)
        if raw_value:
            signode += addnodes.desc_addname(raw_value, " = " + raw_value)

        if container_class_name:
            enum_case = container_class_name + '.' + enum_case
        return enum_case, enum_case, True
Beispiel #18
0
    def handle_signature(self, sig, signode):
        m = ks_sig_re.match(sig)
        name = m.group('object')
        struct = None  #might override further down

        current_struct = self.env.temp_data.get('ks:structure')
        if m.group('prefix') is None:
            if current_struct is not None:
                struct = current_struct
                fullname = current_struct + ':' + name
            else:
                raise Exception("Method name lacks a prefix and isn't " +
                    "indented inside a structure section.  Problem " +
                    "occurred at " + self.env.docname + ", line " +
                     str(self.lineno) +
                     ".")
        else:
            struct = m.group('prefix').split(':')[-1]
            fullname = struct + ':' + name

        if struct is not None:
            if struct != '':
                signode += addnodes.desc_type(struct,struct+':')

        signode += addnodes.desc_name(fullname, name)

        args = m.group('args')
        if args:
            signode += addnodes.desc_parameterlist(args,args)
        else:
            signode += addnodes.desc_parameterlist()


        return fullname
Beispiel #19
0
    def handle_signature(self, sig, signode):
        sig = sig.strip()
        type_name, name, arglist = avro_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
Beispiel #20
0
    def handle_signature(self, sig, signode):
        try:
            tag, name = sig.split()
        except ValueError:
            tag, name = None, sig
        cache = _APP_CACHES.get(self.env.app, {})
        key = {'struct': CursorKind.STRUCT_DECL}[tag], (name, )
        if key in cache:
            node, comment, start, end, members = cache[key]
            signode += addnodes.desc_type(tag, tag + ' ')
            signode += addnodes.desc_name(node.spelling, node.spelling)

            self.content = ViewList()
            for line in comment.splitlines():
                self.content.append(line, '<unknown>')

            self.content.append('', '<unknown>')

            for (_, member_name), value in members.items():
                member_node, member_comment, _, _, _ = value
                self.content.append(
                    '.. c:member:: %s %s' % (member_node.type.spelling, member_node.spelling),
                    '<unknown>'
                )
                self.content.append('', '<unknown>')
                for line in member_comment.splitlines():
                    self.content.append('   ' + line, '<unknown>')
                self.content.append('', '<unknown>')


        return sig
Beispiel #21
0
    def handle_signature(self, sig, signode):
        """Transform a C signature into RST nodes."""
        # first try the function pointer signature regex, it's more specific
        m = c_funcptr_sig_re.match(sig)
        if m is None:
            m = c_sig_re.match(sig)
        if m is None:
            raise ValueError('no match')
        rettype, name, arglist, const = m.groups()

        signode += addnodes.desc_type('', '')
        self._parse_type(signode[-1], rettype)
        try:
            classname, funcname = name.split('::', 1)
            classname += '::'
            signode += addnodes.desc_addname(classname, classname)
            signode += addnodes.desc_name(funcname, funcname)
            # name (the full name) is still both parts
        except ValueError:
            signode += addnodes.desc_name(name, name)
        # clean up parentheses from canonical name
        m = c_funcptr_name_re.match(name)
        if m:
            name = m.group(1)

        typename = self.env.temp_data.get('c:type')
        if self.name == 'c:member' and typename:
            fullname = typename + '.' + name
        else:
            fullname = name

        if not arglist:
            if self.objtype == 'function':
                # for functions, add an empty parameter list
                signode += addnodes.desc_parameterlist()
            if const:
                signode += addnodes.desc_addname(const, const)
            return fullname

        paramlist = addnodes.desc_parameterlist()
        arglist = arglist.replace('`', '').replace('\\ ', '')  # remove markup
        # this messes up function pointer types, but not too badly ;)
        args = arglist.split(',')
        for arg in args:
            arg = arg.strip()
            param = addnodes.desc_parameter('', '', noemph=True)
            try:
                ctype, argname = arg.rsplit(' ', 1)
            except ValueError:
                # no argument name given, only the type
                self._parse_type(param, arg)
            else:
                self._parse_type(param, ctype)
                # separate by non-breaking space in the output
                param += nodes.emphasis(' ' + argname, u'\xa0' + argname)
            paramlist += param
        signode += paramlist
        if const:
            signode += addnodes.desc_addname(const, const)
        return fullname
Beispiel #22
0
 def handle_signature(self, sig, signode):
     mod, typ, name, getter, setter = self.parse_signature(sig)
     signode += addnodes.desc_type(text='{}'.format(mod if mod else 'private'))
     signode += nodes.Text(' ')
     self.append_ref_signature(typ, signode)
     signode += nodes.inline(text=' ')
     signode += addnodes.desc_addname(text='{}'.format(name))
     signode += nodes.Text(' { ')
     accessors = []
     if getter:
         accessors.append('get;')
     if setter:
         accessors.append(setter.strip())
     signode += addnodes.desc_type(text=' '.join(accessors))
     signode += nodes.Text(' } ')
     return self.get_fullname(name)
Beispiel #23
0
Datei: c.py Projekt: Scalr/sphinx
    def handle_signature(self, sig, signode):
        """Transform a C signature into RST nodes."""
        # first try the function pointer signature regex, it's more specific
        m = c_funcptr_sig_re.match(sig)
        if m is None:
            m = c_sig_re.match(sig)
        if m is None:
            raise ValueError('no match')
        rettype, name, arglist, const = m.groups()

        signode += addnodes.desc_type('', '')
        self._parse_type(signode[-1], rettype)
        try:
            classname, funcname = name.split('::', 1)
            classname += '::'
            signode += addnodes.desc_addname(classname, classname)
            signode += addnodes.desc_name(funcname, funcname)
            # name (the full name) is still both parts
        except ValueError:
            signode += addnodes.desc_name(name, name)
        # clean up parentheses from canonical name
        m = c_funcptr_name_re.match(name)
        if m:
            name = m.group(1)

        typename = self.env.temp_data.get('c:type')
        if self.name == 'c:member' and typename:
            fullname = typename + '.' + name
        else:
            fullname = name

        if not arglist:
            if self.objtype == 'function':
                # for functions, add an empty parameter list
                signode += addnodes.desc_parameterlist()
            if const:
                signode += addnodes.desc_addname(const, const)
            return fullname

        paramlist = addnodes.desc_parameterlist()
        arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
        # this messes up function pointer types, but not too badly ;)
        args = arglist.split(',')
        for arg in args:
            arg = arg.strip()
            param = addnodes.desc_parameter('', '', noemph=True)
            try:
                ctype, argname = arg.rsplit(' ', 1)
            except ValueError:
                # no argument name given, only the type
                self._parse_type(param, arg)
            else:
                self._parse_type(param, ctype)
                # separate by non-breaking space in the output
                param += nodes.emphasis(' '+argname, u'\xa0'+argname)
            paramlist += param
        signode += paramlist
        if const:
            signode += addnodes.desc_addname(const, const)
        return fullname
Beispiel #24
0
    def handle_field_signature(self, sig, signode):
        try:
            member = javalang.parse.parse_member_signature(sig)
        except javalang.parser.JavaSyntaxError:
            raise self.error("syntax error in field signature")

        if not isinstance(member, javalang.tree.FieldDeclaration):
            raise self.error("expected field declaration")

        mods = formatter.output_modifiers(member.modifiers).build()
        signode += nodes.Text(mods + ' ', mods + ' ')

        tnode = addnodes.desc_type('', '')
        tnode += self._build_type_node(member.type)

        signode += tnode
        signode += nodes.Text(' ', ' ')

        if len(member.declarators) > 1:
            self.error('only one field may be documented at a time')

        declarator = member.declarators[0]
        signode += addnodes.desc_name(declarator.name, declarator.name)

        dim = '[]' * len(declarator.dimensions)
        signode += nodes.Text(dim)

        if declarator.initializer and isinstance(declarator.initializer, javalang.tree.Literal):
            signode += nodes.Text(' = ' + declarator.initializer.value)

        return declarator.name
Beispiel #25
0
 def handle_signature(self, sig, signode):
     name = CHARmmify(sig, self.length) + ' '
     signode += addnodes.desc_name(name, name)
     for arg in self.arguments[1:]:
         arg = u' %s ' % arg
         signode += addnodes.desc_type(arg, arg)
     return sig.lower()[:self.length]
Beispiel #26
0
    def handle_field_signature(self, sig, signode):
        try:
            member = javalang.parse.parse_member_signature(sig)
        except javalang.parser.JavaSyntaxError:
            raise self.error("syntax error in field signature")

        if not isinstance(member, javalang.tree.FieldDeclaration):
            raise self.error("expected field declaration")

        mods = formatter.output_modifiers(member.modifiers).build()
        signode += nodes.Text(mods + ' ', mods + ' ')

        tnode = addnodes.desc_type('', '')
        tnode += self._build_type_node(member.type)

        signode += tnode
        signode += nodes.Text(' ', ' ')

        if len(member.declarators) > 1:
            self.error('only one field may be documented at a time')

        declarator = member.declarators[0]
        signode += addnodes.desc_name(declarator.name, declarator.name)

        dim = '[]' * len(declarator.dimensions)
        signode += nodes.Text(dim)

        if declarator.initializer and isinstance(declarator.initializer,
                                                 javalang.tree.Literal):
            signode += nodes.Text(' = ' + declarator.initializer.value)

        return declarator.name
Beispiel #27
0
    def handle_signature(self, sig, signode):
        m = ks_sig_re.match(sig)
        name = m.group('object')

        current_struct = self.env.temp_data.get('ks:structure')
        if m.group('prefix') is None:
            if current_struct is not None:
                fullname = current_struct + ':' + name
        else:
            struct = m.group('prefix').split(':')[-1]
            fullname = struct + ':' + name

        if struct is not None:
            if struct != '':
                signode += addnodes.desc_type(struct,struct+':')

        signode += addnodes.desc_name(fullname, name)

        args = m.group('args')
        if args:
            signode += addnodes.desc_parameterlist(args,args)
        else:
            signode += addnodes.desc_parameterlist()


        return fullname
Beispiel #28
0
    def run_definition(self, definition, base_ids):
        r"""
        Writes down the definition of a field of a message and parses its
        description.

        In general it can be seen as a function that converts `MessageField` in
        parsed document, with a description section containing both signature and
        informative content text.

        The signature are set as `attribute` object type.
        
        :param definition: a definition that should be parsed
        :param base_ids: the base id for indexing, local scope will be added to that 
                         id, based on the name of the field.
        :return: a full `desc` node, to be added to the main document
        """
        ids = f"{base_ids}.{definition.name}"
        desc_type = addnodes.desc_type(text=definition.type_text)
        desc_name = addnodes.desc_name(text=definition.name)
        desc_annotation = addnodes.desc_annotation(
            text=definition.default_text)
        desc_signature = addnodes.desc_signature(ids=[ids],
                                                 fullname=[definition.name])
        desc_signature += desc_type
        desc_signature += desc_name
        desc_signature += desc_annotation

        section = self.run_section(definition.text, ids)
        desc_content = addnodes.desc_content()
        desc_content += section
        desc = addnodes.desc(objtype="attribute")
        desc += desc_signature
        desc += desc_content
        return desc
Beispiel #29
0
    def handle_signature(self, sig, signode):
        m = ks_sig_re.match(sig)
        name = m.group('object')
        struct = None  #might override further down

        current_struct = self.env.temp_data.get('ks:structure')
        if m.group('prefix') is None:
            if current_struct is not None:
                struct = current_struct
                fullname = current_struct + ':' + name
            else:
                raise Exception(
                    "Method name lacks a prefix and isn't " +
                    "indented inside a structure section.  Problem " +
                    "occurred at " + self.env.docname + ", line " +
                    str(self.lineno) + ".")
        else:
            struct = m.group('prefix').split(':')[-1]
            fullname = struct + ':' + name

        if struct is not None:
            if struct != '':
                signode += addnodes.desc_type(struct, struct + ':')

        signode += addnodes.desc_name(fullname, name)

        args = m.group('args')
        if args:
            signode += addnodes.desc_parameterlist(args, args)
        else:
            signode += addnodes.desc_parameterlist()

        return fullname
Beispiel #30
0
    def append_type(self, node, input_typ, ignored_types=None):
        """ ignored_types is a list of types to ignore in the generics of this type """
        typ, modifiers, generic_types, inherited_types, array, ptr = parse_type_signature(
            input_typ, (self.env.docname, self.lineno))
        tnode = addnodes.pending_xref('',
                                      refdomain='cs',
                                      reftype='type',
                                      reftarget=typ,
                                      modname=None,
                                      classname=None)

        # Note: this may not be the correct parent namespace
        if not self.has_parent():
            tnode['cs:parent'] = None
        else:
            tnode['cs:parent'] = self.get_parent()

        if modifiers:
            self.append_modifiers(node, modifiers)

        typ_short = ExternalRefs.shorten_type(typ)
        tnode += addnodes.desc_type(typ_short, typ_short)
        node += tnode

        if generic_types:
            self.append_generics(node,
                                 generic_types,
                                 ignored_types=ignored_types)
        if array:
            node += nodes.Text(array)
        if ptr:
            node += nodes.Text(ptr)
Beispiel #31
0
    def render(self):
        title = self.title()
        rettype, name, arglist, const, signature = self.directive.parse_title(
            title)
        fullname = self.directive.get_full_name(name)

        if self.data_object.kind == "function":
            # set True that this might be a structure method
            self.directive.sphinx_directive.typemethod_set = True

        target = self.directive.create_target(fullname)

        if self.data_object.kind == "function":
            self.directive.sphinx_directive.typemethod_set = False

        # add a signature node
        signode = addnodes.desc_signature(signature, '')
        signode['first'] = False

        signode += addnodes.desc_type('', '')

        self.directive.add_return_type(signode[-1], rettype)
        name = self.directive.add_sig_name(signode, name)
        self.directive.add_sig_args(signode, arglist, const)

        description_nodes = self.description()
        content_node = addnodes.desc_content('')
        content_node += description_nodes

        target.extend(signode)
        term = self.node_factory.term("", "", ids=[name], *target)
        entry = self.node_factory.definition_list_item("", term, content_node)

        return [entry]
Beispiel #32
0
    def _handle_object_signature(self, sig, signode, m):
        "Transform a Nim object into RST nodes."
        name = m.groups()[0]

        signode += addnodes.desc_type('object', 'object')
        signode += addnodes.desc_name(name, name)
        return name
Beispiel #33
0
    def render(self):

        title = self.title()
        rettype, name, arglist, const, signature = self.directive.parse_title(
            title)
        target = self.directive.create_target(name)

        # add a signature node
        signode = addnodes.desc_signature(signature, '')
        signode['first'] = False

        signode += addnodes.desc_type('', '')

        self.directive.add_return_type(signode[-1], rettype)
        name = self.directive.add_sig_name(signode, name)
        self.directive.set_name(name)
        self.directive.add_sig_args(signode, arglist, const)

        self.directive.before_content()
        description_nodes = self.description()
        content_node = addnodes.desc_content('')
        content_node += description_nodes
        self.directive.after_content()

        target.extend(signode)
        term = self.node_factory.term("", "", ids=[name], *target)
        entry = self.node_factory.definition_list_item("", term, content_node)

        return [entry]
    def handle_signature(self, sig, signode):
        match = param_var_re.fullmatch(sig)

        if match is None:
            logger.warning('could not parse {}'.format(sig))
            return None

        # normalize type string
        type_str, visibility, name = match.groups()

        if name is None:
            logger.warning('missing name from {}'.format(sig))
            return None

        type_str = normalize_type(type_str)

        signode += addnodes.desc_type(text=type_str + ' ')

        if visibility is not None:
            signode += nodes.emphasis(text=visibility + ' ')

        signode += addnodes.desc_name(text=name)

        return SolObjFullName(
            name=name,
            obj_path=tuple(self.env.ref_context.get('sol:obj_path', [])),
            param_types=None,
        )
Beispiel #35
0
    def handle_signature(self, sig, signode):
        """
        Transform a CFEngine 3 signature into RST nodes.
        """
        sig_d = {}
        m = cf3_sig_re.match(sig)
        try:
            sig_d['type'], sig_d['ns'], sig_d['id'], sig_d['args'] = m.groups()
        except AttributeError:
            raise ValueError

        sig_d['ns'] = sig_d['ns'] or self.options.get(
            'namespace', self.env.temp_data.get('cf3:namespace')
        )
        fullname = []
        fn_app   = fullname.append
        fn_app(self.objtype + _FN_SEP)
        if self.objtype in ('body', 'bundle'):
            tnode  = addnodes.desc_type('', '')
            tnode += nodes.Text(self.objtype + _SP, self.objtype)

            try:
                sig_d['type'] = sig_d['type'].strip()
                tnode += nodes.Text(sig_d['type'] + _SP, sig_d['type'])
                fn_app(sig_d['type'] + _FN_SEP)
            except AttributeError:
                self.state_machine.reporter.warning(
                    'invalid %s definition: %s' % (self.objtype, sig),
                    line=self.lineno
                )
            signode += tnode

        if sig_d['ns'] and sig_d['ns'] != 'default' \
            and self.env.config.add_module_names:
            signode += addnodes.desc_addname(
                sig_d['ns'], sig_d['ns'] + _NS_SEP
            )
        signode += addnodes.desc_name(sig_d['id'], sig_d['id'])
        fn_app(sig_d['id'])

        signode['namespace'] = sig_d['ns']
        signode['fullname']  = ''.join(fullname)

        if self.objtype == 'class':
            signode += addnodes.desc_name(_CL_MRK, _CL_MRK)
            return ''.join(fullname), sig_d['ns']

        if not sig_d['args'] and self.objtype == 'function':
            signode += addnodes.desc_parameterlist()
            return ''.join(fullname), sig_d['ns']

        if sig_d['args']:
            paramlist = addnodes.desc_parameterlist()
            for arg in sig_d['args'].split(','):
                arg = arg.strip()
                paramlist += addnodes.desc_parameter(arg, arg)
            signode += paramlist

        return ''.join(fullname), sig_d['ns']
Beispiel #36
0
		def p_expression_word(p):
			'''expression : WORD
		                  | WORD STAR
                                  | WORD STAR STAR
                                  | WORD LT WORD GT
                                  | ENUM WORD
		                  | VOID '''
                        p[0] = addnodes.desc_type(" ".join(p[1:]), " ".join(p[1:]))
Beispiel #37
0
 def handle_signature(self, sig, signode):
     ssig = sig.split()
     name = u'%s-spec ' % ssig[0]
     signode += addnodes.desc_name(name, name)
     for arg in self.arguments[1:]:
         arg = u' %s ' % arg
         signode += addnodes.desc_type(arg, arg)
     return sig.lower()
Beispiel #38
0
 def handle_signature(self, sig, signode):
     mod, typ, name, self._default = self.parse_signature(sig)
     signode += addnodes.desc_type(text='{}'.format(mod if mod else 'private'))
     signode += nodes.Text(' ')
     self.append_ref_signature(typ, signode)
     signode += nodes.inline(text=' ')
     signode += addnodes.desc_addname(text='{}'.format(name))
     return self.get_fullname(name)
Beispiel #39
0
    def _handle_enum_signature(self, sig, signode, m):
        "Transform a Nim enum into RST nodes."
        name, values = m.groups()

        signode += addnodes.desc_type('enum', 'enum')
        signode += addnodes.desc_name(name, name)
        signode += addnodes.desc_addname(values, '= ' + values)
        return name
Beispiel #40
0
 def handle_signature(self, sig: str, signode: desc_signature) -> Signature:
     annotation = 'field'
     signode += desc_annotation(annotation, annotation)
     struct_name = self.options['struct'] + '.'
     signode += desc_name(sig, sig)
     signode += desc_type(': ', ': ')
     signode.extend(parse_type(self.options['type'], make_desc_type))
     return Signature(self.kind, struct_name + sig, self.options['module'])
Beispiel #41
0
    def _handle_enum_signature(self, sig, signode, m):
        "Transform a Nim enum into RST nodes."
        name, values = m.groups()

        signode += addnodes.desc_type('enum', 'enum')
        signode += addnodes.desc_name(name, name)
        signode += addnodes.desc_addname(values, '= ' + values)
        return name
Beispiel #42
0
    def handle_signature(self, sig: str,
                         signode: addnodes.desc_signature) -> Tuple[str, str]:
        """Transform a signature/object into RST nodes."""
        try:
            self.obj = BlarkSphinxCache.instance().find_by_name(sig)
        except KeyError:
            self.obj = MissingDeclaration(sig)
            logger.error("Could not find object: %r (signatures unsupported)",
                         sig)
            raise ValueError(f"Code object not found: {sig!r}")

        self.env.ref_context["bk:function"] = self.obj

        signode["ids"] = [sig]
        signode["docname"] = self.env.docname
        signode["qualified_name"] = sig
        domain_data = self.env.domaindata["bk"][self.signature_prefix.lower()]
        domain_data.setdefault(sig, []).append(signode)
        sig_prefix = self.get_signature_prefix(sig)
        signode += addnodes.desc_annotation(str(sig_prefix), '', *sig_prefix)
        signode += addnodes.desc_name(self.obj.name, self.obj.name)

        paramlist = addnodes.desc_parameterlist("paramlist")

        for block in ("VAR_INPUT", "VAR_IN_OUT", "VAR_OUTPUT", "STRUCT"):
            decls = self.obj.declarations_by_block.get(block, {})
            for variable, decl in decls.items():
                node = addnodes.desc_parameter()
                # node += addnodes.desc_sig_operator('', '*')
                node += addnodes.desc_type("", decl.type)
                node += addnodes.desc_sig_space()
                node += addnodes.desc_sig_name("", variable)
                if block == "VAR_OUTPUT":
                    node += addnodes.desc_sig_punctuation(text="=>")

                paramlist += node

        signode += paramlist

        if getattr(self.obj, "return_type", None) is not None:
            signode += addnodes.desc_returns()
            signode += addnodes.desc_type(text=self.obj.return_type)

        prefix = ""
        return sig, prefix
Beispiel #43
0
    def handle_signature(self, sig, signode):
        signode += addnodes.desc_annotation("attribute", "attribute ")
        typ, name = sig.split(" ")
        default = None
        if "=" in name:
            name, default = name.split("=")

        signode += addnodes.desc_type(typ, typ + " ")

        show_name = name
        if "." in name:
            _, show_name = name.split(".")
        signode += addnodes.desc_addname(name, show_name)

        if default is not None:
            signode += addnodes.desc_type(default, "=" + default)

        return name
Beispiel #44
0
    def handle_signature(self, sig, signode):
        """
        Transform a CFEngine 3 signature into RST nodes.
        """
        sig_d = {}
        m = cf3_sig_re.match(sig)
        try:
            sig_d['type'], sig_d['ns'], sig_d['id'], sig_d['args'] = m.groups()
        except AttributeError:
            raise ValueError

        sig_d['ns'] = sig_d['ns'] or self.options.get(
            'namespace', self.env.temp_data.get('cf3:namespace'))
        fullname = []
        fn_app = fullname.append
        fn_app(self.objtype + _FN_SEP)
        if self.objtype in ('body', 'bundle'):
            tnode = addnodes.desc_type('', '')
            tnode += nodes.Text(self.objtype + _SP, self.objtype)

            try:
                sig_d['type'] = sig_d['type'].strip()
                tnode += nodes.Text(sig_d['type'] + _SP, sig_d['type'])
                fn_app(sig_d['type'] + _FN_SEP)
            except AttributeError:
                self.state_machine.reporter.warning(
                    'invalid %s definition: %s' % (self.objtype, sig),
                    line=self.lineno)
            signode += tnode

        if sig_d['ns'] and sig_d['ns'] != 'default' \
            and self.env.config.add_module_names:
            signode += addnodes.desc_addname(sig_d['ns'],
                                             sig_d['ns'] + _NS_SEP)
        signode += addnodes.desc_name(sig_d['id'], sig_d['id'])
        fn_app(sig_d['id'])

        signode['namespace'] = sig_d['ns']
        signode['fullname'] = ''.join(fullname)

        if self.objtype == 'class':
            signode += addnodes.desc_name(_CL_MRK, _CL_MRK)
            return ''.join(fullname), sig_d['ns']

        if not sig_d['args'] and self.objtype == 'function':
            signode += addnodes.desc_parameterlist()
            return ''.join(fullname), sig_d['ns']

        if sig_d['args']:
            paramlist = addnodes.desc_parameterlist()
            for arg in sig_d['args'].split(','):
                arg = arg.strip()
                paramlist += addnodes.desc_parameter(arg, arg)
            signode += paramlist

        return ''.join(fullname), sig_d['ns']
Beispiel #45
0
    def _make_typedef_documentation(self, obj):
        kwargs = {
            'refdomain': 'cpp',
            'refexplicit': False,
        }

        content = addnodes.desc_signature()
        content['ids'].append(obj.get_id())
        content.attributes['first'] = True

        span = nodes.inline()
        span += nodes.emphasis(text = u'typedef ')
        if obj._ref is None or obj._ref is '' or self._get_obj_by_refid(obj._ref) is None:
            span += addnodes.desc_type(text = obj._type)
        else:
            ref = self._get_obj_by_refid(obj._ref)
            kwargs['reftarget'] = unicode(ref.get_name())
            kwargs['reftype'] = qiapidoc.data.types.get_obj_type(ref)
            refname = addnodes.desc_name()
            refnode = addnodes.pending_xref('', **kwargs)
            innernode = nodes.literal(text = unicode(ref.name))
            innernode.attributes['classes'].extend(['xref', 'cpp', 'cpp-func'])
            refnode += innernode
            refname += refnode
            span += refname
        content += span

        if obj._args is '':
            content += nodes.Text(u' ')

        span = nodes.inline()
        span += addnodes.desc_type(text = obj.rawname)
        content += span

        if obj._args is not '':
            content += nodes.inline() + addnodes.desc_type(text = obj._args)


        span = nodes.inline()
        span += nodes.Text(obj._desc)

        return content, span
Beispiel #46
0
    def handle_signature(self, sig, signode):
        cache = _APP_CACHES.get(self.env.app, {})
        key = CursorKind.VAR_DECL, (sig, )
        if key in cache:
            node, comment, start, end, _ = cache[key]
            signode += addnodes.desc_type(node.type.spelling, node.type.spelling + ' ')
            signode += addnodes.desc_name(node.spelling, node.spelling)

            self.content = ViewList()
            for lineno, line in enumerate(comment.splitlines(), start[0]):
                self.content.append(line, '<unknown>', lineno)
        return sig
    def handle_type_sig(self, sig, signode):
        m = ada_type_sig_re.match(sig)
        if m is None:
            raise Exception(f"m did not match for sig {sig}")

        name = m.groups()[0]

        signode += addnodes.desc_annotation("type ", "type ")
        fullname = self._resolve_module_name(signode, "", name)

        signode += addnodes.desc_type(name, "")
        return fullname
Beispiel #48
0
    def handle_signature(self, sig, signode):
        cache = _APP_CACHES.get(self.env.app, {})
        key = CursorKind.FUNCTION_DECL, (sig, )
        if key in cache:
            node, comment, start, end, _ = cache[key]

            result_type = node.type.get_result()
            signode += addnodes.desc_type(result_type.spelling, result_type.spelling + ' ')
            signode += addnodes.desc_name(node.spelling, node.spelling)
            paramlist = addnodes.desc_parameterlist()
            for argument in node.get_arguments():
                parameter = addnodes.desc_parameter()
                parameter += addnodes.desc_type(argument.type.spelling, argument.type.spelling + ' ')
                parameter += nodes.Text(argument.spelling, argument.spelling)
                paramlist += parameter
            signode += paramlist

            self.content = ViewList()
            for lineno, line in enumerate(comment.splitlines(), start[0]):
                self.content.append(line, '<unknown>', lineno)
        return sig
 def _parse_type(self, type_name, node):
     if type_name.endswith("..."):
         type_name = type_name[:-3]
     if type_name in primitives:
         node += addnodes.desc_type(type_name, type_name)
     else:
         m = fq_classname_pattern.match(type_name)
         if m is not None:
             package, classname, generics = m.groups()
         else:
             package, classname, generics = None, fqname, None
         if package is not None:
             target = package + classname
         else:
             target = classname
         xref_text = nodes.inline()
         if package is not None and self.env.config.java_show_package:
             xref_text += nodes.Text(package, package)
         xref_text += addnodes.desc_type(classname, classname)
         if generics is not None:
             xref_text += nodes.Text(generics, generics)
         node += addnodes.pending_xref(type_name, xref_text, refdomain="java", reftype="class", reftarget=target)
Beispiel #50
0
def parse_c_signature(signode, sig, desctype):
    """Transform a C (or C++) signature into RST nodes."""
    # first try the function pointer signature regex, it's more specific
    m = c_funcptr_sig_re.match(sig)
    if m is None:
        m = c_sig_re.match(sig)
    if m is None:
        raise ValueError('no match')
    rettype, name, arglist, const = m.groups()

    signode += addnodes.desc_type('', '')
    parse_c_type(signode[-1], rettype)
    try:
        classname, funcname = name.split('::', 1)
        classname += '::'
        signode += addnodes.desc_addname(classname, classname)
        signode += addnodes.desc_name(funcname, funcname)
        # name (the full name) is still both parts
    except ValueError:
        signode += addnodes.desc_name(name, name)
    # clean up parentheses from canonical name
    m = c_funcptr_name_re.match(name)
    if m:
        name = m.group(1)
    if not arglist:
        if desctype == 'cfunction':
            # for functions, add an empty parameter list
            signode += addnodes.desc_parameterlist()
        return name

    paramlist = addnodes.desc_parameterlist()
    arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
    # this messes up function pointer types, but not too badly ;)
    args = arglist.split(',')
    for arg in args:
        arg = arg.strip()
        param = addnodes.desc_parameter('', '', noemph=True)
        try:
            ctype, argname = arg.rsplit(' ', 1)
        except ValueError:
            # no argument name given, only the type
            parse_c_type(param, arg)
        else:
            parse_c_type(param, ctype)
            param += nodes.emphasis(' '+argname, ' '+argname)
        paramlist += param
    signode += paramlist
    if const:
        signode += addnodes.desc_addname(const, const)
    return name
Beispiel #51
0
    def handle_signature(self, sig, signode):
        name = sig.strip()
        fullname = name

        content = '\n'.join(self.content)
        method = _http_method_re.search(content)
        path = _http_path_re.search(content)

        if method and path:
            prefix = method.group(1)
            signode += addnodes.desc_type(prefix + ' ', prefix + ' ')
            signode += api_url_rule(path.group(1))

        return fullname
Beispiel #52
0
 def make_signature(self):
     cls = self.item.cls
     ret = super(InstanceDocumenter, self).make_signature()
     if cls:
         super_ref = addnodes.pending_xref(
             cls.name, nodes.Text(cls.name, cls.name),
             refdomain='js', reftype='class', reftarget=cls.name
         )
         super_ref['js:module'] = cls['sourcemodule'].name
         ret.append(addnodes.desc_annotation(' instance of ', ' instance of '))
         ret.append(addnodes.desc_type(cls.name, '', super_ref))
     if not ret:
         return [addnodes.desc_name('???', '???')]
     return ret
Beispiel #53
0
 def handle_signature(self, sig, signode):
     """
     Transform a memory key signature into RST nodes.
     Returns the name of the event
     """
     m = memkey_sig_re.match(sig)
     if m is None:
         raise ValueError
     type, name = m.groups()
     signode += addnodes.desc_type('', '')
     _parse_type(signode[-1], type)
     #_parse_type(signode, type)
     signode += nodes.Text(" ")
     signode += sphinx.addnodes.desc_name(name, name)
     return name
Beispiel #54
0
    def handle_signature(self, sig, signode):
        ptype = None
        split = sig.split(':')
        name = split[0]

        if len(split) > 1:
            ptype = split[1]

        quoted = '"{0}"'.format(name)
        signode += addnodes.desc_name(quoted, quoted)

        if ptype:
            signode += nodes.inline(':', ': ')
            signode += addnodes.desc_type(ptype, ptype)

        return sig
 def __init__(self, sexp, types=None, show_defaults=False):
     if not isinstance(sexp, list):
         self.sexp = _read(sexp)
     else:
         self.sexp = sexp
     self.types = types
     if self.types:
         for i, type in enumerate(self.types):
             type_node = addnodes.pending_xref(
                 '', refdomain='cl', reftype='type',
                 reftarget=type)
             # type = " " + type
             type_node += addnodes.desc_type(type, type)
             self.sexp[i] = [self.sexp[i], type_node]
     self.show_defaults = show_defaults
     self.show_defaults = True
Beispiel #56
0
    def _handle_type_signature(self, sig, signode):
        m = ada_type_sig_re.match(sig)
        if m is None:
            print("m did not match")
            raise ValueError

        name, value = m.groups()
        fullname = self._resolve_module_name(signode, '', name)
        
        # signode += addnodes.desc_parameterlist()

        # stack = [signode[-1]]

        # signode += addnodes.desc_type(name, name + " is " + value)
        signode += addnodes.desc_type(name, '')

        return fullname
Beispiel #57
0
    def build_signode(self, signode):
        if self.type == 'unary':
            signode += addnodes.desc_name(self.name, self.name)

            context = self.context + self.contextsep
            signode += addnodes.desc_addname(context, context)

            if self.retann:
                signode += addnodes.desc_returns(self.retann, self.retann)

        elif self.type == 'binary':
            context = self.context + self.contextsep
            name = " %s " % (self.name)

            signode += addnodes.desc_addname(context, context)
            signode += addnodes.desc_name(name, name)
            signode += addnodes.desc_addname(context, context)

            if self.retann:
                signode += addnodes.desc_returns(self.retann, self.retann)

        elif self.type == 'index' or self.type == 'newindex':
            context = self.context + self.contextsep
            signode += addnodes.desc_addname(context, context)

            self.build_parameters(signode)

            if self.retann:
                if self.type == 'newindex':
                    retann = " = %s" % (self.retann)
                    signode += addnodes.desc_type(retann, retann)
                else:
                    signode += addnodes.desc_returns(self.retann, self.retann)

        elif self.type == 'convert':
            context = self.context + self.contextsep

            signode += addnodes.desc_name(self.name, self.name)

            paramlist = _desc_parameterlist('(', ')')
            paramlist.append(addnodes.desc_addname(context, context))
            signode.append(paramlist)

            if self.retann:
                signode += addnodes.desc_returns(self.retann, self.retann)
Beispiel #58
0
 def handle_signature(self, sig, signode):
     path = self.get_display_path()
     signode['is_multiline'] = True
     line = addnodes.desc_signature_line()
     line['add_permalink'] = True
     for x in path:
         line += addnodes.desc_addname(x + '.', x + '.')
     line += addnodes.desc_name(sig, sig)
     if 'required' in self.options:
         line += addnodes.desc_annotation(' (required)', ' (required)')
     signode += line
     if 'default' in self.options:
         line = addnodes.desc_signature_line()
         line += addnodes.desc_type('Default: ', 'Default: ')
         line += nodes.literal(self.options['default'],
                               self.options['default'])
         signode += line
     return sig
Beispiel #59
0
    def parse_signature(env, sig, signode):
        m = sql_table_signature_re.match(sig)
        if not m:
            signode += addnodes.desc_name(sig, sig)
            return sig
        name, args = m.groups()
        # TODO: This should be improved with a more appropriate node.
        # Look for instance at the code generated by ..  py:class:: babar
        signode += addnodes.desc_type(kind+' ',kind+' ')

        # Add the name of the class
        signode += addnodes.desc_name(name, name)
        plist = SQLTableSignatureNode()
        for m in sql_column_re.finditer(args):
            x = SQLTableColumnNode()
            x += _get_column_node(m)
            plist += x

        signode += plist
        return name
Beispiel #60
0
 def handle_signature(self, sig, signode):
     try:
         section, name, default, typename = settingRe.match(sig).groups()
     except AttributeError:  # no match
         self.error("Setting signature doesn't look right.")
     if not section:
         try:
             section = self.env.temp_data["setting_section"]
         except KeyError:
             raise self.error(
                 "Please specify a section for the setting, either by "
                 + "prefixing the setting with the sections within square brackets([]) "
                 + 'or by using the "section" directive.'
             )
     name, default, typename = (v.strip() for v in (name, default, typename))
     signode += addnodes.desc_addname(section, "[" + section + "]")
     signode += addnodes.desc_name(name, name)
     if default == "#REQUIRED":
         signode += addnodes.desc_annotation("", " (Required)")
     else:
         signode += addnodes.desc_annotation(default, " = " + default)
     if "init" in self.options:
         signode += addnodes.desc_annotation("", " (Must be set in init.cfg)")
     typenode = addnodes.desc_type(typename, "")
     typenode += nodes.Text(" (", " (")
     typerefnode = self.env.domains[self.domain].roles["type"](
         "type", typename, typename, self.lineno, self.state_machine
     )[0]
     typerefnode[0]["refdomain"] = "ircbot"
     typenode += typerefnode
     typenode += nodes.Text(")", ")")
     signode += typenode
     signode["index"] = "noindex" not in self.options
     signode["name"] = name
     signode["shortname"] = name
     signode["section"] = section
     signode["type"] = typename
     signode["default"] = default
     signode["text"] = "[{0}]{1} = {2} ({3})".format(section, name, default, typename)
     return (self.typename, signode["text"], name)