JSenkCC commited on
Commit
6128e66
·
verified ·
1 Parent(s): a2f6e77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -35
app.py CHANGED
@@ -591,43 +591,62 @@ def generate_markdown_file(documentation, output_path):
591
 
592
  #------------------------------------------------------------------------------------------------------------------------------------------------------------------------
593
  def view_documentation_page():
594
- st.subheader(f"View Documentation for {st.session_state.current_project}")
595
- st.write("This page displays the generated documentation for the selected project.")
596
-
597
- # Check if files are available in session state
598
- pdf_path = st.session_state.get("pdf_file_path")
599
- markdown_path = st.session_state.get("markdown_file_path")
600
-
601
- # Display PDF file if it exists
602
- if pdf_path and os.path.exists(pdf_path):
603
- st.write("### PDF Documentation")
604
- with open(pdf_path, "rb") as pdf_file:
605
- pdf_data = pdf_file.read()
606
- st.download_button(
607
- label="Download PDF",
608
- data=pdf_data,
609
- file_name=os.path.basename(pdf_path),
610
- mime="application/pdf",
611
- )
612
- st.write("View PDF Documentation below:")
613
- st.pdf_viewer(pdf_path)
614
-
615
- # Display Markdown file if it exists
616
- if markdown_path and os.path.exists(markdown_path):
617
- st.write("### Markdown Documentation")
618
- with open(markdown_path, "r") as md_file:
619
- markdown_content = md_file.read()
620
- st.download_button(
621
- label="Download Markdown",
622
- data=markdown_content,
623
- file_name=os.path.basename(markdown_path),
624
- mime="text/markdown",
625
- )
626
- st.markdown(f"```\n{markdown_content}\n```", unsafe_allow_html=True)
627
-
628
- if st.button("Back to Project"):
629
  st.session_state.page = "project_view"
630
  st.rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
 
632
 
633
 
 
591
 
592
  #------------------------------------------------------------------------------------------------------------------------------------------------------------------------
593
  def view_documentation_page():
594
+ # Sidebar with "Back to Project" and "Log Out" buttons
595
+ st.sidebar.title(f"Project: {st.session_state.current_project}")
596
+ if st.sidebar.button("Back to Project"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  st.session_state.page = "project_view"
598
  st.rerun()
599
+ if st.sidebar.button("Log Out"):
600
+ st.session_state.authenticated = False
601
+ st.session_state.username = None
602
+ st.session_state.page = "login"
603
+ st.rerun()
604
+
605
+ st.subheader(f"View Documentation for {st.session_state.current_project}")
606
+ st.write("Below is a list of generated documentation for this project. Click to view or download.")
607
+
608
+ # Define paths for generated files
609
+ user_folder = os.path.join("user_projects", st.session_state.username)
610
+ pdf_path = os.path.join(user_folder, f"{st.session_state.current_project}_Documentation.pdf")
611
+ markdown_path = os.path.join(user_folder, f"{st.session_state.current_project}_Documentation.md")
612
+
613
+ # Check if files exist
614
+ pdf_exists = os.path.exists(pdf_path)
615
+ markdown_exists = os.path.exists(markdown_path)
616
+
617
+ # Display available documentation
618
+ if not pdf_exists and not markdown_exists:
619
+ st.info("No documentation has been generated yet. Please go to the 'Generate Documentation' page.")
620
+ else:
621
+ if pdf_exists:
622
+ with open(pdf_path, "rb") as pdf_file:
623
+ if st.button("View PDF Documentation"):
624
+ st.subheader("PDF Documentation")
625
+ st.write("The generated PDF documentation is displayed below:")
626
+ st.download_button(
627
+ label="Download PDF",
628
+ data=pdf_file.read(),
629
+ file_name=f"{st.session_state.current_project}_Documentation.pdf",
630
+ mime="application/pdf",
631
+ )
632
+
633
+ if markdown_exists:
634
+ with open(markdown_path, "r") as markdown_file:
635
+ markdown_content = markdown_file.read()
636
+ if st.button("View Markdown Documentation"):
637
+ st.subheader("Markdown Documentation")
638
+ st.text_area(
639
+ "Generated Markdown Documentation",
640
+ value=markdown_content,
641
+ height=600,
642
+ disabled=True,
643
+ )
644
+ st.download_button(
645
+ label="Download Markdown",
646
+ data=markdown_content,
647
+ file_name=f"{st.session_state.current_project}_Documentation.md",
648
+ mime="text/markdown",
649
+ )
650
 
651
 
652