diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c0f163..5f7aa32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ### Added +- **Rakefile support (no extension)** — all annotators, actions, and intention actions now accept + a file named `Rakefile` (without `.rb` or `.rake` extension) in addition to `.rb` and `.rake` + files. This ensures the plugin works on standard Rakefiles that have no file extension. - **Graceful handling when docscribe gem not installed** — `DocscribeDaemon` now runs `bundle exec docscribe --version` once on first use and caches the result. If the gem is missing, a user-friendly notification (with "Open Gemfile" action) is shown once, and all operations return a diff --git a/src/main/kotlin/com/florexlabs/docscribe/actions/AggressiveFixAction.kt b/src/main/kotlin/com/florexlabs/docscribe/actions/AggressiveFixAction.kt index 5930ccd..d8a0f2c 100644 --- a/src/main/kotlin/com/florexlabs/docscribe/actions/AggressiveFixAction.kt +++ b/src/main/kotlin/com/florexlabs/docscribe/actions/AggressiveFixAction.kt @@ -72,7 +72,8 @@ class AggressiveFixAction : AnAction() { */ override fun update(e: AnActionEvent) { val file = e.getData(CommonDataKeys.VIRTUAL_FILE) - e.presentation.isEnabledAndVisible = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake")) + e.presentation.isEnabledAndVisible = + file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake") || file.name == "Rakefile") } /** diff --git a/src/main/kotlin/com/florexlabs/docscribe/actions/CheckFileAction.kt b/src/main/kotlin/com/florexlabs/docscribe/actions/CheckFileAction.kt index 1b1c1ac..a412396 100644 --- a/src/main/kotlin/com/florexlabs/docscribe/actions/CheckFileAction.kt +++ b/src/main/kotlin/com/florexlabs/docscribe/actions/CheckFileAction.kt @@ -70,7 +70,8 @@ class CheckFileAction : AnAction() { */ override fun update(e: AnActionEvent) { val file = e.getData(CommonDataKeys.VIRTUAL_FILE) - e.presentation.isEnabledAndVisible = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake")) + e.presentation.isEnabledAndVisible = + file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake") || file.name == "Rakefile") } /** diff --git a/src/main/kotlin/com/florexlabs/docscribe/actions/SafeFixAction.kt b/src/main/kotlin/com/florexlabs/docscribe/actions/SafeFixAction.kt index 5801ee0..090476d 100644 --- a/src/main/kotlin/com/florexlabs/docscribe/actions/SafeFixAction.kt +++ b/src/main/kotlin/com/florexlabs/docscribe/actions/SafeFixAction.kt @@ -70,7 +70,8 @@ class SafeFixAction : AnAction() { */ override fun update(e: AnActionEvent) { val file = e.getData(CommonDataKeys.VIRTUAL_FILE) - e.presentation.isEnabledAndVisible = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake")) + e.presentation.isEnabledAndVisible = + file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake") || file.name == "Rakefile") } /** diff --git a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAggressiveFixIntention.kt b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAggressiveFixIntention.kt index 352f8e5..d823b3c 100644 --- a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAggressiveFixIntention.kt +++ b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAggressiveFixIntention.kt @@ -38,7 +38,7 @@ class DocscribeAggressiveFixIntention : IntentionAction { project: Project, editor: Editor?, file: PsiFile?, - ): Boolean = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake")) + ): Boolean = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake") || file.name == "Rakefile") /** * Run docscribe aggressive fix in a background task, then refresh the file on success. diff --git a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotator.kt b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotator.kt index e02c729..66ee0f8 100644 --- a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotator.kt +++ b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotator.kt @@ -59,7 +59,7 @@ class DocscribeAnnotator : ExternalAnnotator editor: Editor, hasErrors: Boolean, ): AnnotatorFileInfo? { - if (!file.name.endsWith(".rb") && !file.name.endsWith(".rake")) return null + if (!file.name.endsWith(".rb") && !file.name.endsWith(".rake") && file.name != "Rakefile") return null val vFile = file.virtualFile ?: return null val projectDir = file.project.basePath ?: return null @@ -86,7 +86,7 @@ class DocscribeAnnotator : ExternalAnnotator * @return [AnnotatorFileInfo] if the file should be checked, or `null` to skip. */ override fun collectInformation(file: PsiFile): AnnotatorFileInfo? { - if (!file.name.endsWith(".rb") && !file.name.endsWith(".rake")) return null + if (!file.name.endsWith(".rb") && !file.name.endsWith(".rake") && file.name != "Rakefile") return null val vFile = file.virtualFile ?: return null val projectDir = file.project.basePath ?: return null diff --git a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeCheckIntention.kt b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeCheckIntention.kt index a7945d1..6d9324f 100644 --- a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeCheckIntention.kt +++ b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeCheckIntention.kt @@ -40,7 +40,7 @@ class DocscribeCheckIntention : IntentionAction { project: Project, editor: Editor?, file: PsiFile?, - ): Boolean = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake")) + ): Boolean = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake") || file.name == "Rakefile") /** * Run docscribe check in a background task and show a notification on completion. diff --git a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeFixIntention.kt b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeFixIntention.kt index 489a515..5586b58 100644 --- a/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeFixIntention.kt +++ b/src/main/kotlin/com/florexlabs/docscribe/annotator/DocscribeFixIntention.kt @@ -37,7 +37,7 @@ class DocscribeFixIntention : IntentionAction { project: Project, editor: Editor?, file: PsiFile?, - ): Boolean = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake")) + ): Boolean = file != null && (file.name.endsWith(".rb") || file.name.endsWith(".rake") || file.name == "Rakefile") /** * Save the editor, find the project root, and run docscribe safe fix in a background task. diff --git a/src/test/kotlin/com/florexlabs/docscribe/actions/AggressiveFixActionTest.kt b/src/test/kotlin/com/florexlabs/docscribe/actions/AggressiveFixActionTest.kt index be1ebeb..8559ae4 100644 --- a/src/test/kotlin/com/florexlabs/docscribe/actions/AggressiveFixActionTest.kt +++ b/src/test/kotlin/com/florexlabs/docscribe/actions/AggressiveFixActionTest.kt @@ -25,6 +25,20 @@ class AggressiveFixActionTest : BasePlatformTestCase() { assertTrue(presentation.isEnabledAndVisible) } + fun testAggressiveFixActionIsEnabledForRakefile() { + val file = myFixture.configureByText("Rakefile", "task :test do\nend").virtualFile + val dataContext = + SimpleDataContext + .builder() + .add(CommonDataKeys.VIRTUAL_FILE, file) + .add(CommonDataKeys.PROJECT, myFixture.project) + .build() + val presentation = Presentation() + val event = AnActionEvent.createEvent(dataContext, presentation, "test", ActionUiKind.NONE, null) + action.update(event) + assertTrue(presentation.isEnabledAndVisible) + } + fun testAggressiveFixActionIsDisabledForNonRubyFile() { val file = myFixture.configureByText("foo.txt", "plain text").virtualFile val dataContext = diff --git a/src/test/kotlin/com/florexlabs/docscribe/actions/CheckFileActionTest.kt b/src/test/kotlin/com/florexlabs/docscribe/actions/CheckFileActionTest.kt index 768511e..2f0f449 100644 --- a/src/test/kotlin/com/florexlabs/docscribe/actions/CheckFileActionTest.kt +++ b/src/test/kotlin/com/florexlabs/docscribe/actions/CheckFileActionTest.kt @@ -25,6 +25,20 @@ class CheckFileActionTest : BasePlatformTestCase() { assertTrue(presentation.isEnabledAndVisible) } + fun testActionIsEnabledForRakefile() { + val file = myFixture.configureByText("Rakefile", "task :test do\nend").virtualFile + val dataContext = + SimpleDataContext + .builder() + .add(CommonDataKeys.VIRTUAL_FILE, file) + .add(CommonDataKeys.PROJECT, myFixture.project) + .build() + val presentation = Presentation() + val event = AnActionEvent.createEvent(dataContext, presentation, "test", ActionUiKind.NONE, null) + action.update(event) + assertTrue(presentation.isEnabledAndVisible) + } + fun testActionIsDisabledForNonRubyFile() { val file = myFixture.configureByText("foo.txt", "plain text").virtualFile val dataContext = diff --git a/src/test/kotlin/com/florexlabs/docscribe/actions/SafeFixActionTest.kt b/src/test/kotlin/com/florexlabs/docscribe/actions/SafeFixActionTest.kt index cce5b51..b55e398 100644 --- a/src/test/kotlin/com/florexlabs/docscribe/actions/SafeFixActionTest.kt +++ b/src/test/kotlin/com/florexlabs/docscribe/actions/SafeFixActionTest.kt @@ -25,6 +25,20 @@ class SafeFixActionTest : BasePlatformTestCase() { assertTrue(presentation.isEnabledAndVisible) } + fun testSafeFixActionIsEnabledForRakefile() { + val file = myFixture.configureByText("Rakefile", "task :test do\nend").virtualFile + val dataContext = + SimpleDataContext + .builder() + .add(CommonDataKeys.VIRTUAL_FILE, file) + .add(CommonDataKeys.PROJECT, myFixture.project) + .build() + val presentation = Presentation() + val event = AnActionEvent.createEvent(dataContext, presentation, "test", ActionUiKind.NONE, null) + action.update(event) + assertTrue(presentation.isEnabledAndVisible) + } + fun testSafeFixActionIsDisabledForNonRubyFile() { val file = myFixture.configureByText("foo.txt", "plain text").virtualFile val dataContext = diff --git a/src/test/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotatorTest.kt b/src/test/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotatorTest.kt index 17b30a1..d774da5 100644 --- a/src/test/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotatorTest.kt +++ b/src/test/kotlin/com/florexlabs/docscribe/annotator/DocscribeAnnotatorTest.kt @@ -23,6 +23,12 @@ class DocscribeAnnotatorTest : BasePlatformTestCase() { assertNotNull(info) } + fun testAnnotatorReturnsInfoForPlainRakefile() { + val file = myFixture.configureByText("Rakefile", "task :test do\nend") + val info = DocscribeAnnotator().collectInformation(file) + assertNotNull(info) + } + fun testNoEditorOverloadReturnsInfo() { val file = myFixture.configureByText("test.rb", "class Foo\nend") val info = DocscribeAnnotator().collectInformation(file)