File: Synopsis/Formatters/HTML/Parts/Detail.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 import ASG
10from Synopsis.Processor import Parameter
11from Synopsis.Formatters.HTML.Part import Part
12from Synopsis.Formatters.HTML.Fragments import *
13from Synopsis.Formatters.HTML.Tags import *
14
15class Detail(Part):
16
17    fragments = Parameter([DeclarationDetailFormatter(), DetailCommenter()],
18                         '')
19
20    def write_section_start(self, heading):
21        """Start a 'detail' section and write an appropriate heading."""
22
23        self.write('<div class="detail">\n')
24        self.write(div('heading', heading) + '\n')
25
26    def write_section_end(self, heading):
27        """Close the section."""
28
29        self.write('</div><!-- detail -->\n')
30
31    def write_section_item(self, text):
32        """Add an item."""
33
34        self.write(div('item',text) + '\n')
35
36    def process(self, decl):
37        "Print out the details for the children of the given decl"
38
39        if type(decl) == ASG.Forward:
40            return
41
42        doc = self.processor.documentation
43        sorter = self.processor.sorter.clone(decl.declarations)
44
45        # Iterate through the sections with details
46        self.write_start()
47        for section in sorter:
48            # Write a heading
49            heading = section+' Details:'
50            started = 0 # Lazy section start incase no details for this section
51            # Iterate through the children in this section
52            for child in sorter[section]:
53                # Check if need to add to detail list
54                if not doc.details(child, self.view()):
55                    continue
56                # Check section heading
57                if not started:
58                    started = 1
59                    self.write_section_start(heading)
60                child.accept(self)
61            # Finish the section
62            if started: self.write_section_end(heading)
63        self.write_end()
64