aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/base-test-utils/api/base-test-utils.api4
-rw-r--r--plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt1
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt1
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt1
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt1
-rw-r--r--plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt32
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt12
7 files changed, 52 insertions, 0 deletions
diff --git a/plugins/base/base-test-utils/api/base-test-utils.api b/plugins/base/base-test-utils/api/base-test-utils.api
index 992357af..8b3d5af2 100644
--- a/plugins/base/base-test-utils/api/base-test-utils.api
+++ b/plugins/base/base-test-utils/api/base-test-utils.api
@@ -184,6 +184,10 @@ public final class utils/TestOutputWriterPlugin : org/jetbrains/dokka/plugabilit
public final fun getWriter ()Lutils/TestOutputWriter;
}
+public final class utils/Var : utils/Tag {
+ public fun <init> ([Ljava/lang/Object;)V
+}
+
public final class utils/Wbr : utils/Tag {
public static final field INSTANCE Lutils/Wbr;
}
diff --git a/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt b/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt
index e1ae5029..6d308341 100644
--- a/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt
+++ b/plugins/base/base-test-utils/src/main/kotlin/renderers/JsoupUtils.kt
@@ -34,6 +34,7 @@ class BlockQuote(vararg matchers: Any) : Tag("blockquote", *matchers)
class Dl(vararg matchers: Any) : Tag("dl", *matchers)
class Dt(vararg matchers: Any) : Tag("dt", *matchers)
class Dd(vararg matchers: Any) : Tag("dd", *matchers)
+class Var(vararg matchers: Any) : Tag("var", *matchers)
object Wbr : Tag("wbr")
object Br : Tag("br")
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 53645f06..55afef80 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -777,6 +777,7 @@ open class HtmlRenderer(
TextStyle.Italic -> i { body() }
TextStyle.Strikethrough -> strike { body() }
TextStyle.Strong -> strong { body() }
+ TextStyle.Var -> htmlVar { body() }
is TokenStyle -> span("token " + styleToApply.toString().toLowerCase()) { body() }
else -> body()
}
diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
index b46a7679..1c447e9e 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
@@ -254,6 +254,7 @@ open class DocTagToContentConverter : CommentsToContentConverter {
extra = extras
)
)
+ is Var -> buildChildren(docTag, setOf(TextStyle.Var))
else -> buildChildren(docTag)
}
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 ce0d2ff3..7dc8e3a0 100644
--- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt
@@ -424,6 +424,7 @@ class JavadocParser(
"h1" -> ifChildrenPresent { H1(children) }
"h2" -> ifChildrenPresent { H2(children) }
"h3" -> ifChildrenPresent { H3(children) }
+ "var" -> ifChildrenPresent { Var(children) }
else -> listOf(Text(body = element.ownText()))
}
}
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index 4f37923b..af8dbb94 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -396,4 +396,36 @@ class JavadocParserTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `var tag is handled properly`() {
+ val source = """
+ |/src/main/kotlin/test/Test.java
+ |package example
+ |
+ | /**
+ | * An example of using var tag: <var>variable</var>
+ | */
+ | public class Test {}
+ """.trimIndent()
+ testInline(
+ source,
+ configuration,
+ ) {
+ documentablesCreationStage = { modules ->
+ val docs = modules.first().packages.first().classlikes.single().documentation.first().value
+ val root = docs.children.first().root
+
+ kotlin.test.assertEquals(
+ listOf(
+ P(children = listOf(
+ Text("An example of using var tag: "),
+ Var(children = listOf(Text("variable"))),
+ )),
+ ),
+ root.children
+ )
+ }
+ }
+ }
}
diff --git a/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt b/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
index 2c862525..98f73ffa 100644
--- a/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
@@ -80,6 +80,18 @@ class TextStylesTest : HtmlRenderingOnlyTestBase() {
renderedContent.match(BlockQuote("blockquote text"))
}
+ @Test
+ fun `should include var`() {
+ val page = testPage {
+ group(styles = setOf(TextStyle.Var)) {
+ text("variable")
+ }
+ }
+ HtmlRenderer(context).render(page)
+ println(renderedContent)
+ renderedContent.match(Var("variable"))
+ }
+
override val renderedContent: Element
get() = files.contents.getValue("test-page.html").let { Jsoup.parse(it) }.select("#content").single()
} \ No newline at end of file