diff --git a/docs/file_metadata.template.md b/docs/file_metadata.template.md index 313ba953..46e13d23 100644 --- a/docs/file_metadata.template.md +++ b/docs/file_metadata.template.md @@ -1,11 +1,9 @@ # File Metadata Template -## File Information - **Filename:** -- **Path:** ## Code Overview -- **Language:** +- **Language & Frameworks:** - **Primary Purpose:** - **Brief Description:** @@ -14,21 +12,26 @@ - **Public Constants/Variables:** - **Types/Interfaces (if applicable):** -## Example Usage - ## Dependencies - **External Libraries** - **Internal Code: Symbol References** +## Architecture +- **Sequence or Flow Diagrams:** Using Mermaid syntax, include sequence or flow diagram(s) to illustrate important or complex logic. (if applicable) +- **Class Diagrams:** If applicable, describe (do not create) class diagrams needed to illustrate the context of the code + +## Example Usage + ## Code Analysis -- **Complexity (if measurable):** - **Code Style Observations:** +- **Code Review Feedback:** - **Potential Improvements:** ## Features - **Key Functionalities:** - **Algorithms Used:** - **Data Structures:** +- **Potential Improvements:** ## Tags - **Categories:** diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/GenerateDocumentationAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/GenerateDocumentationAction.kt index ea07ab14..3dd183fb 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/GenerateDocumentationAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/generic/GenerateDocumentationAction.kt @@ -1,6 +1,9 @@ package com.github.simiacryptus.aicoder.actions.generic import com.github.simiacryptus.aicoder.actions.FileContextAction +import com.github.simiacryptus.aicoder.actions.test.TestResultAutofixAction +import com.github.simiacryptus.aicoder.actions.test.TestResultAutofixAction.Companion +import com.github.simiacryptus.aicoder.actions.test.TestResultAutofixAction.Companion.findGitRoot import com.github.simiacryptus.aicoder.actions.test.TestResultAutofixAction.Companion.getProjectStructure import com.github.simiacryptus.aicoder.config.AppSettingsState import com.github.simiacryptus.aicoder.config.AppSettingsState.Companion.chatModel @@ -52,13 +55,17 @@ class GenerateDocumentationAction : FileContextAction = listOf(), - var singleOutputFile: Boolean = true + var singleOutputFile: Boolean = true, + var outputDirectory: String = "docs/" ) class Settings( @@ -78,11 +85,13 @@ class GenerateDocumentationAction : FileContextAction filesToProcess.setItemSelected(path, true) } + outputDirectory.text = "docs/" } val dialog = DocumentationCompilerDialog(project, settingsUI) dialog.show() val settings: UserSettings = dialog.userSettings settings.singleOutputFile = settingsUI.singleOutputFile.isSelected + settings.outputDirectory = settingsUI.outputDirectory.text val result = dialog.isOK settings.filesToProcess = when { result -> files.filter { path -> settingsUI.filesToProcess.isItemSelected(path) }.toList() @@ -93,15 +102,19 @@ class GenerateDocumentationAction : FileContextAction { - val root = state.selectedFile.toPath() - var outputPath = root.resolve(config?.settings?.outputFilename ?: "compiled_documentation.md") + val selectedFolder = state.selectedFile.toPath() + val gitRoot = TestResultAutofixAction.findGitRoot(selectedFolder) ?: selectedFolder + val outputDirectory = config?.settings?.outputDirectory ?: "docs/" + var outputPath = + selectedFolder.resolve(config?.settings?.outputFilename ?: "compiled_documentation.md") + outputPath = gitRoot.resolve(outputDirectory).resolve(gitRoot.relativize(outputPath)) if (outputPath.toFile().exists()) { val extension = outputPath.toString().split(".").last() val name = outputPath.toString().split(".").dropLast(1).joinToString(".") val fileIndex = (1..Int.MAX_VALUE).find { - !root.resolve("$name.$it.$extension").toFile().exists() + !selectedFolder.resolve("$name.$it.$extension").toFile().exists() } - outputPath = root.resolve("$name.$fileIndex.$extension") + outputPath = selectedFolder.resolve("$name.$fileIndex.$extension") } val executorService = Executors.newFixedThreadPool(4) outputPath.parent.toFile().mkdirs() @@ -109,7 +122,7 @@ class GenerateDocumentationAction : FileContextAction