Skip to content

Commit

Permalink
Disable copy button for signatures (#2577)
Browse files Browse the repository at this point in the history
* Disable copy button for signatures
  • Loading branch information
IgnatBeresnev committed Jul 27, 2022
1 parent 838ec1b commit f4d2bf4
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 92 deletions.
7 changes: 3 additions & 4 deletions plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
Expand Up @@ -95,7 +95,6 @@ open class HtmlRenderer(
}
node.dci.kind in setOf(ContentKind.Symbol) -> div("symbol $additionalClasses") {
childrenCallback()
if (node.hasStyle(TextStyle.Monospace)) copyButton()
}
node.hasStyle(TextStyle.BreakableAfter) -> {
span { childrenCallback() }
Expand Down Expand Up @@ -472,9 +471,9 @@ open class HtmlRenderer(
div {
it.build(this, pageContext, sourceSetRestriction)
}
if (it is ContentLink && !anchorDestination.isNullOrBlank()) buildAnchorCopyButton(
anchorDestination
)
if (it is ContentLink && !anchorDestination.isNullOrBlank()) {
buildAnchorCopyButton(anchorDestination)
}
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions plugins/base/src/main/resources/dokka/styles/style.css
Expand Up @@ -341,15 +341,15 @@ code.paragraph {
cursor: pointer;
}

.symbol span.copy-icon, .sample-container span.copy-icon {
.sample-container span.copy-icon {
display: none;
}

.symbol:hover span.copy-icon, .sample-container:hover span.copy-icon {
.sample-container:hover span.copy-icon {
display: inline-block;
}

.symbol span.copy-icon::before, .sample-container span.copy-icon::before {
.sample-container span.copy-icon::before {
width: 24px;
height: 24px;
display: inline-block;
Expand All @@ -362,7 +362,7 @@ code.paragraph {
background-color: var(--copy-icon-color);
}

.symbol span.copy-icon:hover::before, .sample-container span.copy-icon:hover::before {
.sample-container span.copy-icon:hover::before {
background-color: var(--copy-icon-hover-color);
}

Expand Down Expand Up @@ -399,7 +399,6 @@ code.paragraph {
left: -15em;
}

.symbol:hover .copy-popup-wrapper.active-popup,
.sample-container:hover .copy-popup-wrapper.active-popup {
display: flex !important;
}
Expand Down
Expand Up @@ -58,7 +58,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": (", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": (", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -77,7 +77,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": (", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": (", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -96,7 +96,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -115,7 +115,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": (param: ", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": (param: ", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -141,7 +141,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
"fun <", A("T"), "> ",
A("f"), "(): (param1:", A("T"),
", param2: ", Span("@", A("Fancy")), " () -> ", A("Unit"),
") -> ", A("String"), Span(),
") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -160,7 +160,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -179,7 +179,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": suspend (", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -198,7 +198,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": suspend ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": suspend ", A("Boolean"), ".(", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -217,7 +217,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").firstSignature().match(
"val ", A("nF"), ": suspend (param: ", A("Int"), ") -> ", A("String"), Span(),
"val ", A("nF"), ": suspend (param: ", A("Int"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -249,8 +249,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
A("Boolean"),
") -> ",
A("String"),
Span(),
ignoreSpanWithTokenStyle = true
ignoreSpanWithTokenStyle = true
)
}
}
Expand All @@ -275,7 +274,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-java-class/index.html").lastSignature().match(
"open var ", A("javaFunction"), ": (", A("Integer"), ") -> ", A("String"), Span(),
"open var ", A("javaFunction"), ": (", A("Integer"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -301,7 +300,7 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/-java-class/index.html").lastSignature().match(
"open var ", A("kotlinFunction"), ": (", A("Integer"), ") -> ", A("String"), Span(),
"open var ", A("kotlinFunction"), ": (", A("Integer"), ") -> ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down
Expand Up @@ -54,7 +54,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[2]
property.match(
"var ", A("a"), ":", A("Int"), Span(),
"var ", A("a"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -68,7 +68,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[1]
property.match(
"open var ", A("a"), ":", A("Int"), Span(),
"open var ", A("a"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[2]
property.match(
"val ", A("a"), ":", A("Int"), Span(),
"val ", A("a"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -113,7 +113,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[1]
property.match(
"open val ", A("a"), ":", A("Int"), Span(),
"open val ", A("a"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -149,7 +149,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
setterFunction.match(
"open fun ", A("setA"), "(", Parameters(
Parameter("a: ", A("Int"))
), ")", Span(),
), ")",
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -162,7 +162,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {
setterFunction.match(
"open fun ", A("setA"), "(", Parameters(
Parameter("a: ", A("Int"))
), ")", Span(),
), ")",
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -199,21 +199,21 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val getterLookalikeFunction = signatures[2]
getterLookalikeFunction.match(
"open fun ", A("getA"), "():", A("Int"), Span(),
"open fun ", A("getA"), "():", A("Int"),
ignoreSpanWithTokenStyle = true
)

val setterLookalikeFunction = signatures[3]
setterLookalikeFunction.match(
"open fun ", A("setA"), "(", Parameters(
Parameter("a: ", A("Int"))
), ")", Span(),
), ")",
ignoreSpanWithTokenStyle = true
)

val property = signatures[4]
property.match(
"var ", A("a"), ":", A("Int"), Span(),
"var ", A("a"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -245,7 +245,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[1]
property.match(
"open var ", A("variable"), ": ", Span("String"), Span(),
"open var ", A("variable"), ": ", Span("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -280,7 +280,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[2]
property.match(
"var ", A("variable"), ": ", A("String"), Span(),
"var ", A("variable"), ": ", A("String"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -294,15 +294,15 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val getter = signatures[1]
getter.match(
"fun ", A("getVariable"), "(): ", Span("String"), Span(),
"fun ", A("getVariable"), "(): ", Span("String"),
ignoreSpanWithTokenStyle = true
)

val setter = signatures[2]
setter.match(
"fun ", A("setVariable"), "(", Parameters(
Parameter("value: ", Span("String"))
), ")", Span(),
), ")",
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -360,7 +360,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[2]
property.match(
"protected var ", A("protectedGetterAndProtectedSetter"), ":", A("Int"), Span(),
"protected var ", A("protectedGetterAndProtectedSetter"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand All @@ -371,7 +371,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[1]
property.match(
"protected open var ", A("protectedGetterAndProtectedSetter"), ":", A("Int"), Span(),
"protected open var ", A("protectedGetterAndProtectedSetter"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down Expand Up @@ -421,7 +421,7 @@ class InheritedAccessorsSignatureTest : BaseAbstractTest() {

val property = signatures[2]
property.match(
"protected var ", A("protectedProperty"), ":", A("Int"), Span(),
"protected var ", A("protectedProperty"), ":", A("Int"),
ignoreSpanWithTokenStyle = true
)
}
Expand Down

0 comments on commit f4d2bf4

Please sign in to comment.