Skip to content

Update Flow.sample KDoc example timings, add tests #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2020

Conversation

elizarov
Copy link
Contributor

  • All Flow.debounce/sample KDoc example code snippets are automatically tested with Knit.
  • Flow.sample timings are made larger, so that they produce an expected output when run under the real time, too.

Fixes #2243

* All Flow.debounce/sample KDoc example code snippets are automatically tested with Knit.
* Flow.sample timings are made larger, so that they produce an expected output when run under the real time, too.

Fixes #2243
Copy link
Collaborator

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition to the Knit!

My comments regarding Knit tag in .kt files are not blockers and can be done later, it's up to you

@@ -33,7 +50,14 @@ import kotlin.time.*
* emit(5)
* }.debounce(1000)
* ```
* produces `3, 4, 5`.
* <!--- KNIT example-delay-01.kt -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if these tests could be numbered automatically without interfering with the source.
In general, I do no mind having Knit-specific directives in our markdown, but this documentation will likely be read from the IDEA rather than from a webpage with processed markdown, so reducing the number of MD tags would be nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are automatically numbered. When writing those directives you can use any number or even just a placeholder like <!--- KNIT example-delay-num.kt --> and when you run gradlew knit it will renumber them sequentially and will update the corresponding source files.

@@ -14,13 +14,30 @@ import kotlinx.coroutines.selects.*
import kotlin.jvm.*
import kotlin.time.*

/* Scaffolding for Knit code examples
<!--- TEST_NAME FlowDelayTest -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, would be nice to hide it in an external file

Copy link
Contributor Author

@elizarov elizarov Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That would be a nice addition. Created Kotlin/kotlinx-knit#18 and Kotlin/kotlinx-knit#19

@elizarov elizarov merged commit b97ebfc into develop Oct 8, 2020
@elizarov elizarov deleted the flow-sample-doc branch October 8, 2020 13:04
recheej pushed a commit to recheej/kotlinx.coroutines that referenced this pull request Dec 28, 2020
* All Flow.debounce/sample KDoc example code snippets are automatically tested with Knit.
* Flow.sample timings are made larger, so that they produce an expected output when run under the real time, too.

Fixes Kotlin#2243
recheej pushed a commit to recheej/kotlinx.coroutines that referenced this pull request Dec 28, 2020
* All Flow.debounce/sample KDoc example code snippets are automatically tested with Knit.
* Flow.sample timings are made larger, so that they produce an expected output when run under the real time, too.

Fixes Kotlin#2243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants