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

Styles feedback #1529

Merged
merged 1 commit into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const NavigationPaneSearch = () => {
setFilterValue('')
}

const shouldShowPopup = (filterState: string): boolean => {
return filterState.trim().length !== 0
}

useEffect(() => {
const pathToRoot = (window as IWindow).pathToRoot
const url = pathToRoot.endsWith('/') ? `${pathToRoot}scripts/navigation-pane.json` : `${pathToRoot}/scripts/navigation-pane.json`
Expand Down Expand Up @@ -60,6 +64,7 @@ export const NavigationPaneSearch = () => {
popupClassName={"navigation-pane-popup"}
onSelect={onChangeSelected}
onFilter={onFilter}
shouldShowPopup={shouldShowPopup}
renderOptimization={false}
/>
<span className={"paneSearchInputClearIcon"} onClick={onClearClick}><ClearIcon /></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ export class DokkaFuzzyFilterComponent extends Select {
})
}
}

_showPopup(){
if(this.props.shouldShowPopup){
if (!this.node) {
return;
}

const shownData = this.getListItems(this.filterValue());
this.setState({
showPopup: this.props.shouldShowPopup(this.filterValue()),
shownData
})
} else {
super._showPopup()
}
}

getListItems(rawFilterString: string, _: Option[]) {
const filterPhrase = (rawFilterString ? rawFilterString : '').trim()
Expand Down
181 changes: 127 additions & 54 deletions plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.jetbrains.dokka.plugability.query
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.utilities.htmlEscape
import org.jetbrains.dokka.utilities.urlEncoded
import java.io.File
import java.net.URI

open class HtmlRenderer(
Expand Down Expand Up @@ -278,12 +277,8 @@ open class HtmlRenderer(
val content = contentsForSourceSetDependent(divergentForPlatformDependent, pageContext)

consumer.onTagContentUnsafe {
+createHTML().div("brief-with-platform-tags") {
consumer.onTagContentUnsafe {
+createHTML().div("inner-brief-with-platform-tags") {
consumer.onTagContentUnsafe { +it.key.first }
}
}
+createHTML().div("with-platform-tags") {
consumer.onTagContentUnsafe { +it.key.first }

consumer.onTagContentUnsafe {
+createHTML().span("pull-right") {
Expand All @@ -296,7 +291,7 @@ open class HtmlRenderer(
}
}
}
div("main-subrow") {
div {
if (node.implicitlySourceSetHinted) {
buildPlatformDependent(divergentForPlatformDependent, pageContext)
} else {
Expand Down Expand Up @@ -366,64 +361,141 @@ open class HtmlRenderer(
.filter { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }
.takeIf { it.isNotEmpty() }
?.let {
val anchorName = node.dci.dri.first().anchor
withAnchor(anchorName) {
div(classes = "table-row") {
if (!style.contains(MultimoduleTable)) {
attributes["data-filterable-current"] = node.sourceSets.joinToString(" ") {
it.sourceSetIDs.merged.toString()
}
attributes["data-filterable-set"] = node.sourceSets.joinToString(" ") {
it.sourceSetIDs.merged.toString()
}
}
when (pageContext) {
is MultimoduleRootPage -> buildRowForMultiModule(node, it, pageContext, sourceSetRestriction, style)
is ModulePage -> buildRowForModule(node, it, pageContext, sourceSetRestriction, style)
else -> buildRowForContent(node, it, pageContext, sourceSetRestriction, style)
}
}
}

it.filterIsInstance<ContentLink>().takeIf { it.isNotEmpty() }?.let {
div("main-subrow " + node.style.joinToString(" ")) {
it.filter { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }
.forEach {
span {
it.build(this, pageContext, sourceSetRestriction)
buildAnchor(anchorName)
}
if (ContentKind.shouldBePlatformTagged(node.dci.kind) && (node.sourceSets.size == 1 || pageContext is ModulePage))
createPlatformTags(node)
}
private fun FlowContent.buildRowForMultiModule(
contextNode: ContentGroup,
toRender: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?,
style: Set<Style>
) {
val anchorName = contextNode.dci.dri.first().anchor
withAnchor(anchorName) {
div(classes = "table-row") {
div("main-subrow " + contextNode.style.joinToString(separator = " ")) {
buildRowHeaderLink(toRender, pageContext, sourceSetRestriction, anchorName, "w-100")
div {
buildRowBriefSectionForDocs(toRender, pageContext, sourceSetRestriction)
}
}
}
}
}

private fun FlowContent.buildRowForModule(
contextNode: ContentGroup,
toRender: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?,
style: Set<Style>
) {
val anchorName = contextNode.dci.dri.first().anchor
withAnchor(anchorName) {
div(classes = "table-row") {
addSourceSetFilteringAttributes(contextNode)
div {
div("main-subrow " + contextNode.style.joinToString(separator = " ")) {
buildRowHeaderLink(toRender, pageContext, sourceSetRestriction, anchorName)
div("pull-right") {
if (ContentKind.shouldBePlatformTagged(contextNode.dci.kind)) {
createPlatformTags(contextNode, cssClasses = "no-gutters")
}
}
}
div {
buildRowBriefSectionForDocs(toRender, pageContext, sourceSetRestriction)
}
}
}
}
}

it.filter { it !is ContentLink }.takeIf { it.isNotEmpty() }?.let {
if (pageContext is ModulePage || pageContext is MultimoduleRootPage) {
private fun FlowContent.buildRowForContent(
contextNode: ContentGroup,
toRender: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?,
style: Set<Style>
) {
val anchorName = contextNode.dci.dri.first().anchor
withAnchor(anchorName) {
div(classes = "table-row") {
addSourceSetFilteringAttributes(contextNode)
div("main-subrow keyValue " + contextNode.style.joinToString(separator = " ")) {
buildRowHeaderLink(toRender, pageContext, sourceSetRestriction, anchorName)
div {
toRender.filter { it !is ContentLink && !it.hasStyle(ContentStyle.RowTitle)}.takeIf { it.isNotEmpty() }?.let {
if (ContentKind.shouldBePlatformTagged(contextNode.dci.kind) && contextNode.sourceSets.size == 1)
createPlatformTags(contextNode)

div("title") {
it.forEach {
span(classes = if (it.dci.kind == ContentKind.Comment) "brief-comment" else "") {
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)
}
}
it.build(this, pageContext, sourceSetRestriction)
}
}
}
}
}
}
}
}

private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DisplaySourceSet>) {
private fun FlowContent.buildRowHeaderLink(
toRender: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?,
anchorName: String,
classes: String = ""
) {
toRender.filter { it is ContentLink || it.hasStyle(ContentStyle.RowTitle) }.takeIf { it.isNotEmpty() }?.let {
div(classes) {
it.filter { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }
.forEach {
span("inline-flex") {
it.build(this, pageContext, sourceSetRestriction)
if(it is ContentLink) buildAnchor(anchorName)
}
}
}
}
}

private fun FlowContent.addSourceSetFilteringAttributes(
contextNode: ContentGroup,
) {
attributes["data-filterable-current"] = contextNode.sourceSets.joinToString(" ") {
it.sourceSetIDs.merged.toString()
}
attributes["data-filterable-set"] = contextNode.sourceSets.joinToString(" ") {
it.sourceSetIDs.merged.toString()
}
}

private fun FlowContent.buildRowBriefSectionForDocs(
toRender: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?,
){
toRender.filter { it !is ContentLink }.takeIf { it.isNotEmpty() }?.let {
it.forEach {
span(classes = if (it.dci.kind == ContentKind.Comment) "brief-comment" else "") {
it.build(this, pageContext, sourceSetRestriction)
}
}
}
}

private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DisplaySourceSet>, cssClasses: String = "") {
if (shouldRenderSourceSetBubbles) {
div("platform-tags") {
sourceSets.forEach {
div("platform-tags " + cssClasses) {
sourceSets.sortedBy { it.name }.forEach {
div("platform-tag") {
when (it.platform.key) {
"common" -> classes = classes + "common-like"
Expand All @@ -440,12 +512,13 @@ open class HtmlRenderer(

private fun FlowContent.createPlatformTags(
node: ContentNode,
sourceSetRestriction: Set<DisplaySourceSet>? = null
sourceSetRestriction: Set<DisplaySourceSet>? = null,
cssClasses: String = ""
) {
node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let {
createPlatformTagBubbles(node.sourceSets.filter {
sourceSetRestriction == null || it in sourceSetRestriction
})
}.sortedBy { it.name }, cssClasses)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
contentBuilder.contentFor(
e,
ContentKind.Symbol,
setOf(TextStyle.Monospace, TextStyle.Block) + e.stylesIfDeprecated(it),
setOf(TextStyle.Monospace) + e.stylesIfDeprecated(it),
sourceSets = setOf(it)
) {
group(styles = setOf(TextStyle.Block)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ open class DefaultPageCreator(

link(it.name, it.dri)
if (it.sourceSets.size == 1 || (documentations.isNotEmpty() && haveSameContent)) {
documentations.first()?.let { firstSentenceComment(kind = ContentKind.Comment, content = it) }
documentations.first()?.let { firstSentenceComment(kind = ContentKind.Comment, content = it.root) }
}
}
}
Expand Down Expand Up @@ -169,8 +169,8 @@ open class DefaultPageCreator(
) {
link(it.name, it.dri, kind = ContentKind.Main)
sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependentHint) {
contentForBrief(it)
+buildSignature(it)
contentForBrief(it)
}
}
s.safeAs<WithExtraProperties<Documentable>>()?.let { it.extra[InheritorsInfo] }?.let { inheritors ->
Expand Down Expand Up @@ -206,8 +206,8 @@ open class DefaultPageCreator(
group(kind = ContentKind.Cover) {
cover(e.name)
sourceSetDependentHint(e.dri, e.sourceSets.toSet()) {
+contentForDescription(e)
+buildSignature(e)
+contentForDescription(e)
}
}
group(styles = setOf(ContentStyle.TabbedContent)) {
Expand All @@ -226,8 +226,8 @@ open class DefaultPageCreator(
group(kind = ContentKind.Cover, sourceSets = mainSourcesetData + extensions.sourceSets) {
cover(c.name.orEmpty())
sourceSetDependentHint(c.dri, c.sourceSets) {
+contentForDescription(c)
+buildSignature(c)
+contentForDescription(c)
}
}

Expand All @@ -249,8 +249,8 @@ open class DefaultPageCreator(
kind = ContentKind.SourceSetDependentHint,
styles = emptySet()
) {
contentForBrief(it)
+buildSignature(it)
contentForBrief(it)
}
}
}
Expand All @@ -267,8 +267,8 @@ open class DefaultPageCreator(
) {
link(it.name, it.dri)
sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependentHint) {
contentForBrief(it)
+buildSignature(it)
contentForBrief(it)
}
}
}
Expand Down Expand Up @@ -464,7 +464,8 @@ open class DefaultPageCreator(
documentable.sourceSets.forEach { sourceSet ->
documentable.documentation[sourceSet]?.children?.firstOrNull()?.root?.let {
group(sourceSets = setOf(sourceSet), kind = ContentKind.BriefComment) {
comment(it)
if(documentable.hasSeparatePage) firstSentenceComment(it)
else comment(it)
}
}
}
Expand Down Expand Up @@ -495,13 +496,13 @@ open class DefaultPageCreator(
}
divergentGroup(ContentDivergentGroup.GroupID("member")) {
instance(setOf(d.dri), d.sourceSets.toSet()) {
before {
+contentForDescription(d)
+contentForComments(d)
}
divergent(kind = ContentKind.Symbol) {
+buildSignature(d)
}
after {
+contentForDescription(d)
+contentForComments(d)
}
}
}
}
Expand Down Expand Up @@ -535,15 +536,15 @@ open class DefaultPageCreator(
) {
elements.map {
instance(setOf(it.dri), it.sourceSets.toSet(), extra = PropertyContainer.withAll(SymbolAnchorHint)) {
before {
contentForBrief(it)
contentForSinceKotlin(it)
}
divergent {
group {
+buildSignature(it)
}
}
after {
contentForBrief(it)
contentForSinceKotlin(it)
}
}
}
}
Expand All @@ -566,4 +567,7 @@ open class DefaultPageCreator(

private val Documentable.descriptions: SourceSetDependent<Description>
get() = groupedTags.withTypeUnnamed<Description>()

private val Documentable.hasSeparatePage: Boolean
get() = this !is DTypeAlias
}
Loading