Synopsis - Synopsis/Formatters/HTML/Fragments/SourceLinker.py

File: Synopsis/Formatters/HTML/Fragments/SourceLinker.py

     1#
     2# Copyright (C) 2000 Stephen Davies
     3# Copyright (C) 2000 Stefan Seefeld
     4# All rights reserved.
     5# Licensed to the public under the terms of the GNU LGPL (>= 2),
     6# see the file COPYING for details.
     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)