Changeset 3417

Show
Ignore:
Timestamp:
03/25/08 09:35:22 (8 months ago)
Author:
jouvin
Message:

Add support for keyword sectionindex in 11.0.0 (see http://trac-hacks.org/ticket/2790 and documentation); version incremented to 11.0.0.3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tocmacro/0.11/setup.py

    r1954 r3417  
    66setup( 
    77    name = 'TracTocMacro', 
    8     version = '11.0.0.2', 
     8    version = '11.0.0.3', 
    99    packages = ['tractoc'], 
    1010    #package_data = { 'toc': ['templates/*.cs','htdocs/*' ] }, 
  • tocmacro/0.11/tractoc/macro.py

    r3030 r3417  
    121121            elif arg == 'notitle': 
    122122                params['min_depth'] = 2     # Skip page title 
    123             elif arg == 'titleindex': 
     123            elif (arg == 'titleindex') or (arg == 'sectionindex'): 
     124                # sectionindex is a page-context sensitive titleindex 
     125                if arg == 'sectionindex': 
     126                    params['section_index'] = True 
    124127                params['title_index'] = True 
    125128                default_heading = default_heading and 'Page Index' 
     
    135138        # Has the user supplied a list of pages? 
    136139        if not pagenames: 
    137             if 'title_index' in params: 
     140            # Be sure to test section_index first as title_index is also true in this case 
     141            if 'section_index' in params: 
     142                # Use 'parent' of current page (level delimiter is /), if any 
     143                toks = re.match('^(?P<parent>.*)/[^/]*$',current_page) 
     144                if toks: 
     145                    pagenames.append(toks.group('parent')+'/') 
     146                else: 
     147                    pagenames.append('*') 
     148            elif 'title_index' in params: 
    138149                pagenames.append('*')       # A marker for 'all' 
    139150            else: 
     
    144155        temp_pagenames = [] 
    145156        for pagename in pagenames: 
     157            if 'section_index' in params: 
     158                # / is considered an equivalent to * in sectionindex 
     159                if pagename == '/': 
     160                    pagename = '*' 
     161                if not pagename.endswith('*'): 
     162                    pagename += '*' 
    146163            if pagename.endswith('*'): 
    147164                temp_pagenames.extend(sorted(