From f4818d591588305751b7e1b6f0ff05e454a78b34 Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Wed, 22 May 2024 10:58:23 +0330 Subject: [PATCH] generating config documentation. --- docs/dive-into-zio-config.md | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/dive-into-zio-config.md b/docs/dive-into-zio-config.md index 614186c87..b8a8a3cfc 100644 --- a/docs/dive-into-zio-config.md +++ b/docs/dive-into-zio-config.md @@ -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`.