Skip to content

Commit 8bd3bce

Browse files
committed
feat(devins-lang): add markdown support for built-in command examples
1 parent ebacccd commit 8bd3bce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/documentation/DevInsDocumentationProvider.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import cc.unitmesh.devti.agent.model.CustomAgentConfig
44
import cc.unitmesh.devti.custom.compile.CustomVariable
55
import cc.unitmesh.devti.language.completion.dataprovider.BuiltinCommand
66
import cc.unitmesh.devti.language.psi.DevInTypes
7+
import cc.unitmesh.devti.util.parser.convertMarkdownToHtml
78
import com.intellij.lang.documentation.AbstractDocumentationProvider
89
import com.intellij.openapi.editor.Editor
910
import com.intellij.psi.PsiElement
1011
import com.intellij.psi.PsiFile
1112
import com.intellij.psi.util.elementType
13+
import org.intellij.markdown.parser.MarkdownParser
1214

1315
class DevInsDocumentationProvider : AbstractDocumentationProvider() {
1416
override fun generateDoc(element: PsiElement?, originalElement: PsiElement?): String? {
1517
val project = element?.project ?: return null
16-
return when (element.elementType) {
18+
val markdownDoc = when (element.elementType) {
1719
DevInTypes.AGENT_ID -> {
1820
val agentConfigs = CustomAgentConfig.loadFromProject(project).filter {
1921
it.name == element.text
@@ -26,7 +28,7 @@ class DevInsDocumentationProvider : AbstractDocumentationProvider() {
2628
DevInTypes.COMMAND_ID -> {
2729
val command = BuiltinCommand.all().find { it.commandName == element.text } ?: return null
2830
val example = BuiltinCommand.example(command)
29-
"${command.description}\n\nExample:\n```devin\n$example\n```\n"
31+
"${command.description}\nExample:\n```devin\n$example\n```\n "
3032
}
3133

3234
DevInTypes.VARIABLE_ID -> {
@@ -37,6 +39,8 @@ class DevInsDocumentationProvider : AbstractDocumentationProvider() {
3739
element.text
3840
}
3941
}
42+
43+
return convertMarkdownToHtml(markdownDoc ?: "")
4044
}
4145

4246
override fun getCustomDocumentationElement(

0 commit comments

Comments
 (0)