Kotlin / kotlinx.coroutines

Library support for Kotlin coroutines
Apache License 2.0
12.82k stars 1.82k forks source link

Improve the API reference #4133

Open globsterg opened 1 month ago

globsterg commented 1 month ago

Describe the bug

kotlinx-datetime was given new and updated documentation... kotlinx-corotoutines could also benefit from the same treatment.

Provide a Reproducer

Going through the list from kotlinx-datetime (https://github.com/Kotlin/kotlinx-datetime/issues/347):

globsterg commented 1 month ago

If you allow it, I would like to contribute to this myself. I am implementing my own programming language and need to learn more about the real-world asynchronous runtimes before deciding on what the concurrency story will look like, and a deep dive into an existing framework would help me tremendously.

Basically, it's a trade offer.

I receive:

You receive:

The effort I can extend on this is limited to a about one workweek this June. My contribution can be as localized or as extensive as you'd like, given the time constraints. I can also start with some small changes before you decide if you are interested in my output.

qwwdfsad commented 1 month ago

Hey, thanks for filing this!

We were planning to jump on it ourselves (as there is a lot of work to revise all the API entry points), and it's easy to split the work -- esp. taking into account that we are trying to align the documentation approach across the libraries, and thus initially there will be a lot of ping-pong discussions.

We would appreciate your help! We have a constraint, though -- starting from the end of the week, both maintainers will be on vacation, and there will be ~2.5 weeks of radio-silence from us. For more straightforward and lower-levelish APIs (e.g. intrinsic, start coroutine, channels) maybe @fzhinkin might chime in the meantime.

If it works for you, I propose the following:

For inspiration, I suggest looking at https://github.com/Kotlin/kotlinx-datetime/pull/367, and I also would ask you to avoid the @sample tag in coroutines for now -- everything is samplified via inline code blocks.

Even if this is not working, I still appreciate the way you handled and proposed it, thanks!

globsterg commented 1 month ago

Thank you for your response, being open to collaboration, and describing the circumstances in detail.

I've looked through https://github.com/Kotlin/kotlinx-datetime/pull/367, noting both how the documentation proposed in the PR is structured and what questions were raised during the review; I've also browsed through https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/ and familiarized myself with the API entries you have. I will try my best to follow the established form.

The plan you propose does look good! Let's double-check the specifics, then:

Does this sound about right?

In the meantime, I've opened a PR in my own fork (https://github.com/globsterg/kotlinx.coroutines/pull/1/files) where I will keep a mishmash of improvements of small things that I notice as I go.