Merge pull request #27005 from akka/documentSourceApply

Merge Source.apply and Source.from docs
This commit is contained in:
Patrik Nordwall 2019-07-02 13:43:00 +02:00 committed by GitHub
commit e3dc7b16b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 34 deletions

View file

@ -16,9 +16,10 @@ RedirectMatch 301 ^(.*)/stream/stages-overview\.html$ $1/stream/operators/index.
RedirectMatch 301 ^(.*)/agents\.html$ $1/project/migration-guide-2.5.x-2.6.x.html
RedirectMatch 301 ^(.*)/typed-actors\.html$ $1/project/migration-guide-2.5.x-2.6.x.html#typedactor
RedirectMatch 301 ^(.*)/stream/operators/Source-or-Flow/balance\.html$ $1/stream/operators/Balance.html
RedirectMatch 301 ^(.*)/stream/operators/Source-or-Flow/broadcast\.html$ $1/stream/operators/Broadcast.html
RedirectMatch 301 ^(.*)/stream/operators/Source-or-Flow/partition\.html$ $1/stream/operators/Partition.html
RedirectMatch 301 ^(.*)/stream/operators/Source-or-Flow/unzip\.html$ $1/stream/operators/unzip.html
RedirectMatch 301 ^(.*)/stream/operators/Source-or-Flow/UnzipWith\.html$ $1/stream/operators/UnzipWith.html
RedirectMatch 301 ^(.*)/stream/operators/Source-or-Flow/apply\.html$ $1/stream/operators/Source/from.html

View file

@ -1,24 +0,0 @@
# apply
Stream the values of an `immutable.Seq`.
@ref[Source operators](../index.md#source-operators)
@@@ div { .group-scala }
## Signature
@@signature [Source.scala](/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala) { #apply }
@@@
## Description
Stream the values of an `immutable.Seq`.
@@@div { .callout }
**emits** the next value of the seq
**completes** when the last element of the seq has been emitted
@@@

View file

@ -1,6 +1,6 @@
# from
# @scala[apply]@java[from]
Stream the values of an `Iterable`.
Stream the values of an @scala[`immutable.Seq`]@java[`Iterable`].
@ref[Source operators](../index.md#source-operators)
@ -9,14 +9,14 @@ Stream the values of an `Iterable`.
## Signature
@@signature [Source.scala](/akka-stream/src/main/scala/akka/stream/javadsl/Source.scala) { #from }
@@signature [Source.scala](/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala) { #apply }
@@@
## Description
Stream the values of an `Iterable`. Make sure the `Iterable` is immutable or at least not modified after being used
as a source. Otherwise the stream may fail with `ConcurrentModificationException` or other more subtle errors may occur.
Stream the values of an @scala[`immutable.Seq`]@java[`Iterable`]. @java[Make sure the `Iterable` is immutable or at least not modified after being used
as a source. Otherwise the stream may fail with `ConcurrentModificationException` or other more subtle errors may occur.]
@@@div { .callout }

View file

@ -16,7 +16,7 @@ These built-in sources are available from @scala[`akka.stream.scaladsl.Source`]
|Source|<a name="cycle"></a>@ref[cycle](Source/cycle.md)|Stream iterator in cycled manner.|
|Source|<a name="empty"></a>@ref[empty](Source/empty.md)|Complete right away without ever emitting any elements.|
|Source|<a name="failed"></a>@ref[failed](Source/failed.md)|Fail directly with a user specified exception.|
|Source|<a name="from"></a>@ref[from](Source/from.md)|Stream the values of an `Iterable`.|
|Source|<a name="from"></a>@ref[@scala[apply]@java[from]](Source/from.md)|Stream the values of an @scala[`immutable.Seq`]@java[`Iterable`].|
|Source|<a name="fromcompletionstage"></a>@ref[fromCompletionStage](Source/fromCompletionStage.md)|Send the single value of the `CompletionStage` when it completes and there is demand.|
|Source|<a name="fromfuture"></a>@ref[fromFuture](Source/fromFuture.md)|Send the single value of the `Future` when it completes and there is demand.|
|Source|<a name="fromfuturesource"></a>@ref[fromFutureSource](Source/fromFutureSource.md)|Streams the elements of the given future source once it successfully completes.|
@ -334,7 +334,7 @@ For more background see the @ref[Error Handling in Streams](../stream-error.md)
* [queue](Source/queue.md)
* [unfoldResource](Source/unfoldResource.md)
* [unfoldResourceAsync](Source/unfoldResourceAsync.md)
* [from](Source/from.md)
* [@scala[apply]@java[from]](Source/from.md)
* [range](Source/range.md)
* [concat](Source-or-Flow/concat.md)
* [prepend](Source-or-Flow/prepend.md)

View file

@ -202,7 +202,9 @@ object StreamOperatorsIndexGenerator extends AutoPlugin {
lines
.map(_._2)
.sortBy(_._2)
.map { case (element, method, md, description) => s"""|$element|<a name="${method.toLowerCase}"></a>@ref[$method]($md)|$description|""" }
.map { case (element, method, md, description) =>
s"""|$element|<a name="${method.toLowerCase}"></a>@ref[${methodToShow(method)}]($md)|$description|"""
}
.mkString("\n")
)
@ -217,12 +219,17 @@ object StreamOperatorsIndexGenerator extends AutoPlugin {
"# Operators\n\n" +
tables +
"\n\n@@@ index\n\n" +
groupedDefs.map { case (_, method, md) => s"* [$method]($md)" }.mkString("\n") + "\n\n@@@\n"
groupedDefs.map { case (_, method, md) => s"* [${methodToShow(method)}]($md)" }.mkString("\n") + "\n\n@@@\n"
if (!file.exists || IO.read(file) != content) IO.write(file, content)
Seq(file)
}
def methodToShow(method: String): String = method match {
case "from" => "@scala[apply]@java[from]"
case other => other
}
def getDetails(file: File): (String, String) = try {
val contents = IO.read(file)
val lines = contents.split("\\r?\\n")