File: Synopsis/Formatters/HTML/Fragments/TemplateSpecializations.py
 1#
 2# Copyright (C) 2008 Stefan Seefeld
 3# All rights reserved.
 4# Licensed to the public under the terms of the GNU LGPL (>= 2),
 5# see the file COPYING for details.
 6#
 7
 8from Synopsis.Formatters.HTML.Tags import *
 9from Synopsis.Formatters.HTML.Fragment import Fragment
10
11class TemplateSpecializations(Fragment):
12    """Cross-link primary templates with their specializations."""
13
14    def format_forward(self, forward):
15
16        if not forward.template:
17            return ''
18        if forward.specializations:
19            spec = '\n'.join([div(self.reference(s))
20                              for s in forward.specializations])
21            return div('Specializations: ' + div(spec),
22                       class_='specializations')
23        elif forward.primary_template:
24            return div('Primary template: ' + self.reference(forward.primary_template),
25                       class_='primary-template')
26        return ''
27
28    def format_class(self, class_):
29
30        if class_.primary_template:
31            return div('Primary template: ' + self.reference(class_.primary_template),
32                       class_='primary-template')
33        return ''
34
35    def format_class_template(self, template_):
36
37        if template_.specializations:
38            spec = ' '.join([div(self.reference(s))
39                             for s in template_.specializations])
40            return div('Specializations: ' + spec, class_='specializations')
41        elif template_.primary_template:
42            return div('Primary template: ' + self.reference(template_.primary_template),
43                       class_='primary-template')
44        return ''
45