Skip to content

Commit

Permalink
Lots of doc stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Katrix committed Jan 3, 2024
1 parent 263ff1a commit 6733d36
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 36 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release
on:
push:
branches: ["main"]
tags: ["*"]
jobs:
publish:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
cache: sbt
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
69 changes: 46 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
# DataPrism

DataPrism as an early in dev FRM (Functional Relational Mapper).
*A new FRM with focus on Higher Kinded Data*

DataPrism focuses on doing its job by using HKD(Higher Kinded Data).
DataPrism is an SQL query construction library built to take full advantage of
the power of higher kinded data. DataPrism builds on `perspective` and the
tools it provides.

DataPrism is more flexible than other SQL libraries made for Scala. Want to
sometimes leave out a column? You can do that. Want to return a List from a query,
sure thing.

DataPrism also works with both Java's JDBC and skunk.

Add DataPrism to your project by adding these statements to your `build.sbt` file.

DataPrism is currently early in development, but feel free to try it out and
report bugs and errors.

```scala
// For JDBC
libraryDependencies += "net.katsstuff" %% "dataprism-jdbc" % "{{versions.dataprism}}"

// For Skunk
libraryDependencies += "net.katsstuff" %% "dataprism-skunk" % "{{versions.dataprism}}"
```

Simple showcase of code
```scala


case class HomeK[F[_]](
owner: F[UUID],
name: F[String],
Expand All @@ -20,39 +43,39 @@ case class HomeK[F[_]](
)

object HomeK {
val table: Table[HomeK] = Table(
import dataprism.jdbc.sql.JdbcType
import dataprism.jdbc.sql.PostgresJdbcTypes.*
val table: Table[HomeK, JdbcType] = Table(
"homes",
HomeK(
owner = Column("owner", DbType.uuid),
name = Column("name", DbType.text),
createdAt = Column("created_at", DbType.timestamptz),
updatedAt = Column("updated_at", DbType.timestamptz),
x = Column("x", DbType.double),
y = Column("y", DbType.double),
z = Column("z", DbType.double),
yaw = Column("yaw", DbType.float),
pitch = Column("pitch", DbType.float),
worldUuid = Column("world_uuid", DbType.uuid)
owner = Column("owner", uuid),
name = Column("name", text),
createdAt = Column("created_at", javaTime.timestamptz),
updatedAt = Column("updated_at", javaTime.timestamptz),
x = Column("x", doublePrecision),
y = Column("y", doublePrecision),
z = Column("z", doublePrecision),
yaw = Column("yaw", real),
pitch = Column("pitch", real),
worldUuid = Column("world_uuid", uuid)
)
)

given HomeK[DbType] = Table.tableDbTypes(table)

given typeclass: KMacros.RepresentableTraverseKC[HomeK] = KMacros.deriveRepresentableTraverseKC[HomeK]
given KMacros.ApplyTraverseKC[HomeK] = KMacros.deriveApplyTraverseKC[HomeK]
}


Query.from(HomeK.table).mapT(homes => (homes.owner, homes.name))
Query.from(HomeK.table).map(homes => (homes.owner, homes.name))

Query
.from(HomeK.table)
.groupByT(homes =>
.groupBy(homes => (homes.owner, homes.name))((grouped, homes) =>
(
homes.owner.groupedBy,
homes.name.groupedBy,
homes.x.asMany.arrayAgg,
homes.y.asMany.arrayAgg,
homes.z.asMany.arrayAgg
grouped._1,
grouped._2,
homes.x.arrayAgg,
homes.y.arrayAgg,
homes.z.arrayAgg
)
)
```
63 changes: 50 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
lazy val commonSettings = Seq(
scalaVersion := "3.3.1",
version := "0.0.1-SNAPSHOT",
organization := "net.katsstuff",
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value) Some("snapshots".at(nexus + "content/repositories/snapshots"))
else Some("releases".at(nexus + "service/local/staging/deploy/maven2"))
},
)

inThisBuild(
Seq(
homepage := Some(url("https://github.com/Katrix/DataPrism")),
organization := "net.katsstuff",
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
developers := List(Developer("Katrix", "Kathryn Frid", "katrix97@hotmail.com", url("http://katsstuff.net/"))),
versionScheme := Some("early-semver")
)
)

lazy val publishSettings = Seq(
publishMavenStyle := true,
Test / publishArtifact := false,
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
scmInfo := Some(
ScmInfo(
url("https://github.com/Katrix/DataPrism"),
"scm:git:github.com/Katrix/DataPrism",
Some("scm:git:github.com/Katrix/DataPrism")
)
),
homepage := Some(url("https://github.com/Katrix/DataPrism")),
developers := List(Developer("Katrix", "Kathryn", "katrix97@hotmail.com", url("http://katsstuff.net/"))),
pomIncludeRepository := (_ => false),
autoAPIMappings := true
)

lazy val noPublishSettings = Seq(publish := {}, publishLocal := {}, publishArtifact := false)
lazy val noPublishSettings = Seq(publish := {}, publishLocal := {}, publishArtifact := false, publish / skip := true)

lazy val common = project.settings(
commonSettings,
Expand All @@ -49,4 +47,43 @@ lazy val skunk = project.settings(
libraryDependencies += "org.tpolecat" %% "skunk-core" % "0.6.2"
).dependsOn(common)

lazy val docsMappingsAPIDir = settingKey[String]("Name of subdirectory in site target directory for api docs")

lazy val docs = project
.enablePlugins(MicrositesPlugin, ScalaUnidocPlugin, GhpagesPlugin)
.settings(
commonSettings,
micrositeName := "DataPrism",
micrositeAuthor := "Katrix",
micrositeDescription := "A new FRM with focus on Higher Kinded Data",
micrositeDocumentationUrl := "/api/dataprism",
micrositeDocumentationLabelDescription := "ScalaDoc",
micrositeHomepage := "https://dataprism.katsstuff.net",
micrositeGithubOwner := "Katrix",
micrositeGithubRepo := "DataPrism",
micrositeGitterChannel := false,
micrositeShareOnSocial := false,
micrositeTheme := "pattern",
ghpagesCleanSite / excludeFilter := "CNAME",
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
autoAPIMappings := true,
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(
common,
jdbc,
skunk,
),
docsMappingsAPIDir := "api",
addMappingsToSiteDir(ScalaUnidoc / packageDoc / mappings, docsMappingsAPIDir),
//mdoc / fork := true,
mdocIn := sourceDirectory.value / "main" / "mdoc",
//ScalaUnidoc / unidoc / fork := true,
ScalaUnidoc / unidoc / scalacOptions ++= Seq(
"-doc-source-url",
"https://github.com/Katrix/DataPrism/tree/master€{FILE_PATH}.scala",
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath
)
)

lazy val root = project.in(file(".")).aggregate(common, jdbc, skunk).settings(noPublishSettings)
1 change: 1 addition & 0 deletions docs/src/main/mdoc/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dataprism.katsstuff.net
7 changes: 7 additions & 0 deletions docs/src/main/mdoc/docs/compiled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: docs
title: Compiled queries and commands
---

# {{page.title}}

7 changes: 7 additions & 0 deletions docs/src/main/mdoc/docs/exotic_data_return_types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: docs
title: Exotic data and return types
---

# {{page.title}}

7 changes: 7 additions & 0 deletions docs/src/main/mdoc/docs/operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: docs
title: Operations
---

# {{page.title}}

7 changes: 7 additions & 0 deletions docs/src/main/mdoc/docs/queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: docs
title: Queries
---

# {{page.title}}

7 changes: 7 additions & 0 deletions docs/src/main/mdoc/docs/skunk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: docs
title: Usage with skunk
---

# {{page.title}}

7 changes: 7 additions & 0 deletions docs/src/main/mdoc/docs/table_definitions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: docs
title: Table definitions
---

# {{page.title}}

37 changes: 37 additions & 0 deletions docs/src/main/mdoc/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
layout: home
title: "DataPrism"
---

{% assign versions = site.data.versions %}

# DataPrism

*A new FRM with focus on Higher Kinded Data*

DataPrism is an SQL query construction library built to take full advantage of
the power of higher kinded data. DataPrism builds on `perspective` and the
tools it provides.

DataPrism is more flexible than other SQL libraries made for Scala. Want to
sometimes leave out a column? You can do that. Want to return a List from a query,
sure thing.

DataPrism also works with both Java's JDBC and skunk.

Add DataPrism to your project by adding these statements to your `build.sbt` file.

DataPrism is currently early in development, but feel free to try it out and
report bugs and errors.

```scala
// For JDBC
libraryDependencies += "net.katsstuff" %% "dataprism-jdbc" % "{{versions.dataprism}}"

// For Skunk
libraryDependencies += "net.katsstuff" %% "dataprism-skunk" % "{{versions.dataprism}}"
```

# More information

For more information, either see the the examples or the ScalaDoc.
18 changes: 18 additions & 0 deletions docs/src/main/resources/microsite/data/menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
options:
- title: Table definitions
url: docs/table_definitions.html

- title: Queries
url: docs/queries.html

- title: Operations
url: docs/operations.html

- title: Compiled queries and commands
url: docs/compiled_queries_commands.html

- title: Usage with Skunk
url: docs/skunk.html

- title: Exotic data and return types
url: docs/exotic_data_return_types.md
1 change: 1 addition & 0 deletions docs/src/main/resources/microsite/data/versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dataprism: "0.1.0"
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
logLevel := Level.Warn
addSbtPlugin("com.47deg" % "sbt-microsites" % "1.4.3")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
1 change: 1 addition & 0 deletions project/unidoc.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")

0 comments on commit 6733d36

Please sign in to comment.