Lenylvt commited on
Commit
b22e396
β€’
1 Parent(s): fd3f5b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -13
app.py CHANGED
@@ -1,28 +1,48 @@
1
  import streamlit as st
2
  import os
3
 
 
 
 
 
 
4
  # Function to read markdown files
5
  def load_markdown_file(path):
6
- with open(path, 'r') as file:
7
  content = file.read()
8
  return content
9
 
 
 
 
 
 
 
10
  # Streamlit UI
11
- st.title('Documentation')
12
 
13
  # Assuming your documentation is in the 'docs' folder
14
  docs_base_path = './docs'
15
 
16
- # List categories based on folder names
17
- categories = [d for d in os.listdir(docs_base_path) if os.path.isdir(os.path.join(docs_base_path, d))]
18
- category = st.sidebar.selectbox('Select a Category', categories)
19
 
20
- # List pages based on markdown files in the selected category folder
21
- pages_path = os.path.join(docs_base_path, category)
22
- pages = [f for f in os.listdir(pages_path) if os.path.isfile(os.path.join(pages_path, f))]
23
- page = st.sidebar.selectbox('Select a Page', pages)
 
 
 
 
 
 
 
24
 
25
- # Load and display the selected markdown file
26
- markdown_path = os.path.join(pages_path, page)
27
- markdown_content = load_markdown_file(markdown_path)
28
- st.markdown(markdown_content, unsafe_allow_html=True)
 
 
 
 
1
  import streamlit as st
2
  import os
3
 
4
+ # Custom CSS to style the markdown content
5
+ def local_css(file_name):
6
+ with open(file_name) "r") as f:
7
+ st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
8
+
9
  # Function to read markdown files
10
  def load_markdown_file(path):
11
+ with open(path, "r") as file:
12
  content = file.read()
13
  return content
14
 
15
+ # Initialize the app with a nicer layout
16
+ st.set_page_config(layout="wide")
17
+
18
+ # Apply some custom styles for better appearance
19
+ local_css("style.css") # Assume you have a style.css file for custom styles
20
+
21
  # Streamlit UI
22
+ st.title('πŸ“š Documentation')
23
 
24
  # Assuming your documentation is in the 'docs' folder
25
  docs_base_path = './docs'
26
 
27
+ # Create columns for sidebar and main content
28
+ col1, col2 = st.columns([1, 3])
 
29
 
30
+ with col1:
31
+ st.write("## Navigation")
32
+
33
+ # List categories based on folder names
34
+ categories = [d for d in os.listdir(docs_base_path) if os.path.isdir(os.path.join(docs_base_path, d))]
35
+ category = st.selectbox('Select a Category', categories)
36
+
37
+ # List pages based on markdown files in the selected category folder
38
+ pages_path = os.path.join(docs_base_path, category)
39
+ pages = [f for f in os.listdir(pages_path) if os.path.isfile(os.path.join(pages_path, f))]
40
+ page = st.selectbox('Select a Page', pages)
41
 
42
+ with col2:
43
+ st.write(f"## {page[:-3]}") # Remove .md extension and display as title
44
+
45
+ # Load and display the selected markdown file
46
+ markdown_path = os.path.join(pages_path, page)
47
+ markdown_content = load_markdown_file(markdown_path)
48
+ st.markdown(markdown_content, unsafe_allow_html=True)