JSenkCC commited on
Commit
b1f0068
·
verified ·
1 Parent(s): 123141f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -7
app.py CHANGED
@@ -426,6 +426,7 @@ def process_gemini_output(output):
426
 
427
  def generate_documentation_page():
428
  import time
 
429
  # Sidebar with "Log Out" and "Back to Project" buttons
430
  st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
431
  st.sidebar.title(f"Project: {st.session_state.current_project}")
@@ -476,11 +477,13 @@ def generate_documentation_page():
476
  # Show progress bar
477
  progress_bar = st.progress(0)
478
  progress_message = st.empty()
479
- for i in range(101):
480
- time.sleep(estimated_time / 100) # Simulate the process
 
481
  progress_bar.progress(i)
482
- progress_message.write(f"Estimated time remaining: {int(estimated_time * (100 - i) / 100)} seconds")
483
- progress_message.empty()
 
484
 
485
  # Generate documentation using Gemini
486
  documentation = generate_detailed_documentation(file_contents, functionality)
@@ -489,12 +492,15 @@ def generate_documentation_page():
489
  st.session_state.generated_documentation = documentation
490
 
491
  # Display the final documentation
 
 
 
 
 
 
492
  st.success("Documentation generated successfully!")
493
  st.text_area("Generated Documentation", documentation, height=600)
494
 
495
- # Remove the progress bar once the output is ready
496
- progress_bar.empty()
497
-
498
  except Exception as e:
499
  st.error(f"An error occurred: {e}")
500
  else:
@@ -548,6 +554,31 @@ def generate_documentation_page():
548
 
549
 
550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
 
552
 
553
  # Helper function to generate Markdown file
 
426
 
427
  def generate_documentation_page():
428
  import time
429
+
430
  # Sidebar with "Log Out" and "Back to Project" buttons
431
  st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
432
  st.sidebar.title(f"Project: {st.session_state.current_project}")
 
477
  # Show progress bar
478
  progress_bar = st.progress(0)
479
  progress_message = st.empty()
480
+
481
+ for i in range(90): # Simulate the process up to 90% completion
482
+ time.sleep(estimated_time / 100)
483
  progress_bar.progress(i)
484
+ progress_message.write(
485
+ f"Estimated time remaining: {int(estimated_time * (100 - i) / 100)} seconds"
486
+ )
487
 
488
  # Generate documentation using Gemini
489
  documentation = generate_detailed_documentation(file_contents, functionality)
 
492
  st.session_state.generated_documentation = documentation
493
 
494
  # Display the final documentation
495
+ progress_bar.progress(100) # Fill the progress bar to 100%
496
+ progress_message.empty() # Clear the message
497
+
498
+ time.sleep(1) # Pause briefly for visual effect
499
+ progress_bar.empty() # Remove the progress bar completely
500
+
501
  st.success("Documentation generated successfully!")
502
  st.text_area("Generated Documentation", documentation, height=600)
503
 
 
 
 
504
  except Exception as e:
505
  st.error(f"An error occurred: {e}")
506
  else:
 
554
 
555
 
556
 
557
+ # Helper function to generate PDF
558
+ def generate_pdf(documentation, pdf_path):
559
+ pdf = FPDF()
560
+ pdf.set_auto_page_break(auto=True, margin=15)
561
+ pdf.add_page()
562
+ pdf.set_font("Courier", size=12) # Maintain the IDE-like font style
563
+
564
+ # Add headers and content
565
+ for line in documentation.splitlines():
566
+ try:
567
+ if line.startswith("- '") or line.startswith("File:"):
568
+ pdf.set_font("Courier", style="B", size=12) # Bold for specific lines
569
+ pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
570
+ elif line.startswith("Project Summary:") or line.startswith("Functionality Summary:") or \
571
+ line.startswith("Functionality Flow:") or line.startswith("Function Documentation:"):
572
+ pdf.set_font("Courier", style="B", size=14) # Bold larger headers
573
+ pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
574
+ else:
575
+ pdf.set_font("Courier", size=12) # Regular for other lines
576
+ pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
577
+ except UnicodeEncodeError as e:
578
+ pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
579
+
580
+ # Save the PDF
581
+ pdf.output(pdf_path)
582
 
583
 
584
  # Helper function to generate Markdown file