Changeset 1209
- Timestamp:
- 08/30/06 17:29:22 (2 years ago)
- Files:
-
- doxygenplugin/0.10 (copied) (copied from doxygenplugin/0.9)
- doxygenplugin/0.10/doxygentrac/doxygentrac.py (copied) (copied from doxygenplugin/0.9/doxygentrac/doxygentrac.py) (19 diffs)
- doxygenplugin/0.10/doxygentrac/htdocs (copied) (copied from doxygenplugin/0.9/doxygentrac/htdocs)
- doxygenplugin/0.10/doxygentrac/htdocs/css/doxygen.css (copied) (copied from doxygenplugin/0.9/doxygentrac/htdocs/css/doxygen.css)
- doxygenplugin/0.10/doxygentrac/templates/doxygen.cs (copied) (copied from doxygenplugin/0.9/doxygentrac/templates/doxygen.cs)
- doxygenplugin/0.10/setup.py (copied) (copied from doxygenplugin/0.9/setup.py) (1 diff)
- doxygenplugin/0.9/setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doxygenplugin/0.10/doxygentrac/doxygentrac.py
r1130 r1209 12 12 import mimetypes 13 13 14 from trac.config import Option 14 15 from trac.core import * 15 16 from trac.web import IRequestHandler 16 17 from trac.perm import IPermissionRequestor 17 from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet 18 from trac.web.chrome import INavigationContributor, ITemplateProvider, \ 19 add_stylesheet 18 20 from trac.Search import ISearchSource 19 21 from trac.wiki import IWikiSyntaxProvider, wiki_to_html 20 22 from trac.wiki.formatter import system_message 21 from trac.util import Markup23 from trac.util.html import html 22 24 23 25 def compare_rank(x, y): … … 32 34 ITemplateProvider, ISearchSource, IWikiSyntaxProvider) 33 35 36 base_path = Option('doxygen', 'path', '/var/lib/trac/doxygen', 37 """Directory containing doxygen generated files.""") 38 39 default_doc = Option('doxygen', 'default_documentation', '', 40 """Default path relative to `base_path` in which to look for 41 documentation files.""") 42 43 title = Option('doxygen', 'title', 'Doxygen', 44 """Title to use for the main navigation tab.""") 45 46 ext = Option('doxygen', 'ext', 'htm html png', 47 """Space separated list of extensions for doxygen managed files.""") 48 49 source_ext = Option('doxygen', 'source_ext', 50 'idl odl java cs py php php4 inc phtml m ' 51 'cpp cxx c hpp hxx h', 52 """Space separated list of source files extensions""") 53 54 index = Option('doxygen', 'index', 'main.html', 55 """Default index page to pick in the generated documentation.""") 56 57 wiki_index = Option('doxygen', 'wiki_index', None, 58 """Wiki page to use as the default page for the Doxygen main page.""") 59 60 encoding = Option('doxygen', 'encoding', 'iso-8859-1', 61 """Default encoding used by the generated documentation files.""") 62 34 63 # IPermissionRequestor methods 35 64 … … 41 70 def get_active_navigation_item(self, req): 42 71 return 'doxygen' 72 43 73 def get_navigation_items(self, req): 44 74 if req.perm.has_permission('DOXYGEN_VIEW'): 45 # Get config variables.46 title = self.env.config.get('doxygen', 'title', 'Doxygen')47 48 75 # Return mainnav buttons. 49 yield 'mainnav', 'doxygen', Markup('<a href="%s">%s</a>' % \50 (self.env.href.doxygen() + '/', title))76 yield 'mainnav', 'doxygen', html.a(self.title, 77 href = req.href.doxygen()) 51 78 52 79 # IRequestHandler methods 53 80 54 81 def match_request(self, req): 55 # Get config variables. 56 base_path = self.config.get('doxygen', 'path', '/var/lib/trac/doxygen') 57 default_doc = self.config.get('doxygen', 'default_documentation', '') 58 ext = self.config.get('doxygen', 'ext', 'htm html png') 59 ext = '|'.join(ext.split(' ')) 60 source_ext = self.config.get('doxygen', 'source_ext', 'idl odl java' \ 61 ' cs py php php4 inc phtml m cpp cxx c hpp hxx h') 62 source_ext = '|'.join(source_ext.split(' ')) 82 ext = '|'.join(self.ext.split(' ')) 83 source_ext = '|'.join(self.source_ext.split(' ')) 63 84 64 85 # Match documentation request. … … 72 93 if not match.group(1) and not match.group(2): 73 94 # Request for documentation index. 74 req.args['path'] = os.path.join(base_path, default_doc) 95 req.args['path'] = os.path.join(self.base_path, 96 self.default_doc) 75 97 req.args['action'] = 'index' 76 98 else: 77 99 # Get doc and file from request. 78 100 if not match.group(2): 79 doc = default_doc101 doc = self.default_doc 80 102 file = match.group(1) 81 103 else: … … 92 114 elif re.match(r'''^(.*)[.](%s)''' % (ext,), file): 93 115 # Request for documentation file. 94 path = os.path.join( base_path, doc, file)116 path = os.path.join(self.base_path, doc, file) 95 117 self.log.debug('path: %s' % (path,)) 96 118 if os.path.exists(path): … … 105 127 if match: 106 128 # Request for source file documentation. 107 path = os.path.join( base_path, doc, '%s_8%s.html'129 path = os.path.join(self.base_path, doc, '%s_8%s.html' 108 130 % (match.group(1), match.group(2))) 109 131 self.log.debug('path: %s' % (path,)) … … 116 138 117 139 else: 118 path = os.path.join( base_path, doc, 'class%s.html'140 path = os.path.join(self.base_path, doc, 'class%s.html' 119 141 % (file,)) 120 142 if os.path.exists(path): … … 122 144 req.args['action'] = 'file' 123 145 else: 124 path = os.path.join( base_path, doc,146 path = os.path.join(self.base_path, doc, 125 147 'struct%s.html' % (file,)) 126 148 if os.path.exists(path): … … 133 155 self.log.debug(result) 134 156 if result['name'] == file: 135 req.redirect( self.env.href.doxygen(doc)157 req.redirect(req.href.doxygen(doc) 136 158 + '/' + result['url']) 137 159 req.args['action'] = 'search' 138 160 req.args['query'] = file 139 140 161 # Request matched. 141 162 return True … … 152 173 action = req.args.get('action') 153 174 154 # Get config variables 155 index = self.config.get('doxygen', 'index', 'main.html') 156 wiki_index = self.config.get('doxygen', 'wiki_index', None) 175 self.log.debug('path: %s' % (path,)) 176 self.log.debug('action: %s' % (action,)) 157 177 158 178 # Redirect search requests. 159 179 if action == 'search': 160 req.redirect( '%s?q=%s&doxygen=on' % (self.env.href.search(),161 req.args.get('query')))180 req.redirect(req.href.search(q = req.args.get('query'), 181 doxygen = 'on')) 162 182 163 183 # Retrun apropriate content to type or search request 164 184 elif action == 'index': 165 if wiki_index:185 if self.wiki_index: 166 186 # Get access to database 167 187 db = self.env.get_db_cnx() 168 188 cursor = db.cursor() 169 189 170 # Get wiki index 190 # Get wiki index # FIXME: use WikiPage() instead 171 191 sql = "SELECT text FROM wiki WHERE name = %s" 172 cursor.execute(sql, ( wiki_index,))173 text = Markup(system_message('Error', 'Wiki page %s does not' \174 ' exists' % (wiki_index)))192 cursor.execute(sql, (self.wiki_index,)) 193 text = system_message('Error', 'Wiki page %s does not exists' % 194 self.wiki_index) 175 195 for row in cursor: 176 196 text = wiki_to_html(row[0], self.env, req) … … 181 201 else: 182 202 add_stylesheet(req, 'doxygen/css/doxygen.css') 183 req.hdf['doxygen.path'] = path + '/' + index203 req.hdf['doxygen.path'] = path + '/' + self.index 184 204 return 'doxygen.cs', 'text/html' 185 205 … … 208 228 def get_search_filters(self, req): 209 229 if req.perm.has_permission('DOXYGEN_VIEW'): 210 # Get config variables 211 title = self.env.config.get('doxygen', 'title', 'Doxygen') 212 213 yield('doxygen', title) 214 215 def get_search_results(self, req, query, filters): 230 yield('doxygen', self.title) 231 232 def get_search_results(self, req, keywords, filters): 216 233 if not 'doxygen' in filters: 217 234 return 218 if query[0] == query[-1] == "'" or query[0] == query[-1] == '"': 219 keywords = [query[1:-1]] 220 else: 221 keywords = query.split(' ') 222 223 base_path = self.config.get('doxygen', 'path') 224 225 for doc in os.listdir(base_path): 235 236 # We have to search for the raw bytes... 237 keywords = [k.encode(self.encoding) for k in keywords] 238 239 for doc in os.listdir(self.base_path): 226 240 # Search in documentation directories 227 path = os.path.join( base_path, doc)241 path = os.path.join(self.base_path, doc) 228 242 if os.path.isdir(path): 229 243 index = os.path.join(path, 'search.idx') … … 231 245 creation = os.path.getctime(index) 232 246 for result in self._search_in_documentation(doc, keywords): 233 result['url'] = self.env.href.doxygen(doc) + '/' \247 result['url'] = req.href.doxygen(doc) + '/' \ 234 248 + result['url'] 235 249 yield result['url'], result['name'], creation, \ … … 237 251 238 252 # Search in common documentation directory 239 index = os.path.join( base_path, 'search.idx')253 index = os.path.join(self.base_path, 'search.idx') 240 254 if os.path.exists(index): 241 255 creation = os.path.getctime(index) 242 256 for result in self._search_in_documentation('', keywords): 243 result['url'] = self.env.href.doxygen() + '/' + \257 result['url'] = req.href.doxygen() + '/' + \ 244 258 result['url'] 245 259 yield result['url'], result['name'], creation, 'doxygen', \ … … 256 270 def _search_in_documentation(self, doc, keywords): 257 271 # Open index file for documentation 258 base_path = self.config.get('doxygen', 'path') 259 index = os.path.join(base_path, doc, 'search.idx') 272 index = os.path.join(self.base_path, doc, 'search.idx') 260 273 if os.path.exists(index): 261 274 fd = open(index) … … 284 297 low = word.lower() 285 298 if w.find(low) != -1: 286 matches.append({'word' : word, 'match' : w, 'index' : statIdx, 'full' : len(low) == len(w)}) 299 matches.append({'word': word, 'match': w, 300 'index': statIdx, 'full': len(low) == len(w)}) 287 301 w = self._readString(fd) 288 302 … … 303 317 idx = self._readInt(fd) 304 318 freq = self._readInt(fd) 305 results.append({'idx' : idx, 'freq' : freq >> 1, 'hi' : freq & 1, 'multi' : multiplier}) 319 results.append({'idx': idx, 'freq': freq >> 1, 320 'hi': freq & 1, 'multi': multiplier}) 306 321 if freq & 1: 307 322 totalHi += 1 … … 323 338 multi = results[i]['multi'] 324 339 if results[i]['hi']: 325 results[i]['rank'] = float((freq * multi + totalFreqLo)) / float(totalFreq) 340 results[i]['rank'] = float(freq*multi + totalFreqLo) \ 341 / float(totalFreq) 326 342 else: 327 results[i]['rank'] = float((freq * multi)) / float(totalFreq) 343 results[i]['rank'] = float(freq*multi) \ 344 / float(totalFreq) 328 345 329 346 return results … … 361 378 def _doxygen_link(self, formatter, ns, params, label): 362 379 if ns == 'doxygen': 363 return '<a href="%s" title="%s">%s</a>' % \364 (self.env.href.doxygen(params), params, label)380 return html.a(label, href = formatter.href.doxygen(params), 381 title = params) 365 382 else: 366 return '<a href="%s" class="missing">%s?</a>' % \367 (self.env.href.doxygen(), label)383 return html.a(label, href = formatter.href.doxygen(), 384 title = params, class_ = 'missing') doxygenplugin/0.10/setup.py
r1129 r1209 1 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 2 3 3 4 from setuptools import setup, find_packages doxygenplugin/0.9/setup.py
r1129 r1209 1 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 2 3 3 4 from setuptools import setup, find_packages
