Add Update Documentation context menu option
Adds AI-powered documentation update feature using CmdForge update-docs tool. Right-click a project and select "Update Documentation..." to: - Analyze project code and current docs - Generate updated overview.md via AI - Optionally deploy to Gitea Pages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1fd92e19c9
commit
8575c30c76
|
|
@ -119,6 +119,11 @@ class ProjectListWidget(QWidget):
|
|||
|
||||
menu.addSeparator()
|
||||
|
||||
# Update Documentation (AI-powered)
|
||||
update_docs = QAction("Update Documentation...", self)
|
||||
update_docs.triggered.connect(lambda: self._update_docs(project))
|
||||
menu.addAction(update_docs)
|
||||
|
||||
# Deploy Docs
|
||||
deploy_docs = QAction("Deploy Docs", self)
|
||||
deploy_docs.triggered.connect(lambda: self._deploy_docs(project))
|
||||
|
|
@ -166,3 +171,72 @@ class ProjectListWidget(QWidget):
|
|||
f"This runs in the background. Check Gitea Pages\n"
|
||||
f"in a minute to verify the deployment."
|
||||
)
|
||||
|
||||
def _update_docs(self, project: Project):
|
||||
"""Update documentation using CmdForge update-docs tool."""
|
||||
from PyQt6.QtWidgets import QMessageBox
|
||||
|
||||
# Ask if user wants to deploy after updating
|
||||
reply = QMessageBox.question(
|
||||
self,
|
||||
"Update Documentation",
|
||||
f"This will use AI to analyze {project.title} and update its documentation.\n\n"
|
||||
f"The update-docs tool will:\n"
|
||||
f"1. Read the project's code and current docs\n"
|
||||
f"2. Generate updated overview.md\n"
|
||||
f"3. Optionally deploy to Gitea Pages\n\n"
|
||||
f"Deploy after updating?",
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No | QMessageBox.StandardButton.Cancel,
|
||||
QMessageBox.StandardButton.Yes
|
||||
)
|
||||
|
||||
if reply == QMessageBox.StandardButton.Cancel:
|
||||
return
|
||||
|
||||
deploy_flag = "true" if reply == QMessageBox.StandardButton.Yes else "false"
|
||||
|
||||
# Run the update-docs CmdForge tool
|
||||
# The tool expects input on stdin (can be empty) and --project argument
|
||||
cmd = [
|
||||
"python3", "-m", "cmdforge.runner", "update-docs",
|
||||
"--project", project.key,
|
||||
"--deploy", deploy_flag
|
||||
]
|
||||
|
||||
try:
|
||||
# Run with empty stdin, capture output
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
input="",
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=120 # 2 minute timeout for AI processing
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
QMessageBox.information(
|
||||
self,
|
||||
"Documentation Updated",
|
||||
f"Documentation for {project.title} has been updated.\n\n"
|
||||
f"{result.stdout}"
|
||||
)
|
||||
else:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
"Update Failed",
|
||||
f"Failed to update documentation:\n\n{result.stderr or result.stdout}"
|
||||
)
|
||||
except subprocess.TimeoutExpired:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
"Update Timeout",
|
||||
"Documentation update timed out. Try running manually:\n\n"
|
||||
f"update-docs --project {project.key}"
|
||||
)
|
||||
except FileNotFoundError:
|
||||
QMessageBox.warning(
|
||||
self,
|
||||
"Tool Not Found",
|
||||
"CmdForge update-docs tool not found.\n\n"
|
||||
"Make sure CmdForge is installed and the update-docs tool exists."
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue