Skip to content

Commit 168cc40

Browse files
authored
Merge pull request #14 from softinio/docs-and-release-improvements
documentation and release improvements including adding cats-effect docs
2 parents a4cfd7f + 4e1c435 commit 168cc40

File tree

10 files changed

+120
-16
lines changed

10 files changed

+120
-16
lines changed

.github/workflows/docs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
- name: Generate documentation
4848
run: |
4949
nix develop --command mill 'duck4s[3.8.2].docJar'
50+
nix develop --command mill 'duck4s-cats-effect[3.8.2].docJar'
5051
5152
# Deploy to gh-pages branch
5253
- name: Deploy to GitHub Pages
@@ -57,7 +58,9 @@ jobs:
5758
5859
# Create temporary directory
5960
TEMP_DIR=$(mktemp -d)
60-
cp -r out/duck4s/3.8.2/docJar.dest/javadoc/* "$TEMP_DIR/"
61+
cp -r out/duck4s/3.8.2/docJar.dest/docs/* "$TEMP_DIR/"
62+
mkdir -p "$TEMP_DIR/cats-effect-api"
63+
cp -r out/duck4s-cats-effect/3.8.2/docJar.dest/docs/* "$TEMP_DIR/cats-effect-api/"
6164
6265
# Check if gh-pages branch exists
6366
if git ls-remote --heads origin gh-pages | grep -q gh-pages; then

CLAUDE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ This project supports multiple Scala versions: **3.3.6** and **3.8.2**
2525

2626
#### Documentation Commands
2727
- **Generate API documentation with static site**: `mill 'duck4s[3.8.2].docJar'`
28-
- **Generated site location**: `out/duck4s/3.8.2/docJar.dest/javadoc/index.html`
28+
- **Generated site location**: `out/duck4s/3.8.2/docJar.dest/docs/index.html`
29+
- **Preview docs locally**: `scala-cli run scripts/preview-docs.scala` (generates both core and cats-effect docs, merges them, and serves at http://localhost:8080)
30+
- Optional port: `scala-cli run scripts/preview-docs.scala -- --port 9000`
2931

3032
#### Development Commands
3133
- **Format code**: `mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources`

build.mill

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ trait Duck4sCatsEffectModule
122122
common :+ "-Xkind-projector:underscores"
123123
else common
124124

125+
def scalaDocOptions = Task {
126+
val version = Task.env.get("DUCK4S_DOC_VERSION").getOrElse(publishVersion())
127+
super.scalaDocOptions() ++ Seq(
128+
"-project",
129+
"Duck4s Cats Effect",
130+
"-project-version",
131+
version,
132+
"-social-links:github::https://github.com/softinio/duck4s",
133+
"-groups",
134+
"-external-mappings:" +
135+
".*scala.*::scaladoc3::https://scala-lang.org/api/3.x/," +
136+
".*java.*::javadoc::https://docs.oracle.com/en/java/javase/17/docs/api/"
137+
)
138+
}
139+
125140
def pomSettings = PomSettings(
126141
description = "Scala 3 cats-effect integration for duck4s DuckDB library",
127142
organization = "com.softinio",

devshell.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
[[commands]]
44
package = "mill"
55

6+
[[commands]]
7+
name = "fmt"
8+
command = "mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources"
9+
help = "Format all source files with Scalafmt"
10+
11+
[[commands]]
12+
name = "preview-docs"
13+
command = "scala-cli run scripts/preview-docs.scala"
14+
help = "Preview the documentation site locally"
15+
616
[devshell]
717
packages = [
818
"coursier",

duck4s-cats-effect/src/DuckDBException.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ class DuckDBException(
3434
cause: Option[Throwable] = None
3535
) extends RuntimeException(message, cause.orNull)
3636

37-
/** Factory methods for creating [[DuckDBException]] from [[DuckDBError]]
38-
* values.
37+
/** Factory methods for creating [[DuckDBException]] from
38+
* [[com.softinio.duck4s.algebra.DuckDBError]] values.
3939
*/
4040
object DuckDBException:
4141

42-
/** Converts a [[DuckDBError]] into a [[DuckDBException]].
42+
/** Converts a [[com.softinio.duck4s.algebra.DuckDBError]] into a
43+
* [[DuckDBException]].
4344
*
4445
* @param error
4546
* The DuckDBError to wrap

duck4s-cats-effect/src/DuckDBIO.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ object DuckDBIO:
4949
private[effect] def liftE[T](e: Either[DuckDBError, T]): IO[T] =
5050
IO.fromEither(e.left.map(DuckDBException.from))
5151

52-
/** Acquires a DuckDB connection as a cats-effect [[Resource]]. The connection
53-
* is closed automatically on release.
52+
/** Acquires a DuckDB connection as a cats-effect [[cats.effect.Resource]].
53+
* The connection is closed automatically on release.
5454
*
5555
* @param config
5656
* Database configuration. Defaults to in-memory mode.
5757
* @return
58-
* A [[Resource]] that manages the connection lifecycle.
58+
* A [[cats.effect.Resource]] that manages the connection lifecycle.
5959
*/
6060
def connect(
6161
config: DuckDBConfig = DuckDBConfig.inMemory

duck4s/docs/_docs/cats-effect.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ object Main extends IOApp.Simple:
299299
## Next Steps
300300

301301
- [Getting Started](getting-started.html) - Core synchronous API
302-
- [API Documentation](../index.html) - Complete API reference
302+
- [Core API Documentation](../index.html) - Core API reference
303+
- [Cats-Effect API Documentation](../cats-effect-api/index.html) - Cats-effect module API reference
303304
- [cats-effect documentation](https://typelevel.org/cats-effect/)
304305
- [fs2 documentation](https://fs2.io/)

duck4s/docs/_docs/index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
---
2-
title: Home
3-
---
41

52
![](images/duck4s_logo.jpeg)
63

@@ -42,4 +39,5 @@ val result = DuckDBConnection.withConnection() { conn =>
4239

4340
- [Getting Started](getting-started.html) - Learn the basics of duck4s
4441
- [Cats-Effect Integration](cats-effect.html) - Effectful IO and streaming with cats-effect and fs2
45-
- [API Documentation](../index.html) - Complete API reference
42+
- [API Documentation](../index.html) - Complete core API reference
43+
- [Cats-Effect API Documentation](../cats-effect-api/index.html) - Cats-effect module API reference

scripts/preview-docs.scala

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//> using scala "3.8.2"
2+
//> using dep "com.lihaoyi::cask:0.11.3"
3+
//> using dep "com.lihaoyi::os-lib:0.11.8"
4+
//> using mainClass "DocServer"
5+
6+
/** Generates both doc sites and serves them locally for preview.
7+
*
8+
* Usage (from project root):
9+
* scala-cli run scripts/preview-docs.scala
10+
* scala-cli run scripts/preview-docs.scala -- --port 9000
11+
*/
12+
13+
object DocServer extends cask.MainRoutes:
14+
private var docsDir: String = ""
15+
private var portNum: Int = 8080
16+
17+
override def port = portNum
18+
override def host = "localhost"
19+
override def debugMode = false
20+
21+
@cask.staticFiles("/")
22+
def staticFiles() = docsDir
23+
24+
initialize()
25+
26+
override def main(args: Array[String]): Unit =
27+
portNum = args.zipWithIndex
28+
.find(_._1 == "--port")
29+
.flatMap { case (_, i) => args.lift(i + 1).flatMap(_.toIntOption) }
30+
.getOrElse(8080)
31+
32+
val projectRoot = os.pwd
33+
34+
println("Generating core documentation...")
35+
os.proc("mill", "duck4s[3.8.2].docJar")
36+
.call(cwd = projectRoot, stdout = os.Inherit, stderr = os.Inherit)
37+
38+
println("Generating cats-effect documentation...")
39+
os.proc("mill", "duck4s-cats-effect[3.8.2].docJar")
40+
.call(cwd = projectRoot, stdout = os.Inherit, stderr = os.Inherit)
41+
42+
val coreDocsDir = projectRoot / "out" / "duck4s" / "3.8.2" / "docJar.dest" / "docs"
43+
val catsDocsDir =
44+
projectRoot / "out" / "duck4s-cats-effect" / "3.8.2" / "docJar.dest" / "docs"
45+
46+
val previewDir = os.temp.dir(prefix = "duck4s-preview")
47+
println(s"Merging docs into $previewDir...")
48+
49+
// Copy core docs into preview root
50+
os.list(coreDocsDir).foreach(p =>
51+
os.copy(p, previewDir / p.last, replaceExisting = true, mergeFolders = true)
52+
)
53+
54+
// Copy cats-effect docs into cats-effect-api/ subdirectory
55+
val catsEffectOut = previewDir / "cats-effect-api"
56+
os.makeDir.all(catsEffectOut)
57+
os.list(catsDocsDir).foreach(p =>
58+
os.copy(p, catsEffectOut / p.last, replaceExisting = true, mergeFolders = true)
59+
)
60+
61+
docsDir = previewDir.toString
62+
63+
println(s"Docs ready. Open http://localhost:$portNum/index.html in your browser.")
64+
println("Press Ctrl+C to stop.\n")
65+
66+
super.main(args)

scripts/publish-docs.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,28 @@ fi
5151

5252
# Generate documentation
5353
echo "Generating documentation with version $VERSION..."
54-
DUCK4S_DOC_VERSION="$VERSION" nix develop --command mill 'duck4s[3.7.0].docJar'
54+
DUCK4S_DOC_VERSION="$VERSION" nix develop --command mill 'duck4s[3.8.2].docJar'
55+
DUCK4S_DOC_VERSION="$VERSION" nix develop --command mill 'duck4s-cats-effect[3.8.2].docJar'
5556

5657
# Check if documentation was generated
57-
if [ ! -d "out/duck4s/3.7.0/docJar.dest/javadoc" ]; then
58+
if [ ! -d "out/duck4s/3.8.2/docJar.dest/docs" ]; then
5859
echo "Error: Documentation generation failed"
5960
exit 1
6061
fi
6162

63+
if [ ! -d "out/duck4s-cats-effect/3.8.2/docJar.dest/docs" ]; then
64+
echo "Error: Cats-effect documentation generation failed"
65+
exit 1
66+
fi
67+
6268
# Create temporary directory for docs
6369
TEMP_DIR=$(mktemp -d)
6470
echo "Preparing documentation in $TEMP_DIR..."
6571

6672
# Copy documentation to temp directory
67-
cp -r out/duck4s/3.7.0/docJar.dest/javadoc/* "$TEMP_DIR/"
73+
cp -r out/duck4s/3.8.2/docJar.dest/docs/* "$TEMP_DIR/"
74+
mkdir -p "$TEMP_DIR/cats-effect-api"
75+
cp -r out/duck4s-cats-effect/3.8.2/docJar.dest/docs/* "$TEMP_DIR/cats-effect-api/"
6876

6977
# Switch to gh-pages branch (create if doesn't exist)
7078
echo "Switching to gh-pages branch..."

0 commit comments

Comments
 (0)