コード例 #1
0
ファイル: tempoiq_sphinx.py プロジェクト: selecsosi/docs
class TempoIQMethod(TempoIQObject):
    has_arguments = True

    doc_field_types = [
        TypedField('arguments',
                   label=l_('Arguments'),
                   names=('argument', 'arg', 'parameter', 'param'),
                   typerolename='class',
                   typenames=('type', 'paramtype'),
                   can_collapse=True),
        Field('endpoint',
              label=l_('HTTP Endpoint'),
              has_arg=False,
              names=('endpoint', )),
        GroupedField('errors',
                     label=l_('Errors'),
                     rolename='err',
                     names=('throws', 'errors'),
                     can_collapse=True),
        Field('returns',
              label=l_('Returns'),
              has_arg=False,
              names=('returns', 'return')),
        Field('cursored',
              label=l_("Cursored"),
              names=('cursored', 'cursor'),
              has_arg=False)
    ]
コード例 #2
0
class PSVariable(PSconfigObject):

    doc_field_types = [
        Field('scope', label=l_('Scope'), has_arg=False,
              names=('scope', 'varscope')),
        Field('cmdline', label=l_('Command Line'), has_arg=False,
              names=('cmdline', 'cline', 'cli')),
        Field('configfile', label=l_('Config File'), has_arg=False,
              names=('conffile', 'configfile', 'conf', 'cfile')),
        Field('dynamic', label=l_('Dynamic'), has_arg=False,
              names=('dynvar', 'dyn')),
        Field('vartype', label=l_('Variable Type'), has_arg=False,
              names=('vartype', 'vtype')),
        Field('default', label=l_('Default Value'), has_arg=False,
              names=('default', 'df')),
        Field('range', label=l_('Range'), has_arg=False,
              names=('range', 'range')),
        Field('allowed', label=l_('Allowed Values'), has_arg=False,
              names=('allowed', 'av')),
        Field('unit', label=l_('Units'), has_arg=False,
              names=('unit', 'un')),
        Field('inpatch', label=l_('Included in Patch'), has_arg=False,
              names=('inpatch')),
        TypedField('versioninfo', label=l_('Version Info'), rolename='obj',
                   names=('version', 'versioninfo'),
                   typerolename='obj', typenames=('paramtype', 'type')),
    ]
コード例 #3
0
class DylanClassDesc (DylanBindingDesc):
    """A Dylan class."""

    display_name = "class"

    annotations = [
        'open', 'primary', 'free', 'abstract', 'concrete', 'instantiable',
        'uninstantiable', 'sealed'
    ] + DylanBindingDesc.annotations

    option_spec = dict(DylanBindingDesc.option_spec.items())
    option_spec.update(dict({
        'open': DIRECTIVES.flag,
        'primary': DIRECTIVES.flag,
        'free': DIRECTIVES.flag,
        'abstract': DIRECTIVES.flag,
        'sealed': DIRECTIVES.flag,
        'concrete': DIRECTIVES.flag,
        'instantiable': DIRECTIVES.flag,
        'uninstantiable': DIRECTIVES.flag,
    }.items()))

    doc_field_types = [
        Field('superclasses', label="Superclasses", has_arg=False,
            names=('supers', 'superclasses', 'super', 'superclass')),
        TypedField('keyword', label="Init-Keywords",
            names=('keyword', 'init-keyword')),
        GroupedField('slots', label="Slots",
            names=('slot', 'getter')),
        Field('conditions', label="Conditions", has_arg=False,
            names=('conditions', 'exceptions', 'condition', 'exception',
                   'signals', 'throws')),
        Field('operations', label="Operations", has_arg=False,
            names=('operations', 'methods', 'functions')),
    ] + DylanBindingDesc.doc_field_types
コード例 #4
0
ファイル: rom.py プロジェクト: developerworks/doc-kurento
class RemoteCallable(RemoteObject):
    """Description of a Kurento ROM function, method or constructor."""
    has_arguments = True

    doc_field_types = [
        TypedField('arguments',
                   label=l_('Arguments'),
                   names=('argument', 'arg', 'parameter', 'param'),
                   typerolename='func',
                   typenames=('paramtype', 'type')),
        GroupedField('errors',
                     label=l_('Throws'),
                     rolename='err',
                     names=('throws', ),
                     can_collapse=True),
        GroupedField('events',
                     label=l_('Events'),
                     rolename='evt',
                     names=('events', ),
                     can_collapse=True),
        Field('returnvalue',
              label=l_('Returns'),
              has_arg=False,
              names=('returns', 'return')),
        Field('returntype',
              label=l_('Return type'),
              has_arg=False,
              names=('rtype', )),
        Field('isabstract',
              label=l_('Abstract'),
              has_arg=False,
              names=('abstract', )),
    ]
コード例 #5
0
ファイル: apidoc.py プロジェクト: b10n1k/build-relengapi
class TypeDirective(ObjectDescription):

    required_arguments = 1
    optional_arguments = 0
    final_argument_whitespace = False
    has_content = True
    option_spec = {}

    doc_field_types = [
        TypedField('key',
                   label='Keys',
                   names=('key', ),
                   typenames=('keytype', ))
    ]

    def get_signatures(self):
        self.type_name = self.arguments[0]
        return [self.type_name]

    def handle_signature(self, sig, signode):
        signode += addnodes.desc_annotation('REST type ', 'REST type ')
        signode += addnodes.desc_name(sig, sig)

    def add_target_and_index(self, name, sig, signode):
        targetname = 'type-' + self.type_name

        # record the target for later cross-referencing
        targets = self.env.domaindata['api']['targets'].setdefault('type', {})
        targets[self.type_name] = self.env.docname, targetname

        # record that we've documented the type
        self.env.domaindata['api']['types'].add(self.type_name)

        # add a target node at the beginning of the result
        signode.insert(0, docutils.nodes.target('', '', ids=[targetname]))
コード例 #6
0
class JinjaResource(ObjectDescription):

    doc_field_types = [
        TypedField('parameter', label='Parameters',
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='obj', typenames=('paramtype', 'type')),
    ]

    method = "template"

    def handle_signature(self, sig, signode):
        method = self.method.upper() + ' '
        signode += addnodes.desc_name(method, method)
        signode += addnodes.desc_name(sig, sig)

        fullname = "Template" + ' ' + sig
        signode['method'] = self.method
        signode['path'] = sig
        signode['fullname'] = fullname
        return (fullname, self.method, sig)

    def needs_arglist(self):
        return False

    def add_target_and_index(self, name_cls, sig, signode):
        signode['ids'].append(jinja_resource_anchor(*name_cls[1:]))
        self.env.domaindata['jinja'][self.method][sig] = (self.env.docname, '')

    def get_index_text(self, modname, name):
        return ''
コード例 #7
0
ファイル: ksdomain.py プロジェクト: Tricky1702/kOS-Scripts
class KOSFunction(KOSObject):
    doc_field_types = [
        Field('access', label=l_('Access'), has_arg=False),
        TypedField('parameter',
                   label=l_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='struct',
                   typenames=('paramtype', 'type')),
        Field('returnvalue',
              label=l_('Returns'),
              has_arg=False,
              names=('returns', 'return')),
        Field('returntype',
              label=l_('Return type'),
              has_arg=False,
              names=('rtype', 'type')),
    ]

    def handle_signature(self, sig, signode):
        m = ks_sig_re.match(sig)
        name = m.group('object')
        signode += addnodes.desc_name(name, name)

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

    def get_index_text(self, objectname, name):
        return _('{}()'.format(name))
コード例 #8
0
class DylanMacroDesc(DylanBindingDesc):
    """A Dylan macro."""

    final_argument_whitespace = True

    display_name = "macro"

    annotations = ['statement', 'function', 'defining', 'macro-type'
                   ] + DylanBindingDesc.annotations

    option_spec = dict(DylanBindingDesc.option_spec.items())
    option_spec.update(
        dict({
            'statement': DIRECTIVES.flag,
            'function': DIRECTIVES.flag,
            'defining': DIRECTIVES.flag,
            'macro-type': DIRECTIVES.unchanged,
        }.items()))

    doc_field_types = [
        TypedField(
            'parameters', label="Parameters", names=('param', 'parameter')),
        GroupedField('values',
                     label="Values",
                     names=('value', 'val', 'retval', 'return')),
        Field('call',
              label="Macro Call",
              has_arg=False,
              names=('call', 'macrocall', 'syntax'))
    ] + DylanBindingDesc.doc_field_types
コード例 #9
0
ファイル: cmakedomain.py プロジェクト: hakuturu583/qibuild
class CMakeFunction(sphinx.directives.ObjectDescription):
    """ CMake Function """
    objtype_pretty = u"CMake function"
    doc_field_types = [
        TypedField('arg', label=l_('Arguments'), names=['arg']),
    ]

    def add_target_and_index(self, name, sig, signode):
        """ Add Target and Index """
        signode['ids'].append(name)
        self.state.document.note_explicit_target(signode)
        inv = self.env.domaindata['cmake'][self.objtype]
        if name in inv:
            msg = 'duplicate CMake {0} description of {1}, other instance ' \
                  'in {2}'.format(self.objtype, name,
                                  self.env.doc2path(inv[name]))
            self.env.warn(self.env.docname, msg, self.lineno)
        inv[name] = self.env.docname
        indextext = u"{0} ({1})".format(name, self.objtype_pretty)
        self.indexnode['entries'].append(('single', indextext, name, name))

    def handle_signature(self, sig, signode):
        """
        Transform CMake Function Signature to RST nodes.
        Return a name to add to the index.
        """
        nb_param = len(sig.split(" "))
        code = sig.replace("] ", "]\n    ")
        if nb_param > 1:
            code = code.replace(")", "\n)")
        literal = docutils.nodes.literal_block(code, code)
        literal['language'] = 'cmake'
        signode += literal
        name = sig.split("(")[0]
        return name
コード例 #10
0
class ClifInst(ClifObject):
    """A Cranelift IR instruction."""

    doc_field_types = [
        TypedField('argument', label=l_('Arguments'),
                   names=('in', 'arg'),
                   typerolename='type', typenames=('type',)),
        TypedField('result', label=l_('Results'),
                   names=('out', 'result'),
                   typerolename='type', typenames=('type',)),
        GroupedField(
            'typevar', names=('typevar',), label=l_('Type Variables')),
        GroupedField('flag', names=('flag',), label=l_('Flags')),
        Field('resulttype', label=l_('Result type'), has_arg=False,
              names=('rtype',)),
    ]

    def handle_signature(self, sig, signode):
        # Look for signatures like
        #
        #   v0, v1 = foo op0, op1
        #   v0 = foo
        #   foo op0

        parts = re.split(sep_equal, sig, 1)
        if len(parts) == 2:
            # Outgoing parameters.
            parse_params(parts[0], signode)
            signode += nodes.Text(' = ')
            name = parts[1]
        else:
            name = parts[0]

        # Parse 'name arg, arg'
        parts = name.split(None, 1)
        name = parts[0]
        signode += addnodes.desc_name(name, name)

        if len(parts) == 2:
            # Incoming parameters.
            signode += nodes.Text(' ')
            parse_params(parts[1], signode)

        return name

    def get_index_text(self, name):
        return name
コード例 #11
0
ファイル: linguidocs.py プロジェクト: stevejay/js-lingui
def setup(app):
    app.add_object_type(directivename='jsxmacro',
                        rolename='jsxmacro',
                        indextemplate="pair: %s; jsxmacro",
                        ref_nodeclass=jsxmacro,
                        objname='React macro',
                        doc_field_types=[
                            TypedField('props',
                                       label=_('Props'),
                                       names=('prop', ),
                                       typerolename='jsxmacro',
                                       typenames=('proptype', 'type')),
                        ])
    app.add_node(jsxmacro,
                 html=(visit_react_macro_html, depart_react_macro_html))

    app.add_object_type(directivename='component',
                        rolename='component',
                        indextemplate="pair: %s; component",
                        ref_nodeclass=react_component,
                        objname='Component',
                        doc_field_types=[
                            TypedField('props',
                                       label=_('Props'),
                                       names=('prop', ),
                                       typerolename='component',
                                       typenames=('proptype', 'type')),
                        ])
    app.add_node(react_component,
                 html=(visit_react_component_html,
                       depart_react_component_html))
    app.add_object_type(directivename='jsmacro',
                        rolename='jsmacro',
                        indextemplate="pair: %s; jsmacro",
                        ref_nodeclass=jsmacro,
                        objname='JS Macro')
    app.add_node(jsmacro, html=(visit_jsmacro_html, depart_jsmacro_html))
    app.add_crossref_type('config', 'conf')
    app.add_crossref_type('icu', 'icu')

    app.add_object_type(
        directivename="lingui-cli",
        rolename="cli",
        indextemplate="pair: %s; lingui-cli command",
        parse_node=parse_lingui_cli_node,
    )
    app.add_directive('lingui-cli-option', Cmdoption)
コード例 #12
0
class DmlFunction(DmlObject):
    """Description of a function."""

    option_spec: OptionSpec = DmlObject.option_spec.copy()
    option_spec.update({
        'const': directives.flag,
        'virtual': directives.flag,
    })
    
    doc_field_types = [
        TypedField('parameter', label=_('Parameters'),
                     names=('param', 'parameter', 'arg', 'argument',
                            'keyword', 'kwarg', 'kwparam'),
                     typenames=('paramtype', 'type'),
                     can_collapse=True),
        TypedField('result', label='Return',
                   names=('return', 'result'),
                   typenames=('returntype', 'resulttype')),
    ]

    def split_signature(self, sig: str) -> Tuple[str, bool, str, List[str], str]:
        
        # return tuple:
        #   - type (class, property, event, function) -> str
        #   - name -> str
        #   - arglist -> List[str]
        #   - annotations -> List[str]
        
        typ = "function"
                
        parts = sig.split("(")
        name = parts[0]
        
        parts = parts[1].split(")")
        arglist = parts[0].split(",")
        
        annotations = []
        if 'const' in self.options:
            annotations.append("constant")
        if 'virtual' in self.options:
            annotations.append("virtual")
            
        return (typ, name, arglist, annotations)

    def get_index_text(self, name_cls: Tuple[str, str]) -> str:
        # add index in own add_target_and_index() instead.
        return "FunctionName " + name_cls[0]
コード例 #13
0
class AvroRecord(AvroObject):
    prefix = 'record'
    doc_field_types = [
        TypedField('fields',
                   label=l_('Fields'),
                   names=('field', 'member'),
                   typenames=('type', ),
                   typerolename='record')
    ]
コード例 #14
0
ファイル: protobufdomain.py プロジェクト: eblot/tde-base
class ProtobufMessage(ProtobufObject):
    prefix = 'message'
    doc_field_types = [
        TypedField('fields',
                   label=_('Fields'),
                   names=('field', 'member'),
                   typenames=('type', ),
                   typerolename='message')
    ]
コード例 #15
0
class PSColumn(PSschemaObject):

    doc_field_types = [
        TypedField('coltype', label=_('Type'), rolename='obj',
                   names=('coltype', 'type'),
                   typerolename='obj', typenames=('paramtype', 'type')),
        Field('inpatch', label=_('Included in Patch'), has_arg=False,
              names=('inpatch')),
    ]
コード例 #16
0
def setup(app):
    from sphinx.util.docfields import TypedField
    app.add_object_type('confval', 'confval',
                        objname='configuration value',
                        indextemplate='pair: %s; configuration value')
    fdesc = TypedField('parameter', label='Parameters',
                         names=['param'], typenames=['type'], can_collapse=True)
    app.add_object_type('event', 'event', 'pair: %s; event', parse_event,
                        doc_field_types=[fdesc])
コード例 #17
0
ファイル: tabledoc.py プロジェクト: grilix/pokedex
class DexTable(PyClasslike):
    """The actual Sphinx documentation generation whatchamacallit
    """
    doc_field_types = [
        TypedField('field', label='Fields',
            typerolename='obj', typenames=('fieldname', 'type')),
        ]

    def get_signature_prefix(self, sig):
        return ''
        #return u'mapped class '

    def run(self):
        section = nodes.section()
        super_result = super(DexTable, self).run()
        title_text = self.names[0][0]
        section += nodes.title(text=title_text)
        section += super_result
        section['ids'] = ['dex-table-%s' % title_text.lower()]
        return [section]

    def before_content(self):
        name = self.names[0][0]
        for cls in tables.mapped_classes:
            if name == cls.__name__:
                break
        else:
            raise ValueError('Table %s not found' % name)
        table = cls.__table__

        remaining_attrs = set(x for x in dir(cls) if not x.startswith('_'))
        remaining_attrs.difference_update(['metadata', 'translation_classes',
                'add_relationships', 'summary_column'])
        for transl_class in cls.translation_classes:
            remaining_attrs.difference_update([
                    transl_class.relation_name,
                    transl_class.relation_name + '_table',
                    transl_class.relation_name + '_local',
                ])

        generated_content = []  # Just a list of lines!

        generated_content.extend(generate_table_header(cls, remaining_attrs))
        generated_content.extend(generate_common(cls, remaining_attrs))
        generated_content.extend(generate_columns(cls, remaining_attrs))
        generated_content.extend(generate_strings(cls, remaining_attrs))
        generated_content.extend(generate_relationships(cls, remaining_attrs))
        generated_content.extend(generate_associationproxies(cls, remaining_attrs))
        generated_content.extend(generate_undocumented(cls, remaining_attrs))
        generated_content.extend(generate_other(cls, remaining_attrs))

        generated_content.append(u'')
        self.content = ViewList(generated_content + list(self.content))
        return super(DexTable, self).before_content()

    def get_index_text(self, modname, name_cls):
        return '%s (mapped class)' % name_cls[0]
コード例 #18
0
class HTTPResource(ObjectDescription):

    doc_field_types = [
        TypedField('parameter',
                   label='Parameters',
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='obj',
                   typenames=('paramtype', 'type')),
        GroupedField('queryparameter',
                     label='Query Parameters',
                     names=('queryparameter', 'queryparam', 'qparam',
                            'query')),
        GroupedField('formparameter',
                     label='Form Parameters',
                     names=('formparameter', 'formparam', 'fparam', 'form')),
        GroupedField('statuscode',
                     label='Status Codes',
                     rolename='statuscode',
                     names=('statuscode', 'status', 'code'))
    ]

    method = NotImplemented

    def handle_signature(self, sig, signode):
        method = self.method.upper() + ' '
        signode += addnodes.desc_name(method, method)
        offset = 0
        for match in http_sig_param_re.finditer(sig):
            path = sig[offset:match.start()]
            signode += addnodes.desc_name(path, path)
            params = addnodes.desc_parameterlist()
            typ = match.group('type')
            if typ:
                typ = typ + ': '
                params += addnodes.desc_annotation(typ, typ)
            name = match.group('name')
            params += addnodes.desc_parameter(name, name)
            signode += params
            offset = match.end()
        if offset < len(sig):
            path = sig[offset:len(sig)]
            signode += addnodes.desc_name(path, path)
        fullname = self.method.upper() + ' ' + path
        signode['method'] = self.method
        signode['path'] = sig
        signode['fullname'] = fullname
        return (fullname, self.method, sig)

    def needs_arglist(self):
        return False

    def add_target_and_index(self, name_cls, sig, signode):
        signode['ids'].append(http_resource_anchor(*name_cls[1:]))
        self.env.domaindata['http'][self.method][sig] = (self.env.docname, '')

    def get_index_text(self, modname, name):
        return ''
コード例 #19
0
 def get_doc_field_types(self):
     return [
         TypedField(self.field_name,
                    label=l_(self.field_label),
                    names=(self.field_name, ),
                    typerolename='msg',
                    typenames=('{0}-{1}'.format(self.field_name,
                                                TYPE_SUFFIX), )),
         TypedField(self.constant_name,
                    label=l_(self.constant_label),
                    names=(self.constant_name, ),
                    typerolename='msg',
                    typenames=('{0}-{1}'.format(self.constant_name,
                                                TYPE_SUFFIX), )),
         GroupedField('{0}-{1}'.format(self.constant_name, VALUE_SUFFIX),
                      label=l_('{0} (Value)'.format(self.constant_label)),
                      names=('{0}-{1}'.format(self.constant_name,
                                              VALUE_SUFFIX), )),
     ]
コード例 #20
0
class KOSMethod(KOSObject):

    doc_field_types = [
        Field('access', label=_('Access'), has_arg=False),
        TypedField('parameter',
                   label=_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='obj',
                   typenames=('paramtype', 'type')),
        Field('returnvalue',
              label=_('Returns'),
              has_arg=False,
              names=('returns', 'return')),
        Field('returntype',
              label=_('Return type'),
              has_arg=False,
              names=('rtype', 'type')),
    ]

    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

    def get_index_text(self, objectname, name):
        return _('{}()'.format(name))
コード例 #21
0
 def __init__(self, *args, **kargs):
     CPPDomain.__init__(self, *args, **kargs)
     self.directives['function'].doc_field_types = [
         TypedField('parameter', label=l_('Parameters'),
                    names=('param', 'parameter', 'arg', 'argument'),
                    typerolename='type', typenames=('type',)),
         Field('returnvalue', label=l_('Returns'), has_arg=False,
               names=('returns', 'return')),
         Field('returntype', label=l_('Return type'), has_arg=False,
               names=('rtype',)),
         ]
コード例 #22
0
class PSTable(PSschemaObject):

    doc_field_types = [
        TypedField('column',
                   label=l_('Columns'),
                   rolename='obj',
                   names=('col', 'column', 'cols'),
                   typerolename='obj',
                   typenames=('paramtype', 'type')),
        Field('inpatch',
              label=l_('Included in Patch'),
              has_arg=False,
              names=('inpatch')),
        TypedField('versioninfo',
                   label=l_('Version Info'),
                   rolename='obj',
                   names=('version', 'versioninfo'),
                   typerolename='obj',
                   typenames=('paramtype', 'type')),
    ]
コード例 #23
0
class PSDatabase(PSschemaObject):

    doc_field_types = [
        TypedField('tbl', label=_('Tables'),
                   names=('tbl', 'table',),
                   typerolename='obj', typenames=('paramtype', 'type')),
        Field('engine', label=_('Storage Engine'), has_arg=False,
              names=('engine')),
        Field('inpatch', label=_('Included in Patch'), has_arg=False,
              names=('inpatch')),
    ]
コード例 #24
0
class AvroRPCMessage(AvroObject):
    doc_field_types = [
        TypedField('arguments',
                   label=l_('Arguments'),
                   names=('argument', 'arg', 'param'),
                   typerolename='rpc'),
        GroupedField('errors',
                     label=l_('Throws'),
                     names=('throws', 'throw'),
                     can_collapse=True),
        Field('returntype', label=l_('Returns'), names=('returns', 'return'))
    ]
コード例 #25
0
ファイル: LuaDomain.py プロジェクト: dedok/doc
class LuaVarFunction(LuaObject):
    typename = l_("varfunc")

    doc_field_types = [
        TypedField('parameter',
                   label=l_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='obj',
                   typenames=('paramtype', 'type', 'ptype')),
        TypedField('returnvalues',
                   label=l_('Returns'),
                   names=('return', 'ret'),
                   typerolename='obj',
                   typenames=('rtype', 'type')),
        Field('returnvalue',
              label=l_('Returns'),
              has_arg=False,
              names=('returns')),
        Field('returntype',
              label=l_('Return type'),
              has_arg=False,
              names=('returntype', )),
    ]

    lua_signature_re = re.compile(
        r'''^ ([\w\.\:/\-]+[:.])?     # class name(s)
              ([{|}<>\w/\-/.]+)  \s*  # thing name(s)
              (?: ([({])(.*)([)}]))?  # optional: arguments
              (?:\s* -> \s* (.*))?    # optional: return annotation
              $                       # and nothing more
              ''', re.VERBOSE)

    def build_objtype(self):
        return self.options.get('objtype') or ""

    def needs_arglist(self):
        return True

    def get_index_name(self, names):
        return '%s()' % (names['fullname'])
コード例 #26
0
class DylanFunctionDesc (DylanBindingDesc):
    """A Dylan function, method, or generic function."""

    doc_field_types = [
        TypedField('parameters', label="Parameters",
            names=('param', 'parameter')),
        GroupedField('values', label="Values",
            names=('value', 'val', 'retval', 'return')),
        Field('signature', label="Signature", has_arg=False,
            names=('sig', 'signature')),
        Field('conditions', label="Conditions", has_arg=False,
            names=('conditions', 'exceptions', 'signals', 'throws')),
    ] + DylanBindingDesc.doc_field_types
コード例 #27
0
class JavaMethod(JavaObject):
    doc_field_types = [
        TypedField('parameter', label=l_('Parameters'),
                   names=('param', 'parameter', 'arg', 'argument'),
                   typerolename='type', typenames=('type',)),
        Field('returnvalue', label=l_('Returns'), has_arg=False,
              names=('returns', 'return')),
        GroupedField('throws', names=('throws',), label=l_('Throws'), rolename='type')
    ]

    def handle_method_signature(self, sig, signode):
        try:
            member = javalang.parse.parse_member_signature(sig)
        except javalang.parser.JavaSyntaxError:
            raise self.error("syntax error in method signature")

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

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

        if  member.type_parameters:
            type_params = formatter.output_type_params(member.type_parameters).build()
            signode += nodes.Text(type_params, type_params)
            signode += nodes.Text(' ', ' ')

        rnode = addnodes.desc_type('', '')
        rnode += self._build_type_node(member.return_type)

        signode += rnode
        signode += nodes.Text(' ', ' ')
        signode += addnodes.desc_name(member.name, member.name)

        paramlist = addnodes.desc_parameterlist()
        for parameter in member.parameters:
            param = addnodes.desc_parameter('', '', noemph=True)
            param += self._build_type_node(parameter.type)

            if parameter.varargs:
                param += nodes.Text('...', '')

            param += nodes.emphasis(' ' + parameter.name, ' ' + parameter.name)
            paramlist += param
        signode += paramlist

        param_reprs = [formatter.output_type(param.type, with_generics=False).build() for param in member.parameters]
        return member.name + '(' + ', '.join(param_reprs) + ')'

    def get_index_text(self, package, type, name):
        return _('%s (Java method)' % (name,))
コード例 #28
0
class JSCallable(JSObject):
    """Description of a JavaScript function, method or constructor."""
    has_arguments = True

    doc_field_types = [
        TypedField('arguments', label=l_('Arguments'),
                   names=('argument', 'arg', 'parameter', 'param'),
                   typerolename='func', typenames=('paramtype', 'type')),
        GroupedField('errors', label=l_('Throws'), rolename='err',
                     names=('throws', ),
                     can_collapse=True),
        Field('returnvalue', label=l_('Returns'), has_arg=False,
              names=('returns', 'return')),
    ]
コード例 #29
0
ファイル: domain.py プロジェクト: octaG-M/javasphinx
class JavaConstructor(JavaObject):
    doc_field_types = [
        TypedField(
            'parameter',
            label=_('Parameters'),  # replaced the old "label=l_('Parameters')"
            names=('param', 'parameter', 'arg', 'argument'),
            typerolename='type',
            typenames=('type', )),
        GroupedField(
            'throws',
            names=('throws', ),
            label=_('Throws')  # replaced the old "label=l_('Throws')"
        )
    ]

    def handle_constructor_signature(self, sig, signode):
        try:
            member = javalang.parse.parse_constructor_signature(sig)
        except javalang.parser.JavaSyntaxError:
            raise self.error("syntax error in constructor signature")

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

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

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

        paramlist = addnodes.desc_parameterlist()
        for parameter in member.parameters:
            param = addnodes.desc_parameter('', '', noemph=True)
            param += self._build_type_node(parameter.type)

            if parameter.varargs:
                param += nodes.Text('...', '')

            param += nodes.emphasis(' ' + parameter.name, ' ' + parameter.name)
            paramlist += param
        signode += paramlist

        param_reprs = [
            formatter.output_type(param.type, with_generics=False).build()
            for param in member.parameters
        ]
        return '%s(%s)' % (member.name, ', '.join(param_reprs))

    def get_index_text(self, package, type, name):
        return _('%s (Java constructor)' % (name, ))
コード例 #30
0
class DMCallable(DMObject):
    """Description of a DM proc or verb."""
    has_arguments = True

    doc_field_types = [
        TypedField('arguments',
                   label=l_('Arguments'),
                   names=('argument', 'arg', 'parameter', 'param'),
                   typerolename='proc',
                   typenames=('paramtype', 'type')),
        Field('returnvalue',
              label=l_('Returns'),
              has_arg=False,
              names=('returns', 'return')),
    ]