File: Synopsis/Formatters/HTML/Views/InheritanceTree.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.Processor import Parameter
10from Synopsis.Formatters.HTML.View import View
11from Synopsis.Formatters.HTML.Tags import *
12
13class InheritanceTree(View):
14
15    def filename(self):
16
17        if self.main:
18            return self.directory_layout.index()
19        else:
20            return self.directory_layout.special('InheritanceTree')
21
22    def title(self):
23
24        return 'Inheritance Tree'
25
26    def root(self):
27
28        return self.filename(), self.title()
29
30    def process(self):
31
32        self.start_file()
33        self.write_navigation_bar()
34        self.write(element('h1', 'Inheritance Tree'))
35        self.write('<ul>')
36        module = self.processor.root
37        for r in self.processor.class_tree.roots():
38            self.process_inheritance(r, module.name)
39        self.write('</ul>')
40        self.end_file()
41
42    def process_inheritance(self, name, rel_name):
43        self.write('<li>')
44        self.write(self.reference(name, rel_name))
45        parents = self.processor.class_tree.superclasses(name)
46        if parents:
47            self.write(' <i>(%s)</i>'%', '.join([str(p) for p in parents]))
48        subs = self.processor.class_tree.subclasses(name)
49        if subs:
50            self.write('<ul>')
51            for s in subs:
52                self.process_inheritance(s, name)
53            self.write('</ul>\n')
54        self.write('</li>')
55