Skip to content

Commit

Permalink
fix all Scaladocs (except Task's) in monix.eval
Browse files Browse the repository at this point in the history
  • Loading branch information
jozic committed Sep 4, 2018
1 parent 1b61986 commit cd8f212
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 24 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -469,7 +469,7 @@ lazy val executionJS = project.in(file("monix-execution/js"))

lazy val doctestTestSettings = Seq(
doctestTestFramework := DoctestTestFramework.Minitest,
doctestIgnoreRegex := Some("^(?!.*?(?:(Coeval|Fiber))).*$"),
doctestIgnoreRegex := Some(s".*Task(|App).scala"),
doctestOnlyCodeBlocksMode := true
)

Expand Down
5 changes: 3 additions & 2 deletions monix-eval/shared/src/main/scala/monix/eval/MVar.scala
Expand Up @@ -73,9 +73,10 @@ abstract class MVar[A] {
* until there is a value available, at which point the operation
* resorts to a [[take]] followed by a [[put]].
*
* This `read` operation is equivalent to:
* This `read` operation is equivalent to a method like this:
* {{{
* for (a <- v.take; _ <- v.put(a)) yield a
* def readMVar[A](v: MVar[A]) =
* for (a <- v.take; _ <- v.put(a)) yield a
* }}}
*
* This operation is not atomic. Being equivalent with a `take`
Expand Down
5 changes: 3 additions & 2 deletions monix-eval/shared/src/main/scala/monix/eval/TaskApp.scala
Expand Up @@ -38,14 +38,15 @@ import monix.execution.Scheduler
* with the numeric value of the signal plus 128.
*
* {{{
* import monix.eval._
* import cats.effect._
* import cats.implicits._
* import monix.eval._
*
* object MyApp extends TaskApp {
* def run(args: List[String]): Task[ExitCode] =
* args.headOption match {
* case Some(name) =>
* Task(println(s"Hello, \${name}.")).as(ExitCode.Success)
* Task(println(s"Hello, \\${name}.")).as(ExitCode.Success)
* case None =>
* Task(System.err.println("Usage: MyApp name")).as(ExitCode(2))
* }
Expand Down
Expand Up @@ -109,15 +109,16 @@ import scala.util.{Failure, Success}
* throw new RuntimeException("dummy")
* }
*
* val task = circuitBreaker.protect(problematic)
* val task = circuitBreaker
* .flatMap(_.protect(problematic))
* }}}
*
* When attempting to close the circuit breaker and resume normal
* operations, we can also apply an exponential backoff for repeated
* failed attempts, like so:
*
* {{{
* val circuitBreaker = TaskCircuitBreaker(
* val exponential = TaskCircuitBreaker(
* maxFailures = 5,
* resetTimeout = 10.seconds,
* exponentialBackoffFactor = 2,
Expand Down Expand Up @@ -535,9 +536,9 @@ object TaskCircuitBreaker {
* when the `Open` state is to transition to [[HalfOpen]].
*
* It is calculated as:
* {{{
* ```scala
* startedAt + resetTimeout.toMillis
* }}}
* ```
*/
val expiresAt: Timestamp = startedAt + resetTimeout.toMillis
}
Expand Down
10 changes: 5 additions & 5 deletions monix-eval/shared/src/main/scala/monix/eval/TaskLike.scala
Expand Up @@ -20,7 +20,7 @@ package monix.eval
import cats.Eval
import cats.effect.{ConcurrentEffect, Effect, IO, SyncIO}
import scala.annotation.implicitNotFound
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.Future
import scala.util.Try

/** A lawless type class that provides conversions to [[Task]].
Expand All @@ -31,13 +31,13 @@ import scala.util.Try
* import cats.Eval
*
* val source0 = Eval.always(1 + 1)
* val task0 = TaskLike[Eval].toTask(source)
* val task0 = TaskLike[Eval].toTask(source0)
*
* // Conversion from Future
* import scala.concurrent.Future
*
* val source1 = Future(1 + 1)
* val task1 = TaskLike[Future].toTask(source)
* val source1 = Future.successful(1 + 1)
* val task1 = TaskLike[Future].toTask(source1)
*
* // Conversion from IO
* import cats.effect.IO
Expand Down Expand Up @@ -79,7 +79,7 @@ object TaskLike extends TaskLikeImplicits0 {
/**
* Converts to `Task` from [[scala.concurrent.Future]].
*/
implicit def fromFuture(implicit ec: ExecutionContext): TaskLike[Future] =
implicit val fromFuture: TaskLike[Future] =
new TaskLike[Future] {
def toTask[A](fa: Future[A]): Task[A] =
Task.fromFuture(fa)
Expand Down
18 changes: 11 additions & 7 deletions monix-eval/shared/src/main/scala/monix/eval/TaskLocal.scala
Expand Up @@ -38,7 +38,10 @@ import monix.execution.misc.Local
* a single call is sufficient just before `runAsync`:
*
* {{{
* task.executeWithOptions(_.enableLocalContextPropagation)
* import monix.execution.Scheduler.Implicits.global
*
* val t = Task(42)
* t.executeWithOptions(_.enableLocalContextPropagation)
* // triggers the actual execution
* .runAsync
* }}}
Expand All @@ -48,21 +51,22 @@ import monix.execution.misc.Local
* and specify the set of options implicitly:
*
* {{{
* implicit val opts = Task.defaultOptions.enableLocalContextPropagation
* {
* implicit val options = Task.defaultOptions.enableLocalContextPropagation
*
* // Options passed implicitly
* val f = task.runAsyncOpt
* // Options passed implicitly
* val f = t.runAsyncOpt
* }
* }}}
*
* Full example:
*
* {{{
* import monix.eval.{Task, TaskLocal}
*
* val local = TaskLocal(0)
*
* val task: Task[Unit] =
* for {
* local <- TaskLocal(0)
* value1 <- local.read // value1 == 0
* _ <- local.write(100)
* value2 <- local.read // value2 == 100
Expand Down Expand Up @@ -90,7 +94,7 @@ import monix.execution.misc.Local
* implicit val opts = Task.defaultOptions.enableLocalContextPropagation
*
* // Triggering actual execution
* val f = task.runAsyncOpt
* val result = task.runAsyncOpt
* }}}
*/
final class TaskLocal[A] private (default: => A) {
Expand Down
Expand Up @@ -29,13 +29,17 @@ import monix.execution.schedulers.TrampolinedRunnable
* maximum parallelism of 10:
*
* {{{
* case class HttpRequest()
* case class HttpResponse()
*
* val semaphore = TaskSemaphore(maxParallelism = 10)
*
* def makeRequest(r: HttpRequest): Task[HttpResponse] = ???
*
* // For such a task no more than 10 requests
* // are allowed to be executed in parallel.
* val task = semaphore.greenLight(makeRequest(???))
* val task = semaphore
* .flatMap(_.greenLight(makeRequest(???)))
* }}}
*/
final class TaskSemaphore private (maxParallelism: Int) extends Serializable {
Expand Down
Expand Up @@ -84,6 +84,10 @@ private[eval] abstract class TaskBinCompat[+A] { self: Task[A] =>
* redundant, as it can be expressed with `flatMap`, with the
* same effect:
* {{{
* import monix.eval.Task
*
* val trigger = Task(println("do it"))
* val task = Task(println("must be done now"))
* trigger.flatMap(_ => task)
* }}}
*
Expand All @@ -108,6 +112,10 @@ private[eval] abstract class TaskBinCompat[+A] { self: Task[A] =>
* with the same effect:
*
* {{{
* import monix.eval.Task
*
* val task = Task(5)
* val selector = (n: Int) => Task(n.toString)
* task.flatMap(a => selector(a).map(_ => a))
* }}}
*/
Expand Down Expand Up @@ -145,9 +153,9 @@ private[eval] abstract class TaskBinCompat[+A] { self: Task[A] =>

/** DEPRECATED - replace with usage of [[Task.runSyncMaybe]]:
*
* {{{
* ```scala
* task.coeval <-> Coeval(task.runSyncMaybe)
* }}}
* ```
*/
@deprecated("Replaced with start", since="3.0.0-RC2")
final def coeval(implicit s: Scheduler): Coeval[Either[CancelableFuture[A], A]] = {
Expand Down

0 comments on commit cd8f212

Please sign in to comment.