File: Synopsis/Formatters/HTML/Fragments/SourceLinker.py 1
2
3
4
5
6
7
8
9from Synopsis.Formatters.HTML.Tags import *
10from Default import Default
11
12_icons = {'C':'src-c.png',
13 'C++':'src-c++.png',
14 'Python':'src-py.png'}
15
16class SourceLinker(Default):
17 """Adds a link to the decl on the file view to all declarations"""
18
19 def register(self, formatter):
20
21 Default.register(self, formatter)
22 self.sxr = self.processor.sxr_prefix and True
23
24 def format_declaration(self, decl):
25
26 if not self.sxr or not decl.file: return ''
27 language = decl.file.annotations['language']
28 icon = _icons[language]
29 url = self.directory_layout.file_source(decl.file.name) + '#line%d' % decl.line
30 label = img(src=rel(self.view.filename(), icon), alt='source code')
31 return href(rel(self.view.filename(), url), label)
32
Generated on Thu Apr 16 16:27:13 2009 by
synopsis (version devel)