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

Add simple examples to Javadoc #2458

Closed
danieldietrich opened this issue Jul 25, 2019 · 6 comments
Closed

Add simple examples to Javadoc #2458

danieldietrich opened this issue Jul 25, 2019 · 6 comments

Comments

@danieldietrich
Copy link
Member

danieldietrich commented Jul 25, 2019

This is an ongoing issue. I would love to see contributions in form of several small PRs that successively add examples to our Javadoc.

The Javadoc should have the following general structure:

/**
 * <text text text>
 *
+* <pre>{@code
+* <example(s)>
+* }</pre>
 *
 * <@annotations>
 */

Example:

/**
    * Consumes the cause if this is a {@link Try.Failure} and the cause is instance of the given {@code exceptionType}.
    *
    * <pre>{@code
    * // (does not print anything)
    * Try.success(1).onFailure(Error.class, System.out::println);
    *
    * // prints "java.lang.Error"
    * Try.failure(new Error()).onFailure(Error.class, System.out::println);
    *
    * // (does not print anything)
    * Try.failure(new Exception()).onFailure(Error.class, System.out::println);
    * }</pre>
    *
    * @param <X>           Exception type
    * @param exceptionType The specific exception type that should be handled
    * @param action        An exception consumer
    * @return this
    * @throws NullPointerException if one of {@code exceptionType} or {@code action} is null
    */
public <X extends Throwable> Try<T> onFailure(Class<X> exceptionType, Consumer<? super Throwable> action) {
    Objects.requireNonNull(exceptionType, "exceptionType is null");
    Objects.requireNonNull(action, "action is null");
    if (isFailure() && exceptionType.isInstance(getCause())) {
        action.accept(getCause());
    }
    return this;
}

Please note that src-gen/**/*.java must not be edited directly. You can either skip these classes or edit generator/Generator.sc instead. Run ./gradlew generateSources to re-generate the code, if you do so.

Please run ./gradlew check && ./gradlew javadoc before submitting your PR.

@FuncGuy
Copy link
Contributor

FuncGuy commented Jul 25, 2019

i'm ready to take this issue but i'm confused from where to start?

@danieldietrich
Copy link
Member Author

danieldietrich commented Jul 25, 2019

@FuncGuy Great! It is meant to be on a fine-grained basis. Just pick methods of your choice. I expect several persons will participate over time! You might do several PRs over time. Thx!

danieldietrich pushed a commit that referenced this issue Jul 25, 2019
danieldietrich pushed a commit that referenced this issue Jul 28, 2019
…2465)

* Added javadoc examples for Either.bimap (#2458)

* Added javadoc examples for Either.fold (#2458)

* Added javadoc examples for Either.traverse (#2458)

* Spacing fixed (#2458)
@FuncGuy
Copy link
Contributor

FuncGuy commented Jul 31, 2019

thanks for adding me to the contributor list.

@danieldietrich danieldietrich added this to the v1.0.0 milestone Aug 2, 2019
@pepijno
Copy link
Contributor

pepijno commented Aug 12, 2019

Hi, I would like to contribute. Can I add examples for Option or is someone already working on this?

@thiyagu-7
Copy link
Contributor

Can I work on the Value class?

Happy to work on some other class too (if you have anything specific)

@danieldietrich
Copy link
Member Author

We got many contributions here the last months. I will consider this issue as finished. Documentation is an ongoing task.

thadumi pushed a commit to thadumi/vavr that referenced this issue Dec 11, 2019
thadumi pushed a commit to thadumi/vavr that referenced this issue Dec 11, 2019
) (vavr-io#2465)

* Added javadoc examples for Either.bimap (vavr-io#2458)

* Added javadoc examples for Either.fold (vavr-io#2458)

* Added javadoc examples for Either.traverse (vavr-io#2458)

* Spacing fixed (vavr-io#2458)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants