diff options
Diffstat (limited to 'plugins')
6 files changed, 108 insertions, 55 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 22fb3e63..0118dcfd 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -386,23 +386,31 @@ open class HtmlRenderer( it.build(this, pageContext, sourceSetRestriction) buildAnchor(anchorName) } - if (ContentKind.shouldBePlatformTagged(node.dci.kind) && (node.sourceSets.size == 1)) + if (ContentKind.shouldBePlatformTagged(node.dci.kind) && (node.sourceSets.size == 1 || pageContext is ModulePage)) createPlatformTags(node) } } } it.filter { it !is ContentLink }.takeIf { it.isNotEmpty() }?.let { - div("platform-dependent-row keyValue") { - val title = it.filter { it.style.contains(ContentStyle.RowTitle) } - div { - title.forEach { + if(pageContext is ModulePage){ + it.forEach { + span(classes = if(it.dci.kind == ContentKind.Comment) "brief-comment" else "") { it.build(this, pageContext, sourceSetRestriction) } } - div("title") { - (it - title).forEach { - it.build(this, pageContext, sourceSetRestriction) + } else { + div("platform-dependent-row keyValue") { + val title = it.filter { it.style.contains(ContentStyle.RowTitle) } + div { + title.forEach { + it.build(this, pageContext, sourceSetRestriction) + } + } + div("title") { + (it - title).forEach { + it.build(this, pageContext, sourceSetRestriction) + } } } } @@ -513,13 +521,20 @@ open class HtmlRenderer( override fun FlowContent.buildNavigation(page: PageNode) = div(classes = "breadcrumbs") { - locationProvider.ancestors(page).asReversed().forEach { node -> - text("/") - if (node.isNavigable) buildLink(node, page) - else text(node.name) + val path = locationProvider.ancestors(page).filterNot { it is RendererSpecificPage }.asReversed() + if(path.isNotEmpty()){ + buildNavigationElement(path.first(), page) + path.drop(1).forEach { node -> + text("/") + buildNavigationElement(node, page) + } } } + private fun FlowContent.buildNavigationElement(node: PageNode, page: PageNode) = + if (node.isNavigable) buildLink(node, page) + else text(node.name) + private fun FlowContent.buildLink(to: PageNode, from: PageNode) = locationProvider.resolve(to, from)?.let { path -> buildLink(path) { diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 3f3e157e..30f35003 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -83,11 +83,18 @@ open class DefaultPageCreator( } } +contentForComments(m) + block("Packages", 2, ContentKind.Packages, m.packages, m.sourceSets.toSet()) { + val documentations = it.sourceSets.map { platform -> + it.descriptions[platform]?.also { it.root } + } + val haveSameContent = documentations.all { it?.root == documentations.firstOrNull()?.root && it?.root != null } + link(it.name, it.dri) + if(it.sourceSets.size == 1 || (documentations.isNotEmpty() && haveSameContent)){ + documentations.first()?.let { firstSentenceComment(kind = ContentKind.Comment, content = it) } + } } -// text("Index\n") TODO -// text("Link to allpage here") } protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) { @@ -261,18 +268,15 @@ open class DefaultPageCreator( protected open fun contentForDescription( d: Documentable ): List<ContentNode> { - val tags: GroupedTags = d.documentation.flatMap { (pd, doc) -> - doc.children.asSequence().map { pd to it }.toList() - }.groupBy { it.second::class } - + val tags: GroupedTags = d.groupedTags val platforms = d.sourceSets.toSet() return contentBuilder.contentFor(d, styles = setOf(TextStyle.Block)) { - val description = tags.withTypeUnnamed<Description>() - if (description.any { it.value.root.children.isNotEmpty() }) { + val descriptions = d.descriptions + if (descriptions.any { it.value.root.children.isNotEmpty() }) { platforms.forEach { platform -> - description[platform]?.also { - group(sourceSets = setOf(platform)) { + descriptions[platform]?.also { + group(sourceSets = setOf(platform), styles = emptySet()) { comment(it.root) } } @@ -286,7 +290,7 @@ open class DefaultPageCreator( platforms.forEach { platform -> unnamedTags.forEach { pdTag -> pdTag[platform]?.also { tag -> - group(sourceSets = setOf(platform)) { + group(sourceSets = setOf(platform), styles = emptySet()) { header(4, tag.toHeaderString()) comment(tag.root) } @@ -308,10 +312,7 @@ open class DefaultPageCreator( protected open fun contentForComments( d: Documentable ): List<ContentNode> { - val tags: GroupedTags = d.documentation.flatMap { (pd, doc) -> - doc.children.asSequence().map { pd to it }.toList() - }.groupBy { it.second::class } - + val tags = d.groupedTags val platforms = d.sourceSets fun DocumentableContentBuilder.contentForParams() { @@ -522,4 +523,12 @@ open class DefaultPageCreator( private val List<Documentable>.sourceSets: Set<DokkaSourceSet> get() = flatMap { it.sourceSets }.toSet() + + private val Documentable.groupedTags: GroupedTags + get() = documentation.flatMap { (pd, doc) -> + doc.children.asSequence().map { pd to it }.toList() + }.groupBy { it.second::class } + + private val Documentable.descriptions: SourceSetDependent<Description> + get() = groupedTags.withTypeUnnamed<Description>() } diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt index a1f3c002..42700f20 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt @@ -7,6 +7,7 @@ import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentCon import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.SourceSetDependent +import org.jetbrains.dokka.model.doc.Description import org.jetbrains.dokka.model.doc.DocTag import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.toDisplaySourceSets @@ -287,6 +288,22 @@ open class PageContentBuilder( contents += ContentGroup(content, DCI(mainDRI, kind), sourceSets.toDisplaySourceSets(), styles, extra) } + fun firstSentenceComment( + content: Description, + kind: Kind = ContentKind.Comment, + sourceSets: Set<DokkaSourceSet> = mainSourcesetData, + styles: Set<Style> = mainStyles, + extra: PropertyContainer<ContentNode> = mainExtra + ){ + val builtDescription = commentsConverter.buildContent( + content.root, + DCI(mainDRI, kind), + sourceSets + ) + + contents += ContentGroup(briefFromContentNodes(builtDescription), DCI(mainDRI, kind), sourceSets.toDisplaySourceSets(), styles, extra) + } + fun group( dri: Set<DRI> = mainDRI, sourceSets: Set<DokkaSourceSet> = mainSourcesetData, diff --git a/plugins/base/src/main/kotlin/translators/documentables/briefFromContentNodes.kt b/plugins/base/src/main/kotlin/translators/documentables/briefFromContentNodes.kt new file mode 100644 index 00000000..9fe128dd --- /dev/null +++ b/plugins/base/src/main/kotlin/translators/documentables/briefFromContentNodes.kt @@ -0,0 +1,26 @@ +package org.jetbrains.dokka.base.translators.documentables + +import org.jetbrains.dokka.pages.ContentGroup +import org.jetbrains.dokka.pages.ContentNode +import org.jetbrains.dokka.pages.ContentText +import org.jetbrains.dokka.pages.TextStyle + +fun briefFromContentNodes(description: List<ContentNode>): List<ContentNode> { + val firstSentenceRegex = Regex("^((?:[^.?!]|[.!?](?!\\s))*[.!?])") + + var sentenceFound = false + fun lookthrough(node: ContentNode): ContentNode = + if (node is ContentText && firstSentenceRegex.containsMatchIn(node.text)) { + sentenceFound = true + node.copy(text = firstSentenceRegex.find(node.text)?.value.orEmpty()) + } else if (node is ContentGroup) { + node.copy(children = node.children.mapNotNull { + if (!sentenceFound) lookthrough(it) else null + }, style = node.style - TextStyle.Paragraph) + } else { + node + } + return description.mapNotNull { + if (!sentenceFound) lookthrough(it) else null + } +}
\ No newline at end of file diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css index 51165883..f5a1e65b 100644 --- a/plugins/base/src/main/resources/dokka/styles/style.css +++ b/plugins/base/src/main/resources/dokka/styles/style.css @@ -5,6 +5,7 @@ :root { --breadcrumb-font-color: #A6AFBA; --hover-link-color: #5B5DEF; + --average-color: #637282; --footer-height: 64px; --footer-padding-top: 48px; --horizontal-spacing-for-content: 42px; @@ -38,7 +39,7 @@ border-bottom: 1px solid #DADFE6; padding: 11px 3px; font-size: 14px; - color: #637282; + color: var(--average-color); outline: none; margin: 0 8px; } @@ -90,7 +91,6 @@ display: flex; flex-direction: column; width: 100%; - padding-bottom: 48px; } .tabbedcontent { @@ -253,7 +253,7 @@ code.paragraph { } .symbol span.copy-icon path { - fill: #637282; + fill: var(--average-color); } .symbol span.copy-icon:hover path { @@ -317,7 +317,7 @@ code.paragraph { display: block; align-items: center; height: 100%; - color: #637282; + color: var(--average-color); overflow: hidden; } @@ -434,7 +434,7 @@ h1, h2, h3, h4, h5, h6 { } p, ul, ol, table, pre, dl { - margin: 0 0 20px; + margin: 0; } h1 { @@ -709,7 +709,7 @@ footer { .platform-selector:not([data-active]) { border: 1px solid #DADFE6; background-color: transparent; - color: #637282; + color: var(--average-color); } td.content { @@ -755,7 +755,7 @@ td.content { } .main-subrow .anchor-icon > svg path { - fill: #637282; + fill: var(--average-color); } .main-subrow .anchor-icon:hover { @@ -862,6 +862,7 @@ td.content { .cover .with-platform-tabs { background-color: white; + font-size: 14px; } .cover > .with-platform-tabs .platform-bookmarks-row { @@ -908,6 +909,10 @@ td.content { padding: 16px 24px 16px 24px; } +.table-row .brief-comment { + color: var(--average-color); +} + .platform-dependent-row { display: grid; padding-top: 8px; @@ -1025,7 +1030,7 @@ td.content { } .footer span.go-to-top-icon path { - fill: #637282; + fill: var(--average-color); } .footer > span:first-child { diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt index a8e10db5..05de8fa1 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt @@ -6,6 +6,7 @@ import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter +import org.jetbrains.dokka.base.translators.documentables.briefFromContentNodes import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.doc.Description import org.jetbrains.dokka.model.doc.Index @@ -171,8 +172,6 @@ open class JavadocPageCreator( sources.firstOrNull { it != expectPresentInSet } ?: sources.firstOrNull() } - private val firstSentenceRegex = Regex("^((?:[^.?!]|[.!?](?!\\s))*[.!?])") - private inline fun <reified T : TagWrapper> Documentable.findNodeInDocumentation(sourceSetData: DokkaSourceSet?): T? = documentation[sourceSetData]?.firstChildOfTypeOrNull<T>() @@ -197,24 +196,6 @@ open class JavadocPageCreator( private fun Documentable.brief(sourceSet: DokkaSourceSet? = highestJvmSourceSet): List<ContentNode> = briefFromContentNodes(descriptionToContentNodes(sourceSet)) - private fun briefFromContentNodes(description: List<ContentNode>): List<ContentNode> { - var sentenceFound = false - fun lookthrough(node: ContentNode): ContentNode = - if (node is ContentText && firstSentenceRegex.containsMatchIn(node.text)) { - sentenceFound = true - node.copy(text = firstSentenceRegex.find(node.text)?.value.orEmpty()) - } else if (node is ContentGroup) { - node.copy(children = node.children.mapNotNull { - if (!sentenceFound) lookthrough(it) else null - }, style = node.style - TextStyle.Paragraph) - } else { - node - } - return description.mapNotNull { - if (!sentenceFound) lookthrough(it) else null - } - } - private fun DParameter.brief(sourceSet: DokkaSourceSet? = highestJvmSourceSet): List<ContentNode> = briefFromContentNodes(paramsToContentNodes(sourceSet).dropWhile { it is ContentDRILink }) |