Skip to content

Commit 603a4c2

Browse files
committed
feat(living-docs): add parameter and return tag instructions
Add parameter and return tag instructions to LivingDocumentation classes for Kotlin and Java providers. This commit updates the Kotlin and Java LivingDocumentation classes to include instructions for using @param and @return tags. The instructions are now accessible through the parameterTagInstruction and returnTagInstruction properties.
1 parent 2860c85 commit 603a4c2

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

java/src/main/kotlin/cc/unitmesh/idea/provider/JavaLivingDocumentation.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import com.intellij.psi.util.PsiTreeUtil
1212
import com.intellij.util.IncorrectOperationException
1313

1414
class JavaLivingDocumentation : LivingDocumentation {
15+
override val parameterTagInstruction: String get() = "use @param tag"
16+
override val returnTagInstruction: String get() = "use @return tag"
17+
1518
override val forbiddenRules: List<String> = listOf(
1619
"do not return example code",
1720
"do not use @author and @version tags"

kotlin/src/main/kotlin/cc/unitmesh/kotlin/provider/KotlinLivingDocumentation.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ import org.jetbrains.kotlin.psi.KtNamedFunction
5353
* @see LivingDocumentationType
5454
*/
5555
class KotlinLivingDocumentation : LivingDocumentation {
56+
override val parameterTagInstruction: String get() = "use @param tag"
57+
override val returnTagInstruction: String get() = "use @return tag"
58+
5659
companion object {
5760
private val logger = logger<KotlinLivingDocumentation>()
5861
}

src/main/kotlin/cc/unitmesh/devti/intentions/action/task/LivingDocPromptBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ open class LivingDocPromptBuilder(
7474
if (context.paramNames.isNotEmpty()) {
7575
instruction = """
7676
$instruction
77-
${documentation.parameterTagInstruction}
77+
${documentation.parameterTagInstruction ?: ""}
7878
""".trimIndent()
7979
}
8080

8181
val returnType = context.returnType
8282
if (!returnType.isNullOrEmpty()) {
8383
instruction = """
8484
$instruction
85-
${documentation.returnTagInstruction}
85+
${documentation.returnTagInstruction ?: ""}
8686
""".trimIndent()
8787
}
8888

src/main/kotlin/cc/unitmesh/devti/provider/LivingDocumentation.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import com.intellij.psi.PsiNameIdentifierOwner
1717
interface LivingDocumentation {
1818
val forbiddenRules: List<String>
1919

20-
val parameterTagInstruction: String get() = "use @param tag"
21-
val returnTagInstruction: String get() = "use @return tag"
20+
val parameterTagInstruction: String? get() = null
21+
val returnTagInstruction: String? get() = null
2222

2323
fun startEndString(type: LivingDocumentationType): Pair<String, String>
2424

0 commit comments

Comments
 (0)