Changeset 1244

Show
Ignore:
Timestamp:
09/05/06 01:38:34 (2 years ago)
Author:
cboos
Message:

DoxygenPlugin:

Follow-up to r1226, as the applied patch was mostly work in progress. The basic functionality is now restored, and the plugin seems to be usable.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doxygenplugin/0.10

    • Property svn:ignore set to
      build
      dist
      TracDoxygen.egg-info
      .hg
      .hgignore
  • doxygenplugin/0.10/doxygentrac

    • Property svn:ignore set to
      *.pyc
  • doxygenplugin/0.10/doxygentrac/doxygentrac.py

    r1226 r1244  
    8080        if req.perm.has_permission('DOXYGEN_VIEW'): 
    8181            # Return mainnav buttons. 
    82             yield 'mainnav', 'doxygen', \ 
    83                   html.a(self.title, href = req.href.doxygen()) 
     82            yield 'mainnav', 'doxygen', html.a(self.title, 
     83                                               href=req.href.doxygen()) 
    8484 
    8585    # IRequestHandler methods 
    8686 
    8787    def match_request(self, req): 
    88         # Match documentation request. 
    8988        if re.match(r'^/doxygen(?:$|/)', req.path_info): 
    90             if 'path' not in req.args: 
    91                 segments = filter(None, req.path_info.split('/')) 
    92                 segments = segments[1:] # ditch 'doxygen' 
    93                 action, path, link = self._doxygen_lookup(segments) 
    94                 if action
    95                     req.args['action'] = action 
    96                     if action == 'search' and path
    97                         req.args['query'] = path 
    98                     req.args['path'] = path 
     89            segments = filter(None, req.path_info.split('/')) 
     90            segments = segments[1:] # ditch 'doxygen' 
     91            action, path, link = self._doxygen_lookup(segments) 
     92            req.args['action'] = action 
     93            if action == 'search' and link
     94                req.args['query'] = link 
     95            elif action == 'redirect'
     96                req.args['link'] = link 
     97            req.args['path'] = path 
    9998            return True 
    10099             
     
    105104        path = req.args.get('path') 
    106105        action = req.args.get('action') 
    107  
    108         self.log.debug('Performing %s on "%s"' % (action or 'default', path)) 
     106        link = req.args.get('link') 
     107 
     108        self.log.debug('Performing %s(%s,%s)"' % (action or 'default', 
     109                                                  path, link)) 
    109110 
    110111        # Redirect search requests. 
     
    112113            req.redirect(req.href.search(q=req.args.get('query'), 
    113114                                         doxygen='on')) 
     115        if action == 'redirect': 
     116            if link: # we need to really redirect if there is a link 
     117                if path: 
     118                    req.redirect(req.href.doxygen(path=path)+link) 
     119                else: 
     120                    req.redirect(req.href.doxygen(link)) 
     121            else: 
     122                self.log.warn("redirect without link") 
    114123 
    115124        # Handle /doxygen request 
     
    125134            path = os.path.join(self.base_path, self.default_doc, self.index) 
    126135 
    127         # view or redirect 
     136        # view  
    128137        mimetype = mimetypes.guess_type(path)[0] 
    129138        if mimetype == 'text/html': 
     
    185194        def doxygen_link(formatter, ns, params, label): 
    186195            action, path, link = self._doxygen_lookup(params.split('/')) 
    187             if action in ('view', 'index', 'redirect'): 
     196            if action == 'index': 
     197                return html.a(label, title=self.title, 
     198                              href=formatter.href.doxygen()) 
     199            if action == 'redirect': 
     200                if path: 
     201                    return html.a(label, title="Search result for "+params, 
     202                                  href=formatter.href.doxygen(path=path)+link) 
     203                else: 
     204                    action = 'view' 
     205            if action in ('view', 'index'): 
    188206                return html.a(label, title=params, 
    189207                              href=formatter.href.doxygen(link, path=path)) 
     
    206224         - `path` is the location on disk of the resource. 
    207225         - `link` is the link to the resource, relative to the 
    208            req.href.doxygen base, 
     226           req.href.doxygen base or a target in case of 'redirect' 
    209227        """ 
    210228        doc, file = segments[:-1], segments and segments[-1] 
    211         doc = doc and os.path.join(*doc) or self.default_doc 
     229 
     230        if not doc and not file: 
     231            return ('index', None, None)  
     232        if doc: 
     233            doc = os.path.join(*doc) 
     234        else: 
     235            if self.default_doc: # we can't stay at the 'doxygen/' level 
     236                return 'redirect', None, \ 
     237                       self.default_doc + '/' + (file or self.index) 
     238            else: 
     239                doc = '' 
     240         
    212241        def lookup(file, category='undefined'): 
     242            """Build (full path, relative link) and check if path exists.""" 
    213243            path = os.path.join(self.base_path, doc, file) 
    214244            self.log.debug('%s file "%s" (at %s)' % (category, file, path)) 
    215245            return os.path.exists(path) and path, doc + '/' + file 
    216246 
    217         if not file: 
    218             path, link = lookup('index.html', 'index') 
    219             return 'index', path, link 
    220  
    221247        self.log.debug('looking up "%s" in documentation "%s"' % (file, doc)) 
    222248 
    223249        # Direct request for searching 
    224250        if file == 'search.php': 
    225             return 'search', None, None 
     251            return 'search', None, None # keep existing 'query' arg 
    226252 
    227253        # Request for a documentation file. 
     
    232258                return 'view', path, link 
    233259            else: 
    234                 return 'search', file, Non
     260                return 'search', None, fil
    235261 
    236262        # Request for source file documentation. 
     
    244270                return 'view', path, link 
    245271            else: 
    246                 return 'search', file, Non
     272                return 'search', None, fil
    247273 
    248274        # Request for summary pages 
     
    270296            name = result['name'] 
    271297            if name == file or name == class_ref: 
    272                 path, link = lookup(result['url']) 
    273                 return 'redirect', path, link 
     298                url = result['url'] 
     299                target = '' 
     300                if '#' in url: 
     301                    url, target = url.split('#', 2) 
     302                path, link = lookup(url) 
     303                if path: 
     304                    return 'redirect', path, target 
    274305        self.log.debug('%s not found in %s' % (file, doc)) 
    275         return 'search', file, Non
     306        return 'search', None, fil
    276307 
    277308    def _search_in_documentation(self, doc, keywords):