/
demo_app.py
28 lines (19 loc) · 943 Bytes
/
demo_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import streamlit as st
import streamlit.components.v1 as components
from alkh import logic_core
from alkh import app_core
# file_path = "tests/demo_test.py"
file_path = "alkh/logic_core.py"
file_lines = open(file_path).readlines()
file_content = "".join(file_lines)
call_graph_manager = logic_core.CallGraphManager(file_path)
line_number = st.sidebar.number_input('line number', min_value=1, max_value=len(file_lines))
lines_numbers_list = call_graph_manager.get_lines_numbers_affecting_line_number(line_number)
lines_numbers_string = ",".join(map(str, lines_numbers_list))
hocus_tab, focus_tab = st.tabs(["Hocus", "Focus"])
with hocus_tab:
html = app_core.get_full_code_html(lines_numbers_list, file_content)
components.html(html, height=400, width=800, scrolling=True)
with focus_tab:
html = app_core.get_focused_code_html(lines_numbers_list, file_lines)
components.html(html, height=400, width=800, scrolling=True)