fix: drop fiddle_code (#2237)
* fix: drop fiddle_code * fix: fix indentation * fix: fix formatting * fix: fix failing pull request test
This commit is contained in:
parent
4f2434b650
commit
1feb26f89e
7 changed files with 5 additions and 29 deletions
|
|
@ -13,14 +13,12 @@
|
||||||
|
|
||||||
package docs.org.apache.pekko.typed
|
package docs.org.apache.pekko.typed
|
||||||
|
|
||||||
//#fiddle_code
|
|
||||||
//#imports
|
//#imports
|
||||||
import org.apache.pekko
|
import org.apache.pekko
|
||||||
import pekko.actor.typed.scaladsl.Behaviors
|
import pekko.actor.typed.scaladsl.Behaviors
|
||||||
import pekko.actor.typed.scaladsl.LoggerOps
|
import pekko.actor.typed.scaladsl.LoggerOps
|
||||||
import pekko.actor.typed.{ ActorRef, ActorSystem, Behavior }
|
import pekko.actor.typed.{ ActorRef, ActorSystem, Behavior }
|
||||||
//#imports
|
//#imports
|
||||||
//#fiddle_code
|
|
||||||
|
|
||||||
import pekko.NotUsed
|
import pekko.NotUsed
|
||||||
import pekko.Done
|
import pekko.Done
|
||||||
|
|
@ -35,17 +33,14 @@ import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
object IntroSpec {
|
object IntroSpec {
|
||||||
//format: OFF
|
//format: OFF
|
||||||
//#fiddle_code
|
|
||||||
|
|
||||||
//#hello-world-actor
|
//#hello-world-actor
|
||||||
object HelloWorld {
|
object HelloWorld {
|
||||||
final case class Greet(whom: String, replyTo: ActorRef[Greeted])
|
final case class Greet(whom: String, replyTo: ActorRef[Greeted])
|
||||||
final case class Greeted(whom: String, from: ActorRef[Greet])
|
final case class Greeted(whom: String, from: ActorRef[Greet])
|
||||||
|
|
||||||
def apply(): Behavior[Greet] = Behaviors.receive { (context, message) =>
|
def apply(): Behavior[Greet] = Behaviors.receive { (context, message) =>
|
||||||
//#fiddle_code
|
|
||||||
context.log.info("Hello {}!", message.whom)
|
context.log.info("Hello {}!", message.whom)
|
||||||
//#fiddle_code
|
|
||||||
//#hello-world-actor
|
//#hello-world-actor
|
||||||
println(s"Hello ${message.whom}!")
|
println(s"Hello ${message.whom}!")
|
||||||
//#hello-world-actor
|
//#hello-world-actor
|
||||||
|
|
@ -65,9 +60,7 @@ object IntroSpec {
|
||||||
private def bot(greetingCounter: Int, max: Int): Behavior[HelloWorld.Greeted] =
|
private def bot(greetingCounter: Int, max: Int): Behavior[HelloWorld.Greeted] =
|
||||||
Behaviors.receive { (context, message) =>
|
Behaviors.receive { (context, message) =>
|
||||||
val n = greetingCounter + 1
|
val n = greetingCounter + 1
|
||||||
//#fiddle_code
|
|
||||||
context.log.info2("Greeting {} for {}", n, message.whom)
|
context.log.info2("Greeting {} for {}", n, message.whom)
|
||||||
//#fiddle_code
|
|
||||||
//#hello-world-bot
|
//#hello-world-bot
|
||||||
println(s"Greeting $n for ${message.whom}")
|
println(s"Greeting $n for ${message.whom}")
|
||||||
//#hello-world-bot
|
//#hello-world-bot
|
||||||
|
|
@ -111,7 +104,6 @@ object IntroSpec {
|
||||||
|
|
||||||
// Entry point for the execution
|
// Entry point for the execution
|
||||||
HelloWorldMain.main(Array.empty)
|
HelloWorldMain.main(Array.empty)
|
||||||
//#fiddle_code
|
|
||||||
//format: ON
|
//format: ON
|
||||||
|
|
||||||
object CustomDispatchersExample {
|
object CustomDispatchersExample {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ object ClassicSample {
|
||||||
|
|
||||||
override def receive: Receive = {
|
override def receive: Receive = {
|
||||||
case Greet(whom) =>
|
case Greet(whom) =>
|
||||||
// #fiddle_code
|
|
||||||
log.info("Hello {}!", whom)
|
log.info("Hello {}!", whom)
|
||||||
sender() ! Greeted(whom)
|
sender() ! Greeted(whom)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ construction.
|
||||||
|
|
||||||
#### Here is another example:
|
#### Here is another example:
|
||||||
|
|
||||||
@@snip [ActorDocSpec.scala](/docs/src/test/scala/docs/actor/ActorDocSpec.scala) { #fiddle_code template="Pekko" layout="v75" minheight="400px" }
|
@@snip [ActorDocSpec.scala](/docs/src/test/scala/docs/actor/ActorDocSpec.scala) { #my-actor }
|
||||||
|
|
||||||
@@@
|
@@@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ whether the stream terminated normally or exceptionally.
|
||||||
<a name="here-is-another-example"></a>
|
<a name="here-is-another-example"></a>
|
||||||
Here is another example:
|
Here is another example:
|
||||||
|
|
||||||
@@snip [TwitterStreamQuickstartDocSpec.scala](/docs/src/test/scala/docs/stream/TwitterStreamQuickstartDocSpec.scala) { #fiddle_code template=Pekko layout=v75 minheight=400px }
|
@@snip [TwitterStreamQuickstartDocSpec.scala](/docs/src/test/scala/docs/stream/TwitterStreamQuickstartDocSpec.scala) { #first-sample }
|
||||||
|
|
||||||
|
|
||||||
## Reusable Pieces
|
## Reusable Pieces
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ You will also need to add a @ref:[logging dependency](logging.md) to see that ou
|
||||||
|
|
||||||
#### Here is another example:
|
#### Here is another example:
|
||||||
|
|
||||||
@@snip [IntroSpec.scala](/actor-typed-tests/src/test/scala/docs/org/apache/pekko/typed/IntroSpec.scala) { #fiddle_code template=Pekko layout=v75 minheight=400px }
|
@@snip [IntroSpec.scala](/actor-typed-tests/src/test/scala/docs/org/apache/pekko/typed/IntroSpec.scala) { #hello-world-main }
|
||||||
|
|
||||||
@@@
|
@@@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,6 @@ final case class Give(thing: Any)
|
||||||
|
|
||||||
//#receive-orElse
|
//#receive-orElse
|
||||||
|
|
||||||
//#fiddle_code
|
|
||||||
import org.apache.pekko.actor.{ Actor, ActorRef, ActorSystem, PoisonPill, Props }
|
import org.apache.pekko.actor.{ Actor, ActorRef, ActorSystem, PoisonPill, Props }
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
|
|
@ -364,8 +363,6 @@ class Ponger(pinger: ActorRef) extends Actor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#fiddle_code
|
|
||||||
|
|
||||||
//#immutable-message-definition
|
//#immutable-message-definition
|
||||||
case class User(name: String)
|
case class User(name: String)
|
||||||
|
|
||||||
|
|
@ -409,7 +406,6 @@ class ActorDocSpec extends PekkoSpec("""
|
||||||
}
|
}
|
||||||
|
|
||||||
"run basic Ping Pong" in {
|
"run basic Ping Pong" in {
|
||||||
// #fiddle_code
|
|
||||||
val system = ActorSystem("pingpong")
|
val system = ActorSystem("pingpong")
|
||||||
|
|
||||||
val pinger = system.actorOf(Props[Pinger](), "pinger")
|
val pinger = system.actorOf(Props[Pinger](), "pinger")
|
||||||
|
|
@ -421,8 +417,6 @@ class ActorDocSpec extends PekkoSpec("""
|
||||||
ponger ! Ping
|
ponger ! Ping
|
||||||
}
|
}
|
||||||
|
|
||||||
// #fiddle_code
|
|
||||||
|
|
||||||
val testProbe = new TestProbe(system)
|
val testProbe = new TestProbe(system)
|
||||||
testProbe.watch(pinger)
|
testProbe.watch(pinger)
|
||||||
testProbe.expectTerminated(pinger)
|
testProbe.expectTerminated(pinger)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import org.apache.pekko.testkit.PekkoSpec
|
||||||
import scala.concurrent.ExecutionContext
|
import scala.concurrent.ExecutionContext
|
||||||
|
|
||||||
object TwitterStreamQuickstartDocSpec {
|
object TwitterStreamQuickstartDocSpec {
|
||||||
// #fiddle_code
|
|
||||||
import org.apache.pekko
|
import org.apache.pekko
|
||||||
import pekko.NotUsed
|
import pekko.NotUsed
|
||||||
import pekko.actor.ActorSystem
|
import pekko.actor.ActorSystem
|
||||||
|
|
@ -53,15 +52,12 @@ object TwitterStreamQuickstartDocSpec {
|
||||||
val pekkoTag = Hashtag("#pekko")
|
val pekkoTag = Hashtag("#pekko")
|
||||||
// #model
|
// #model
|
||||||
|
|
||||||
// #fiddle_code
|
|
||||||
|
|
||||||
abstract class TweetSourceDecl {
|
abstract class TweetSourceDecl {
|
||||||
// #tweet-source
|
// #tweet-source
|
||||||
val tweets: Source[Tweet, NotUsed]
|
val tweets: Source[Tweet, NotUsed]
|
||||||
// #tweet-source
|
// #tweet-source
|
||||||
}
|
}
|
||||||
|
|
||||||
// #fiddle_code
|
|
||||||
val tweets: Source[Tweet, NotUsed] = Source(
|
val tweets: Source[Tweet, NotUsed] = Source(
|
||||||
Tweet(Author("rolandkuhn"), System.currentTimeMillis, "#pekko rocks!") ::
|
Tweet(Author("rolandkuhn"), System.currentTimeMillis, "#pekko rocks!") ::
|
||||||
Tweet(Author("patriknw"), System.currentTimeMillis, "#pekko !") ::
|
Tweet(Author("patriknw"), System.currentTimeMillis, "#pekko !") ::
|
||||||
|
|
@ -75,7 +71,6 @@ object TwitterStreamQuickstartDocSpec {
|
||||||
Tweet(Author("drama"), System.currentTimeMillis, "we compared #apples to #oranges!") ::
|
Tweet(Author("drama"), System.currentTimeMillis, "we compared #apples to #oranges!") ::
|
||||||
Nil)
|
Nil)
|
||||||
|
|
||||||
// #fiddle_code
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
||||||
|
|
@ -87,14 +82,12 @@ class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
||||||
def println(s: Any): Unit = ()
|
def println(s: Any): Unit = ()
|
||||||
|
|
||||||
trait Example1 {
|
trait Example1 {
|
||||||
// #fiddle_code
|
|
||||||
// #first-sample
|
// #first-sample
|
||||||
// #system-setup
|
// #system-setup
|
||||||
implicit val system: ActorSystem = ActorSystem("reactive-tweets")
|
implicit val system: ActorSystem = ActorSystem("reactive-tweets")
|
||||||
// #system-setup
|
// #system-setup
|
||||||
// #first-sample
|
// #first-sample
|
||||||
|
|
||||||
// #fiddle_code
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"filter and map" in {
|
"filter and map" in {
|
||||||
|
|
@ -158,9 +151,8 @@ class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
||||||
// format: ON
|
// format: ON
|
||||||
}
|
}
|
||||||
|
|
||||||
"simple fiddle showcase" in {
|
"simple example showcase" in {
|
||||||
|
|
||||||
// #fiddle_code
|
|
||||||
tweets
|
tweets
|
||||||
.filterNot(_.hashtags.contains(pekkoTag)) // Remove all tweets containing #pekko hashtag
|
.filterNot(_.hashtags.contains(pekkoTag)) // Remove all tweets containing #pekko hashtag
|
||||||
.map(_.hashtags) // Get all sets of hashtags ...
|
.map(_.hashtags) // Get all sets of hashtags ...
|
||||||
|
|
@ -168,7 +160,6 @@ class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
||||||
.mapConcat(identity) // Flatten the set of hashtags to a stream of hashtags
|
.mapConcat(identity) // Flatten the set of hashtags to a stream of hashtags
|
||||||
.map(_.name.toUpperCase) // Convert all hashtags to upper case
|
.map(_.name.toUpperCase) // Convert all hashtags to upper case
|
||||||
.runWith(Sink.foreach(println)) // Attach the Flow to a Sink that will finally print the hashtags
|
.runWith(Sink.foreach(println)) // Attach the Flow to a Sink that will finally print the hashtags
|
||||||
// #fiddle_code
|
|
||||||
.value
|
.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue