Skip to content

Commit

Permalink
Table.toGithubFlavouredMarkdown: link to section heading anchors (#1543)
Browse files Browse the repository at this point in the history
assume the format of anchor identifiers currently used by both Github
and the HTML generator used to build the ZIO website
  • Loading branch information
igneus authored Mar 6, 2025
1 parent 0ed21bf commit d0682b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions core/shared/src/main/scala/zio/config/ConfigDocsModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,14 @@ trait ConfigDocsModule {
*/
def githubFlavoured: (Heading, Int, Either[FieldName, Format]) => Link =
(heading, index, fieldNameOrFormat) => {
val headingStr =
heading.path
val headingStr = {
"#" + heading.path
.map(_.asString(Some("Field Descriptions")))
.mkString
.toLowerCase
.replace(".", "")
.replace(" ", "")
.replace(" ", "-")
}

val name = fieldNameOrFormat.fold(
_.asString(Some("Field Descriptions")),
Expand Down
16 changes: 8 additions & 8 deletions core/shared/src/test/scala/zio/config/GenerateDocsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ object GenerateDocsTest extends BaseSpec {
s"""|## Configuration Details
|
|
||FieldName|Format |Description|Sources|
||--- |--- |--- |--- |
|| |[all-of](fielddescriptions)| | |
||FieldName|Format |Description|Sources|
||--- |--- |--- |--- |
|| |[all-of](#field-descriptions)| | |
|
|### Field Descriptions
|
||FieldName |Format |Description |Sources|
||--- |--- |--- |--- |
||SECRET |primitive |a text property, Application secret| |
||[CREDENTIALS](credentials)|[all-of](credentials)|Credentials | |
||[DATABASE](database) |[all-of](database) |Database | |
||FieldName |Format |Description |Sources|
||--- |--- |--- |--- |
||SECRET |primitive |a text property, Application secret| |
||[CREDENTIALS](#credentials)|[all-of](#credentials)|Credentials | |
||[DATABASE](#database) |[all-of](#database) |Database | |
|
|### CREDENTIALS
|
Expand Down

0 comments on commit d0682b5

Please sign in to comment.