Update app.py
Browse files
app.py
CHANGED
@@ -212,7 +212,9 @@ def read_project_files(project_path):
|
|
212 |
file_paths = []
|
213 |
for root, _, files in os.walk(project_path):
|
214 |
for file in files:
|
215 |
-
|
|
|
|
|
216 |
return file_paths
|
217 |
|
218 |
def read_files(file_paths):
|
@@ -261,13 +263,13 @@ def identify_required_functions(project_path, functionality_description):
|
|
261 |
|
262 |
def generate_documentation_page():
|
263 |
st.subheader(f"Generate Documentation for {st.session_state.current_project}")
|
264 |
-
st.write("Enter the functionality or parts of the project for which you'd like to
|
265 |
|
266 |
# Prompt user for functionality description
|
267 |
-
functionality = st.text_area("Describe the functionality
|
268 |
|
269 |
-
# Button to start
|
270 |
-
if st.button("
|
271 |
if functionality.strip():
|
272 |
st.write("Analyzing project files... Please wait.")
|
273 |
|
@@ -275,15 +277,24 @@ def generate_documentation_page():
|
|
275 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
276 |
project_folder = os.path.join(user_folder, st.session_state.current_project)
|
277 |
|
278 |
-
#
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
else:
|
286 |
-
st.error("Please enter the functionality to
|
287 |
|
288 |
# Button to navigate back to the project page
|
289 |
if st.button("Back to Project"):
|
@@ -291,6 +302,7 @@ def generate_documentation_page():
|
|
291 |
st.rerun()
|
292 |
|
293 |
|
|
|
294 |
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
295 |
|
296 |
|
|
|
212 |
file_paths = []
|
213 |
for root, _, files in os.walk(project_path):
|
214 |
for file in files:
|
215 |
+
# Skip .git files or folders from GitHub clones
|
216 |
+
if ".git" not in root:
|
217 |
+
file_paths.append(os.path.join(root, file))
|
218 |
return file_paths
|
219 |
|
220 |
def read_files(file_paths):
|
|
|
263 |
|
264 |
def generate_documentation_page():
|
265 |
st.subheader(f"Generate Documentation for {st.session_state.current_project}")
|
266 |
+
st.write("Enter the functionality or parts of the project for which you'd like to identify relevant functions.")
|
267 |
|
268 |
# Prompt user for functionality description
|
269 |
+
functionality = st.text_area("Describe the functionality", placeholder="e.g., Explain the function of the file `main.py`")
|
270 |
|
271 |
+
# Button to start analyzing functionality
|
272 |
+
if st.button("Analyze"):
|
273 |
if functionality.strip():
|
274 |
st.write("Analyzing project files... Please wait.")
|
275 |
|
|
|
277 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
278 |
project_folder = os.path.join(user_folder, st.session_state.current_project)
|
279 |
|
280 |
+
# Ensure compatibility with GitHub repositories
|
281 |
+
if os.path.exists(project_folder):
|
282 |
+
try:
|
283 |
+
# Call the function to identify relevant functions
|
284 |
+
result = identify_required_functions(project_folder, functionality)
|
285 |
+
|
286 |
+
# Check if Gemini returned an error message
|
287 |
+
if "No relevant functions found" in result:
|
288 |
+
st.error("No relevant functions were found for the specified functionality. Please refine your input.")
|
289 |
+
else:
|
290 |
+
st.success("Relevant functions identified successfully!")
|
291 |
+
st.text_area("Relevant Functions", result, height=400)
|
292 |
+
except Exception as e:
|
293 |
+
st.error(f"An error occurred: {e}")
|
294 |
+
else:
|
295 |
+
st.error("Project folder not found. Ensure the GitHub repository was cloned successfully.")
|
296 |
else:
|
297 |
+
st.error("Please enter the functionality to analyze.")
|
298 |
|
299 |
# Button to navigate back to the project page
|
300 |
if st.button("Back to Project"):
|
|
|
302 |
st.rerun()
|
303 |
|
304 |
|
305 |
+
|
306 |
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
307 |
|
308 |
|