User: rednesto Date: 12 Aug 24 18:12 Revision: 0b8b8e4177bac877853ca3539813c713d742417a Summary: Generated proper doc mods.toml doc in completion TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9601&personal=false Index: src/main/kotlin/toml/platform/forge/ModsTomlDocumentationProvider.kt =================================================================== --- src/main/kotlin/toml/platform/forge/ModsTomlDocumentationProvider.kt (revision bf660ea493e5138d25d1fb7b05029231ec66e7a5) +++ src/main/kotlin/toml/platform/forge/ModsTomlDocumentationProvider.kt (revision 0b8b8e4177bac877853ca3539813c713d742417a) @@ -65,8 +65,8 @@ return null } - val description = entry.description.joinToString("\n") - return if (description.isNotBlank()) { + val description = entry.description.filter { it.isNotBlank() } + return if (description.isNotEmpty()) { TomlSchemaKeyElement(entry.key, description, psiManager) } else { null @@ -75,7 +75,7 @@ override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? { if (element is TomlSchemaKeyElement) { - return element.description + return generateDoc(element.description) } if (element !is TomlKeySegment || !isModsToml(originalElement)) { @@ -85,7 +85,7 @@ val key = element.parentOfType() ?: return null val schema = ModsTomlSchema.get(element.project) val table = element.parentOfType() - val description = when (val parent = key.parent) { + val lines = when (val parent = key.parent) { is TomlTableHeader -> { if (element != parent.key?.segments?.firstOrNull()) { return null @@ -102,15 +102,18 @@ } else -> null }?.takeUnless { it.isEmpty() } ?: return null - return DocumentationMarkup.CONTENT_START + description.joinToString("
") + DocumentationMarkup.CONTENT_END + return generateDoc(lines) } + private fun generateDoc(lines: List): String = + DocumentationMarkup.CONTENT_START + lines.joinToString("
") + DocumentationMarkup.CONTENT_END + private fun isModsToml(element: PsiElement?): Boolean = element?.containingFile?.virtualFile?.name in ForgeTomlConstants.FILE_NAMES private class TomlSchemaKeyElement( val key: String, - val description: String, + val description: List, val psiManager: PsiManager ) : FakePsiElement() {