Skip to content

Commit

Permalink
Remove doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
regiskuckaertz committed Jun 27, 2020
1 parent 5ec40c9 commit 527e055
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 808 deletions.
4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -16,10 +16,6 @@ Building and testing Scanamo
Scanamo uses a standard [SBT](https://www.scala-sbt.org/) build. If you
have SBT installed, you should first run `startDynamodbLocal` task from the SBT prompt to start a local dynamodb instance and afterwards run the `test` command to compile Scanamo and run its tests.

Most, though not all of Scanamo's tests are from examples in the scaladoc,
or `README.md`, which are turned into tests by
[sbt-doctest](https://github.com/tkawachi/sbt-doctest).

Contributing documentation
--------------------------

Expand Down
4 changes: 1 addition & 3 deletions build.sbt
Expand Up @@ -56,9 +56,7 @@ val commonSettings = Seq(
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint"),
scalacOptions := stdOptions ++ extraOptions(scalaVersion.value),
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
// sbt-doctest leaves some unused values
// see https://github.com/scala/bug/issues/10270
scalacOptions in Test := {
Test / scalacOptions := {
val mainScalacOptions = scalacOptions.value
(if (CrossVersion.partialVersion(scalaVersion.value) == Some((2, 12)))
mainScalacOptions.filter(!Seq("-Ywarn-value-discard", "-Xlint").contains(_)) :+ "-Xlint:-unused,_"
Expand Down
17 changes: 8 additions & 9 deletions project/plugins.sbt
@@ -1,9 +1,8 @@
addSbtPlugin("com.localytics" % "sbt-dynamodb" % "2.0.3")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.9.6")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.2.1")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.1")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.13")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.localytics" % "sbt-dynamodb" % "2.0.3")
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.2.1")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.1")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.13")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
39 changes: 9 additions & 30 deletions scanamo/src/main/scala/org/scanamo/ScanamoSync.scala
Expand Up @@ -25,40 +25,19 @@ import org.scanamo.ops._
*
* To avoid blocking, use [[org.scanamo.ScanamoAsync]]
*/
class Scanamo private (client: DynamoDbClient) {
final private val interpreter = new ScanamoSyncInterpreter(client)
final class Scanamo private (client: DynamoDbClient) {
private val interpreter = new ScanamoSyncInterpreter(client)

/**
* Execute the operations built with [[org.scanamo.Table]], using the client
* provided synchronously
*
* {{{
* >>> import org.scanamo.generic.auto._
*
* >>> case class Transport(mode: String, line: String)
* >>> val transport = Table[Transport]("transport")
*
* >>> val client = LocalDynamoDB.syncClient()
* >>> val scanamo = Scanamo(client)
* >>> import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType._
*
* >>> LocalDynamoDB.withTable(client)("transport")("mode" -> S, "line" -> S) {
* ... import org.scanamo.syntax._
* ... val operations = for {
* ... _ <- transport.putAll(Set(
* ... Transport("Underground", "Circle"),
* ... Transport("Underground", "Metropolitan"),
* ... Transport("Underground", "Central")))
* ... results <- transport.query("mode" -> "Underground" and ("line" beginsWith "C"))
* ... } yield results.toList
* ... scanamo.exec(operations)
* ... }
* List(Right(Transport(Underground,Central)), Right(Transport(Underground,Circle)))
* }}}
* Execute the operations built with [[org.scanamo.Table]]
*/
final def exec[A](op: ScanamoOps[A]): A = op.foldMap(interpreter)
def exec[A](op: ScanamoOps[A]): A = op.foldMap(interpreter)

final def execT[M[_]: Monad, A](hoist: Id ~> M)(op: ScanamoOpsT[M, A]): M[A] =
/**
* Execute the operations built with [[org.scanamo.Table]] with
* effects in the monad `M` threaded in.
*/
def execT[M[_]: Monad, A](hoist: Id ~> M)(op: ScanamoOpsT[M, A]): M[A] =
op.foldMap(interpreter andThen hoist)
}

Expand Down
107 changes: 0 additions & 107 deletions scanamo/src/main/scala/org/scanamo/SecondaryIndex.scala
Expand Up @@ -31,30 +31,6 @@ sealed abstract class SecondaryIndex[V] {

/**
* Scan a secondary index
*
* This will only return items with a value present in the secondary index
*
* {{{
* >>> case class Bear(name: String, favouriteFood: String, antagonist: Option[String])
*
* >>> val client = LocalDynamoDB.syncClient()
* >>> val scanamo = Scanamo(client)
* >>> import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType._
*
* >>> import org.scanamo.generic.auto._
*
* >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)("name" -> S)("antagonist" -> S) { (t, i) =>
* ... val table = Table[Bear](t)
* ... val ops = for {
* ... _ <- table.put(Bear("Pooh", "honey", None))
* ... _ <- table.put(Bear("Yogi", "picnic baskets", Some("Ranger Smith")))
* ... _ <- table.put(Bear("Paddington", "marmalade sandwiches", Some("Mr Curry")))
* ... antagonisticBears <- table.index(i).scan()
* ... } yield antagonisticBears
* ... scanamo.exec(ops)
* ... }
* List(Right(Bear(Paddington,marmalade sandwiches,Some(Mr Curry))), Right(Bear(Yogi,picnic baskets,Some(Ranger Smith))))
* }}}
*/
def scan(): ScanamoOps[List[Either[DynamoReadError, V]]]

Expand All @@ -79,32 +55,6 @@ sealed abstract class SecondaryIndex[V] {

/**
* Run a query against keys in a secondary index
*
* {{{
* >>> case class GithubProject(organisation: String, repository: String, language: String, license: String)
*
* >>> val client = LocalDynamoDB.syncClient()
* >>> val scanamo = Scanamo(client)
* >>> import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType._
*
* >>> import org.scanamo.syntax._
* >>> import org.scanamo.generic.auto._
*
* >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)("organisation" -> S, "repository" -> S)("language" -> S, "license" -> S) { (t, i) =>
* ... val githubProjects = Table[GithubProject](t)
* ... val operations = for {
* ... _ <- githubProjects.putAll(Set(
* ... GithubProject("typelevel", "cats", "Scala", "MIT"),
* ... GithubProject("localytics", "sbt-dynamodb", "Scala", "MIT"),
* ... GithubProject("tpolecat", "tut", "Scala", "MIT"),
* ... GithubProject("guardian", "scanamo", "Scala", "Apache 2")
* ... ))
* ... scalaMIT <- githubProjects.index(i).query("language" -> "Scala" and ("license" -> "MIT"))
* ... } yield scalaMIT.toList
* ... scanamo.exec(operations)
* ... }
* List(Right(GithubProject(typelevel,cats,Scala,MIT)), Right(GithubProject(tpolecat,tut,Scala,MIT)), Right(GithubProject(localytics,sbt-dynamodb,Scala,MIT)))
* }}}
*/
def query(query: Query[_]): ScanamoOps[List[Either[DynamoReadError, V]]]

Expand Down Expand Up @@ -132,70 +82,13 @@ sealed abstract class SecondaryIndex[V] {

/**
* Query or scan an index, limiting the number of items evaluated by Dynamo
*
* {{{
* >>> case class Transport(mode: String, line: String, colour: String)
*
* >>> val client = LocalDynamoDB.syncClient()
* >>> val scanamo = Scanamo(client)
* >>> import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType._
* >>> import org.scanamo.syntax._
* >>> import org.scanamo.generic.auto._
*
* >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)(
* ... "mode" -> S, "line" -> S)("mode" -> S, "colour" -> S
* ... ) { (t, i) =>
* ... val transport = Table[Transport](t)
* ... val operations = for {
* ... _ <- transport.putAll(Set(
* ... Transport("Underground", "Circle", "Yellow"),
* ... Transport("Underground", "Metropolitan", "Magenta"),
* ... Transport("Underground", "Central", "Red"),
* ... Transport("Underground", "Picadilly", "Blue"),
* ... Transport("Underground", "Northern", "Black")))
* ... somethingBeginningWithBl <- transport.index(i).limit(1).descending.query(
* ... ("mode" -> "Underground" and ("colour" beginsWith "Bl"))
* ... )
* ... } yield somethingBeginningWithBl.toList
* ... scanamo.exec(operations)
* ... }
* List(Right(Transport(Underground,Picadilly,Blue)))
* }}}
*/
def limit(n: Int): SecondaryIndex[V]

/**
* Filter the results of `scan` or `query` within DynamoDB
*
* Note that rows filtered out still count towards your consumed capacity
* {{{
* >>> case class Transport(mode: String, line: String, colour: String)
*
* >>> val client = LocalDynamoDB.syncClient()
* >>> val scanamo = Scanamo(client)
* >>> import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType._
* >>> import org.scanamo.syntax._
* >>> import org.scanamo.generic.auto._
*
* >>> LocalDynamoDB.withRandomTableWithSecondaryIndex(client)(
* ... "mode" -> S, "line" -> S)("mode" -> S, "colour" -> S
* ... ) { (t, i) =>
* ... val transport = Table[Transport](t)
* ... val operations = for {
* ... _ <- transport.putAll(Set(
* ... Transport("Underground", "Circle", "Yellow"),
* ... Transport("Underground", "Metropolitan", "Magenta"),
* ... Transport("Underground", "Central", "Red"),
* ... Transport("Underground", "Picadilly", "Blue"),
* ... Transport("Underground", "Northern", "Black")))
* ... somethingBeginningWithC <- transport.index(i)
* ... .filter("line" beginsWith ("C"))
* ... .query("mode" -> "Underground")
* ... } yield somethingBeginningWithC.toList
* ... scanamo.exec(operations)
* ... }
* List(Right(Transport(Underground,Central,Red)), Right(Transport(Underground,Circle,Yellow)))
* }}}
*/
def filter[C: ConditionExpression](condition: C): SecondaryIndex[V]

Expand Down

0 comments on commit 527e055

Please sign in to comment.