@@ -53,7 +53,8 @@ def setup(app):
5353 app .add_config_value ("activecode_hide_load_history" , False , "html" )
5454 app .add_config_value ("wasm_uri" , "/_static" , "html" )
5555
56- app .add_node (ActivcodeNode , html = (visit_ac_node , depart_ac_node ))
56+ app .add_node (ActivecodeNode , html = (visit_ac_node , depart_ac_node ),
57+ xml = (visit_ac_xml , depart_ac_xml ))
5758
5859 app .connect ("doctree-resolved" , process_activcode_nodes )
5960 app .connect ("env-purge-doc" , purge_activecodes )
@@ -79,16 +80,18 @@ def setup(app):
7980"""
8081
8182
82- class ActivcodeNode (nodes .General , nodes .Element , RunestoneIdNode ):
83- def __init__ (self , content , ** kwargs ):
84- """
83+ class ActivecodeNode (nodes .General , nodes .Element , RunestoneIdNode ):
84+ pass
85+
86+
87+ def visit_ac_xml (self , node ):
88+ res = TEMPLATE_START % node ["runestone_options" ]
89+ self .output .append (res )
90+
8591
86- Arguments:
87- - `self`:
88- - `content`:
89- """
90- super (ActivcodeNode , self ).__init__ (name = content ["name" ], ** kwargs )
91- self .runestone_options = content
92+ def depart_ac_xml (self , node ):
93+ res = TEMPLATE_END % node ["runestone_options" ]
94+ self .output .append (res )
9295
9396
9497# self for these functions is an instance of the writer class. For example
@@ -97,15 +100,15 @@ def __init__(self, content, **kwargs):
97100def visit_ac_node (self , node ):
98101 # print self.settings.env.activecodecounter
99102
100- # todo: handle above in node. runestone_options
101- # todo handle 'hidecode' not in node. runestone_options:
102- # todo: handle if 'gradebutton' in node. runestone_options: res += GRADES
103+ # todo: handle above in node[" runestone_options"]
104+ # todo handle 'hidecode' not in node[" runestone_options"] :
105+ # todo: handle if 'gradebutton' in node[" runestone_options"] : res += GRADES
103106
104- node . delimiter = "_start__{}_" .format (node . runestone_options ["divid" ])
107+ node [ " delimiter" ] = "_start__{}_" .format (node [ " runestone_options" ] ["divid" ])
105108
106- self .body .append (node . delimiter )
109+ self .body .append (node [ " delimiter" ] )
107110
108- res = TEMPLATE_START % node . runestone_options
111+ res = TEMPLATE_START % node [ " runestone_options" ]
109112 self .body .append (res )
110113
111114
@@ -114,16 +117,16 @@ def depart_ac_node(self, node):
114117 etc and did not want to do all of the processing in visit_ac_node any finishing touches could be
115118 added here.
116119 """
117- res = TEMPLATE_END % node . runestone_options
120+ res = TEMPLATE_END % node [ " runestone_options" ]
118121 self .body .append (res )
119122
120123 addHTMLToDB (
121- node . runestone_options ["divid" ],
122- node . runestone_options ["basecourse" ],
123- "" .join (self .body [self .body .index (node . delimiter ) + 1 :]),
124+ node [ " runestone_options" ] ["divid" ],
125+ node [ " runestone_options" ] ["basecourse" ],
126+ "" .join (self .body [self .body .index (node [ " delimiter" ] ) + 1 :]),
124127 )
125128
126- self .body .remove (node . delimiter )
129+ self .body .remove (node [ " delimiter" ] )
127130
128131
129132def process_activcode_nodes (app , env , docname ):
@@ -448,8 +451,10 @@ def run(self):
448451 "This should only affect the grading interface. Everything else should be fine."
449452 )
450453
451- acnode = ActivcodeNode (self .options , rawsource = self .block_text )
452- acnode .source , acnode .line = self .state_machine .get_source_and_line (self .lineno )
454+ acnode = ActivecodeNode (self .options , rawsource = self .block_text )
455+ acnode ["runestone_options" ] = self .options
456+ acnode ["source" ], acnode ["line" ] = self .state_machine .get_source_and_line (
457+ self .lineno )
453458 self .add_name (acnode ) # make this divid available as a target for :ref:
454459
455460 maybeAddToAssignment (self )
0 commit comments