@@ -19,12 +19,15 @@ class WidgetExample(SphinxDirective):
1919
2020 option_spec = {
2121 "linenos" : directives .flag ,
22- "live-example-is-default-tab" : directives .flag ,
22+ "result-is-default-tab" : directives .flag ,
23+ "activate-result" : directives .flag ,
2324 }
2425
2526 def run (self ):
2627 example_name = self .arguments [0 ]
2728 show_linenos = "linenos" in self .options
29+ live_example_is_default_tab = "result-is-default-tab" in self .options
30+ activate_result = "activate-result" in self .options
2831
2932 py_ex_path = examples / f"{ example_name } .py"
3033 if not py_ex_path .exists ():
@@ -34,26 +37,32 @@ def run(self):
3437 )
3538
3639 labeled_tab_items = {
37- "Python Code " : _literal_include_py (
40+ "python " : _literal_include_py (
3841 name = example_name ,
3942 linenos = show_linenos ,
4043 ),
41- "Live Example " : _interactive_widget (
44+ "result " : _interactive_widget (
4245 name = example_name ,
43- with_activate_button = "live-example-is-default-tab" not in self . options ,
46+ with_activate_button = not activate_result ,
4447 ),
4548 }
4649
50+ labeled_tab_titles = {
51+ "python" : "Python" ,
52+ "javascript" : "Javascript" ,
53+ "result" : "▶️ Result" ,
54+ }
55+
4756 if (examples / f"{ example_name } .js" ).exists ():
48- labeled_tab_items ["Javascript Code " ] = _literal_include_js (
57+ labeled_tab_items ["javascript " ] = _literal_include_js (
4958 name = example_name ,
5059 linenos = show_linenos ,
5160 )
5261
5362 tab_label_order = (
54- ["Live Example " , "Python Code " , "Javascript Code " ]
55- if "live-example-is-default-tab" in self . options
56- else ["Python Code " , "Javascript Code " , "Live Example " ]
63+ ["result " , "python " , "javascript " ]
64+ if live_example_is_default_tab
65+ else ["python " , "javascript " , "result " ]
5766 )
5867
5968 return TabSetDirective (
@@ -62,7 +71,7 @@ def run(self):
6271 {},
6372 _make_tab_items (
6473 [
65- (label , labeled_tab_items [label ])
74+ (labeled_tab_titles [ label ] , labeled_tab_items [label ])
6675 for label in tab_label_order
6776 if label in labeled_tab_items
6877 ]
0 commit comments