Changeset 989


Ignore:
Timestamp:
Jul 2, 2012 3:13:44 PM (11 years ago)
Author:
jemian
Message:

refs #8, still need to understand how the index is configured in the domain

Location:
specdomain/trunk/src/specdomain
Files:
3 edited

Legend:

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

    r988 r989  
    190190        indextext = self._get_index_text(name)
    191191        if indextext:
    192             self.indexnode['entries'].append(('single', indextext,
    193                                               targetname, ''))
     192            self.indexnode['entries'].append(('single', indextext, targetname, ''))
     193            self.indexnode['entries'].append(('single', sig, targetname, ''))
    194194
    195195    def _get_index_text(self, name):
     
    242242    # TODO: array variables are not handled at all
    243243    # TODO: variables cited by *role* should link back to their *directive* declarations
    244     #       probably need to override handle_signature() and add_target_and_index()
    245244
    246245    def handle_signature(self, sig, signode):
     
    248247        # TODO: Should it match a regular expression?
    249248        # TODO: What if global or local? 
     249        signode += addnodes.desc_name(sig, sig)
    250250        return sig
    251251
     
    253253        targetname = '%s-%s' % (self.objtype, name)
    254254        signode['ids'].append(targetname)
    255         # TODO: index entry here is at line before directive, now must get it right
    256255        # TODO: role does not point back to it yet
    257256        # http://sphinx.pocoo.org/markup/misc.html#directive-index
  • specdomain/trunk/src/specdomain/sphinxcontrib/specmacrofileparser.py

    r987 r989  
    4949        Assume all extended comments contain ReST formatted comments,
    5050        *including initial section titles or transitions*.
    51         The first and simplest thing to do is to read the .mac file and only extract
    52         all the extended comments and add them as nodes to the current document.
    5351   
    5452    Assume macro definitions are not nested (but test for this).
     53   
     54    Assume macro files are small enough to load completely in memory.
    5555       
    5656    An additional step would be to parse for:
    57     * def
    58     * cdef
    59     * rdef
     57    * def    (done)
     58    * cdef    (done)
     59    * rdef    (done)
    6060    * global    (done)
    6161    * local    (done)
     
    379379        macros = []             # def, cdef, and rdef macros
    380380        functions = []          # def and rdef function macros
    381         title = 'Extended Comments'
    382         s = ['', title, '='*len(title), ]
     381        #title = 'Extended Comments'
     382        #s = ['', title, '='*len(title), ]
     383        s = []
    383384        for r in self.findings:
    384385            if r['objtype'] == 'extended comment':
     
    390391                s.append( '' )
    391392                s.append(r['text'])
    392             elif r['objtype'] in ('def', 'rdef', 'cdef'):
     393            elif r['objtype'] in ('def', 'rdef', 'cdef', ):
    393394                macros.append(r)
     395                s.append( '' )
     396                s.append( '.. %s %s %s %d %d' % (self.filename,
     397                                              r['objtype'],
     398                                              r['name'],
     399                                              r['start_line'],
     400                                              r['end_line']) )
     401                s.append( '' )
     402                s.append( '.. rubric:: %s macro declaration' % r['objtype']  )
     403                s.append( '' )
     404                #s.append( '.. spec:%s:: %s %s' % ( r['objtype'], r['name'], r['args'],) )
     405                s.append( '.. spec:%s:: %s' % ( r['objtype'], r['name'],) )
    394406            elif r['objtype'] in ('function def', 'function rdef',):
     407                # FIXME:  not getting here, such as for kohzuE_cmd()
    395408                functions.append(r)
     409                s.append( '' )
     410                s.append( '.. %s %s %s %d %d' % (self.filename,
     411                                              r['objtype'],
     412                                              r['name'],
     413                                              r['start_line'],
     414                                              r['end_line']) )
     415                s.append( '' )
     416                s.append( '.. rubric:: %s macro function declaration' % r['objtype']  )
     417                s.append( '' )
     418                s.append( '.. spec:%s:: %s(%s)' % ( r['objtype'], r['name'], r['args']) )
    396419            elif r['objtype'] in ('local', 'global', 'constant'):
    397420                declarations.append(r)
  • specdomain/trunk/src/specdomain/test/test_doc.rst

    r988 r989  
    9494           ``i`` is a local loop counter
    9595
     96constant declaration: 
     97
     98        .. spec:local:: TWO_PI
     99       
     100           ``TWO_PI`` is the ratio of a circle's circumference to its diameter.
     101
    96102array variable declaration:
    97103
     
    106112* local variable declaration:   :spec:local:`i`
    107113* array variable declaration:   *--tba--*
    108 * constant declaration:                 *--tba--*
     114* constant declaration:                 :spec:constant:`TWO_PI`
    109115
    110116
     
    134140* local variable, such as:      :spec:local:`i`
    135141* array variable declaration:   *--tba--*
    136 * constant declaration:                 *--tba--*
     142* constant declaration:                 :spec:constant:`TWO_PI`
    137143
    138144Source code documentation
Note: See TracChangeset for help on using the changeset viewer.