16 from docutils 
import nodes
 
   17 from docutils.parsers.rst 
import directives, roles, states
 
   20     app.add_directive(
'toggle', ToggleDirective)
 
   21     app.add_directive(
'toggle_table', ToggleTableDirective)
 
   25     Base class that will be used by the two toggle directives 
   27     required_arguments = 1
 
   28     optional_arguments = 0
 
   29     final_argument_whitespace = 
True 
   32     node_class = nodes.container
 
   35         self.assert_has_content()
 
   36         text = 
'\n'.join(self.content)
 
   39         label = self.arguments[0]
 
   40         label_strip = label.replace(
' ', 
'')
 
   41         node += nodes.raw(self.arguments[0], 
'<div class="toggleable_div label_%s">' % label_strip, format=
"html")
 
   44         self.state.nested_parse(self.content, self.content_offset, node)
 
   45         node += nodes.raw(self.arguments[0], 
'</div>', format=
"html")
 
   50     Class used to create a set of buttons to toggle different sections 
   52     required_arguments = 0
 
   53     optional_arguments = 10
 
   54     final_argument_whitespace = 
True 
   56     for i 
in xrange(0, 100):
 
   57         option_spec[
'arg' + str(i)] = str
 
   59     node_class = nodes.container
 
   63 function toggle(label) { 
   64   $('.toggleable_button').css({border: '2px outset', 'border-radius': '4px'}); 
   65   $('.toggleable_button.label_' + label).css({border: '2px inset', 'border-radius': '4px'}); 
   66   $('.toggleable_div').css('display', 'none'); 
   67   $('.toggleable_div.label_' + label).css('display', 'block'); 
   74 $(document).ready(function() { 
   75   var classList =$('.toggleable_button').attr('class').split(/\s+/); 
   76   $.each( classList, function(index, item){ 
   77     if (item.substring(0, 5) === 'label') { 
   78       toggle(item.substring(6)); 
   87         for key 
in self.options.keys():
 
   89                 raise RuntimeError(key + 
' not in the contructor of ToggleTableDirective, use arg0 to arg99')
 
   90             label = self.options[key]
 
   91             label_strip = label.replace(
' ', 
'')
 
   92             str1 = 
'<button class="toggleable_button label_%s" onclick="' % label_strip
 
   93             str2 = js_toggle + 
"toggle('%s')" % label_strip
 
   94             str3 = 
'">%s</button>' % label
 
   95             node += nodes.raw(key, str1 + str2 + str3 + js_ready, format=
"html")