Esempio n. 1
0
 def handle_signature(self, sig, signode):
     """Handle IDL signature lines"""
     m = idl_sig_re.match(sig)
     if not m:
         self.env.app.warn("Signature did not match for {}".format(sig))
         raise ValueError("Signature did not match!")
     pro_or_function, name, arglist = m.groups()
     
     # Add a prefix for function/program
     if self.display_prefix:
         signode += addnodes.desc_annotation(self.display_prefix,
                                             self.display_prefix)
     
     signode += addnodes.desc_annotation(self.objtype, self.objtype)
     
     # Register the full name of the program
     signode['fullname'] = name
     signode += addnodes.desc_name(name, name)
     
     # Parse the argument list from the signature
     if not arglist and self.objtype == 'function':
         signode += addnodes.desc_parameterlist()
     elif arglist:
         _pseudo_parse_arglist(signode, arglist)
     return (name, '')
Esempio n. 2
0
	def handle_signature(self, sig, signode):
		sig = sig.strip()
		if '(' in sig and sig[-1:] == ')':
			prefix, arglist = sig.split('(', 1)
			prefix = prefix.strip()
			arglist = arglist[:-1].strip()
		else:
			prefix = sig
			arglist = None
		if '.' in prefix:
			nameprefix, name = prefix.rsplit('.', 1)
		else:
			nameprefix = None
			name = prefix

		objectname = self.env.temp_data.get('js:object')
		if nameprefix:
		 	if objectname:
				# someone documenting the method of an attribute
				# of the current object? shouldn't happen but
				# who knows...
				nameprefix = objectname + '.' + nameprefix
			fullname = nameprefix + '.' + name

		elif objectname:
			fullname = objectname + '.' + name

		else:
			# just a function or constructor
			objectname = ''
			fullname = name

		signode['object'] = objectname
		signode['fullname'] = fullname

		if self.display_prefix:
			signode += addnodes.desc_annotation(self.display_prefix,
				self.display_prefix)

		if nameprefix:
			 signode += addnodes.desc_addname(nameprefix + '.',
				nameprefix + '.')
		signode += addnodes.desc_name(name, name)
		if self.has_arguments:
			if not arglist:
				signode += addnodes.desc_parameterlist()
			else:
				_pseudo_parse_arglist(signode, arglist)

		class_name = self.options.get('outertype')
		# object belongs to some class or namespace
		if class_name:
			# func_desc = function return type + function name
			func_desc = fullname.split(' ', 1)
			if len(func_desc) > 1:
				fullname = func_desc[0] + ' ' + class_name +\
					'.' + func_desc[1]

		return fullname, nameprefix
Esempio n. 3
0
def parse(sig):
    m = py_sig_re.match(sig)
    if m is None:
        raise ValueError
    name_prefix, name, arglist, retann = m.groups()
    signode = addnodes.desc_signature(sig, '')
    _pseudo_parse_arglist(signode, arglist)
    return signode.astext()
Esempio n. 4
0
    def handle_signature(self, sig, signode):
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            prefix, arglist = sig.split('(', 1)
            arglist = arglist[:-1].strip()
        else:
            prefix = sig
            arglist = None

        absolute = False
        if prefix.startswith('/'):
            prefix = prefix[1:]
            absolute = True

        if '/' in prefix:
            nameprefix, name = prefix.rsplit('/', 1)
        else:
            nameprefix = None
            name = prefix

        if absolute:
            if nameprefix is None:
                nameprefix = '/'
            else:
                nameprefix = '/' + nameprefix.strip('/')

        objectname = self.env.temp_data.get('dm:object')
        if nameprefix:
            if objectname:
                # someone documenting the method of an attribute of the current
                # object? shouldn't happen but who knows...
                nameprefix = objectname + '/' + nameprefix.lstrip('/')
            fullname = nameprefix + '/' + name
        elif objectname:
            fullname = objectname + '/' + name
        else:
            # just a function or constructor
            objectname = ''
            fullname = name

        # fullname = '/' + fullname

        signode['object'] = objectname
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if nameprefix:
            signode += addnodes.desc_addname(nameprefix, nameprefix)
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, nameprefix
    def handle_signature(self, sig_input, signode):
        """Parses out pieces from construct signatures

        Parses out prefix and argument list from construct definition. This is
        assuming that the .NET languages this will support will be in a common
        format, such as::

            Namespace.Class.method(argument, argument, ...)

        The namespace and class will be determined by the nesting of rST
        directives.

        Returns
            Altered :py:data:`signode` with attributes corrected for rST
            nesting/etc
        """
        try:
            sig = self.parse_signature(sig_input.strip())
        except ValueError:
            self.env.warn(self.env.docname,
                          'Parsing signature failed: "{}"'.format(sig_input),
                          self.lineno)
            raise

        prefix = self.env.ref_context.get('dn:prefix', None)

        if prefix is not None:
            sig.prefix = prefix

        signode['object'] = sig.member
        signode['prefix'] = sig.prefix
        signode['fullname'] = sig.full_name()

        # Prefix modifiers
        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        for prefix in ['public', 'protected', 'static']:
            if prefix in self.options:
                signode += addnodes.desc_annotation(prefix + ' ',
                                                    prefix + ' ')

        # Show prefix only on shorter declarations
        if sig.prefix is not None and not self.has_arguments:
            signode += addnodes.desc_addname(sig.prefix + '.', sig.prefix + '.')

        signode += addnodes.desc_name(sig.member, sig.member)
        if self.has_arguments:
            if not sig.arguments:
                signode += addnodes.desc_parameterlist()
            else:
                # TODO replace this
                _pseudo_parse_arglist(signode, ', '.join(sig.arguments))

        if isinstance(self, DotNetObjectNested):
            return sig.full_name(), sig.full_name()
        return sig.full_name(), sig.prefix
    def handle_signature(self, sig, signode):
        """Parses out pieces from construct signatures

        Parses out prefix and argument list from construct definition. This is
        assuming that the .NET languages this will support will be in a common
        format, such as::

            Namespace.Class.method(argument, argument, ...)

        The namespace and class will be determined by the nesting of rST
        directives.

        Returns
            Altered :py:data:`signode` with attributes corrected for rST
            nesting/etc
        """
        try:
            sig = self.parse_signature(sig.strip())
        except ValueError:
            self.env.warn(self.env.docname,
                          'Parsing signature failed: "{}"'.format(sig),
                          self.lineno)
            raise

        prefix = self.env.ref_context.get('dn:prefix', None)

        if prefix is not None:
            sig.prefix = prefix

        signode['object'] = sig.member
        signode['prefix'] = sig.prefix
        signode['fullname'] = sig.full_name()

        # Prefix modifiers
        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        for prefix in ['public', 'protected', 'static']:
            if prefix in self.options:
                signode += addnodes.desc_annotation(prefix + ' ', prefix + ' ')

        # Show prefix only on shorter declarations
        if sig.prefix is not None and not self.has_arguments:
            signode += addnodes.desc_addname(sig.prefix + '.',
                                             sig.prefix + '.')

        signode += addnodes.desc_name(sig.member, sig.member)
        if self.has_arguments:
            if not sig.arguments:
                signode += addnodes.desc_parameterlist()
            else:
                # TODO replace this
                _pseudo_parse_arglist(signode, ', '.join(sig.arguments))

        if isinstance(self, DotNetObjectNested):
            return sig.full_name(), sig.full_name()
        return sig.full_name(), sig.prefix
Esempio n. 7
0
    def handle_signature(self, sig, signode):
        """Transform a Lasso signature into RST nodes.
        """
        sig = sig.strip().replace('  ',
                                  ' ').replace(' ::',
                                               '::').replace(':: ', '::')
        if '(' in sig:
            if ')::' in sig:
                sig, returntype = sig.rsplit('::', 1)
            else:
                returntype = None
            prefix, arglist = sig.split('(', 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip().replace(' =',
                                                   '=').replace('= ', '=')
        else:
            if '::' in sig:
                sig, returntype = sig.rsplit('::', 1)
            else:
                returntype = None
            prefix = sig
            arglist = None
        if '->' in prefix:
            objectprefix, name = prefix.rsplit('->', 1)
            objectprefix += '->'
        else:
            objectprefix = None
            name = prefix

        objectname = self.env.ref_context.get('ls:object')
        if objectprefix:
            fullname = objectprefix + name
        elif objectname:
            fullname = objectname + '->' + name
        else:
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        sig_prefix = self.get_signature_prefix(sig)
        if sig_prefix:
            signode += addnodes.desc_annotation(sig_prefix, sig_prefix)
        if objectprefix:
            signode += addnodes.desc_addname(objectprefix, objectprefix)

        signode += addnodes.desc_name(name, name)
        if self.needs_arglist():
            if arglist:
                _pseudo_parse_arglist(signode, arglist)
            else:
                signode += addnodes.desc_parameterlist()
            if returntype:
                signode += addnodes.desc_returns(returntype, returntype)
        return fullname, objectprefix
Esempio n. 8
0
    def handle_signature(self, sig, signode):
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            prefix, arglist = sig.split('(', 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip()
        else:
            prefix = sig
            arglist = None
        if '.' in prefix:
            nameprefix, name = prefix.rsplit('.', 1)
        else:
            nameprefix = None
            name = prefix

        objectname = self.env.temp_data.get('mongodb:object')
        if nameprefix:
            if objectname:
                # someone documenting the method of an attribute of the current
                # object? shouldn't happen but who knows...
                nameprefix = objectname + '.' + nameprefix
            fullname = nameprefix + '.' + name
        elif objectname:
            fullname = objectname + '.' + name
        else:
            # just a function or constructor
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)

        if nameprefix:
            if nameprefix in conf['suppress-prefix']:
                pass
            else:
                nameprefix += '.'
                for prefix in conf['suppress-prefix']:
                    if nameprefix.startswith(prefix):
                        nameprefix = nameprefix[len(prefix)+1:]
                        break

                signode += addnodes.desc_addname(nameprefix, nameprefix)
                nameprefix[:-1]

        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, nameprefix
Esempio n. 9
0
    def handle_signature(self, sig, signode):
        # type: (str, addnodes.desc_signature) -> Tuple[str, str]
        """Breaks down construct signatures

        Parses out prefix and argument list from construct definition. The
        namespace and class will be determined by the nesting of domain
        directives.
        """
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            member, arglist = sig.split('(', 1)
            member = member.strip()
            arglist = arglist[:-1].strip()
        else:
            member = sig
            arglist = None
        # If construct is nested, prefix the current prefix
        prefix = self.env.ref_context.get('als:object', None)
        mod_name = self.env.ref_context.get('als:module')
        name = member
        try:
            member_prefix, member_name = member.rsplit('.', 1)

        except ValueError:
            member_name = name
            member_prefix = ''
        finally:
            name = member_name
            if prefix and member_prefix:
                prefix = '.'.join([prefix, member_prefix])
            elif prefix is None and member_prefix:
                prefix = member_prefix
        fullname = name
        if prefix:
            fullname = '.'.join([prefix, name])

        signode['module'] = mod_name
        signode['object'] = prefix
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if prefix:
            signode += addnodes.desc_addname(prefix + '.', prefix + '.')
        elif mod_name:
            signode += addnodes.desc_addname(mod_name + '.', mod_name + '.')
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, prefix
Esempio n. 10
0
    def handle_signature(self, sig, signode):
        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix, self.display_prefix)

        fullname, _, args = sig.partition('(')
        modname, name = fullname.split('::')
        args = args[:-1]
        signode += addnodes.desc_name(name, name)
        if isinstance(self, CoffeeFunction):
            _pseudo_parse_arglist(signode, args)
        return fullname
Esempio n. 11
0
    def handle_signature(self, sig, signode):
        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)

        fullname, _, args = sig.partition('(')
        modname, name = fullname.split('::')
        args = args[:-1]
        signode += addnodes.desc_name(name, name)
        if isinstance(self, CoffeeFunction):
            _pseudo_parse_arglist(signode, args)
        return fullname
Esempio n. 12
0
    def handle_signature(self, sig, signode):
        """Transform a Lasso signature into RST nodes.
        """
        sig = sig.strip().replace('  ', ' ').replace(' ::', '::').replace(':: ', '::')
        if '(' in sig:
            if ')::' in sig:
                sig, returntype = sig.rsplit('::', 1)
            else:
                returntype = None
            prefix, arglist = sig.split('(', 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip().replace(' =', '=').replace('= ', '=')
        else:
            if '::' in sig:
                sig, returntype = sig.rsplit('::', 1)
            else:
                returntype = None
            prefix = sig
            arglist = None
        if '->' in prefix:
            objectprefix, name = prefix.rsplit('->', 1)
            objectprefix += '->'
        else:
            objectprefix = None
            name = prefix

        objectname = self.env.ref_context.get('ls:object')
        if objectprefix:
            fullname = objectprefix + name
        elif objectname:
            fullname = objectname + '->' + name
        else:
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        sig_prefix = self.get_signature_prefix(sig)
        if sig_prefix:
            signode += addnodes.desc_annotation(sig_prefix, sig_prefix)
        if objectprefix:
            signode += addnodes.desc_addname(objectprefix, objectprefix)

        signode += addnodes.desc_name(name, name)
        if self.needs_arglist():
            if arglist:
                _pseudo_parse_arglist(signode, arglist)
            else:
                signode += addnodes.desc_parameterlist()
            if returntype:
                signode += addnodes.desc_returns(returntype, returntype)
        return fullname, objectprefix
Esempio n. 13
0
    def handle_signature(self, sig, signode):
        # type: (unicode, addnodes.desc_signature) -> Tuple[unicode, unicode]
        """Breaks down construct signatures

        Parses out prefix and argument list from construct definition. The
        namespace and class will be determined by the nesting of domain
        directives.
        """
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            member, arglist = sig.split('(', 1)
            member = member.strip()
            arglist = arglist[:-1].strip()
        else:
            member = sig
            arglist = None
        # If construct is nested, prefix the current prefix
        prefix = self.env.ref_context.get('js:object', None)
        mod_name = self.env.ref_context.get('js:module')
        name = member
        try:
            member_prefix, member_name = member.rsplit('.', 1)
        except ValueError:
            member_name = name
            member_prefix = ''
        finally:
            name = member_name
            if prefix and member_prefix:
                prefix = '.'.join([prefix, member_prefix])
            elif prefix is None and member_prefix:
                prefix = member_prefix
        fullname = name
        if prefix:
            fullname = '.'.join([prefix, name])

        signode['module'] = mod_name
        signode['object'] = prefix
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if prefix:
            signode += addnodes.desc_addname(prefix + '.', prefix + '.')
        elif mod_name:
            signode += addnodes.desc_addname(mod_name + '.', mod_name + '.')
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, prefix
Esempio n. 14
0
    def handle_signature(self, sig, signode):
        """Transform a Python signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        """
        name_prefix = None
        name = sig
        arglist = None
        retann = None

        # determine module and class name (if applicable), as well as full name
        modname = self.options.get(
            'module', self.env.temp_data.get('py:module'))
        classname = self.env.temp_data.get('py:class')

        fullname = name

        signode['module'] = modname
        signode['class'] = classname
        signode['fullname'] = fullname

        sig_prefix = self.get_signature_prefix(sig)
        if sig_prefix:
            signode += addnodes.desc_annotation(sig_prefix, sig_prefix)

        if name_prefix:
            signode += addnodes.desc_addname(name_prefix, name_prefix)

        anno = self.options.get('annotation')

        signode += addnodes.desc_name(name, name)
        if not arglist:
            if self.needs_arglist():
                # for callables, add an empty parameter list
                signode += addnodes.desc_parameterlist()
            if retann:
                signode += addnodes.desc_returns(retann, retann)
            if anno:
                signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
            return fullname, name_prefix

        _pseudo_parse_arglist(signode, arglist)
        if retann:
            signode += addnodes.desc_returns(retann, retann)
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
        return fullname, name_prefix
Esempio n. 15
0
    def handle_signature(self, sig, signode):
        """Transform a Python signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        """
        name_prefix = None
        name = sig
        arglist = None
        retann = None

        # determine module and class name (if applicable), as well as full name
        modname = self.options.get(
            'module', self.env.temp_data.get('py:module'))
        classname = self.env.temp_data.get('py:class')

        fullname = name

        signode['module'] = modname
        signode['class'] = classname
        signode['fullname'] = fullname

        sig_prefix = self.get_signature_prefix(sig)
        if sig_prefix:
            signode += addnodes.desc_annotation(sig_prefix, sig_prefix)

        if name_prefix:
            signode += addnodes.desc_addname(name_prefix, name_prefix)

        anno = self.options.get('annotation')

        signode += addnodes.desc_name(name, name)
        if not arglist:
            if self.needs_arglist():
                # for callables, add an empty parameter list
                signode += addnodes.desc_parameterlist()
            if retann:
                signode += addnodes.desc_returns(retann, retann)
            if anno:
                signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
            return fullname, name_prefix

        _pseudo_parse_arglist(signode, arglist)
        if retann:
            signode += addnodes.desc_returns(retann, retann)
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
        return fullname, name_prefix
Esempio n. 16
0
    def handle_signature(self, sig, signode):
        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix, self.display_prefix)

        fullname, paren, args = sig.partition('(')
        modname, name = fullname.split(MOD_SEP)
        classname = self.env.temp_data.get('autodoc:class')
        if classname and name.startswith(classname):
            name = name[len(classname):]
        args = args[:-1]
        signode += addnodes.desc_name(name, name)
        if isinstance(self, CoffeeFunction):
            _pseudo_parse_arglist(signode, args)
        return fullname
Esempio n. 17
0
    def handle_signature(self, sig, signode):
        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)

        fullname, paren, args = sig.partition('(')
        modname, name = fullname.split(MOD_SEP)
        classname = self.env.temp_data.get('autodoc:class')
        if classname and name.startswith(classname):
            name = name[len(classname):]
        args = args[:-1]
        signode += addnodes.desc_name(name, name)
        if isinstance(self, CoffeeFunction):
            _pseudo_parse_arglist(signode, args)
        return fullname
Esempio n. 18
0
    def handle_signature(self, sig, signode):
        # type: (unicode, addnodes.desc_signature) -> Tuple[unicode, unicode]
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            prefix, arglist = sig.split('(', 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip()
        else:
            prefix = sig
            arglist = None
        if '.' in prefix:
            nameprefix, name = prefix.rsplit('.', 1)
        else:
            nameprefix = None
            name = prefix

        objectname = self.env.ref_context.get('js:object')
        if nameprefix:
            if objectname:
                # someone documenting the method of an attribute of the current
                # object? shouldn't happen but who knows...
                nameprefix = objectname + '.' + nameprefix
            fullname = nameprefix + '.' + name
        elif objectname:
            fullname = objectname + '.' + name
        else:
            # just a function or constructor
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if nameprefix:
            signode += addnodes.desc_addname(nameprefix + '.',
                                             nameprefix + '.')
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, nameprefix
Esempio n. 19
0
    def handle_signature(self, sig, signode):
        # type: (unicode, addnodes.desc_signature) -> Tuple[unicode, unicode]
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            prefix, arglist = sig.split('(', 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip()
        else:
            prefix = sig
            arglist = None
        if '.' in prefix:
            nameprefix, name = prefix.rsplit('.', 1)
        else:
            nameprefix = None
            name = prefix

        objectname = self.env.ref_context.get('js:object')
        if nameprefix:
            if objectname:
                # someone documenting the method of an attribute of the current
                # object? shouldn't happen but who knows...
                nameprefix = objectname + '.' + nameprefix
            fullname = nameprefix + '.' + name
        elif objectname:
            fullname = objectname + '.' + name
        else:
            # just a function or constructor
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if nameprefix:
            signode += addnodes.desc_addname(nameprefix + '.', nameprefix + '.')
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, nameprefix
Esempio n. 20
0
    def handle_signature(self, sig, signode):
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            prefix, arglist = sig.split('(', 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip()
        else:
            prefix = sig
            arglist = None
        if re.search(separators, prefix):
            separator = re.findall(separators, prefix)[-1]
            nameprefix, name = prefix.rsplit(separator, 1)
        else:
            separator = None
            nameprefix = None
            name = prefix

        objectname = self.env.temp_data.get('lua:object')
        if nameprefix:
            if objectname:
                nameprefix = objectname + '.' + nameprefix
            fullname = nameprefix + separator + name
        elif objectname:
            fullname = objectname + '.' + name
        else:
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if nameprefix:
            signode += addnodes.desc_addname(nameprefix + separator,
                                             nameprefix + separator)
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, nameprefix
Esempio n. 21
0
    def handle_signature(self, sig, signode):
        sig = sig.strip()
        if "(" in sig and sig[-1:] == ")":
            prefix, arglist = sig.split("(", 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip()
        else:
            prefix = sig
            arglist = None
        if "." in prefix:
            nameprefix, name = prefix.rsplit(".", 1)
        else:
            nameprefix = None
            name = prefix

        objectname = self.env.temp_data.get("mongodb:object")
        if nameprefix:
            if objectname:
                # someone documenting the method of an attribute of the current
                # object? shouldn't happen but who knows...
                nameprefix = objectname + "." + nameprefix
            fullname = nameprefix + "." + name
        elif objectname:
            fullname = objectname + "." + name
        else:
            # just a function or constructor
            objectname = ""
            fullname = name

        signode["object"] = objectname
        signode["fullname"] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix, self.display_prefix)
        if nameprefix:
            signode += addnodes.desc_addname(nameprefix + ".", nameprefix + ".")
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, nameprefix
Esempio n. 22
0
    def handle_signature(self, sig, signode):
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            # name(arglist)
            prefix, arglist = sig.split('(', 1)
            prefix = prefix.strip()
            arglist = arglist[:-1].strip()
        else:
            prefix = sig
            arglist = None
        if '.' in prefix:
            nameprefix, name = prefix.rsplit('.', 1)
        else:
            nameprefix = None
            name = prefix

        objectname = self.env.temp_data.get('tempoiq:object')
        if nameprefix:
            if objectname:
                # someone documenting the method of an attribute of the current
                # object? shouldn't happen but who knows...
                nameprefix = objectname + '.' + nameprefix
            fullname = nameprefix + '.' + name
        elif objectname:
            fullname = objectname + '.' + name
        else:
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        if nameprefix:
            signode += addnodes.desc_addname(nameprefix + '.',
                                             nameprefix + '.')
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)

        return fullname, nameprefix
Esempio n. 23
0
  def handle_signature(self, sig, signode):
    sig = sig.strip()
    if '(' in sig and sig[-1:] == ')':
      prefix, arglist = sig.split('(', 1)
      prefix = prefix.strip()
      arglist = arglist[:-1].strip()
    else:
      prefix = sig
      arglist = None
    if re.search(separators, prefix):
      separator = re.findall(separators, prefix)[-1]
      nameprefix, name = prefix.rsplit(separator, 1)
    else:
      separator = None
      nameprefix = None
      name = prefix

    objectname = self.env.temp_data.get('lua:object')
    if nameprefix:
      if objectname:
        nameprefix = objectname + '.' + nameprefix
      fullname = nameprefix + separator + name
    elif objectname:
      fullname = objectname + '.' + name
    else:
      objectname = ''
      fullname = name

    signode['object'] = objectname
    signode['fullname'] = fullname

    if self.display_prefix:
      signode += addnodes.desc_annotation(self.display_prefix,
                        self.display_prefix)
    if nameprefix:
      signode += addnodes.desc_addname(nameprefix + separator, nameprefix + separator)
    signode += addnodes.desc_name(name, name)
    if self.has_arguments:
      if not arglist:
        signode += addnodes.desc_parameterlist()
      else:
        _pseudo_parse_arglist(signode, arglist)
    return fullname, nameprefix
Esempio n. 24
0
    def handle_signature(self, sig, signode):
        """Transform a Python signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        """
        # determine module and class name (if applicable), as well as full name
        from sphinx import addnodes

        r = re.compile(r"(\w+)\s+([^\(]+)\s*\((.*)\)")
        m = r.match(sig)
        if m is None:
            raise ValueError

        method, name, arglist = m.groups()

        modname = self.options.get(
            'module', self.env.temp_data.get('py:module'))
        add_module = True
        classname = ''
        fullname = "%s %s" % (method, name)

        signode['module'] = modname
        signode['class'] = classname
        signode['fullname'] = fullname

        signode += addnodes.desc_name(fullname, fullname)

        if not arglist:
            return fullname, ''

        from sphinx.domains.python import _pseudo_parse_arglist

        _pseudo_parse_arglist(signode, arglist)
        return fullname, ''
Esempio n. 25
0
    def handle_signature(self, sig, signode):
        """Transform a Python signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        """
        # determine module and class name (if applicable), as well as full name
        from sphinx import addnodes

        r = re.compile(r"(\w+)\s+([^\(]+)\s*\((.*)\)")
        m = r.match(sig)
        if m is None:
            raise ValueError

        method, name, arglist = m.groups()

        modname = self.options.get('module',
                                   self.env.temp_data.get('py:module'))
        classname = ''
        fullname = "%s %s" % (method, name)

        signode['module'] = modname
        signode['class'] = classname
        signode['fullname'] = fullname

        signode += addnodes.desc_name(fullname, fullname)

        if not arglist:
            return fullname, ''

        from sphinx.domains.python import _pseudo_parse_arglist

        _pseudo_parse_arglist(signode, arglist)
        return fullname, ''
Esempio n. 26
0
    def handle_signature(self, sig, signode):
        sig = sig.strip()
        prefix = sig
        arglist = None
        nameprefix = None
        name = prefix

        objectname = self.env.temp_data.get('make:object')
        if nameprefix:
            if objectname:
                # someone documenting the method of an attribute of the current
                # object? shouldn't happen but who knows...
                nameprefix = objectname + '.' + nameprefix
            fullname = nameprefix + '.' + name
        elif objectname:
            fullname = objectname + '.' + name
        else:
            # just a function or constructor
            objectname = ''
            fullname = name

        signode['object'] = objectname
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)
        if nameprefix:
            signode += addnodes.desc_addname(nameprefix + '.', nameprefix + '.')
        signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, nameprefix
Esempio n. 27
0
    def handle_signature(self, sig, signode):
        """Transform a Lua signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        """
        m = lua_sig_re.match(sig)
        if m is None:
            raise ValueError
        name_prefix, name, argstart, arglist, argend, retann = m.groups()

        # determine module and class name (if applicable), as well as full name
        modname = self.options.get("module", self.env.temp_data.get("lua:module"))
        classname = self.env.temp_data.get("lua:class")
        if classname:
            add_module = False
            if name_prefix and name_prefix.startswith(classname):
                fullname = name_prefix + name
                # class name is given again in the signature
                name_prefix = name_prefix[len(classname) :].lstrip(".:")
            elif name_prefix:
                # class name is given in the signature, but different
                # (shouldn't happen)
                fullname = classname + "." + name_prefix + name
            else:
                # class name is not given in the signature
                fullname = classname + ":" + name
        else:
            add_module = True
            if name_prefix:
                classname = name_prefix.rstrip(".:")
                fullname = name_prefix + name
            else:
                classname = ""
                fullname = name

        signode["module"] = modname
        signode["class"] = classname
        signode["fullname"] = fullname

        sig_prefix = self.get_signature_prefix(sig)
        if sig_prefix:
            signode += addnodes.desc_annotation(sig_prefix, sig_prefix)

        if name_prefix:
            signode += addnodes.desc_addname(name_prefix, name_prefix)
        # exceptions are a special case, since they are documented in the
        # 'exceptions' module.
        elif add_module and self.env.config.add_module_names:
            modname = self.options.get("module", self.env.temp_data.get("lua:module"))
            if modname and modname != "exceptions":
                nodetext = modname + "."
                signode += addnodes.desc_addname(nodetext, nodetext)

        anno = self.options.get("annotation")

        signode += addnodes.desc_name(name, name)
        if not arglist:
            if self.needs_arglist():
                # for callables, add an empty parameter list
                listnode = lua_desc_parameterlist(argstart, argend)
                signode += listnode
            if retann:
                signode += addnodes.desc_returns(retann, retann)
            if anno:
                signode += addnodes.desc_annotation(" " + anno, " " + anno)
            return fullname, name_prefix

        _pseudo_parse_arglist(signode, arglist)
        if retann:
            signode += addnodes.desc_returns(retann, retann)
        if anno:
            signode += addnodes.desc_annotation(" " + anno, " " + anno)
        return fullname, name_prefix
Esempio n. 28
0
    def _handle_signature(self, cid, lineno, sig, signode):
        # type: (str, addnodes.desc_signature) -> Tuple[str, str]
        """Transform a Python signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present

        This is the xml string result of signode, whitespace is not
        equivalent for readability.
        <desc_signature
            class=""
            first="False"
            fullname="com.google.fonts/check/all_glyphs_have_codepoints"
            module="fontbakery.profiles.cmap"
            >
                <desc_annotation
                    xml:space="preserve">FontBakeryCheck </desc_annotation>
                <desc_addname
                    xml:space="preserve">fontbakery.profiles.cmap.</desc_addname>
                <desc_name
                    xml:space="preserve">com_google_fonts_check_all_glyphs_have_codepoints</desc_name>
                <desc_parameterlist
                    xml:space="preserve">
                        <desc_parameter xml:space="preserve">ttFont</desc_parameter>
                </desc_parameterlist>
          </desc_signature>

        """
        m = py_sig_re.match(sig)
        if m is None:
            # this is the immediate fail!!!
            raise ValueError
        prefix, name, arglist, retann = m.groups()
        # print('prefix, name, arglist, retann =', prefix, name, arglist, retann)
        # > prefix, name, arglist, retann = None com_google_fonts_check_all_glyphs_have_codepoints ttFont None

        # determine module and class name (if applicable), as well as full name
        modname = self.options.get('module',
                                   self.env.ref_context.get('py:module'))
        classname = self.env.ref_context.get('py:class')
        if classname:
            add_module = False
            if prefix and (prefix == classname
                           or prefix.startswith(classname + ".")):
                fullname = prefix + name
                # class name is given again in the signature
                prefix = prefix[len(classname):].lstrip('.')
            elif prefix:
                # class name is given in the signature, but different
                # (shouldn't happen)
                fullname = classname + '.' + prefix + name
            else:
                # class name is not given in the signature
                fullname = classname + '.' + name
        else:
            add_module = True
            if prefix:
                classname = prefix.rstrip('.')
                fullname = prefix + name
            else:
                classname = ''
                fullname = name

        signode['module'] = modname
        signode['class'] = classname
        signode['fullname'] = fullname
        signode.attributes['lineno'] = lineno

        #sig_prefix = self.get_signature_prefix(sig)
        #if sig_prefix:
        #  signode += addnodes.desc_annotation(sig_prefix, sig_prefix)

        if prefix:
            signode += addnodes.desc_addname(prefix, prefix)
        elif add_module and self.env.config.add_module_names:
            if modname and modname != 'exceptions':
                # exceptions are a special case, since they are documented in the
                # 'exceptions' module.
                #nodetext = modname + ' ID: '
                #signode += addnodes.desc_addname(nodetext, nodetext)
                pass

        signode += addnodes.desc_name(name, cid)
        if arglist:
            _pseudo_parse_arglist(signode, arglist)
        else:
            if self.needs_arglist():
                # for callables, add an empty parameter list
                signode += addnodes.desc_parameterlist()

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

        anno = self.options.get('annotation')
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)

        return cid, prefix
Esempio n. 29
0
    def handle_signature(self, sig, signode):
        """Transform a Lua signature into RST nodes.

        Return (fully qualified name of the thing, classname if any).

        If inside a class, the current class name is handled intelligently:
        * it is stripped from the displayed name if present
        * it is added to the full name (return value) if not present
        """
        m = lua_sig_re.match(sig)
        if m is None:
            raise ValueError
        name_prefix, name, argstart, arglist, argend, retann = m.groups()

        # determine module and class name (if applicable), as well as full name
        modname = self.options.get(
            'module', self.env.temp_data.get('lua:module'))
        classname = self.env.temp_data.get('lua:class')
        if classname:
            add_module = False
            if name_prefix and name_prefix.startswith(classname):
                fullname = name_prefix + name
                # class name is given again in the signature
                name_prefix = name_prefix[len(classname):].lstrip('.:')
            elif name_prefix:
                # class name is given in the signature, but different
                # (shouldn't happen)
                fullname = classname + '.' + name_prefix + name
            else:
                # class name is not given in the signature
                fullname = classname + ':' + name
        else:
            add_module = True
            if name_prefix:
                classname = name_prefix.rstrip('.:')
                fullname = name_prefix + name
            else:
                classname = ''
                fullname = name

        signode['module'] = modname
        signode['class'] = classname
        signode['fullname'] = fullname

        sig_prefix = self.get_signature_prefix(sig)
        if sig_prefix:
            signode += addnodes.desc_annotation(sig_prefix, sig_prefix)

        if name_prefix:
            signode += addnodes.desc_addname(name_prefix, name_prefix)
        # exceptions are a special case, since they are documented in the
        # 'exceptions' module.
        elif add_module and self.env.config.add_module_names:
            modname = self.options.get(
                'module', self.env.temp_data.get('lua:module'))
            if modname and modname != 'exceptions':
                nodetext = modname + '.'
                signode += addnodes.desc_addname(nodetext, nodetext)

        anno = self.options.get('annotation')

        signode += addnodes.desc_name(name, name)
        if not arglist:
            if self.needs_arglist():
                # for callables, add an empty parameter list
                listnode = lua_desc_parameterlist(argstart, argend)
                signode += listnode
            if retann:
                signode += addnodes.desc_returns(retann, retann)
            if anno:
                signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
            return fullname, name_prefix

        _pseudo_parse_arglist(signode, arglist)
        if retann:
            signode += addnodes.desc_returns(retann, retann)
        if anno:
            signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
        return fullname, name_prefix
Esempio n. 30
0
    def handle_signature(self, sig: str,
                         signode: desc_signature) -> Tuple[str, str]:
        """Breaks down construct signatures

        Parses out prefix and argument list from construct definition. The
        namespace and class will be determined by the nesting of domain
        directives.
        """
        sig = sig.strip()
        if '(' in sig and sig[-1:] == ')':
            member, arglist = sig.split('(', 1)
            member = member.strip()
            arglist = arglist[:-1].strip()
        elif ',' in sig:
            # Bit ugly. For subcommands w/ aliases
            member, alias = sig.split(',', 1)
            member = member.strip()
            alias = alias.strip()
        else:
            member = sig
            arglist = None
            alias = None
        # If construct is nested, prefix the current prefix
        prefix = self.env.ref_context.get('minio:object', None)
        mod_name = self.env.ref_context.get('minio:command')
        name = member
        try:
            member_prefix, member_name = member.rsplit('.', 1)
        except ValueError:
            member_name = name
            member_prefix = ''
        finally:
            name = member_name
            if prefix and member_prefix:
                prefix = '.'.join([prefix, member_prefix])
            elif prefix is None and member_prefix:
                prefix = member_prefix
        fullname = name
        if prefix and self.allow_nesting == False:
            fullname = '.'.join([prefix, name])
        elif prefix and self.allow_nesting == True:
            fullname = ' '.join([prefix, name])

        signode['module'] = mod_name
        signode['object'] = prefix
        signode['fullname'] = fullname

        if self.display_prefix:
            signode += addnodes.desc_annotation(self.display_prefix,
                                                self.display_prefix)

        # In our current usage, we only nest for command/subcommand. So we
        # need to split some of the logic here from nesting of YAML or JSON
        # So if allow_nesting is true, we should use " " instead of "." for
        # the prefix description.
        # We also have an exit for the 'subcommand' type so that we don't end
        # up building long name strings for subcommands
        # Finally for subcommands w/ aliases, need to append the alias name

        if prefix and self.allow_nesting == False:
            signode += addnodes.desc_addname(prefix + '.', prefix + '.')
        elif prefix and self.allow_nesting == True and self.objtype != 'subcommand':
            signode += addnodes.desc_addname(prefix + ' ', prefix + ' ')
            signode += addnodes.desc_addname(alias + ' ', alias + ' ')
        elif mod_name:
            signode += addnodes.desc_addname(mod_name + '.', mod_name + '.')
        if (alias != None):
            signode += addnodes.desc_name(name + ", " + alias,
                                          name + ", " + alias)
        else:
            signode += addnodes.desc_name(name, name)
        if self.has_arguments:
            if not arglist:
                signode += addnodes.desc_parameterlist()
            else:
                _pseudo_parse_arglist(signode, arglist)
        return fullname, prefix
Esempio n. 31
0
  def _handle_signature(self, cid, lineno, sig, signode):
    # type: (str, addnodes.desc_signature) -> Tuple[str, str]
    """Transform a Python signature into RST nodes.

    Return (fully qualified name of the thing, classname if any).

    If inside a class, the current class name is handled intelligently:
    * it is stripped from the displayed name if present
    * it is added to the full name (return value) if not present

    This is the xml string result of signode, whitespace is not
    equivalent for readability.
    <desc_signature
        class=""
        first="False"
        fullname="com.google.fonts/check/all_glyphs_have_codepoints"
        module="fontbakery.profiles.cmap"
        >
            <desc_annotation
                xml:space="preserve">FontBakeryCheck </desc_annotation>
            <desc_addname
                xml:space="preserve">fontbakery.profiles.cmap.</desc_addname>
            <desc_name
                xml:space="preserve">com_google_fonts_check_all_glyphs_have_codepoints</desc_name>
            <desc_parameterlist
                xml:space="preserve">
                    <desc_parameter xml:space="preserve">ttFont</desc_parameter>
            </desc_parameterlist>
      </desc_signature>

    """
    m = py_sig_re.match(sig)
    if m is None:
      # this is the immediate fail!!!
      raise ValueError
    prefix, name, arglist, retann = m.groups()
    # print('prefix, name, arglist, retann =', prefix, name, arglist, retann)
    # > prefix, name, arglist, retann = None com_google_fonts_check_all_glyphs_have_codepoints ttFont None

    # determine module and class name (if applicable), as well as full name
    modname = self.options.get('module', self.env.ref_context.get('py:module'))
    classname = self.env.ref_context.get('py:class')
    if classname:
      add_module = False
      if prefix and (prefix == classname or
               prefix.startswith(classname + ".")):
        fullname = prefix + name
        # class name is given again in the signature
        prefix = prefix[len(classname):].lstrip('.')
      elif prefix:
        # class name is given in the signature, but different
        # (shouldn't happen)
        fullname = classname + '.' + prefix + name
      else:
        # class name is not given in the signature
        fullname = classname + '.' + name
    else:
      add_module = True
      if prefix:
        classname = prefix.rstrip('.')
        fullname = prefix + name
      else:
        classname = ''
        fullname = name


    signode['module'] = modname
    signode['class'] = classname
    signode['fullname'] = fullname
    signode.attributes['lineno'] = lineno


    #sig_prefix = self.get_signature_prefix(sig)
    #if sig_prefix:
    #  signode += addnodes.desc_annotation(sig_prefix, sig_prefix)


    if prefix:
      signode += addnodes.desc_addname(prefix, prefix)
    elif add_module and self.env.config.add_module_names:
      if modname and modname != 'exceptions':
        # exceptions are a special case, since they are documented in the
        # 'exceptions' module.
        #nodetext = modname + ' ID: '
        #signode += addnodes.desc_addname(nodetext, nodetext)
        pass


    signode += addnodes.desc_name(name, cid)
    if arglist:
      _pseudo_parse_arglist(signode, arglist)
    else:
      if self.needs_arglist():
        # for callables, add an empty parameter list
        signode += addnodes.desc_parameterlist()


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


    anno = self.options.get('annotation')
    if anno:
      signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)


    return cid, prefix