Skip to content

Commit

Permalink
Add Unidoc Support (zio#1919)
Browse files Browse the repository at this point in the history
* add support for scaladoc.

* add zioHttpLogging to docs dependencies.
  • Loading branch information
khajavi authored Jan 9, 2023
1 parent 629f6a9 commit a305800
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 67 deletions.
40 changes: 32 additions & 8 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,40 @@ name: Website
push:
branches:
- main
pull_request: {}
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Git Checkout
uses: actions/[email protected]
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/[email protected]
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Check that site workflow is up to date
run: sbt docs/checkGithubWorkflow
- name: Check artifacts build process
run: sbt +publishLocal
- name: Check website build process
run: sbt docs/buildWebsite
publish-docs:
name: Publish Docs
runs-on: ubuntu-latest
if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.2.0
uses: actions/checkout@v3.3.0
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.6.0
uses: actions/setup-java@v3.9.0
with:
distribution: temurin
java-version: 17
Expand All @@ -38,14 +60,15 @@ jobs:
generate-readme:
name: Generate README
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'push') || ((github.event_name == 'release') && (github.event_name == 'published')) }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.2.0
uses: actions/checkout@v3.3.0
with:
ref: ${{ github.head_ref }}
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.6.0
uses: actions/setup-java@v3.9.0
with:
distribution: temurin
java-version: 17
Expand All @@ -59,14 +82,15 @@ jobs:
git add README.md
git commit -m "Update README.md" || echo "No changes to commit"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v4.2.3
with:
title: Update README.md
commit-message: Update README.md
branch: zio-sbt-website/update-readme
body: |-
Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin.
I will automatically update the README.md file whenever there is new change for README.md, e.g.
- After each release, I will update the version in the installation section.
- After any changes to the "docs/index.md" file, I will update the README.md file accordingly.
branch: zio-sbt-website/update-readme
commit-message: Update README.md
delete-branch: true
title: Update README.md
78 changes: 32 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
# ZIO Http
[//]: # (This file was autogenerated using `zio-sbt-website` plugin via `sbt generateReadme` command.)
[//]: # (So please do not edit it manually. Instead, change "docs/index.md" file or sbt setting keys)
[//]: # (e.g. "readmeDocumentation" and "readmeSupport".)

ZIO Http is a scala library for building http apps. It is powered by [ZIO] and [netty] and aims at being the defacto solution for writing, highly scalable and [performant](#benchmarks) web applications using idiomatic scala.
# ZIO Http

Check out the full documentation here: [Documentation]
ZIO Http is a scala library for building http apps. It is powered by ZIO and [netty](https://netty.io/) and aims at being the defacto solution for writing, highly scalable and performant web applications using idiomatic scala.

[Documentation]: https://zio.dev/zio-http
@PROJECT-BADGES@

![Continuous Integration](https://github.com/zio/zio-http/workflows/Continuous%20Integration/badge.svg)
[![Discord Chat](https://img.shields.io/discord/629491597070827530.svg?logo=discord)](https://discord.com/channels/629491597070827530/819703129267372113)
[![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/dev.zio/zio-http_2.13?server=https%3A%2F%2Foss.sonatype.org)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-http_2.13/)
[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/dev.zio/zio-http_2.13?server=https%3A%2F%2Foss.sonatype.org)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-http_2.13/)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/zio/zio-http.svg)](http://isitmaintained.com/project/zio/zio-http "Average time to resolve an issue")
[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/zio/zio-http)
## Installation

[zio]: https://zio.dev
[netty]: http://netty.io
Setup via `build.sbt`:

**Table of Contents**
```scala
libraryDependencies += "dev.zio" %% "http" % "0.0.3"
```

- [ZIO Http](#zio-http)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Documentation](https://zio.dev/zio-http/)
**NOTE:** ZIO Http is compatible with `ZIO 1.x` and `ZIO 2.x`.

# Getting Started
## Getting Started

A simple Http server can be built using a few lines of code.

Expand All @@ -42,47 +37,38 @@ object HelloWorld extends ZIOAppDefault {
Server.serve(app).provide(Server.default)
}
```
#### Examples

You can checkout more examples in the [example](https://github.com/zio/zio-http/tree/main/example/src/main/scala/example) project —

- [Simple Server](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/HelloWorld.scala)
- [Advanced Server](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/HelloWorldAdvanced.scala)
- [WebSocket Server](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/WebSocketEcho.scala)
- [Streaming Response](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/StreamingResponse.scala)
- [Simple Client](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/SimpleClient.scala)
- [File Streaming](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/FileStreaming.scala)
- [Basic Authentication](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/BasicAuth.scala)
- [JWT Authentication Client](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/AuthenticationClient.scala)
- [JWT Authentication Server](https://github.com/zio/zio-http/blob/main/zio-http-example/src/main/scala/example/AuthenticationServer.scala)

#### Steps to run an example
## Steps to run an example

1. Edit the [RunSettings](https://github.com/zio/zio-http/blob/main/project/BuildHelper.scala#L109) - modify `className` to the example you'd like to run.
2. From sbt shell, run `~example/reStart`. You should see `Server started on port: 8080`.
3. Send curl request for defined `http Routes`, for eg : `curl -i "http://localhost:8080/text"` for `example.HelloWorld`.

# Installation
## Watch Mode

Setup via `build.sbt`
You can use the [sbt-revolver] plugin to start the server and run it in watch mode using `~ reStart` command on the SBT console.

### Stable
```scala
libraryDependencies += "io.d11" %% "zhttp" % "[version]"
```
[sbt-revolver]: https://github.com/spray/sbt-revolver

### Snapshot
```scala
libraryDependencies += "dev.zio" %% "zio-http" % "[version]"
```
## Documentation

Learn more on the [ZIO Http homepage](https://github.com/zio/zio-http)!

**NOTE:** ZIO Http is compatible with `ZIO 1.x` and `ZIO 2.x`.
## Contributing

For the general guidelines, see ZIO [contributor's guide](https://zio.dev/about/contributing).

# Watch Mode
## Code of Conduct

You can use the [sbt-revolver] plugin to start the server and run it in watch mode using `~ reStart` command on the SBT console.
See the [Code of Conduct](https://zio.dev/about/code-of-conduct)

[sbt-revolver]: https://github.com/spray/sbt-revolver
## Support

Come chat with us on [![Badge-Discord]][Link-Discord].

[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord "chat on discord"
[Link-Discord]: https://discord.gg/2ccFBr4 "Discord"

## License

[License](LICENSE)
18 changes: 7 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,14 @@ lazy val zioHttpTestkit = (project in file("zio-http-testkit"))
lazy val docs = project
.in(file("zio-http-docs"))
.settings(
publish / skip := true,
moduleName := "zio-http-docs",
moduleName := "zio-http-docs",
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings",
projectName := "ZIO Http",
badgeInfo := Some(
BadgeInfo(
artifact = "zio-http_2.12",
projectStage = ProjectStage.Development,
),
),
docsPublishBranch := "main",
projectName := "ZIO Http",
mainModuleName := (zioHttp / moduleName).value,
projectStage := ProjectStage.Development,
docsPublishBranch := "main",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(zioHttp, zioHttpLogging),
)
// .dependsOn(zioHttp)
.dependsOn(zioHttp, zioHttpLogging)
.enablePlugins(WebsitePlugin)
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.5.1")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.2.2")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.2")

resolvers += Resolver.sonatypeRepo("public")
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ object NettyDriver {
new AtomicReference[(HttpApp[Any, Throwable], ZEnvironment[Any])]((Http.empty, ZEnvironment.empty)),
)
val ecb = ZLayer.succeed(new AtomicReference[Option[Server.ErrorCallback]](Option.empty))
val time = ZLayer.succeed(ServerTime.make(1000 millis))
val time = ZLayer.succeed(ServerTime.make(1000.millis))

val nettyBits = ZLayer.fromZIOEnvironment(for {
elg <- ZIO.service[EventLoopGroup]
Expand Down

0 comments on commit a305800

Please sign in to comment.