{"id":24769566,"url":"https://github.com/slava0135/doktest","last_synced_at":"2026-05-03T19:35:04.074Z","repository":{"id":139417081,"uuid":"584674579","full_name":"Slava0135/doktest","owner":"Slava0135","description":"The Gradle plugin that verifies your Kotlin code inside KDoc comments.","archived":false,"fork":false,"pushed_at":"2023-06-10T08:03:15.000Z","size":224,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T19:45:18.776Z","etag":null,"topics":["docs","doctest","gradle","gradle-plugin","kdoc","kotlin","testing"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Slava0135.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-03T08:14:37.000Z","updated_at":"2023-05-05T10:13:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"9a0f39a0-3b82-4e3e-8a1b-7749830a0635","html_url":"https://github.com/Slava0135/doktest","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Slava0135/doktest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slava0135%2Fdoktest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slava0135%2Fdoktest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slava0135%2Fdoktest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slava0135%2Fdoktest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Slava0135","download_url":"https://codeload.github.com/Slava0135/doktest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Slava0135%2Fdoktest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32582841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docs","doctest","gradle","gradle-plugin","kdoc","kotlin","testing"],"created_at":"2025-01-29T03:00:15.558Z","updated_at":"2026-05-03T19:35:04.069Z","avatar_url":"https://github.com/Slava0135.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Doktest Plugin for Gradle\n\n[![Run Tests](https://github.com/Slava0135/doktest/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Slava0135/doktest/actions/workflows/test.yml)\n\nThe plugin that verifies your Kotlin code inside KDoc comments.\n\n[**Also check out Intellij IDEA plugin!**](https://plugins.jetbrains.com/plugin/21791-doktest)\n\n## About\n\nSometimes you want to add samples into documention for your code.\n\nKDoc allows you to use special `@sample` tag that inserts linked code into comment.\n\nHowever there are few problems with this approach:\n\n- There is a [bug](https://youtrack.jetbrains.com/issue/KTIJ-8414) in Intellij IDEA because of which you can't see samples in documentation for libraries (even for standard one!)\n- Samples are always put in the end of comment, limiting your freedom in expressing yourself\n\nOther approach would be using \"code blocks\" markdown syntax like this:\n\n```kotlin\n/**\n * ```\n * your sample goes here\n * ```\n */\nfun foo() { ...\n```\n\nBut there is no way to verify those samples are correct... unless you use this plugin!\n\nBasically, this plugin allows you to write documentation tests (or doctests for short), similar to [Rust](https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html) or [Python](https://docs.python.org/3/library/doctest.html).\n\n## Setup\n\n```kotlin\nplugins {\n    id(\"io.github.slava0135.doktest\") version \"0.1.1\"\n}\n...\ndependencies {\n    testImplementation(kotlin(\"test\"))\n}\n```\n\nYou would also need a testing framework (like JUnit).\n\n## Syntax\n\nTo write a doctest do this:\n\n```kotlin\npackage foo\n...\n/**\n * ```kotlin doctest\n * import bar.*\n * val s = \"faz\"\n * assertEquals(s, faz())\n * ```\n */\nfun faz() = \"faz\"\n```\n\nAnd it will be treated as following code:\n\n```kotlin\nimport kotlin.test.*\nimport foo.*\nimport bar.*\n\nfun main() {\n    val s = \"faz\"\n    assertEquals(s, faz())\n}\n```\n\nYou can use `import` declarations inside samples as normal and they will be inserted in import section as shown.\n\n**NOTE**: only official KDoc style is supported, e.g. all `*` symbols should start on the same column.\n\n```kotlin\n/**\n  * won't work!\n */\n```\n\nThere are 3 options:\n\n- `run` =\u003e (**default**) executes sample as normal test\n- `norun` =\u003e just compiles the sample\n- `nomain` =\u003e the sample code won't be surrounded with \"main\" function (and it won't be executed, unless you write it like test).\n\nTo use them write `doctest:option`:\n\n```kotlin\n/**\n * ```kotlin doctest:nomain\n * your sample goes here\n * ```\n */\n```\n\n## Run\n\nTo verify all samples written using syntax above are correct:\n\n```sh\n./gradlew doktest\n```\n\nThere are also 2 options available for command line:\n\n- `--file` =\u003e only samples from specified file will be tested (doesn't have to be full path - just unambiguous, treated as file suffix without `.kt` extension)\n- `--line` =\u003e only sample on specified line will be tested (use with `--file` option)\n\n```sh\n./gradlew doktest --file foo --line 42\n```\n\nWill test sample from `foo.kt` on line `42` (or will fail if there is no sample to be found)\n\n## Configuration\n\nBy default it uses `JUnit Platform` testing framework for executing samples but you can change this as in any other `Test` task:\n\n```kotlin\ntasks.doktestTest {\n    useJUnitPlatform() // default, you don't need to write this\n}\n```\n\n## Notes\n\nI consider this plugin to be experimental (maybe expect some issues).\n\nFeedback and help would be appreciated!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslava0135%2Fdoktest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslava0135%2Fdoktest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslava0135%2Fdoktest/lists"}