From af652eb4cdf06b7fba044c0822c3b63a7cd4843c Mon Sep 17 00:00:00 2001 From: Ian Clarke Date: Sat, 24 Jul 2021 10:33:19 -0500 Subject: [PATCH] remove kdoc samples until they can be fixed --- build.gradle | 8 +++ src/main/kotlin/kweb/Element.kt | 6 +-- src/main/kotlin/kweb/WebBrowser.kt | 4 +- .../kotlin/kweb/config/KwebConfiguration.kt | 50 ++----------------- .../plugins/jqueryCore/JQueryCorePlugin.kt | 2 +- src/main/kotlin/kweb/prelude.kt | 6 +-- src/main/kotlin/kweb/routing/routing.kt | 2 +- src/main/kotlin/kweb/state/render.kt | 4 +- src/main/kotlin/kweb/table.kt | 4 +- 9 files changed, 26 insertions(+), 60 deletions(-) diff --git a/build.gradle b/build.gradle index 02cc2ada55..f76ff5113a 100755 --- a/build.gradle +++ b/build.gradle @@ -110,3 +110,11 @@ shadowJar { } mergeServiceFiles() } + +dokkaHtml { + dokkaSourceSets { + configureEach { + samples.from(files("src/main/kotlin/samples.kt")) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/kweb/Element.kt b/src/main/kotlin/kweb/Element.kt index 707a6a3ce2..39d5bba059 100644 --- a/src/main/kotlin/kweb/Element.kt +++ b/src/main/kotlin/kweb/Element.kt @@ -483,7 +483,7 @@ open class Element( * Return a KVar that is tied to a property related to an element, which will update when an specified * event fires on this element. This is a convenience wrapper around [bind]. * - * @sample kweb.InputElement.checked + * // @sample kweb.InputElement.checked * * @param accessor Function that takes an element id and returns a JavaScript expression to access that element * @param updateOnEvent The event to listen for that signifies this element has been updated @@ -497,7 +497,7 @@ open class Element( * Return a KVar that is tied to a property related to an element, which will update when an specified * event fires on this element. * - * @sample kweb.InputElement.checked + * // @sample kweb.InputElement.checked * * @param reader Function that takes an element id and returns a JavaScript expression to read that element * @param writer Function that takes an element id and a new value, and returns a JavaScript expression to @@ -573,7 +573,7 @@ open class Element( * @param preventDefault Whether [preventDefault()](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) * will be called on the event object. * - * @sample kweb.ValueElement.getValue + * // @sample kweb.ValueElement.getValue */ fun on(retrieveJs: String? = null, preventDefault: Boolean = false) = OnReceiver(this, retrieveJs, preventDefault) diff --git a/src/main/kotlin/kweb/WebBrowser.kt b/src/main/kotlin/kweb/WebBrowser.kt index 2a9e5c59d2..8254e1f122 100755 --- a/src/main/kotlin/kweb/WebBrowser.kt +++ b/src/main/kotlin/kweb/WebBrowser.kt @@ -149,7 +149,7 @@ class WebBrowser(private val sessionId: String, val httpRequestInfo: HttpRequest * If your JavaScript needs to use an empty JavaScript map, just insert a space * between the {}s, eg. `{ }` * - * @sample kweb.callJsFunction_sample + * // @sample kweb.callJsFunction_sample */ fun callJsFunction(jsBody: String, vararg args: JsonElement) { val functionCall = if (cachedFunctions[jsBody] != null) { @@ -185,7 +185,7 @@ class WebBrowser(private val sessionId: String, val httpRequestInfo: HttpRequest } } - fun callJsFunction_sample() { + private fun callJsFunction_sample() { callJsFunction("alert({});", JsonPrimitive("Hello, I'm an alert box!")) } diff --git a/src/main/kotlin/kweb/config/KwebConfiguration.kt b/src/main/kotlin/kweb/config/KwebConfiguration.kt index 1bb593477b..73ae0fef23 100644 --- a/src/main/kotlin/kweb/config/KwebConfiguration.kt +++ b/src/main/kotlin/kweb/config/KwebConfiguration.kt @@ -48,65 +48,23 @@ abstract class KwebConfiguration { * Override the default robots.txt behavior, which is to return with a 404. Passed a Ktor [ApplicationCall] * which may be used to return whatever you wish. * - * @sample kweb.config.KwebConfiguration.robots_txt_sample + * // @sample robots_txt_sample */ open suspend fun robotsTxt(call: ApplicationCall) { call.response.status(HttpStatusCode.NotFound) call.respondText("robots.txt has not been specified)") } - fun robots_txt_sample() { - val config = object : KwebDefaultConfiguration() { - override suspend fun robotsTxt(call: ApplicationCall) { - call.respondText( - ContentType("text", "plain"), - HttpStatusCode.OK - ) { - """ - User-agent: Googlebot - Disallow: /nogooglebot/ - - User-agent: * - Allow: / - - """.trimIndent() - } - } - } - Kweb(port = 1245, kwebConfig = config) { - // ... - } - } - /** - * Override the default favicon.ico behavior, which is to return with a 404. Passed a Ktor [ApplicationCall] + * Override the default robots.txt behavior, which is to return with a 404. Passed a Ktor [ApplicationCall] * which may be used to return whatever you wish. * - * @sample kweb.config.KwebConfiguration.favicon_sample - **/ + * // @sample favicon_sample + */ open suspend fun faviconIco(call: ApplicationCall) { call.respondText("favicons not currently supported by kweb", status = HttpStatusCode.NotFound) } - fun favicon_sample() { - // We should cache faviconBytes rather than re-loading for every function call - val faviconBytes = this::class.java.getResourceAsStream("favicon.ico")!!.readAllBytes() - val config = object : KwebDefaultConfiguration() { - override suspend fun faviconIco(call: ApplicationCall) { - call.respondBytes( - // Here the favicon.ico file is read from a resource - faviconBytes, - ContentType("image", "x-icon"), - status = HttpStatusCode.OK - ) - } - } - - Kweb(port = 1245, kwebConfig = config) { - // ... - } - } - protected object Accessor { private val env = System.getenv() diff --git a/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt b/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt index f39fa5162c..d9dd1c7f27 100755 --- a/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt +++ b/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt @@ -29,7 +29,7 @@ val jqueryCore = JQueryCorePlugin() /** * Selects the element based on id, then executes the provided js * - * @sample table().executeOnSelf(".tablesort()") + * // @sample table().executeOnSelf(".tablesort()") */ fun Element.executeOnSelf(js: String) { callJsFunction("$('#' + {})$js", id.json) diff --git a/src/main/kotlin/kweb/prelude.kt b/src/main/kotlin/kweb/prelude.kt index 4df545b1a4..f51e886ae0 100644 --- a/src/main/kotlin/kweb/prelude.kt +++ b/src/main/kotlin/kweb/prelude.kt @@ -395,7 +395,7 @@ class SelectElement(parent: Element) : ValueElement(parent, kvarUpdateEvent = "c /** * [