From eadc8708602afbfe7ba6b7338d988a28047bc2c7 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Tue, 19 Mar 2024 18:00:58 +0100 Subject: [PATCH 1/2] Setup scaladoc --- .github/workflows/scaladoc.yml | 46 +++++++++++++++++++++++++++ build.sbt | 5 ++- docs/_docs/index.md | 57 ++++++++++++++++++++++++++++++++++ docs/sidebar.yml | 1 + 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/scaladoc.yml create mode 100644 docs/_docs/index.md create mode 100644 docs/sidebar.yml diff --git a/.github/workflows/scaladoc.yml b/.github/workflows/scaladoc.yml new file mode 100644 index 0000000..aa8be66 --- /dev/null +++ b/.github/workflows/scaladoc.yml @@ -0,0 +1,46 @@ +name: docs + +on: + push: + branches: ["main"] + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + scaladoc: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Git Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Java 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Generate GUInep documentation + run: sbt guinep3/doc + + - name: Setup Pages + uses: actions/configure-pages@v2 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: 'GUInep/target/jvm-3/api' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 \ No newline at end of file diff --git a/build.sbt b/build.sbt index e63bc15..4731e17 100644 --- a/build.sbt +++ b/build.sbt @@ -40,7 +40,10 @@ lazy val guinep = projectMatrix .in(file("guinep")) .settings(commonSettings) .settings( - name := "GUInep" + name := "GUInep", + Compile / doc / scalacOptions ++= Seq( + "-siteroot", "docs" + ) ) .jvmPlatform(scalaVersions = List(scala3)) diff --git a/docs/_docs/index.md b/docs/_docs/index.md new file mode 100644 index 0000000..c115521 --- /dev/null +++ b/docs/_docs/index.md @@ -0,0 +1,57 @@ +# GUInep + +> Guinep are small tropical fruits from the Caribbean and Central/Southern America. They are described to taste like a cross between Lime and Lychee. + +PoC library to turn Scala 3 functions into UI forms with a single line of code. + +## Example + +```scala +def upperCaseText(text: String): String = + text.toUpperCase + +@main +def run = + guinep.web(upperCaseText) +``` + +This will start a local web server with auto generated endpoints for running all listed functions. And an auto generated front-end with a form for each function. + +## Usage (with build tools) + +### sbt + +```scala +libraryDependencies ++= Seq( + "io.github.kacperfkorban" %% "guinep-web" % "version_from_releases" +) +``` + +### scala-cli + +```scala +//> using lib "io.github.kacperfkorban::guinep-web:version_from_releases" +``` + +## Usage (in code) + +`GUInep` only exposes one function `guinep.web` which takes some number of functions as arguments. + +```scala +def upperCaseText(text: String): String = + text.toUpperCase + +def rollDice(sides: Int): Int = + scala.util.Random.nextInt(sides) + 1 + +@main +def run = + guinep.web( + upperCaseText, + rollDice + ) +``` + +## Demo + +![GUInep_classes_demo](https://github.com/KacperFKorban/GUInep/assets/39772805/556b6c1b-ea72-4089-8cbd-16f680484177) diff --git a/docs/sidebar.yml b/docs/sidebar.yml new file mode 100644 index 0000000..1795ba3 --- /dev/null +++ b/docs/sidebar.yml @@ -0,0 +1 @@ +index : index.md From a15c5f9960f0ee43d6186e5682618ad5a4667ec3 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Tue, 19 Mar 2024 18:06:00 +0100 Subject: [PATCH 2/2] Change scaladoc setup to use the web3 module --- .github/workflows/scaladoc.yml | 4 ++-- build.sbt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/scaladoc.yml b/.github/workflows/scaladoc.yml index aa8be66..081f278 100644 --- a/.github/workflows/scaladoc.yml +++ b/.github/workflows/scaladoc.yml @@ -31,7 +31,7 @@ jobs: java-version: 11 - name: Generate GUInep documentation - run: sbt guinep3/doc + run: sbt web3/doc - name: Setup Pages uses: actions/configure-pages@v2 @@ -39,7 +39,7 @@ jobs: - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: - path: 'GUInep/target/jvm-3/api' + path: 'web/target/jvm-3/api' - name: Deploy to GitHub Pages id: deployment diff --git a/build.sbt b/build.sbt index 4731e17..50e57bd 100644 --- a/build.sbt +++ b/build.sbt @@ -40,10 +40,7 @@ lazy val guinep = projectMatrix .in(file("guinep")) .settings(commonSettings) .settings( - name := "GUInep", - Compile / doc / scalacOptions ++= Seq( - "-siteroot", "docs" - ) + name := "GUInep" ) .jvmPlatform(scalaVersions = List(scala3)) @@ -52,6 +49,9 @@ lazy val web = projectMatrix .settings(commonSettings) .settings( name := "GUInep-web", + Compile / doc / scalacOptions ++= Seq( + "-siteroot", "docs" + ), libraryDependencies ++= Seq( "dev.zio" %% "zio-http" % "3.0.0-RC4", "dev.zio" %% "zio-json" % "0.6.2"