Skip to content

Commit

Permalink
generating config documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
khajavi committed May 22, 2024
1 parent 1ba774f commit f4818d5
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions docs/dive-into-zio-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,34 @@ source.load(MyConfig.config)
## Generating Config Documentation

```scala mdoc:silent
generateDocs(MyConfig.config)
//Creates documentation (automatic)
import utils._

val betterConfig =
(string("LDAP") ?? "Related to auth" zip int("PORT") ?? "Database port" zip
string("DB_URL") ?? "url of database"
).to[MyConfig]
printSource("examples/shared/src/main/scala/zio/config/examples/documentation/DocsGeneration.scala")
```

Here is the output:

```scala
auto-generated documentation of MyConfig:

## Configuration Details

generateDocs(betterConfig).toTable.toGithubFlavouredMarkdown
// Custom documentation along with auto generated docs

|FieldName|Format |Description|Sources|
|--- |--- |--- |--- |
| |[all-of](fielddescriptions)| | |

### Field Descriptions

|FieldName|Format |Description |Sources|
|--- |--- |--- |--- |
|LDAP |primitive|a text property, Related to auth | |
|PORT |primitive|an integer property, Database port| |
|DB_URL |primitive|a text property, URL of database | |
```

Currently, ZIO Config supports generating the documentation in two flavors: GitHub and Confluence markdown.

## Accumulating all errors

For any misconfiguration, the `ReadError` collects all of them with proper semantics: `AndErrors` and `OrErrors`.
Expand Down

0 comments on commit f4818d5

Please sign in to comment.