i just read about doctests, <https://www.hillelway...
# announcements
c
i just read about doctests, https://www.hillelwayne.com/post/python-doctests/ and it something that i always wanted. executable javadocs/kdocs. can this be added to kotlin?
g
Why should it be added to Kotlin? I think it's work for a some third party tool, that parses kdoc, finds doctest blocks and generates code
3
c
@gildor the format how to write the examples could be standardized, but yeah you are probably right
n
KDoc does have a way to indicate code blocks, eg:
Copy code
```kotlin
// Code goes here ...
```
As Andrey mentioned a separate tool should be developed which handles the code blocks.
g
There is also a project from #C5UPMM0A0 guys called Ank: https://github.com/arrow-kt/ank It allows to verify and evaluate code snippets in documentation. Not exactly the same (no kdoc support as I understand), but pretty close and probably can be extended to test generation Maybe @raulraja or @pguardiola could comment this possible use case. Because code snippet output verification is also sounds like a good feature for Ank
👍 1
Also KDoc supports
@sample
tag, which allows to embed code snippet to documentation and already supports output (not sure about testing of output tho)
r
@gildor kdoc support in ank has been discussed and we agreed that it would be a great feature, but it's a low priority still because we have a pretty big pipeline of important stuff that Arrow still needs to cover before 1.0. Having said that we will support it down the road and potentially use https://github.com/hhariri/mark-code/ for asciidocs too. In general we'd like to abstract away the source and let ank support multiple input/output formats
g
@raulraja But what about snippet output check? Is it already supported by Ank or not?
p
At the moment, it's not supported @gildor We're tracking adding kdocs support in https://github.com/arrow-kt/ank/issues/25 and as @raulraja said eventually we're going to add other formats @christophsturm If you want specifically support for output check please cut a new ticket in the repo and we'll prioritize. In any case, that's a great feature to have 👌 Thanks!
r
@gildor nope but as @pguardiola said we can prioritize that and it should not be hard to implement