MCPcopy Index your code
hub / github.com/reactive-python/reactpy / run

Method run

docs/source/_exts/reactpy_example.py:29–93  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

27 }
28
29 def run(self):
30 example_name = get_normalized_example_name(
31 self.arguments[0],
32 # only used if example name starts with "/"
33 self.get_source_info()[0],
34 )
35
36 show_linenos = "linenos" in self.options
37 live_example_is_default_tab = "result-is-default-tab" in self.options
38 activate_result = "activate-button" not in self.options
39
40 ex_files = get_example_files_by_name(example_name)
41 if not ex_files:
42 src_file, line_num = self.get_source_info()
43 msg = f"Missing example named {example_name!r} referenced by document {src_file}:{line_num}"
44 raise ValueError(msg)
45
46 labeled_tab_items: list[tuple[str, Any]] = []
47 if len(ex_files) == 1:
48 labeled_tab_items.append(
49 (
50 "main.py",
51 _literal_include(
52 path=ex_files[0],
53 linenos=show_linenos,
54 ),
55 )
56 )
57 else:
58 for path in sorted(
59 ex_files, key=lambda p: "" if p.name == "main.py" else p.name
60 ):
61 labeled_tab_items.append(
62 (
63 path.name,
64 _literal_include(
65 path=path,
66 linenos=show_linenos,
67 ),
68 )
69 )
70
71 result_tab_item = (
72 "🚀 result",
73 _interactive_widget(
74 name=example_name,
75 with_activate_button=not activate_result,
76 ),
77 )
78 if live_example_is_default_tab:
79 labeled_tab_items.insert(0, result_tab_item)
80 else:
81 labeled_tab_items.append(result_tab_item)
82
83 return TabSetDirective(
84 "WidgetExample",
85 [],
86 {},

Callers 15

lint_pyFunction · 0.45
test_docsFunction · 0.45
_docker_docsFunction · 0.45
_live_docsFunction · 0.45
in_pyFunction · 0.45
in_jsFunction · 0.45
get_current_tagsFunction · 0.45
prepare_js_releaseFunction · 0.45
publishFunction · 0.45
prepare_py_releaseFunction · 0.45
install_hatch_projectFunction · 0.45
install_poetry_projectFunction · 0.45

Calls 5

_literal_includeFunction · 0.85
_interactive_widgetFunction · 0.85
_make_tab_itemsFunction · 0.85

Tested by 1

test_docsFunction · 0.36