@@ -31,8 +31,11 @@ def setup(app):
3131
3232 app .add_config_value ("codelens_div_class" , "cd_section" , "html" )
3333 app .add_config_value ("trace_url" , "http://tracer.runestone.academy:5000" , "html" )
34- app .add_node (CodeLensNode , html = (visit_codelens_html , depart_codelens_html ),
35- xml = (visit_codelens_xml , depart_codelens_xml ))
34+ app .add_node (
35+ CodeLensNode ,
36+ html = (visit_codelens_html , depart_codelens_html ),
37+ xml = (visit_codelens_xml , depart_codelens_xml ),
38+ )
3639
3740
3841# data-tracefile="pytutor-embed-demo/java.json"
@@ -64,7 +67,7 @@ def setup(app):
6467"""
6568
6669PTX_TEMPLATE = """
67- <program xml:id="{divid} interactive="codelens" language="{language}>
70+ <program xml:id="{divid}" interactive="codelens" language="{language}" >
6871 <input>
6972{source}
7073 </input>
@@ -79,18 +82,26 @@ class CodeLensNode(nodes.General, nodes.Element, RunestoneIdNode):
7982def visit_codelens_xml (self , node ):
8083 html = VIS
8184 if "caption" not in node ["runestone_options" ]:
82- node ["runestone_options" ]["caption" ] = node ["runestone_options" ]["question_label" ]
85+ node ["runestone_options" ]["caption" ] = node ["runestone_options" ][
86+ "question_label"
87+ ]
8388 if "tracedata" in node ["runestone_options" ]:
84- node ["runestone_options" ]["tracedata" ] = node ["runestone_options" ]["tracedata" ].replace (
85- "<" , "<" ).replace (">" , ">" )
89+ node ["runestone_options" ]["tracedata" ] = (
90+ node ["runestone_options" ]["tracedata" ]
91+ .replace ("<" , "<" )
92+ .replace (">" , ">" )
93+ )
8694
8795 res = PTX_TEMPLATE .format (** node ["runestone_options" ])
96+ self .output .append (res )
8897
8998
9099def visit_codelens_html (self , node ):
91100 html = VIS
92101 if "caption" not in node ["runestone_options" ]:
93- node ["runestone_options" ]["caption" ] = node ["runestone_options" ]["question_label" ]
102+ node ["runestone_options" ]["caption" ] = node ["runestone_options" ][
103+ "question_label"
104+ ]
94105 if "tracedata" in node ["runestone_options" ]:
95106 html += DATA
96107 else :
@@ -99,7 +110,9 @@ def visit_codelens_html(self, node):
99110
100111 self .body .append (html )
101112 addHTMLToDB (
102- node ["runestone_options" ]["divid" ], node ["runestone_options" ]["basecourse" ], html
113+ node ["runestone_options" ]["divid" ],
114+ node ["runestone_options" ]["basecourse" ],
115+ html ,
103116 )
104117
105118
@@ -149,24 +162,24 @@ def depart_codelens_xml(self, node):
149162
150163class Codelens (RunestoneIdDirective ):
151164 """
152- .. codelens:: uniqueid
153- :tracedata: Autogenerated or provided
154- :caption: caption below
155- :showoutput: show stdout from program
156- :question: Text of question to ask on breakline
157- :correct: correct answer to the question
158- :feedback: feedback for incorrect answers
159- :breakline: Line to stop on and pop up a question dialog
160- :python: either py2 or py3
165+ .. codelens:: uniqueid
166+ :tracedata: Autogenerated or provided
167+ :caption: caption below
168+ :showoutput: show stdout from program
169+ :question: Text of question to ask on breakline
170+ :correct: correct answer to the question
171+ :feedback: feedback for incorrect answers
172+ :breakline: Line to stop on and pop up a question dialog
173+ :python: either py2 or py3
161174
162- x = 0
163- for i in range(10):
164- x = x + i
175+ x = 0
176+ for i in range(10):
177+ x = x + i
165178
166179
167- config values (conf.py):
180+ config values (conf.py):
168181
169- - codelens_div_class - custom CSS class of the component's outermost div
182+ - codelens_div_class - custom CSS class of the component's outermost div
170183 """
171184
172185 required_arguments = 1
0 commit comments