JSenkCC commited on
Commit
7c3b325
·
verified ·
1 Parent(s): 9f0b379

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -425,6 +425,10 @@ def generate_documentation_page():
425
  st.subheader(f"Generate Documentation for {st.session_state.current_project}")
426
  st.write("Enter the functionality or parts of the project for which you'd like to generate documentation.")
427
 
 
 
 
 
428
  # Prompt user for functionality description
429
  functionality = st.text_area(
430
  "Describe the functionality",
@@ -436,10 +440,6 @@ def generate_documentation_page():
436
  if functionality.strip():
437
  st.write("Analyzing project files... Please wait.")
438
 
439
- # Get the path of the current project
440
- user_folder = os.path.join("user_projects", st.session_state.username)
441
- project_folder = os.path.join(user_folder, st.session_state.current_project)
442
-
443
  if os.path.exists(project_folder):
444
  try:
445
  # Gather all file paths in the project directory
@@ -492,18 +492,26 @@ def generate_documentation_page():
492
  st.download_button(
493
  label="Download PDF",
494
  data=open(pdf_file.name, "rb").read(),
495
- file_name="documentation.pdf",
496
  mime="application/pdf",
497
  )
498
  os.unlink(pdf_file.name)
499
 
500
  # Button to generate Markdown file
501
  if st.button("Generate Markdown File"):
502
- markdown_file_path = os.path.join(user_folder, f"{st.session_state.current_project}_documentation.md")
503
  with open(markdown_file_path, "w") as md_file:
504
  md_file.write(f"# Documentation for {st.session_state.current_project}\n\n")
505
  md_file.write(documentation)
506
- st.success(f"Markdown file generated at: {markdown_file_path}")
 
 
 
 
 
 
 
 
507
 
508
  # Helper function to generate PDF
509
  def generate_pdf(documentation):
 
425
  st.subheader(f"Generate Documentation for {st.session_state.current_project}")
426
  st.write("Enter the functionality or parts of the project for which you'd like to generate documentation.")
427
 
428
+ # Get the path of the current project
429
+ user_folder = os.path.join("user_projects", st.session_state.username)
430
+ project_folder = os.path.join(user_folder, st.session_state.current_project)
431
+
432
  # Prompt user for functionality description
433
  functionality = st.text_area(
434
  "Describe the functionality",
 
440
  if functionality.strip():
441
  st.write("Analyzing project files... Please wait.")
442
 
 
 
 
 
443
  if os.path.exists(project_folder):
444
  try:
445
  # Gather all file paths in the project directory
 
492
  st.download_button(
493
  label="Download PDF",
494
  data=open(pdf_file.name, "rb").read(),
495
+ file_name=f"{st.session_state.current_project} Documentation.pdf",
496
  mime="application/pdf",
497
  )
498
  os.unlink(pdf_file.name)
499
 
500
  # Button to generate Markdown file
501
  if st.button("Generate Markdown File"):
502
+ markdown_file_path = os.path.join(user_folder, f"{st.session_state.current_project} Documentation.md")
503
  with open(markdown_file_path, "w") as md_file:
504
  md_file.write(f"# Documentation for {st.session_state.current_project}\n\n")
505
  md_file.write(documentation)
506
+
507
+ # Save and allow download of the Markdown file
508
+ with open(markdown_file_path, "rb") as md_file:
509
+ st.download_button(
510
+ label="Download Markdown File",
511
+ data=md_file.read(),
512
+ file_name=f"{st.session_state.current_project} Documentation.md",
513
+ mime="text/markdown",
514
+ )
515
 
516
  # Helper function to generate PDF
517
  def generate_pdf(documentation):