Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ import requests
|
|
11 |
from fpdf import FPDF
|
12 |
import markdown
|
13 |
import tempfile
|
|
|
14 |
|
15 |
|
16 |
# Database setup
|
@@ -422,6 +423,7 @@ def process_gemini_output(output):
|
|
422 |
|
423 |
return "\n".join(processed_lines)
|
424 |
|
|
|
425 |
def generate_documentation_page():
|
426 |
# Sidebar with "Log Out" and "Back to Project" buttons
|
427 |
st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
|
@@ -461,6 +463,20 @@ def generate_documentation_page():
|
|
461 |
# Read file contents
|
462 |
file_contents = read_files(file_paths)
|
463 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
# Generate documentation using Gemini
|
465 |
documentation = generate_detailed_documentation(file_contents, functionality)
|
466 |
|
@@ -534,32 +550,6 @@ def generate_documentation_page():
|
|
534 |
st.write("Click 'Generate Markdown File' to be able to download and store the documentation as a markdown file")
|
535 |
|
536 |
|
537 |
-
# Helper function to generate PDF
|
538 |
-
def generate_pdf(documentation, pdf_path):
|
539 |
-
pdf = FPDF()
|
540 |
-
pdf.set_auto_page_break(auto=True, margin=15)
|
541 |
-
pdf.add_page()
|
542 |
-
pdf.set_font("Courier", size=12) # Maintain the IDE-like font style
|
543 |
-
|
544 |
-
# Add headers and content
|
545 |
-
for line in documentation.splitlines():
|
546 |
-
try:
|
547 |
-
if line.startswith("- '") or line.startswith("File:"):
|
548 |
-
pdf.set_font("Courier", style="B", size=12) # Bold for specific lines
|
549 |
-
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
550 |
-
elif line.startswith("Project Summary:") or line.startswith("Functionality Summary:") or \
|
551 |
-
line.startswith("Functionality Flow:") or line.startswith("Function Documentation:"):
|
552 |
-
pdf.set_font("Courier", style="B", size=14) # Bold larger headers
|
553 |
-
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
554 |
-
else:
|
555 |
-
pdf.set_font("Courier", size=12) # Regular for other lines
|
556 |
-
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
557 |
-
except UnicodeEncodeError as e:
|
558 |
-
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
559 |
-
|
560 |
-
# Save the PDF
|
561 |
-
pdf.output(pdf_path)
|
562 |
-
|
563 |
|
564 |
|
565 |
|
|
|
11 |
from fpdf import FPDF
|
12 |
import markdown
|
13 |
import tempfile
|
14 |
+
import time
|
15 |
|
16 |
|
17 |
# Database setup
|
|
|
423 |
|
424 |
return "\n".join(processed_lines)
|
425 |
|
426 |
+
|
427 |
def generate_documentation_page():
|
428 |
# Sidebar with "Log Out" and "Back to Project" buttons
|
429 |
st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
|
|
|
463 |
# Read file contents
|
464 |
file_contents = read_files(file_paths)
|
465 |
|
466 |
+
# Calculate the total lines of code
|
467 |
+
total_lines = sum(content.count("\n") for content in file_contents.values())
|
468 |
+
|
469 |
+
# Estimate time remaining
|
470 |
+
lines_per_minute = 2500
|
471 |
+
estimated_time = total_lines / lines_per_minute
|
472 |
+
st.info(f"Estimated time remaining: {int(estimated_time)} minute(s)")
|
473 |
+
|
474 |
+
# Simulate real-time progress (optional for UX)
|
475 |
+
progress_bar = st.progress(0)
|
476 |
+
for i in range(int(estimated_time * 10)): # Simulate 10 steps per minute
|
477 |
+
time.sleep(6) # Update every 6 seconds
|
478 |
+
progress_bar.progress((i + 1) / (estimated_time * 10))
|
479 |
+
|
480 |
# Generate documentation using Gemini
|
481 |
documentation = generate_detailed_documentation(file_contents, functionality)
|
482 |
|
|
|
550 |
st.write("Click 'Generate Markdown File' to be able to download and store the documentation as a markdown file")
|
551 |
|
552 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
|
554 |
|
555 |
|