aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheOnlyTails <theonlytails@theonlytails.com>2022-05-13 16:16:03 +0300
committerGitHub <noreply@github.com>2022-05-13 16:16:03 +0300
commitc532003c71cc551ce0df797a8d6207c0edb8eaab (patch)
treee39c948c0d0e305dbb0a61be7744e517fd924367
parent3e55be9954acc7e4cab11ed661cb62ed347e9b84 (diff)
downloaddokka-c532003c71cc551ce0df797a8d6207c0edb8eaab.tar.gz
dokka-c532003c71cc551ce0df797a8d6207c0edb8eaab.tar.bz2
dokka-c532003c71cc551ce0df797a8d6207c0edb8eaab.zip
Render quotes as blockquotes instead of code blocks. (#2496)
-rw-r--r--core/api/core.api1
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt2
-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.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt1
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt10
-rw-r--r--plugins/base/src/main/resources/dokka/styles/style.css5
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt10
-rw-r--r--plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt81
9 files changed, 74 insertions, 42 deletions
diff --git a/core/api/core.api b/core/api/core.api
index 8add4bd8..28f55df6 100644
--- a/core/api/core.api
+++ b/core/api/core.api
@@ -4277,6 +4277,7 @@ public final class org/jetbrains/dokka/pages/TextStyle : java/lang/Enum, org/jet
public static final field Italic Lorg/jetbrains/dokka/pages/TextStyle;
public static final field Monospace Lorg/jetbrains/dokka/pages/TextStyle;
public static final field Paragraph Lorg/jetbrains/dokka/pages/TextStyle;
+ public static final field Quotation Lorg/jetbrains/dokka/pages/TextStyle;
public static final field Span Lorg/jetbrains/dokka/pages/TextStyle;
public static final field Strikethrough Lorg/jetbrains/dokka/pages/TextStyle;
public static final field Strong Lorg/jetbrains/dokka/pages/TextStyle;
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt
index 4210b4dd..0e89b3f6 100644
--- a/core/src/main/kotlin/pages/ContentNodes.kt
+++ b/core/src/main/kotlin/pages/ContentNodes.kt
@@ -384,7 +384,7 @@ enum class TokenStyle : Style {
enum class TextStyle : Style {
Bold, Italic, Strong, Strikethrough, Paragraph,
- Block, Span, Monospace, Indented, Cover, UnderCoverText, BreakableAfter, Breakable, InlineComment
+ Block, Span, Monospace, Indented, Cover, UnderCoverText, BreakableAfter, Breakable, InlineComment, Quotation
}
enum class ContentStyle : Style {
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 6a31e468..992357af 100644
--- a/plugins/base/base-test-utils/api/base-test-utils.api
+++ b/plugins/base/base-test-utils/api/base-test-utils.api
@@ -113,6 +113,10 @@ public final class utils/B : utils/Tag {
public fun <init> ([Ljava/lang/Object;)V
}
+public final class utils/BlockQuote : utils/Tag {
+ public fun <init> ([Ljava/lang/Object;)V
+}
+
public final class utils/Br : utils/Tag {
public static final field INSTANCE Lutils/Br;
}
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 22581d3a..3562fb8e 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
@@ -29,6 +29,8 @@ class A(vararg matchers: Any) : Tag("a", *matchers)
class B(vararg matchers: Any) : Tag("b", *matchers)
class I(vararg matchers: Any) : Tag("i", *matchers)
class STRIKE(vararg matchers: Any) : Tag("strike", *matchers)
+
+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)
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 7ce41866..9be7428a 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -128,6 +128,7 @@ open class HtmlRenderer(
}
node.hasStyle(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() }
node.hasStyle(TextStyle.Block) -> div(additionalClasses) { childrenCallback() }
+ node.hasStyle(TextStyle.Quotation) -> blockQuote(additionalClasses) { childrenCallback() }
node.isAnchorable -> buildAnchor(
node.anchor!!,
node.anchorLabel!!,
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 85b082ef..b46a7679 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
@@ -123,7 +123,15 @@ open class DocTagToContentConverter : CommentsToContentConverter {
styles
)
)
- is BlockQuote, is Pre, is CodeBlock -> listOf(
+ is BlockQuote -> listOf(
+ ContentGroup(
+ buildChildren(docTag),
+ dci,
+ sourceSets.toDisplaySourceSets(),
+ styles + TextStyle.Quotation,
+ )
+ )
+ is Pre, is CodeBlock -> listOf(
ContentCodeBlock(
buildChildren(docTag),
docTag.params.getOrDefault("lang", ""),
diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css
index 94200bd1..9bc9f07d 100644
--- a/plugins/base/src/main/resources/dokka/styles/style.css
+++ b/plugins/base/src/main/resources/dokka/styles/style.css
@@ -612,10 +612,11 @@ a small {
}
blockquote {
- border-left: 1px solid #e5e5e5;
+ border-left: 1ch solid var(--default-gray);
margin: 0;
- padding: 0 0 0 20px;
+ padding-left: 1ch;
font-style: italic;
+ color: var(--average-color);
}
pre {
diff --git a/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt b/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
index fd2f7860..2c862525 100644
--- a/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/TextStylesTest.kt
@@ -69,6 +69,16 @@ class TextStylesTest : HtmlRenderingOnlyTestBase() {
files.contents.getValue("test-page.html").contains("&nbsp;<strike><b>styled text</b></strike>")
}
+ @Test
+ fun `should include blockquote`() {
+ val page = testPage {
+ group(styles = setOf(TextStyle.Quotation)) {
+ text("blockquote text")
+ }
+ }
+ HtmlRenderer(context).render(page)
+ renderedContent.match(BlockQuote("blockquote text"))
+ }
override val renderedContent: Element
get() = files.contents.getValue("test-page.html").let { Jsoup.parse(it) }.select("#content").single()
diff --git a/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt b/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt
index 9a77172b..07dc0bc7 100644
--- a/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt
+++ b/plugins/base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt
@@ -14,8 +14,8 @@ class CommentsToContentConverterTest {
private val converter = DocTagToContentConverter()
private fun executeTest(
- docTag:DocTag,
- match: ContentMatcherBuilder<ContentComposite>.() -> Unit
+ docTag: DocTag,
+ match: ContentMatcherBuilder<ContentComposite>.() -> Unit,
) {
val dci = DCI(
setOf(
@@ -225,12 +225,16 @@ class CommentsToContentConverterTest {
)
executeTest(docTag) {
group {
- node<ContentCodeBlock> {
- +"Blockquotes are very handy in email to emulate reply text. This line is part of the same quote."
+ group {
+ group {
+ +"Blockquotes are very handy in email to emulate reply text. This line is part of the same quote."
+ }
}
group { +"Quote break." }
- node<ContentCodeBlock> {
- +"Quote"
+ group {
+ group {
+ +"Quote"
+ }
}
}
}
@@ -261,16 +265,16 @@ class CommentsToContentConverterTest {
)
executeTest(docTag) {
group {
- node<ContentCodeBlock> {
- +"text 1 text 2"
- node<ContentCodeBlock> {
- +"text 3 text 4"
+ group {
+ group { +"text 1 text 2" }
+ group {
+ group { +"text 3 text 4" }
}
- +"text 5"
+ group { +"text 5" }
}
group { +"Quote break." }
- node<ContentCodeBlock> {
- +"Quote"
+ group {
+ group { +"Quote" }
}
}
}
@@ -326,48 +330,49 @@ class CommentsToContentConverterTest {
)
)
executeTest(docTag) {
- group { link {
- +"I'm an inline-style link"
- check {
- assertEquals(
- assertedCast<ContentResolvedLink> { "Link should be resolved" }.address,
- "https://www.google.com"
- )
+ group {
+ link {
+ +"I'm an inline-style link"
+ check {
+ assertEquals(
+ assertedCast<ContentResolvedLink> { "Link should be resolved" }.address,
+ "https://www.google.com"
+ )
+ }
}
- } }
+ }
}
}
-
@Test
fun `ordered list`() {
val docTag =
Ol(
- listOf(
- Li(
- listOf(
- P(listOf(Text("test1"))),
- P(listOf(Text("test2"))),
- )
- ),
- Li(
- listOf(
- P(listOf(Text("test3"))),
- P(listOf(Text("test4"))),
+ listOf(
+ Li(
+ listOf(
+ P(listOf(Text("test1"))),
+ P(listOf(Text("test2"))),
+ )
+ ),
+ Li(
+ listOf(
+ P(listOf(Text("test3"))),
+ P(listOf(Text("test4"))),
+ )
)
)
)
- )
executeTest(docTag) {
node<ContentList> {
group {
- +"test1"
- +"test2"
+ +"test1"
+ +"test2"
}
group {
- +"test3"
- +"test4"
+ +"test3"
+ +"test4"
}
}
}