Skip to content
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

Update contributing guide with Knit #2634

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ use the following priority check list:

#### 1. Snippets for public API docs

If the snippet is just docs for a public method of a type (as in arguments, return type, or how it should be used from call sites), that should be inlined in the Kdocs of that given method using Dokka. That's done under the actual type file. [Here you have a simple example for `Option` methods](https://github.com/arrow-kt/arrow/blob/11a65faa9eed23182994778fa0ce218b69bfc4ba/modules/core/arrow-core/src/main/kotlin/arrow/core/Option.kt#L14).
If the snippet is just docs for a public method of a type (as in arguments, return type, or how it should be used from call sites), that should be inlined in the Kdocs of that given method using Dokka and annotated with Knit (see above for more details). That's done under the actual type file. Here you have [a simple example for `Option` type](https://github.com/arrow-kt/arrow/blob/8659228f06bb44b2ea42d18b97d3dc0bdf424763/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Option.kt#L19).

That will automatically inline the docs of each method into the docs of the given data type. This is intended to be used just for public APIs exposed to users of the library.

Expand All @@ -104,29 +104,35 @@ Public docs in Arrow follow a particular structure that ensures users have a sim

Declarations including classes, functions, and others must include docs in the following structure:

All Kdocs should include a short header that describes what the data type or function is for and a triple backticks ``` fenced block demonstrating its use
All Kdocs should include a short header that describes what the data type or function is for and a triple backticks ``` fenced block demonstrating its use (ending with an appropriate Knit annotation)

for example

```kotlin
/**
* [Refined] is an Abstract class providing predicate validation in refined types companions.
*
* The example below shows a refined type `Positive` that ensures [Int] is > than 0.
* (...)
*
* `Option<A>` is a container for an optional value of type `A`. If the value of type `A` is present, the `Option<A>` is an instance of `Some<A>`, containing the present value of type `A`. If the value is absent, the `Option<A>` is the object `None`.
*
* ```kotlin
* import arrow.refinement.Refined
* import arrow.refinement.ensure
* import arrow.core.Option
* import arrow.core.Some
* import arrow.core.none
*
* @JvmInline
* value class Positive /* private constructor */ (val value: Int) {
* companion object : Refined<Int, Positive>(::Positive, {
* ensure((it > 0) to "$it should be > 0")
* })
* //sampleStart
* val someValue: Option<String> = Some("I am wrapped in something")
* val emptyValue: Option<String> = none()
* //sampleEnd
* fun main() {
* println("value = $someValue")
* println("emptyValue = $emptyValue")
* }
* ```
*/
abstract class Refined<A, out B>
* <!--- KNIT example-option-01.kt -->
*
* (...)
*/
public sealed class Option<out A> {
```

#### 2. Snippets for broader samples
Expand Down Expand Up @@ -241,10 +247,10 @@ Execution failed for task ':arrow-core:apiCheck'.
+++ /Users/john/projects/arrow/arrow-libs/core/arrow-core/build/api/arrow-core-retrofit.api
```

To make the check pass you need to run:
To make the check pass you need to run the `apiDump` task in the subproject which API you modified (here `arrow-core` as example):

```bash
./gradlew apiDump
./gradlew :arrow-core:apiDump

Choose a reason for hiding this comment

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

Is it not easier to just run apiDump in all projects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe you're right... I just tested on a project without API changes.
The initial run of ./gradlew apiDump took 2 min 13 s on my MacBook.
All the subsequent runs take around 50-55 s, regardless if I run the task on all projects with ./gradlew apiDump or just one subproject with ./gradlew :arrow-core-retrofit:apiDump. This is because Gradle recognizes the task as up-to-date:

> Task :arrow-core-retrofit:compileKotlin UP-TO-DATE
> Task :arrow-core-retrofit:compileJava NO-SOURCE
> Task :arrow-core-retrofit:classes UP-TO-DATE
> Task :arrow-core-retrofit:apiBuild UP-TO-DATE
> Task :arrow-core-retrofit:apiDump UP-TO-DATE

So it's probably better to remove this remark 👍

```

This will generate updated `.api` files which you can then manually review (if the API changes are the ones you intended) and commit and push for the Arrow maintainers to review as well.
Expand Down