Skip to content

Commit d0682b5

Browse files
authored
Table.toGithubFlavouredMarkdown: link to section heading anchors (#1543)
assume the format of anchor identifiers currently used by both Github and the HTML generator used to build the ZIO website
1 parent 0ed21bf commit d0682b5

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

core/shared/src/main/scala/zio/config/ConfigDocsModule.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,14 @@ trait ConfigDocsModule {
432432
*/
433433
def githubFlavoured: (Heading, Int, Either[FieldName, Format]) => Link =
434434
(heading, index, fieldNameOrFormat) => {
435-
val headingStr =
436-
heading.path
435+
val headingStr = {
436+
"#" + heading.path
437437
.map(_.asString(Some("Field Descriptions")))
438438
.mkString
439439
.toLowerCase
440440
.replace(".", "")
441-
.replace(" ", "")
441+
.replace(" ", "-")
442+
}
442443

443444
val name = fieldNameOrFormat.fold(
444445
_.asString(Some("Field Descriptions")),

core/shared/src/test/scala/zio/config/GenerateDocsTest.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ object GenerateDocsTest extends BaseSpec {
1515
s"""|## Configuration Details
1616
|
1717
|
18-
||FieldName|Format |Description|Sources|
19-
||--- |--- |--- |--- |
20-
|| |[all-of](fielddescriptions)| | |
18+
||FieldName|Format |Description|Sources|
19+
||--- |--- |--- |--- |
20+
|| |[all-of](#field-descriptions)| | |
2121
|
2222
|### Field Descriptions
2323
|
24-
||FieldName |Format |Description |Sources|
25-
||--- |--- |--- |--- |
26-
||SECRET |primitive |a text property, Application secret| |
27-
||[CREDENTIALS](credentials)|[all-of](credentials)|Credentials | |
28-
||[DATABASE](database) |[all-of](database) |Database | |
24+
||FieldName |Format |Description |Sources|
25+
||--- |--- |--- |--- |
26+
||SECRET |primitive |a text property, Application secret| |
27+
||[CREDENTIALS](#credentials)|[all-of](#credentials)|Credentials | |
28+
||[DATABASE](#database) |[all-of](#database) |Database | |
2929
|
3030
|### CREDENTIALS
3131
|

0 commit comments

Comments
 (0)