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
|
||||
|
||||
//#fiddle_code
|
||||
//#imports
|
||||
import org.apache.pekko
|
||||
import pekko.actor.typed.scaladsl.Behaviors
|
||||
import pekko.actor.typed.scaladsl.LoggerOps
|
||||
import pekko.actor.typed.{ ActorRef, ActorSystem, Behavior }
|
||||
//#imports
|
||||
//#fiddle_code
|
||||
|
||||
import pekko.NotUsed
|
||||
import pekko.Done
|
||||
|
|
@ -35,17 +33,14 @@ import java.nio.charset.StandardCharsets
|
|||
|
||||
object IntroSpec {
|
||||
//format: OFF
|
||||
//#fiddle_code
|
||||
|
||||
|
||||
//#hello-world-actor
|
||||
object HelloWorld {
|
||||
final case class Greet(whom: String, replyTo: ActorRef[Greeted])
|
||||
final case class Greeted(whom: String, from: ActorRef[Greet])
|
||||
|
||||
def apply(): Behavior[Greet] = Behaviors.receive { (context, message) =>
|
||||
//#fiddle_code
|
||||
context.log.info("Hello {}!", message.whom)
|
||||
//#fiddle_code
|
||||
//#hello-world-actor
|
||||
println(s"Hello ${message.whom}!")
|
||||
//#hello-world-actor
|
||||
|
|
@ -65,9 +60,7 @@ object IntroSpec {
|
|||
private def bot(greetingCounter: Int, max: Int): Behavior[HelloWorld.Greeted] =
|
||||
Behaviors.receive { (context, message) =>
|
||||
val n = greetingCounter + 1
|
||||
//#fiddle_code
|
||||
context.log.info2("Greeting {} for {}", n, message.whom)
|
||||
//#fiddle_code
|
||||
//#hello-world-bot
|
||||
println(s"Greeting $n for ${message.whom}")
|
||||
//#hello-world-bot
|
||||
|
|
@ -111,7 +104,6 @@ object IntroSpec {
|
|||
|
||||
// Entry point for the execution
|
||||
HelloWorldMain.main(Array.empty)
|
||||
//#fiddle_code
|
||||
//format: ON
|
||||
|
||||
object CustomDispatchersExample {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ object ClassicSample {
|
|||
|
||||
override def receive: Receive = {
|
||||
case Greet(whom) =>
|
||||
// #fiddle_code
|
||||
log.info("Hello {}!", whom)
|
||||
sender() ! Greeted(whom)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ construction.
|
|||
|
||||
#### 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>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ You will also need to add a @ref:[logging dependency](logging.md) to see that ou
|
|||
|
||||
#### 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
|
||||
|
||||
//#fiddle_code
|
||||
import org.apache.pekko.actor.{ Actor, ActorRef, ActorSystem, PoisonPill, Props }
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
|
@ -364,8 +363,6 @@ class Ponger(pinger: ActorRef) extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
//#fiddle_code
|
||||
|
||||
//#immutable-message-definition
|
||||
case class User(name: String)
|
||||
|
||||
|
|
@ -409,7 +406,6 @@ class ActorDocSpec extends PekkoSpec("""
|
|||
}
|
||||
|
||||
"run basic Ping Pong" in {
|
||||
// #fiddle_code
|
||||
val system = ActorSystem("pingpong")
|
||||
|
||||
val pinger = system.actorOf(Props[Pinger](), "pinger")
|
||||
|
|
@ -421,8 +417,6 @@ class ActorDocSpec extends PekkoSpec("""
|
|||
ponger ! Ping
|
||||
}
|
||||
|
||||
// #fiddle_code
|
||||
|
||||
val testProbe = new TestProbe(system)
|
||||
testProbe.watch(pinger)
|
||||
testProbe.expectTerminated(pinger)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import org.apache.pekko.testkit.PekkoSpec
|
|||
import scala.concurrent.ExecutionContext
|
||||
|
||||
object TwitterStreamQuickstartDocSpec {
|
||||
// #fiddle_code
|
||||
import org.apache.pekko
|
||||
import pekko.NotUsed
|
||||
import pekko.actor.ActorSystem
|
||||
|
|
@ -53,15 +52,12 @@ object TwitterStreamQuickstartDocSpec {
|
|||
val pekkoTag = Hashtag("#pekko")
|
||||
// #model
|
||||
|
||||
// #fiddle_code
|
||||
|
||||
abstract class TweetSourceDecl {
|
||||
// #tweet-source
|
||||
val tweets: Source[Tweet, NotUsed]
|
||||
// #tweet-source
|
||||
}
|
||||
|
||||
// #fiddle_code
|
||||
val tweets: Source[Tweet, NotUsed] = Source(
|
||||
Tweet(Author("rolandkuhn"), System.currentTimeMillis, "#pekko rocks!") ::
|
||||
Tweet(Author("patriknw"), System.currentTimeMillis, "#pekko !") ::
|
||||
|
|
@ -75,7 +71,6 @@ object TwitterStreamQuickstartDocSpec {
|
|||
Tweet(Author("drama"), System.currentTimeMillis, "we compared #apples to #oranges!") ::
|
||||
Nil)
|
||||
|
||||
// #fiddle_code
|
||||
}
|
||||
|
||||
class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
||||
|
|
@ -87,14 +82,12 @@ class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
|||
def println(s: Any): Unit = ()
|
||||
|
||||
trait Example1 {
|
||||
// #fiddle_code
|
||||
// #first-sample
|
||||
// #system-setup
|
||||
implicit val system: ActorSystem = ActorSystem("reactive-tweets")
|
||||
// #system-setup
|
||||
// #first-sample
|
||||
|
||||
// #fiddle_code
|
||||
}
|
||||
|
||||
"filter and map" in {
|
||||
|
|
@ -158,9 +151,8 @@ class TwitterStreamQuickstartDocSpec extends PekkoSpec {
|
|||
// format: ON
|
||||
}
|
||||
|
||||
"simple fiddle showcase" in {
|
||||
"simple example showcase" in {
|
||||
|
||||
// #fiddle_code
|
||||
tweets
|
||||
.filterNot(_.hashtags.contains(pekkoTag)) // Remove all tweets containing #pekko hashtag
|
||||
.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
|
||||
.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
|
||||
// #fiddle_code
|
||||
.value
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue