diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-04-06 22:24:30 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-04-08 17:02:01 +0200 |
commit | a128cdd43265134a2a2c6b45f5d55b3543a9c794 (patch) | |
tree | b5ad1118fcef7337f49054e5c92d3114e5af7019 | |
parent | 17ac290f4d460961dd5f1970a6bc83eea174efaa (diff) | |
download | dokka-a128cdd43265134a2a2c6b45f5d55b3543a9c794.tar.gz dokka-a128cdd43265134a2a2c6b45f5d55b3543a9c794.tar.bz2 dokka-a128cdd43265134a2a2c6b45f5d55b3543a9c794.zip |
Fix unnecessary wrapping of signatures, changes in layout
7 files changed, 194 insertions, 116 deletions
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index cbb5b656..4e77d663 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -25,6 +25,7 @@ data class ContentText( override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentNode = copy(extra = newExtras) } +// TODO: Remove data class ContentBreakLine( override val platforms: Set<PlatformData>, override val dci: DCI = DCI(emptySet(), ContentKind.Empty), @@ -170,7 +171,7 @@ interface Kind enum class ContentKind : Kind { Comment, Constructors, Functions, Parameters, Properties, Classlikes, Packages, Symbol, Sample, Main, BriefComment, - Empty, Source, TypeAliases; + Empty, Source, TypeAliases, Cover, Subtypes; companion object { private val platformTagged = diff --git a/core/src/main/resources/dokka/styles/style.css b/core/src/main/resources/dokka/styles/style.css index 80865758..5c347128 100644 --- a/core/src/main/resources/dokka/styles/style.css +++ b/core/src/main/resources/dokka/styles/style.css @@ -13,9 +13,10 @@ } #leftColumn { - padding-left: 12px; + width: 280px; min-height: 100%; - border-right: 2px solid #DADFE6; + border-right: 1px solid #DADFE6; + flex: 0 0 auto; } @media screen and (max-width: 600px) { @@ -29,12 +30,9 @@ } #sideMenu { - padding-top: 12px; - padding-right: 12px; -} - -#sideMenu .sideMenuPart { - padding-left: 1em; + padding-top: 16px; + position: relative; + overflow: auto; } #sideMenu img { @@ -50,12 +48,14 @@ } #logo { - padding: 5px; - background-size: 55% 90%; - border-bottom: 2px solid #DADFE6; + background-size: 125px 26px; + border-bottom: 1px solid #DADFE6; background-repeat: no-repeat; background-image: url(../images/docs_logo.svg); - height: 6vh; + background-origin: content-box; + padding-left: 24px; + padding-top: 24px; + height: 48px; } .monospace, @@ -63,31 +63,76 @@ font-family: monospace; } +.overview > .navButton { + width: 100%; + height: 100%; + align-items: center; + display: flex; + justify-content: flex-end; + padding-right: 24px; +} + .strikethrough { text-decoration: line-through; } .symbol:empty { - padding: 0px; + padding: 0; } + .symbol { - padding: 5px; background-color: #F4F4F4; + align-items: center; + display: flex; + padding: 8px 16px; + box-sizing: border-box; + font-weight: bold; + white-space: pre; +} + +#nav-submenu > .sideMenuPart { + padding-left: 0; /* packages are same level as modules */ } .sideMenuPart > .overview { + height: 40px; width: 100%; - display: inline-flex; + display: flex; + align-items: center; + position: relative; + user-select: none; /* there's a weird bug with text selection */ } -.overview > .navButton { - width: 100%; - display: inline-flex; - justify-content: flex-end; +.sideMenuPart a { + display: flex; + align-items: center; + flex: 1; + height: 100%; + color: #637282; } -.sideMenuPart > .overview:hover { - background-color: rgba(91, 93, 239, 0.15); +.sideMenuPart > .overview:before { + box-sizing: border-box; + content: ''; + top: 0; + width: 200%; + right: 0; + bottom: 0; + position: absolute; + z-index: -1; +} + +.overview:hover:before { + background-color: #DADFE5; +} + +#nav-submenu { + padding-left: 24px; +} + +.sideMenuPart { + padding-left: 12px; + box-sizing: border-box; } .sideMenuPart .hidden > .overview .navButtonContent::before { @@ -121,7 +166,7 @@ body, table { font: 14px/1.5 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif; background: #F4F4F4; font-weight: 300; - margin-right: auto; + margin: 0; max-width: 1440px; } @@ -134,6 +179,7 @@ table { tbody > tr { border-bottom: 2px solid #F4F4F4; + min-height: 56px; } td:first-child { @@ -149,6 +195,12 @@ td:first-child { .symbol { font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; font-size: 12px; + min-height: 43px; +} + +.symbol > a { + color: #5B5DEF; + text-decoration: underline; } .identifier { @@ -195,8 +247,8 @@ a { } a:hover { - color: inherit; - text-decoration: underline; + color: #282E34; + text-decoration: none; } a small { @@ -343,41 +395,41 @@ footer { } .platform-tag { - text-indent: 100%; - white-space: nowrap; - overflow: hidden; - width: 10px; - height: 10px; - max-width: 10px; - max-height: 10px; - border-radius: 8px; - transition: width 1s, height 1s; - margin-left: 14px; - margin-top: auto; - margin-bottom: auto; - font-family: Inter, Arial, sans-serif; - font-size: 12px; - font-weight: 400; - font-style: normal; - font-stretch: normal; - line-height: normal; - letter-spacing: normal; - text-align: center; - color: #fff + text-indent: 100%; + white-space: nowrap; + overflow: hidden; + width: 10px; + height: 10px; + max-width: 10px; + max-height: 10px; + border-radius: 8px; + transition: width 1s, height 1s; + margin-left: 14px; + margin-top: auto; + margin-bottom: auto; + font-family: Inter, Arial, sans-serif; + font-size: 12px; + font-weight: 400; + font-style: normal; + font-stretch: normal; + line-height: normal; + letter-spacing: normal; + text-align: center; + color: #fff } .platform-tagged:hover .platform-tag, -.platform-tagged:hover>.platform-tag { - text-indent: 0; - white-space: nowrap; - padding: 0 7px; - border-radius: 9px; - margin-left: 8px; - width: auto; - height: 15px; - max-width: 500px; - max-height: 500px; - transition: max-width 1s, max-height 1s +.platform-tagged:hover > .platform-tag { + text-indent: 0; + white-space: nowrap; + padding: 0 7px; + border-radius: 9px; + margin-left: 8px; + width: auto; + height: 15px; + max-width: 500px; + max-height: 500px; + transition: max-width 1s, max-height 1s } .platform-tagged { @@ -416,9 +468,23 @@ tr.platform-tagged { color: white; } -.platform-tagged > .content { - display: block; - flex: auto; +td.content { + padding-left: 24px; + padding-top: 16px; + display: flex; + flex-direction: column; +} + +.content > a { + text-decoration: none; + font-style: normal; + font-weight: 600; + font-size: 14px; + color: #282E34; +} + +.content > a:hover { + color: #5B5DEF; } @media print, screen and (max-width: 960px) { diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 1365fecb..e1025ed4 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -29,9 +29,13 @@ open class HtmlRenderer( ) { val additionalClasses = node.style.joinToString(" ") { it.toString().toLowerCase() } return when { - ContentKind.shouldBePlatformTagged(node.dci.kind) -> wrapPlatformTagged(node, pageContext) { childrenCallback() } + ContentKind.shouldBePlatformTagged(node.dci.kind) -> wrapPlatformTagged( + node, + pageContext + ) { childrenCallback() } node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } + node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { childrenCallback() } node.style.contains(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() } node.style.contains(TextStyle.Block) -> div(additionalClasses) { childrenCallback() } else -> childrenCallback() @@ -43,13 +47,13 @@ open class HtmlRenderer( pageContext: ContentPage, childrenCallback: FlowContent.() -> Unit ) { - div("platform-tagged"){ + div("platform-tagged") { node.platforms.forEach { - div("platform-tag ${it.platformType.name}"){ + div("platform-tag ${it.platformType.name}") { text(it.platformType.key.toUpperCase()) } } - div("content"){ + div("content") { childrenCallback() } } @@ -176,7 +180,7 @@ open class HtmlRenderer( } } tbody { - if(ContentKind.shouldBePlatformTagged(node.dci.kind)) { + if (ContentKind.shouldBePlatformTagged(node.dci.kind)) { buildPlatformTaggedRow(node, pageContext, platformRestriction) } else { buildRow(node, pageContext, platformRestriction) @@ -198,10 +202,12 @@ open class HtmlRenderer( } override fun FlowContent.buildNavigation(page: PageNode) = - locationProvider.ancestors(page).asReversed().forEach { node -> - text("/") - if (node.isNavigable) buildLink(node, page) - else text(node.name) + div(classes = "breadcrumbs") { + locationProvider.ancestors(page).asReversed().forEach { node -> + text("/") + if (node.isNavigable) buildLink(node, page) + else text(node.name) + } } private fun FlowContent.buildLink(to: PageNode, from: PageNode) = @@ -257,7 +263,7 @@ open class HtmlRenderer( } override fun FlowContent.buildText(textNode: ContentText) { - when{ + when { textNode.style.contains(TextStyle.Indented) -> consumer.onTagContentEntity(Entities.nbsp) } text(textNode.text) diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index ef557eaf..7b35c455 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -55,9 +55,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private fun regularSignature(c: DClasslike, platformData: Set<PlatformData> = c.platformData.toSet()) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace), platformData = platformData) { - platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } + platformText(c.visibility, platformData) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " } if (c is DClass) { - platformText(c.modifier) { + platformText(c.modifier, platformData) { if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.DATA) == true && it.name == "final") "data " else it.name + " " } @@ -71,16 +71,15 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } link(c.name!!, c.dri) if (c is DClass) { - val pConstructor = c.constructors.singleOrNull() { it.extra[PrimaryConstructorExtra] != null } + val pConstructor = c.constructors.singleOrNull { it.extra[PrimaryConstructorExtra] != null } list(pConstructor?.parameters.orEmpty(), "(", ")", ",", pConstructor?.platformData.orEmpty().toSet()) { - breakLine() text(it.name ?: "", styles = mainStyles.plus(TextStyle.Bold).plus(TextStyle.Indented)) text(": ") signatureForProjection(it.type) } } if (c is WithSupertypes) { - c.supertypes.map { (p, dris) -> + c.supertypes.filter { it.key in platformData }.map { (p, dris) -> list(dris, prefix = " : ", platformData = setOf(p)) { link(it.sureClassNames, it, platformData = setOf(p)) } @@ -128,7 +127,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } private fun signature(t: DTypeAlias) = - contentBuilder.contentFor(t, ContentKind.Symbol, setOf(TextStyle.Monospace)) { + contentBuilder.contentFor(t) { t.underlyingType.entries.groupBy({ it.value }, { it.key }).map { (type, platforms) -> +contentBuilder.contentFor( t, diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt index e372ad9c..8c014a29 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt @@ -42,7 +42,7 @@ class InheritorsExtractorTransformer : DocumentableTransformer { .map { (k, v) -> k to v.flatMap { p -> p.groupBy({ it.first }) { it.second }.toList() } .groupBy({ it.first }) { it.second }.map { (k2, v2) -> k2 to v2.flatten() }.toMap() - }.toMap() + }.filter{ it.second.values.isEmpty() }.toMap() private fun <T : Documentable> T.getInheritanceEntriesRec(): List<Pair<PlatformData, List<Pair<DRI, DRI>>>> = this.toInheritanceEntries() + children.flatMap { it.getInheritanceEntriesRec() } diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 312c7a5a..e1bce565 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -1,13 +1,11 @@ package org.jetbrains.dokka.base.translators.documentables import org.jetbrains.dokka.base.signatures.SignatureProvider -import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder.DocumentableContentBuilder import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.doc.* -import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.utilities.DokkaLogger import kotlin.reflect.KClass @@ -38,7 +36,7 @@ open class DefaultPageCreator( open fun pageForEnumEntry(e: DEnumEntry): ClasslikePageNode = ClasslikePageNode( - e.name.orEmpty(), contentForEnumEntry(e), setOf(e.dri), e, + e.name, contentForEnumEntry(e), setOf(e.dri), e, e.classlikes.map(::pageForClasslike) + e.filteredFunctions.map(::pageForFunction) ) @@ -63,7 +61,9 @@ open class DefaultPageCreator( get() = functions.filter { it.extra[InheritedFunction]?.isInherited != true } protected open fun contentForModule(m: DModule) = contentBuilder.contentFor(m) { - header(1) { text(m.name) } + group(kind = ContentKind.Cover) { + header(1) { text(m.name) } + } +contentForComments(m) block("Packages", 2, ContentKind.Packages, m.packages, m.platformData.toSet()) { link(it.name, it.dri) @@ -73,7 +73,7 @@ open class DefaultPageCreator( } protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) { - group(p.dri, p.platformData.toSet(), ContentKind.Packages) { + group(kind = ContentKind.Cover) { header(1) { text("Package ${p.name}") } } +contentForComments(p) @@ -124,40 +124,49 @@ open class DefaultPageCreator( platformDependentHint(it.dri, it.platformData.toSet()) { +buildSignature(it) } - breakLine() group(kind = ContentKind.BriefComment) { text(it.briefDocumentation()) } } } - (s as? WithExtraProperties<Documentable>)?.let { it.extra[InheritorsInfo] }?.let { inheritors -> - val map = inheritors.value.map - text("Subclasses:") - platformDependentHint(dri = s.dri, platformData = map.keys) { - map.keys.forEach { pd -> - linkTable(map[pd].orEmpty(), ContentKind.Classlikes, setOf(pd)) - } - } - } + // TODO: Fix this after fixing InheritorsExtractorTransformer +// (s as? WithExtraProperties<Documentable>)?.let { it.extra[InheritorsInfo] }?.let { inheritors -> +// val map = inheritors.value.map +// if (map.values.any()) { +// header(2) { text("Subtypes") } +// +ContentTable( +// emptyList(), +// map.entries.groupBy({ it.value }, { it.key }).map { (types, platforms) -> +// buildGroup(dri, platforms.toSet(), ContentKind.Subtypes) { +// types.map { +// link(it.toString(), it) +// } +// } +// }, +// DCI(setOf(dri), ContentKind.Subtypes), +// platformData.toSet(), +// style = emptySet() +// ) +// } +// } } protected open fun contentForEnumEntry(e: DEnumEntry) = contentBuilder.contentFor(e) { - header(1) { text(e.name.orEmpty()) } - +buildSignature(e) - + group(kind = ContentKind.Cover) { + header(1) { text(e.name) } + +buildSignature(e) + } +contentForComments(e) - +contentForScope(e, e.dri, e.platformData) } protected open fun contentForClasslike(c: DClasslike) = contentBuilder.contentFor(c) { - group(c.dri, c.platformData.toSet(), ContentKind.Classlikes) { + group(kind = ContentKind.Cover) { header(1) { text(c.name.orEmpty()) } platformDependentHint(c.dri, c.platformData.toSet()) { +buildSignature(c) } } - breakLine() +contentForComments(c) if (c is WithConstructors) { @@ -224,7 +233,6 @@ open class DefaultPageCreator( description.getOrExpect(platform)?.also { group(platformData = setOf(platform)) { comment(it.root) - breakLine() } } } @@ -263,7 +271,7 @@ open class DefaultPageCreator( fun DocumentableContentBuilder.contentForSeeAlso() { val seeAlsoTags = tags.withTypeNamed<See>() - if(seeAlsoTags.isNotEmpty()) { + if (seeAlsoTags.isNotEmpty()) { header(4, kind = ContentKind.Comment) { text("See also") } table(kind = ContentKind.Comment) { platforms.flatMap { platform -> @@ -311,7 +319,7 @@ open class DefaultPageCreator( } protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) { - group(f.dri, f.platformData.toSet(), ContentKind.Functions) { + group(kind = ContentKind.Cover) { header(1) { text(f.name) } platformDependentHint(f.dri, f.platformData.toSet()) { +buildSignature(f) @@ -321,8 +329,10 @@ open class DefaultPageCreator( } protected open fun contentForTypeAlias(t: DTypeAlias) = contentBuilder.contentFor(t) { - header(1) { text(t.name) } - +buildSignature(t) + group(kind = ContentKind.Cover) { + header(1) { text(t.name) } + +buildSignature(t) + } +contentForComments(t) } diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt index 74d0011f..d9a78d0d 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt @@ -39,7 +39,7 @@ open class PageContentBuilder( ): ContentGroup = DocumentableContentBuilder(d.dri, platformData, styles, extra) .apply(block) - .build(d.platformData.toSet(), kind, styles, extra) + .build(platformData, kind, styles, extra) @ContentBuilderMarker open inner class DocumentableContentBuilder( @@ -123,12 +123,12 @@ open class PageContentBuilder( extra: PropertyContainer<ContentNode> = mainExtra, operation: DocumentableContentBuilder.() -> List<ContentGroup> ) { - contents += ContentTable( - emptyList(), - operation(), - DCI(setOf(mainDRI), kind), - platformData, styles, extra - ) + contents += ContentTable( + emptyList(), + operation(), + DCI(setOf(mainDRI), kind), + platformData, styles, extra + ) } fun <T : Documentable> block( @@ -148,7 +148,6 @@ open class PageContentBuilder( emptyList(), elements.map { buildGroup(it.dri, it.platformData.toSet(), kind, styles, extra) { - // TODO this will fail operation(it) } }, @@ -244,10 +243,6 @@ open class PageContentBuilder( block: DocumentableContentBuilder.() -> Unit ): ContentGroup = contentFor(dri, platformData, kind, styles, extra, block) - fun breakLine(platformData: Set<PlatformData> = mainPlatformData) { - contents += ContentBreakLine(platformData) - } - fun platformDependentHint( dri: DRI = mainDRI, platformData: Set<PlatformData> = mainPlatformData, @@ -273,8 +268,9 @@ open class PageContentBuilder( fun <T> platformText( value: PlatformDependent<T>, + platforms: Set<PlatformData> = value.keys, transform: (T) -> String - ) = value.entries.forEach { (p, v) -> + ) = value.entries.filter { it.key in platforms }.forEach { (p, v) -> transform(v).takeIf { it.isNotBlank() }?.also { text(it, platformData = setOf(p)) } } } |