Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render quotes as blockquotes instead of code blocks. #2496

Merged
merged 8 commits into from May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/api/core.api
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/kotlin/pages/ContentNodes.kt
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
@@ -1,5 +1,5 @@
# Project Settings
dokka_version=1.7.0-SNAPSHOT
dokka_version=1.7.0-quotations-SNAPSHOT
TheOnlyTails marked this conversation as resolved.
Show resolved Hide resolved
dokka_integration_test_parallelism=2
# Versions
kotlin_version=1.6.21
Expand Down
Expand Up @@ -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!!,
Expand Down
Expand Up @@ -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", ""),
Expand Down
5 changes: 3 additions & 2 deletions plugins/base/src/main/resources/dokka/styles/style.css
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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(
Expand Down Expand Up @@ -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"
}
}
}
}
Expand Down Expand Up @@ -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" }
}
}
}
Expand Down Expand Up @@ -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"
}
}
}
Expand Down