| 59 | | |
|---|
| 60 | | # Match index |
|---|
| 61 | | if re.match('^/doxygen/$', req.path_info): |
|---|
| 62 | | req.args['path'] = base_path |
|---|
| 63 | | req.args['type'] = 'index' |
|---|
| | 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(' ')) |
|---|
| | 63 | |
|---|
| | 64 | # Match documentation request. |
|---|
| | 65 | self.log.debug(req.path_info) |
|---|
| | 66 | match = re.match('^/doxygen(?:/?$|/([^/]*)(?:/?$|/(.*)$))', |
|---|
| | 67 | req.path_info) |
|---|
| | 68 | if match: |
|---|
| | 69 | self.log.debug('matched group 1: %s' % (match.group(1),)) |
|---|
| | 70 | self.log.debug('matched group 2: %s' % (match.group(2),)) |
|---|
| | 71 | |
|---|
| | 72 | if not match.group(1) and not match.group(2): |
|---|
| | 73 | # Request for documentation index. |
|---|
| | 74 | req.args['path'] = os.path.join(base_path, default_project) |
|---|
| | 75 | req.args['action'] = 'index' |
|---|
| | 76 | else: |
|---|
| | 77 | # Get project and file from request. |
|---|
| | 78 | if not match.group(2): |
|---|
| | 79 | project = default_project |
|---|
| | 80 | file = match.group(1) |
|---|
| | 81 | else: |
|---|
| | 82 | project = match.group(1) |
|---|
| | 83 | file = match.group(2) |
|---|
| | 84 | |
|---|
| | 85 | self.log.debug('project: %s' % (project,)) |
|---|
| | 86 | self.log.debug('file: %s' % (file,)) |
|---|
| | 87 | |
|---|
| | 88 | if re.match(r'''^search.php$''', file): |
|---|
| | 89 | # Request for searching. |
|---|
| | 90 | req.args['action'] = 'search' |
|---|
| | 91 | |
|---|
| | 92 | elif re.match(r'''^(.*)[.](%s)''' % (ext,), file): |
|---|
| | 93 | # Request for documentation file. |
|---|
| | 94 | path = os.path.join(base_path, project, file) |
|---|
| | 95 | self.log.debug('path: %s' % (path,)) |
|---|
| | 96 | if os.path.exists(path): |
|---|
| | 97 | req.args['path'] = path |
|---|
| | 98 | req.args['action'] = 'file' |
|---|
| | 99 | else: |
|---|
| | 100 | req.args['action'] = 'search' |
|---|
| | 101 | req.args['query'] = file |
|---|
| | 102 | |
|---|
| | 103 | else: |
|---|
| | 104 | match = re.match(r'''^(.*)[.](%s)''' % (source_ext,), file) |
|---|
| | 105 | if match: |
|---|
| | 106 | # Request for source file documentation. |
|---|
| | 107 | path = os.path.join(base_path, project, '%s_8%s.html' |
|---|
| | 108 | % (match.group(1), match.group(2))) |
|---|
| | 109 | self.log.debug('path: %s' % (path,)) |
|---|
| | 110 | if os.path.exists(path): |
|---|
| | 111 | req.args['path'] = path |
|---|
| | 112 | req.args['action'] = 'file' |
|---|
| | 113 | else: |
|---|
| | 114 | req.args['action'] = 'search' |
|---|
| | 115 | req.args['query'] = file |
|---|
| | 116 | |
|---|
| | 117 | else: |
|---|
| | 118 | path = os.path.join(base_path, project, 'class%s.html' |
|---|
| | 119 | % (file,)) |
|---|
| | 120 | if os.path.exists(path): |
|---|
| | 121 | req.args['path'] = path |
|---|
| | 122 | req.args['action'] = 'file' |
|---|
| | 123 | else: |
|---|
| | 124 | path = os.path.join(base_path, project, |
|---|
| | 125 | 'struct%s.html' % (file,)) |
|---|
| | 126 | if os.path.exists(path): |
|---|
| | 127 | req.args['path'] = path |
|---|
| | 128 | req.args['action'] = 'file' |
|---|
| | 129 | else: |
|---|
| | 130 | results = self._search_in_project(project, |
|---|
| | 131 | [file]) |
|---|
| | 132 | for result in results: |
|---|
| | 133 | self.log.debug(result) |
|---|
| | 134 | if result['name'] == file: |
|---|
| | 135 | req.redirect(self.env.href.doxygen( |
|---|
| | 136 | project) + '/' + result['url']) |
|---|
| | 137 | req.args['action'] = 'search' |
|---|
| | 138 | req.args['query'] = file |
|---|
| | 139 | |
|---|
| | 140 | # Request matched. |
|---|
| 114 | | elif type == 'text/html': |
|---|
| 115 | | add_stylesheet(req, 'doxygen/css/doxygen.css') |
|---|
| 116 | | req.hdf['doxygen.path'] = path |
|---|
| 117 | | return 'doxygen.cs', type |
|---|
| 118 | | else: |
|---|
| 119 | | req.send_file(path, type) |
|---|
| 120 | | return None, None |
|---|
| | 185 | |
|---|
| | 186 | elif action == 'file': |
|---|
| | 187 | type = mimetypes.guess_type(path)[0] |
|---|
| | 188 | |
|---|
| | 189 | if type == 'text/html': |
|---|
| | 190 | add_stylesheet(req, 'doxygen/css/doxygen.css') |
|---|
| | 191 | req.hdf['doxygen.path'] = path |
|---|
| | 192 | return 'doxygen.cs', 'text/html' |
|---|
| | 193 | else: |
|---|
| | 194 | req.send_file(path, type) |
|---|
| 149 | | path = self.config.get('doxygen', 'path') |
|---|
| 150 | | path = os.path.join(path, 'search.idx') |
|---|
| 151 | | |
|---|
| 152 | | if os.path.exists(path): |
|---|
| 153 | | fd = open(path) |
|---|
| 154 | | |
|---|
| | 223 | base_path = self.config.get('doxygen', 'path') |
|---|
| | 224 | |
|---|
| | 225 | for project in os.listdir(base_path): |
|---|
| | 226 | # Search in project documentation directories |
|---|
| | 227 | path = os.path.join(base_path, project) |
|---|
| | 228 | if os.path.isdir(path): |
|---|
| | 229 | index = os.path.join(path, 'search.idx') |
|---|
| | 230 | if os.path.exists(index): |
|---|
| | 231 | creation = os.path.getctime(index) |
|---|
| | 232 | for result in self._search_in_project(project, keywords): |
|---|
| | 233 | result['url'] = self.env.href.doxygen(project) + '/' \ |
|---|
| | 234 | + result['url'] |
|---|
| | 235 | yield result['url'], result['name'], creation, \ |
|---|
| | 236 | 'doxygen', None |
|---|
| | 237 | |
|---|
| | 238 | # Search in common documentation directory |
|---|
| | 239 | index = os.path.join(base_path, 'search.idx') |
|---|
| | 240 | if os.path.exists(index): |
|---|
| | 241 | creation = os.path.getctime(index) |
|---|
| | 242 | for result in self._search_in_project('', keywords): |
|---|
| | 243 | result['url'] = self.env.href.doxygen() + '/' + \ |
|---|
| | 244 | result['url'] |
|---|
| | 245 | yield result['url'], result['name'], creation, 'doxygen', \ |
|---|
| | 246 | None |
|---|
| | 247 | |
|---|
| | 248 | # IWikiSyntaxProvider |
|---|
| | 249 | def get_link_resolvers(self): |
|---|
| | 250 | yield ('doxygen', self._doxygen_link) |
|---|
| | 251 | |
|---|
| | 252 | def get_wiki_syntax(self): |
|---|
| | 253 | return [] |
|---|
| | 254 | |
|---|
| | 255 | # internal methods |
|---|
| | 256 | def _search_in_project(self, project, keywords): |
|---|
| | 257 | # Open index file for project documentation |
|---|
| | 258 | base_path = self.config.get('doxygen', 'path') |
|---|
| | 259 | index = os.path.join(base_path, project, 'search.idx') |
|---|
| | 260 | if os.path.exists(index): |
|---|
| | 261 | fd = open(index) |
|---|
| | 262 | |
|---|
| | 263 | # Search for keywords in index |
|---|