Ignore:
Timestamp:
Jul 13, 2012 6:22:00 PM (11 years ago)
Author:
jemian
Message:

refs #8, also index macro declarations under parent macro file, handle one pathological case in index

File:
1 edited

Legend:

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

    r1007 r1012  
    239239            self.indexnode['entries'].append(('single', indextext, targetname, ''))
    240240            self.indexnode['entries'].append(('single', sig, targetname, ''))
     241            # TODO: what if there is more than one file, same name, different path?
     242            filename = os.path.split(signode.document.current_source)[1]
     243            if filename.endswith('.mac'):
     244                # TODO: change the match pattern with an option
     245                indextext = '%s; %s' % (filename, sig)
     246                self.indexnode['entries'].append(('single', indextext, targetname, ''))
     247
     248    macro_types = {
     249        'def':  'SPEC macro definition; %s',
     250        'rdef': 'SPEC run-time macro definition; %s',
     251        'cdef': 'SPEC chained macro definition; %s',
     252    }
    241253
    242254    def _get_index_text(self, name):
    243         macro_types = {
    244             'def':  'SPEC macro definition; %s',
    245             'rdef': 'SPEC run-time macro definition; %s',
    246             'cdef': 'SPEC chained macro definition; %s',
    247         }
    248         if self.objtype in macro_types:
    249             return _(macro_types[self.objtype]) % name
     255        if self.objtype in self.macro_types:
     256            return _(self.macro_types[self.objtype]) % name
    250257        else:
    251258            return ''
     
    298305
    299306    def add_target_and_index(self, name, sig, signode):
    300         targetname = '%s-%s' % (self.objtype, name)
     307        #text = u'! ' + sig      # TODO: How to use emphasized index entry in this context?
     308        text = name.split()[0]   # when sig = "tth    #: scattering angle"
     309        targetname = '%s-%s' % (self.objtype, text)
    301310        signode['ids'].append(targetname)
    302311        # TODO: role does not point back to it yet
    303312        # http://sphinx.pocoo.org/markup/misc.html#directive-index
    304         text = u'! ' + sig      # TODO: How to use emphasized index entry in this context?
    305         text = sig              # FIXME: temporary override
    306313        self.indexnode['entries'].append(('single', text, targetname, ''))
    307314        text = u'SPEC %s variable; %s' % (self.objtype, sig)
Note: See TracChangeset for help on using the changeset viewer.