diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-03-01 11:57:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 11:57:30 +0100 |
commit | c01e49eec9558736959d12820361624a3c3e41e5 (patch) | |
tree | a88ee64c5ba5a8d4c9ff037fdfbea6a3527349fe /plugins/base/src/main/kotlin/translators | |
parent | 201a9785a04d631fae65a3af3b495962e4f16d14 (diff) | |
download | dokka-c01e49eec9558736959d12820361624a3c3e41e5.tar.gz dokka-c01e49eec9558736959d12820361624a3c3e41e5.tar.bz2 dokka-c01e49eec9558736959d12820361624a3c3e41e5.zip |
Suppress tag support (#1742)
* Suppress tag support
* Support Hide tag in javadoc
* Extract hide tag to be in separate plugin
Diffstat (limited to 'plugins/base/src/main/kotlin/translators')
3 files changed, 16 insertions, 7 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt index c2fb6fb4..21c2c72a 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/InheritDocResolver.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull internal data class CommentResolutionContext( val comment: PsiDocComment, - val tag: JavadocTag, + val tag: JavadocTag?, val name: String? = null, val parameterIndex: Int? = null, ) @@ -25,7 +25,7 @@ internal class InheritDocResolver( JavadocTag.PARAM -> context.parameterIndex?.let { paramIndex -> resolveParamTag(context.comment, paramIndex) } JavadocTag.DEPRECATED -> resolveGenericTag(context.comment, JavadocTag.DESCRIPTION) JavadocTag.SEE -> emptyList() - else -> resolveGenericTag(context.comment, context.tag) + else -> context.tag?.let { tag -> resolveGenericTag(context.comment, tag) } } private fun resolveGenericTag(currentElement: PsiDocComment, tag: JavadocTag): List<PsiElement> = diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt index 96c62b36..a02bceac 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt @@ -12,6 +12,7 @@ import org.jetbrains.dokka.analysis.from import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.model.doc.Deprecated +import org.jetbrains.dokka.model.doc.Suppress import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.dokka.utilities.enumValueOrNull import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName @@ -118,7 +119,15 @@ class JavadocParser( else -> null //TODO https://github.com/Kotlin/dokka/issues/1618 } - } + } ?: CustomTagWrapper( + wrapTagIfNecessary( + convertJavadocElements( + tag.contentElementsWithSiblingIfNeeded(), + context = CommentResolutionContext(docComment, null) + ) + ), + tag.name + ) private fun wrapTagIfNecessary(list: List<DocTag>): CustomDocTag = if (list.size == 1 && (list.first() as? CustomDocTag)?.name == MarkdownElementTypes.MARKDOWN_FILE.name) @@ -148,14 +157,14 @@ class JavadocParser( } private data class ParserState( - val currentJavadocTag: JavadocTag, + val currentJavadocTag: JavadocTag?, val previousElement: PsiElement? = null, val openPreTags: Int = 0, val closedPreTags: Int = 0 ) private data class ParsingResult(val newState: ParserState, val parsedLine: String? = null) { - constructor(tag: JavadocTag) : this(ParserState(tag)) + constructor(tag: JavadocTag?) : this(ParserState(tag)) operator fun plus(other: ParsingResult): ParsingResult = ParsingResult( @@ -267,7 +276,7 @@ class JavadocParser( private fun convertInlineDocTag( tag: PsiInlineDocTag, - javadocTag: JavadocTag, + javadocTag: JavadocTag?, context: CommentResolutionContext ) = when (tag.name) { diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt index 8ea39453..869ced30 100644 --- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt +++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocTag.kt @@ -1,7 +1,7 @@ package org.jetbrains.dokka.base.translators.psi.parsers internal enum class JavadocTag { - PARAM, THROWS, RETURN, AUTHOR, SEE, DEPRECATED, EXCEPTION, + PARAM, THROWS, RETURN, AUTHOR, SEE, DEPRECATED, EXCEPTION, HIDE, /** * Artificial tag created to handle tag-less section |