Changeset 916


Ignore:
Timestamp:
Jun 12, 2012 5:03:27 PM (10 years ago)
Author:
jemian
Message:

hitting a wall here, understanding how this is supposed to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • specdomain/src/specdomain/sphinxcontrib/specdomain.py

    r910 r916  
    3131
    3232
     33class SpecObject(ObjectDescription):
     34    """
     35    Description of a SPEC object (macro definition or variable).
     36    """
     37    def _get_index_text(self, name):
     38        if self.objtype == 'def':
     39            return _('%s (SPEC macro)') % name
     40        elif self.objtype == 'rdef':
     41            return _('%s (SPEC macro)') % name
     42        elif self.objtype == 'cdef':
     43            return _('%s (SPEC global)') % name
     44        else:
     45            return ''
     46
     47
     48class SpecXRefRole(XRefRole):
     49    def process_link(self, env, refnode, has_explicit_title, title, target):
     50        refnode['spec:def'] = env.temp_data.get('spec:def')
     51        if not has_explicit_title:
     52            title = title.lstrip(':')   # only has a meaning for the target
     53            target = target.lstrip('~') # only has a meaning for the title
     54            # if the first character is a tilde, don't display the module/class
     55            # parts of the contents
     56            if title[0:1] == '~':
     57                title = title[1:]
     58                colon = title.rfind(':')
     59                if colon != -1:
     60                    title = title[colon+1:]
     61        return title, target
     62
     63
    3364class SpecDomain(Domain):
    3465    """SPEC language domain."""
    3566    name = 'spec'
    3667    label = 'SPEC, http://www.certif.com'
     68    object_types = {    # type of object that a domain can document
     69        'def':  ObjType(l_('def'),  'def'),
     70        'rdef': ObjType(l_('rdef'), 'rdef'),
     71        'cdef': ObjType(l_('cdef'), 'cdef'),
     72    }
     73    directives = {
     74        'def':          SpecObject,
     75        'rdef':         SpecObject,
     76        'cdef':         SpecObject,
     77    }
     78    roles = {
     79        'def' :  SpecXRefRole(),
     80        'rdef':  SpecXRefRole(),
     81        'cdef':  SpecXRefRole(),
     82    }
     83    #indices = [
     84    #    SpecMacroIndex,
     85    #]
    3786
    3887
Note: See TracChangeset for help on using the changeset viewer.