How to use the sphinx.domains.ObjType function in Sphinx

To help you get started, we’ve selected a few Sphinx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duangle / scopes / doc / scopesdomain.py View on Github external
def after_content(self):
        #print("after_content")
        if self.typename_set:
            self.env.ref_context.pop('c:type', None)

class ScopesXRefRole(XRefRole):
    def process_link(self, env, refnode, has_explicit_title, title, target):
        #print("process_link",env,refnode,has_explicit_title,title,target)
        return title, target

class ScopesDomain(Domain):
    """Scopes language domain."""
    name = domain_name
    label = 'Scopes'
    object_types = {
        'special': ObjType(l_('special'), 'special'),
        'macro':    ObjType(l_('macro'),    'macro'),
        'infix-macro':    ObjType(l_('infix-macro'), 'infix-macro'),
        'symbol-prefix':    ObjType(l_('symbol-prefix'), 'symbol-prefix'),
        'function': ObjType(l_('function'), 'function'),
        'define': ObjType(l_('define'), 'define'),
        'type': ObjType(l_('type'), 'type'),
        'type-factory': ObjType(l_('type-factory'), 'type-factory'),
    }

    directives = {
        'special': ScopesObject,
        'macro':    ScopesObject,
        'infix-macro':    ScopesObject,
        'symbol-prefix':    ScopesObject,
        'function': ScopesObject,
        'define': ScopesObject,
github sphinx-contrib / httpdomain / sphinxcontrib / httpdomain.py View on Github external
class HTTPDomain(Domain):
    """HTTP domain."""

    name = 'http'
    label = 'HTTP'

    object_types = {
        'options': ObjType('options', 'options', 'obj'),
        'head': ObjType('head', 'head', 'obj'),
        'post': ObjType('post', 'post', 'obj'),
        'get': ObjType('get', 'get', 'obj'),
        'put': ObjType('put', 'put', 'obj'),
        'patch': ObjType('patch', 'patch', 'obj'),
        'delete': ObjType('delete', 'delete', 'obj'),
        'trace': ObjType('trace', 'trace', 'obj'),
        'connect': ObjType('connect', 'connect', 'obj'),
        'copy': ObjType('copy', 'copy', 'obj'),
        'any': ObjType('any', 'any', 'obj')
    }

    directives = {
        'options': HTTPOptions,
        'head': HTTPHead,
        'post': HTTPPost,
        'get': HTTPGet,
        'put': HTTPPut,
        'patch': HTTPPatch,
        'delete': HTTPDelete,
        'trace': HTTPTrace,
        'connect': HTTPConnect,
        'copy': HTTPCopy,
        'any': HTTPAny
github mongodb / docs / bin / aggregation_domain.py View on Github external
class AggregationCallable(MongoDBMethod):
    pass

class AggregationXRefRole(MongoDBXRefRole):
    pass

class AggregationDomain(MongoDBDomain):
    """Aggregation Framework Documentation domain."""
    name = 'agg'
    label = 'Aggregation Framework'
    # if you add a new object type make sure to edit AggregationObject.get_index_string
    object_types = {
        'pipeline':     ObjType(l_('pipeline'),    'pipeline'),
        'group':        ObjType(l_('group'),       'group'),
        'expression':   ObjType(l_('expression'),  'expression'),
    }
    directives = {
        'pipeline':      AggregationObject,
        'group':         AggregationObject,
        'expression':    AggregationObject,
    }
    roles = {
        'pipeline':    AggregationXRefRole(),
        'group':       AggregationXRefRole(),
        'expression':  AggregationXRefRole(),
    }

def setup(app):
    app.add_domain(AggregationDomain)
github apache / couchdb-documentation / ext / configdomain.py View on Github external
content[section].append((
                name, 2, path,
                '%s/%s' % (section, name),
                '', '', descr
            ))

        return (sorted(content.items()), False)


class ConfigDomain(Domain):

    name = 'config'
    label = 'CONFIG'

    object_types = {
        'section': ObjType('section', 'section', 'obj'),
        'option': ObjType('option', 'option', 'obj'),
    }

    directives = {
        'section': ConfigObject,
        'option': ConfigObject,
    }

    roles = {
        'section': XRefRole(),
        'option': XRefRole(),
    }

    initial_data = {
        'section': {},
        'option': {}
github mongodb / docs / bin / sphinxext / mongodb.py View on Github external
title = title[1:]
                dot = title.rfind('.')
                if dot != -1:
                    title = title[dot+1:]
        if target[0:1] == '.':
            target = target[1:]
            refnode['refspecific'] = True
        return title, target

class MongoDBDomain(Domain):
    """MongoDB Documentation domain."""
    name = 'mongodb'
    label = 'MongoDB'
    # if you add a new object type make sure to edit MongoDBObject.get_index_string
    object_types = {
        'dbcommand':    ObjType(l_('dbcommand'),   'dbcommand'),
        'operator':     ObjType(l_('operator'),    'operator'),
        'projection':   ObjType(l_('projection'),  'projection'),
        'binary':       ObjType(l_('binary'),      'program'),
        'setting':      ObjType(l_('setting'),     'setting'),
        'readmode':     ObjType(l_('readmode'),    'readmode'),
        'method':       ObjType(l_('method'),      'method'),
        'data':         ObjType(l_('data'),        'data'),
        'collflag':     ObjType(l_('collflag'),    'collflag'),
        'error':        ObjType(l_('error'),       'error'),
        'macro':        ObjType(l_('macro'),       'macro'),
        'limit':        ObjType(l_('limit'),       'limit'),
        'bsontype':     ObjType(l_('bsontype'),    'bsontype'),
        'authrole':     ObjType(l_('authrole'),    'authrole'),
        'parameter':    ObjType(l_('parameter'),   'parameter'),
        'pipeline':     ObjType(l_('pipeline'),    'pipeline'),
        'group':        ObjType(l_('group'),       'group'),
github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / sphinx / domains / javascript.py View on Github external
dot = title.rfind('.')
                if dot != -1:
                    title = title[dot+1:]
        if target[0:1] == '.':
            target = target[1:]
            refnode['refspecific'] = True
        return title, target


class JavaScriptDomain(Domain):
    """JavaScript language domain."""
    name = 'js'
    label = 'JavaScript'
    # if you add a new object type make sure to edit JSObject.get_index_string
    object_types = {
        'function':  ObjType(l_('function'),  'func'),
        'class':     ObjType(l_('class'),     'class'),
        'data':      ObjType(l_('data'),      'data'),
        'attribute': ObjType(l_('attribute'), 'attr'),
    }
    directives = {
        'function':  JSCallable,
        'class':     JSConstructor,
        'data':      JSObject,
        'attribute': JSObject,
    }
    roles = {
        'func':  JSXRefRole(fix_parens=True),
        'class': JSXRefRole(fix_parens=True),
        'data':  JSXRefRole(),
        'attr':  JSXRefRole(),
    }
github chapel-lang / sphinxcontrib-chapeldomain / sphinxcontrib / chapeldomain.py View on Github external
name = 'chpl'
    labels = 'Chapel'

    object_types = {
        'data': ObjType(l_('data'), 'data', 'const', 'var', 'param', 'type'),
        'type': ObjType(l_('type'), 'type', 'data'),
        'function': ObjType(l_('function'), 'func', 'proc'),
        'iterfunction': ObjType(l_('iterfunction'), 'func', 'iter', 'proc'),
        'enum': ObjType(l_('enum'), 'enum'),
        'class': ObjType(l_('class'), 'class'),
        'record': ObjType(l_('record'), 'record'),
        'method': ObjType(l_('method'), 'meth', 'proc'),
        'itermethod': ObjType(l_('itermethod'), 'meth', 'iter'),
        'attribute': ObjType(l_('attribute'), 'attr'),
        'module': ObjType(l_('module'), 'mod'),
    }

    directives = {
        'data': ChapelModuleLevel,
        'type': ChapelModuleLevel,
        'function': ChapelModuleLevel,
        'iterfunction': ChapelModuleLevel,

        # TODO: Consider making enums ChapelClassObject, then each constant
        #       becomes an attribute on the class. Then xrefs to each constant
        #       would be possible, plus it would scale to large numbers of
        #       constants. (thomasvandoren, 2015-03-12)
        'enum': ChapelModuleLevel,

        'class': ChapelClassObject,
        'record': ChapelClassObject,
github zeek / zeek / doc / source / ext / bro.py View on Github external
class BroIdentifier(BroGeneric):
    def get_index_text(self, objectname, name):
        return name

class BroAttribute(BroGeneric):
    def get_index_text(self, objectname, name):
        return _('%s (attribute)') % (name)

class BroDomain(Domain):
    """Bro domain."""
    name = 'bro'
    label = 'Bro'

    object_types = {
        'type':             ObjType(l_('type'),             'type'),
        'namespace':        ObjType(l_('namespace'),        'namespace'),
        'id':               ObjType(l_('id'),               'id'),
        'enum':             ObjType(l_('enum'),             'enum'),
        'attr':             ObjType(l_('attr'),             'attr'),
    }

    directives = {
        'type':             BroGeneric,
        'namespace':        BroNamespace,
        'id':               BroIdentifier,
        'enum':             BroEnum,
        'attr':             BroAttribute,
    }

    roles = {
        'type':             XRefRole(),
        'namespace':        XRefRole(),
github Source-Python-Dev-Team / Source.Python / addons / source-python / packages / site-packages / sphinx / domains / c.py View on Github external
if title[0:1] == '~':
                title = title[1:]
                dot = title.rfind('.')
                if dot != -1:
                    title = title[dot+1:]
        return title, target


class CDomain(Domain):
    """C language domain."""
    name = 'c'
    label = 'C'
    object_types = {
        'function': ObjType(l_('function'), 'func'),
        'member':   ObjType(l_('member'),   'member'),
        'macro':    ObjType(l_('macro'),    'macro'),
        'type':     ObjType(l_('type'),     'type'),
        'var':      ObjType(l_('variable'), 'data'),
    }

    directives = {
        'function': CObject,
        'member':   CObject,
        'macro':    CObject,
        'type':     CObject,
        'var':      CObject,
    }
    roles = {
        'func':   CXRefRole(fix_parens=True),
        'member': CXRefRole(),
        'macro':  CXRefRole(),
        'data':   CXRefRole(),
github VACUMM / sphinx-fortran / sphinxfortran / fortran_domain.py View on Github external
collapse = len(modules) - num_toplevels < num_toplevels

        # sort by first letter
        content = sorted(six.iteritems(content))

        return content, collapse


class FortranDomain(Domain):
    """Fortran language domain."""
    name = 'f'
    label = 'Fortran'
    object_types = {
        'program': ObjType(_('program'), 'prog'),
        'type': ObjType(_('type'), 'type'),
        'variable': ObjType(_('variable'), 'var'),
        'function': ObjType(_('function'), 'func'),
        'subroutine': ObjType(_('subroutine'), 'func', 'subr'),
        'module': ObjType(_('module'), 'mod'),
    }

    directives = {
        'program': FortranProgram,
        'type': FortranType,
        'variable': FortranObject,
        'function': FortranWithSig,
        'subroutine': FortranWithSig,
        'module': FortranModule,
        'currentmodule': FortranCurrentModule,
    }

    roles = {