Skip to content

Commit f8225ac

Browse files
committed
better scaladoc
1 parent 6455367 commit f8225ac

File tree

4 files changed

+76
-11
lines changed

4 files changed

+76
-11
lines changed

build.sbt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//val dottyVersion = "3.0.0-RC2-bin-SNAPSHOT"
2-
val dottyVersion = "3.0.2"
2+
val dottyVersion = "3.1.0-RC2"
33
//val dottyVersion = dottyLatestNightlyBuild.get
44

55
ThisBuild/version := "2.1.1-SNAPSHOT"
@@ -42,12 +42,18 @@ lazy val gopher = crossProject(JSPlatform, JVMPlatform)
4242
s"-javaagent:${System.getProperty("user.home")}/.ivy2/local/com.github.rssh/trackedfuture_3/0.5.0/jars/trackedfuture_3-assembly.jar"
4343
)
4444
*/
45+
Compile / doc / scalacOptions := Seq("-groups",
46+
"-source-links:shared=github://rssh/scala-gopher/master#shared",
47+
"-source-links:jvm=github://rssh/scala-gopher/master#jvm"),
4548
mimaPreviousArtifacts := Set( "com.github.rssh" %% "scala-gopher" % "2.1.0")
4649
).jsSettings(
4750
libraryDependencies += ("org.scala-js" %%% "scalajs-java-logging" % "1.0.0").cross(CrossVersion.for3Use2_13),
4851
// TODO: switch to ModuleES ?
4952
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) },
5053
scalaJSUseMainModuleInitializer := true,
54+
Compile / doc / scalacOptions := Seq("-groups",
55+
"-source-links:shared=github://rssh/scala-gopher/master#shared",
56+
"-source-links:js=github://rssh/scala-gopher/master#js"),
5157
)
5258

5359
lazy val GopherJVM = config("gopher.jvm")

shared/src/main/scala/gopher/Gopher.scala

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,57 @@ import java.util.concurrent.Executor
1010

1111

1212
/**
13-
* core of GopherAPI.
14-
* Given instance of Gopher[F] need for using most of Gopher operations.
13+
* core of Gopher API. Given instance of Gopher[F] need for using most of Gopher operations.
1514
*
16-
* Gopehr API ia a framework, which implements CSP (Communication Sequence Process).
17-
* Process here - scala units of execution (i.e. )
15+
* Gopher is a framework, which implements CSP (Communication Sequence Process).
16+
* Process here - scala units of execution (i.e. functions, blok of code, etc).
17+
* Communication channels represented by [gopher.Channel]
18+
*
19+
* @see [gopher.Channel]
20+
* @see [gopher#select]
1821
**/
1922
trait Gopher[F[_]:CpsSchedulingMonad]:
2023

2124
type Monad[X] = F[X]
2225

23-
26+
/**
27+
* Monad which control asynchronic execution.
28+
* The main is scheduling: i.e. ability to submit monadic expression to scheduler
29+
* and know that this monadic expression will be evaluated.
30+
**/
2431
def asyncMonad: CpsSchedulingMonad[F] = summon[CpsSchedulingMonad[F]]
2532

26-
33+
/**
34+
* Create Read/Write channel.
35+
* @param bufSize - size of buffer. If it is zero, the channel is unbuffered. (i.e. writer is blocked until reader start processing).
36+
* @param autoClose - close after first message was written to channel.
37+
* @see [gopher.Channel]
38+
**/
2739
def makeChannel[A](bufSize:Int = 0,
2840
autoClose: Boolean = false): Channel[F,A,A]
2941

42+
/**
43+
* Create channel where you can write only one element.
44+
* @see [gopher.Channel]
45+
**/
3046
def makeOnceChannel[A](): Channel[F,A,A] =
3147
makeChannel[A](1,true)
3248

49+
/***
50+
*Create a select statement, which used for choosing one action from a set of potentially concurrent asynchronics events.
51+
*[@see gopher.Select]
52+
**/
3353
def select: Select[F] =
3454
new Select[F](this)
3555

56+
/**
57+
* get an object with time operations.
58+
**/
3659
def time: Time[F]
3760

61+
/**
62+
* set logging function, which output internal diagnostics and errors from spawned processes.
63+
**/
3864
def setLogFun(logFun:(LogLevel, String, Throwable|Null) => Unit): ((LogLevel, String, Throwable|Null) => Unit)
3965

4066
def log(level: LogLevel, message: String, ex: Throwable| Null): Unit
@@ -55,18 +81,30 @@ trait Gopher[F[_]:CpsSchedulingMonad]:
5581
()
5682
}
5783

84+
end Gopher
5885

59-
86+
87+
/**
88+
* Create Read/Write channel.
89+
* @param bufSize - size of buffer. If it is zero, the channel is unbuffered. (i.e. writer is blocked until reader start processing).
90+
* @param autoClose - close after first message was written to channel.
91+
* @see [gopher.Channel]
92+
**/
6093
def makeChannel[A](bufSize:Int = 0,
6194
autoClose: Boolean = false)(using g:Gopher[?]):Channel[g.Monad,A,A] =
6295
g.makeChannel(bufSize, autoClose)
96+
6397

6498
def makeOnceChannel[A]()(using g:Gopher[?]): Channel[g.Monad,A,A] =
6599
g.makeOnceChannel[A]()
66100

101+
67102
def select(using g:Gopher[?]):Select[g.Monad] =
68103
g.select
69104

105+
/**
106+
* represent `F[_]` as read channel.
107+
**/
70108
def futureInput[F[_],A](f: F[A])(using g: Gopher[F]): ReadChannel[F,A] =
71109
val ch = g.makeOnceChannel[Try[A]]()
72110
g.spawnAndLogFail{

shared/src/main/scala/gopher/Select.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ class Select[F[_]](api: Gopher[F]):
3131
SelectMacro.onceImpl[F,A]('pf, 'api )
3232
}
3333

34-
/***
34+
/**
3535
* create select groop
3636
*@see [gopher.SelectGroup]
3737
**/
3838
def group[S]: SelectGroup[F,S] = new SelectGroup[F,S](api)
3939

4040
def once[S]: SelectGroup[F,S] = new SelectGroup[F,S](api)
4141

42+
/**
43+
* create Select Loop.
44+
**/
4245
def loop: SelectLoop[F] = new SelectLoop[F](api)
4346

4447

shared/src/main/scala/gopher/Time.scala

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ abstract class Time[F[_]](gopherAPI: Gopher[F]) {
2727
**/
2828
type after = FiniteDuration
2929

30+
/**
31+
* return channel, then after `duration` ellapses, send signal to this channel.
32+
**/
3033
def after(duration: FiniteDuration): ReadChannel[F,FiniteDuration] =
3134
{
3235
val ch = gopherAPI.makeOnceChannel[FiniteDuration]()
@@ -39,6 +42,9 @@ abstract class Time[F[_]](gopherAPI: Gopher[F]) {
3942
ch
4043
}
4144

45+
/**
46+
* return future which will be filled after time will ellapse.
47+
**/
4248
def asleep(duration: FiniteDuration): F[FiniteDuration] =
4349
{
4450
var fun: Try[FiniteDuration] => Unit = _ => ()
@@ -51,6 +57,9 @@ abstract class Time[F[_]](gopherAPI: Gopher[F]) {
5157
retval
5258
}
5359

60+
/**
61+
* synonim for `await(asleep(duration))`. Should be used inside async block.
62+
**/
5463
transparent inline def sleep(duration: FiniteDuration): FiniteDuration =
5564
given CpsSchedulingMonad[F] = gopherAPI.asyncMonad
5665
await(asleep(duration))
@@ -66,7 +75,9 @@ abstract class Time[F[_]](gopherAPI: Gopher[F]) {
6675
newTicker(duration).channel
6776
}
6877

69-
78+
/**
79+
* ticker which hold channel with expirable tick messages and iterface to stop one.
80+
**/
7081
class Ticker(duration: FiniteDuration) {
7182

7283
val channel = gopherAPI.makeChannel[FiniteDuration](0).withExpiration(duration, false)
@@ -97,6 +108,10 @@ abstract class Time[F[_]](gopherAPI: Gopher[F]) {
97108

98109
}
99110

111+
/**
112+
* create ticker with given `duration` between ticks.
113+
*@see [gopher.Time.Ticker]
114+
**/
100115
def newTicker(duration: FiniteDuration): Ticker =
101116
{
102117
new Ticker(duration)
@@ -108,7 +123,7 @@ abstract class Time[F[_]](gopherAPI: Gopher[F]) {
108123

109124

110125
/**
111-
* Low lwvel interface for scheduler
126+
* Low level interface for scheduler
112127
*/
113128
def schedule(fun: () => Unit, delay: FiniteDuration): Time.Scheduled
114129

@@ -131,6 +146,9 @@ object Time:
131146
type after = FiniteDuration
132147

133148

149+
/**
150+
* return channl on which event will be delivered after `duration`
151+
**/
134152
def after[F[_]](duration: FiniteDuration)(using Gopher[F]): ReadChannel[F,FiniteDuration] =
135153
summon[Gopher[F]].time.after(duration)
136154

0 commit comments

Comments
 (0)