From 8575c30c7660b72d0f211b603d22acc5acb1f8d7 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 6 Jan 2026 03:18:19 -0400 Subject: [PATCH] Add Update Documentation context menu option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/development_hub/project_list.py | 74 +++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/development_hub/project_list.py b/src/development_hub/project_list.py index 3efec5c..ce5a9f3 100644 --- a/src/development_hub/project_list.py +++ b/src/development_hub/project_list.py @@ -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." + )