Changeset 1244
- Timestamp:
- 09/05/06 01:38:34 (2 years ago)
- Files:
-
- doxygenplugin/0.10 (modified) (1 prop)
- doxygenplugin/0.10/doxygentrac (modified) (1 prop)
- doxygenplugin/0.10/doxygentrac/doxygentrac.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doxygenplugin/0.10
- Property svn:ignore set to
build
dist
TracDoxygen.egg-info
.hg
.hgignore
- Property svn:ignore set to
doxygenplugin/0.10/doxygentrac
- Property svn:ignore set to
*.pyc
- Property svn:ignore set to
doxygenplugin/0.10/doxygentrac/doxygentrac.py
r1226 r1244 80 80 if req.perm.has_permission('DOXYGEN_VIEW'): 81 81 # 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()) 84 84 85 85 # IRequestHandler methods 86 86 87 87 def match_request(self, req): 88 # Match documentation request.89 88 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'] = action96 if action == 'search' and path:97 req.args['query'] = path98 req.args['path'] = path89 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 99 98 return True 100 99 … … 105 104 path = req.args.get('path') 106 105 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)) 109 110 110 111 # Redirect search requests. … … 112 113 req.redirect(req.href.search(q=req.args.get('query'), 113 114 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") 114 123 115 124 # Handle /doxygen request … … 125 134 path = os.path.join(self.base_path, self.default_doc, self.index) 126 135 127 # view or redirect136 # view 128 137 mimetype = mimetypes.guess_type(path)[0] 129 138 if mimetype == 'text/html': … … 185 194 def doxygen_link(formatter, ns, params, label): 186 195 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'): 188 206 return html.a(label, title=params, 189 207 href=formatter.href.doxygen(link, path=path)) … … 206 224 - `path` is the location on disk of the resource. 207 225 - `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' 209 227 """ 210 228 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 212 241 def lookup(file, category='undefined'): 242 """Build (full path, relative link) and check if path exists.""" 213 243 path = os.path.join(self.base_path, doc, file) 214 244 self.log.debug('%s file "%s" (at %s)' % (category, file, path)) 215 245 return os.path.exists(path) and path, doc + '/' + file 216 246 217 if not file:218 path, link = lookup('index.html', 'index')219 return 'index', path, link220 221 247 self.log.debug('looking up "%s" in documentation "%s"' % (file, doc)) 222 248 223 249 # Direct request for searching 224 250 if file == 'search.php': 225 return 'search', None, None 251 return 'search', None, None # keep existing 'query' arg 226 252 227 253 # Request for a documentation file. … … 232 258 return 'view', path, link 233 259 else: 234 return 'search', file, None260 return 'search', None, file 235 261 236 262 # Request for source file documentation. … … 244 270 return 'view', path, link 245 271 else: 246 return 'search', file, None272 return 'search', None, file 247 273 248 274 # Request for summary pages … … 270 296 name = result['name'] 271 297 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 274 305 self.log.debug('%s not found in %s' % (file, doc)) 275 return 'search', file, None306 return 'search', None, file 276 307 277 308 def _search_in_documentation(self, doc, keywords):
