-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add doc * Clean samples * Simpler * Add twirl index page generation for server demo. * Fix dev * Useless import
- Loading branch information
Showing
29 changed files
with
468 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
//import ProjectDef._ | ||
import java.nio.charset.StandardCharsets | ||
import org.scalajs.linker.interface.ModuleSplitStyle | ||
|
||
lazy val currentYear: String = | ||
java.util.Calendar.getInstance().get(java.util.Calendar.YEAR).toString | ||
|
||
val scala33 = "3.3.1" | ||
|
||
inThisBuild( | ||
|
@@ -43,6 +39,15 @@ inThisBuild( | |
) | ||
) | ||
|
||
lazy val generator = project | ||
.in(file("examples/generator")) | ||
.enablePlugins(SbtTwirl) | ||
.settings( | ||
libraryDependencies += "com.github.scopt" %% "scopt" % "4.1.0", | ||
libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.9.2", | ||
libraryDependencies += "org.slf4j" % "slf4j-simple" % "1.7.32" | ||
) | ||
|
||
val dev = sys.env.get("DEV").isDefined | ||
|
||
val serverPlugins = dev match { | ||
|
@@ -63,6 +68,7 @@ val serverSettings = dev match { | |
lazy val root = project | ||
.in(file(".")) | ||
.aggregate( | ||
generator, | ||
server, | ||
core, | ||
ui5, | ||
|
@@ -74,9 +80,36 @@ lazy val root = project | |
publish / skip := true | ||
) | ||
|
||
val staticGenerationSettings = | ||
if (dev) Seq() | ||
else | ||
Seq( | ||
Assets / resourceGenerators += Def | ||
.taskDyn[Seq[File]] { | ||
val baseDir = baseDirectory.value | ||
val rootFolder = (Assets / resourceManaged).value / "public" | ||
rootFolder.mkdirs() | ||
(generator / Compile / runMain) | ||
.toTask { | ||
Seq( | ||
"BuildIndex", | ||
"--title", | ||
s""""Laminar Form Derivation v ${version.value}"""", | ||
"--resource-managed", | ||
rootFolder | ||
).mkString(" ", " ", "") | ||
} | ||
.map(_ => (rootFolder ** "*.html").get) | ||
} | ||
.taskValue | ||
) | ||
|
||
lazy val server = project | ||
.in(file("examples/server")) | ||
.enablePlugins(serverPlugins: _*) | ||
.settings( | ||
staticGenerationSettings | ||
) | ||
.settings( | ||
fork := true, | ||
scalaJSProjects := Seq(example), | ||
|
@@ -102,7 +135,8 @@ val usedScalacOptions = Seq( | |
"-unchecked", | ||
"-language:higherKinds", | ||
"-language:implicitConversions", | ||
"-Xmax-inlines:64" | ||
"-Xmax-inlines:64", | ||
"-Wunused:all" | ||
) | ||
lazy val core = scalajsProject("core", false) | ||
.settings( | ||
|
@@ -222,35 +256,3 @@ Global / onLoad := { | |
|
||
(Global / onLoad).value | ||
} | ||
enablePlugins( | ||
SiteScaladocPlugin, | ||
SitePreviewPlugin, | ||
ScalaUnidocPlugin, | ||
GhpagesPlugin | ||
) | ||
|
||
ScalaUnidoc / siteSubdirName := "" | ||
addMappingsToSiteDir( | ||
ScalaUnidoc / packageDoc / mappings, | ||
ScalaUnidoc / siteSubdirName | ||
) | ||
git.remoteRepo := "[email protected]:cheleb/laminar-form-derivation.git" | ||
ghpagesNoJekyll := true | ||
Compile / doc / scalacOptions ++= Seq( | ||
"-siteroot", | ||
"docs", | ||
"-project", | ||
"Laminar Form Derivation", | ||
"-groups", | ||
"-project-version", | ||
version.value, | ||
"-revision", | ||
version.value, | ||
"-default-templates", | ||
"static-site-main", | ||
"-project-footer", | ||
s"Copyright (c) 2022-$currentYear, Olivier NOUGUIER", | ||
"-Ygenerate-inkuire", | ||
"-skip-by-regex:demo\\..*", | ||
"-skip-by-regex:samples\\..*" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Getting Started | ||
|
||
## Installation | ||
|
||
```sbt | ||
libraryDependencies += "dev.cheleb" %%% "laminar-form-derivation" % "{{ version }}" | ||
``` | ||
|
||
### Requirements | ||
|
||
### Sample | ||
|
||
```scala sc:nocompile | ||
|
||
import dev.cheleb.scalamigen.{*, given} | ||
import dev.cheleb.scalamigen.ui5.UI5WidgetFactory | ||
|
||
import com.raquo.laminar.api.L.* | ||
|
||
import com.raquo.airstream.state.Var | ||
|
||
given WidgetFactory = UI5WidgetFactory | ||
|
||
case class Cat(name: String, age: Int) | ||
case class Dog(name: String, age: Int) | ||
|
||
val either = { | ||
|
||
case class EitherSample( | ||
either: Either[Cat, Dog], | ||
optionalInt: Option[Int] | ||
) | ||
|
||
val eitherVar = Var(EitherSample(Left(Cat("Scala le chat", 6)), Some(1))) | ||
|
||
div( | ||
child <-- eitherVar.signal.map { item => | ||
div( | ||
s"$item" | ||
) | ||
}, | ||
Form.renderVar(eitherVar) | ||
) | ||
} | ||
|
||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
```scala mdoc | ||
import java.time.Instant | ||
|
||
def now() = Instant.now() | ||
object Foo extends App{ | ||
println(now()) | ||
} | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.