Skip to content

Commit

Permalink
misc: disable search and address some accessibility violations (#1154)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis authored Dec 15, 2023
1 parent 1e99683 commit f9d4702
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changes/ef256fac-bada-4c42-8632-577faeac6800.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "ef256fac-bada-4c42-8632-577faeac6800",
"type": "misc",
"description": "Disable search and address accessibility violations in documentation"
}
25 changes: 16 additions & 9 deletions docs/dokka-presets/css/aws-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,10 @@
outline-offset: 2px; /* Space between the outline and the button */
}

#pages-search {
margin: 0;
padding-top: 10px;
}

#pages-search:focus {
outline: revert;
}

#pages-search-label {
display: none;
}

/* copied from Dokka except for background-color attribute */
.navigation {
display: flex;
Expand All @@ -48,3 +39,19 @@

z-index: 4;
}

/* Styles for section tabs like "Types" and "Functions" */
.section-tab:focus, .section-tab:active {
outline: 2px solid var(--active-tab-border-color); /* The color appears unresolved, but it is defined in Dokka style sheets */
}

/*
Dokka does not break links or code blocks properly by default. Add word-wrap to prevent left/right scrollbar from
appearing on small screens.
*/
.main-content a:not([data-name]) {
word-wrap: break-word;
}
.symbol {
overflow-wrap: break-word;
}
2 changes: 0 additions & 2 deletions docs/dokka-presets/templates/includes/header.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
</div>
<div class="navigation-controls">
<button class="navigation-controls--btn navigation-controls--theme" id="theme-toggle-button" type="button">switch theme</button>
<label for="pages-search" id="pages-search-label">Search</label>
<div class="navigation-controls--btn navigation-controls--search" id="searchBar" role="button">search in API</div>
</div>
</nav>
</#macro>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package aws.sdk.kotlin.dokka

import aws.sdk.kotlin.dokka.transformers.FilterInternalApis
import aws.sdk.kotlin.dokka.transformers.NoOpSearchbarDataInstaller
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.plugability.DokkaPlugin
import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
Expand All @@ -25,6 +26,12 @@ class AwsDokkaPlugin : DokkaPlugin() {
dokkaBase.preMergeDocumentableTransformer providing ::FilterInternalApis
}

// FIXME Re-enable search once Dokka addresses performance issues
// https://github.com/Kotlin/dokka/issues/2741
val disableSearch by extending {
dokkaBase.htmlPreprocessors providing ::NoOpSearchbarDataInstaller override dokkaBase.baseSearchbarDataInstaller
}

@DokkaPluginApiPreview
override fun pluginApiPreviewAcknowledgement() = PluginApiPreviewAcknowledgement
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

package aws.sdk.kotlin.dokka.transformers

import org.jetbrains.dokka.base.renderers.html.SearchRecord
import org.jetbrains.dokka.base.renderers.html.SearchbarDataInstaller
import org.jetbrains.dokka.pages.DriResolver
import org.jetbrains.dokka.plugability.DokkaContext

/**
* Disable the search bar data (pages.json).
*/
class NoOpSearchbarDataInstaller(context: DokkaContext) : SearchbarDataInstaller(context) {
override fun generatePagesList(pages: List<SignatureWithId>, locationResolver: DriResolver): List<SearchRecord> = listOf()
}

0 comments on commit f9d4702

Please sign in to comment.