File: Synopsis/Formatters/HTML/Fragments/DeclarationCommenter.py
 1#
 2# Copyright (C) 2009 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 Default import Default
10
11class DeclarationCommenter(Default):
12    """Add annotation details to all declarations."""
13
14    def format_declaration(self, decl):
15
16        doc = self.processor.documentation.doc(decl, self.view)
17        if doc.has_details():
18            c = self.view.generate_id()
19            more = span(' More...', class_='expand-toggle',
20                        onclick='return decl_doc_expand(\'d%d\');'%c)
21            summary = div(doc.summary + more, class_='summary collapsed')
22            less = para('-', class_='collapse-toggle expanded',
23                        onclick='return decl_doc_collapse(\'d%d\');'%c)
24            details = div(doc.details, class_='details expanded')
25            return div(less + '\n' + summary + '\n' + details,
26                       class_='doc collapsible', id='d%d'%c)
27        else:
28            return div(doc.details or '', class_='doc')
29
30