aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt4
-rw-r--r--plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt9
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt13
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt15
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt7
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt4
7 files changed, 39 insertions, 15 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt
index e81eb513..277fd35e 100644
--- a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt
+++ b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt
@@ -16,9 +16,9 @@ object DocTagsFromIElementFactory {
MarkdownElementTypes.INLINE_LINK -> if(dri == null) A(children, params) else DocumentationLink(dri, children, params)
MarkdownElementTypes.STRONG -> B(children, params)
MarkdownElementTypes.BLOCK_QUOTE -> BlockQuote(children, params)
- MarkdownElementTypes.CODE_SPAN,
+ MarkdownElementTypes.CODE_SPAN -> CodeInline(children, params)
MarkdownElementTypes.CODE_BLOCK,
- MarkdownElementTypes.CODE_FENCE -> Code(children, params)
+ MarkdownElementTypes.CODE_FENCE -> CodeBlock(children, params)
MarkdownElementTypes.ATX_1 -> H1(children, params)
MarkdownElementTypes.ATX_2 -> H2(children, params)
MarkdownElementTypes.ATX_3 -> H3(children, params)
diff --git a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt
index de7c3cad..124dc3b4 100644
--- a/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt
+++ b/plugins/base/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt
@@ -13,7 +13,7 @@ object DocTagsFromStringFactory {
"blockquote" -> BlockQuote(children, params)
"br" -> Br
"cite" -> Cite(children, params)
- "code" -> Code(children, params)
+ "code" -> if(params.isEmpty()) CodeInline(children, params) else CodeBlock(children, params)
"dd" -> Dd(children, params)
"dfn" -> Dfn(children, params)
"dir" -> Dir(children, params)
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index 75fbb187..afee1b33 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -74,7 +74,11 @@ abstract class DefaultRenderer<T>(
nodes.forEach { it.build(this, pageContext, sourceSetRestriction) }
}
- open fun T.buildCode(code: ContentCode, pageContext: ContentPage) {
+ open fun T.buildCodeBlock(code: ContentCodeBlock, pageContext: ContentPage) {
+ code.children.forEach { it.build(this, pageContext) }
+ }
+
+ open fun T.buildCodeInline(code: ContentCodeInline, pageContext: ContentPage) {
code.children.forEach { it.build(this, pageContext) }
}
@@ -102,7 +106,8 @@ abstract class DefaultRenderer<T>(
when (node) {
is ContentText -> buildText(node)
is ContentHeader -> buildHeader(node, pageContext, sourceSetRestriction)
- is ContentCode -> buildCode(node, pageContext)
+ is ContentCodeBlock -> buildCodeBlock(node, pageContext)
+ is ContentCodeInline -> buildCodeInline(node, pageContext)
is ContentDRILink ->
buildLink(locationProvider.resolve(node.address, node.sourceSets, pageContext)) {
buildLinkText(node.children, pageContext, sourceSetRestriction)
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 8e18547c..44ca5e20 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -554,8 +554,8 @@ open class HtmlRenderer(
override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) =
a(href = address, block = content)
- override fun FlowContent.buildCode(
- code: ContentCode,
+ override fun FlowContent.buildCodeBlock(
+ code: ContentCodeBlock,
pageContext: ContentPage
) {
div("sample-container") {
@@ -566,6 +566,15 @@ open class HtmlRenderer(
}
}
+ override fun FlowContent.buildCodeInline(
+ code: ContentCodeInline,
+ pageContext: ContentPage
+ ) {
+ code {
+ code.children.forEach { buildContentNode(it, pageContext) }
+ }
+ }
+
private fun getSymbolSignature(page: ContentPage) = page.content.dfs { it.dci.kind == ContentKind.Symbol }
private fun flattenToText(node: ContentNode): String {
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 1770dc6f..19817992 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
@@ -91,7 +91,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
)
)
is BlockQuote -> listOf(
- ContentCode(
+ ContentCodeBlock(
buildChildren(docTag),
"",
dci,
@@ -99,8 +99,17 @@ object DocTagToContentConverter : CommentsToContentConverter {
styles
)
)
- is Code -> listOf(
- ContentCode(
+ is CodeInline -> listOf(
+ ContentCodeInline(
+ buildChildren(docTag),
+ "",
+ dci,
+ sourceSets,
+ styles
+ )
+ )
+ is CodeBlock -> listOf(
+ ContentCodeBlock(
buildChildren(docTag),
"",
dci,
diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
index 41dea1a2..695ef050 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
@@ -86,7 +86,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer {
| //sampleEnd
|}""".trimMargin()
- private fun ContentNode.dfs(fqName: String, node: ContentCode): ContentNode {
+ private fun ContentNode.dfs(fqName: String, node: ContentCodeBlock): ContentNode {
return when (this) {
is ContentHeader -> copy(children.map { it.dfs(fqName, node) })
is ContentDivergentGroup -> @Suppress("UNCHECKED_CAST") copy(children.map {
@@ -96,7 +96,8 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer {
before.let { it?.dfs(fqName, node) },
divergent.dfs(fqName, node),
after.let { it?.dfs(fqName, node) })
- is ContentCode -> copy(children.map { it.dfs(fqName, node) })
+ is ContentCodeBlock -> copy(children.map { it.dfs(fqName, node) })
+ is ContentCodeInline -> copy(children.map { it.dfs(fqName, node) })
is ContentDRILink -> copy(children.map { it.dfs(fqName, node) })
is ContentResolvedLink -> copy(children.map { it.dfs(fqName, node) })
is ContentEmbeddedResource -> copy(children.map { it.dfs(fqName, node) })
@@ -131,7 +132,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer {
styles: Set<Style> = emptySet(),
extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) =
- ContentCode(
+ ContentCodeBlock(
children = listOf(
ContentText(
text = content,
diff --git a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
index 89226821..2e921e83 100644
--- a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
@@ -158,7 +158,7 @@ class JavadocParser(
"strong" -> Strong(children)
"i" -> I(children)
"em" -> Em(children)
- "code" -> Code(children)
+ "code" -> CodeBlock(children)
"pre" -> Pre(children)
"ul" -> Ul(children)
"ol" -> Ol(children)
@@ -196,7 +196,7 @@ class JavadocParser(
tag.referenceElement()?.toDocumentationLink(tag.dataElements.firstIsInstanceOrNull<PsiDocToken>())
}
"code", "literal" -> {
- Code(listOf(Text(tag.text)))
+ CodeInline(listOf(Text(tag.text)))
}
else -> Text(tag.text)
}