@@ -71,8 +71,6 @@ public class DefaultTemplateModelFactory(
71
71
}
72
72
mapper[" template_cmd" ] = TemplateDirective (context.configuration, pathToRoot)
73
73
74
- calculateSourceUrlFromSourceLinks()?.let { mapper[" sourceUrl" ] = it }
75
-
76
74
if (page is ContentPage ) {
77
75
val sourceSets = page.content.withDescendants()
78
76
.flatMap { it.sourceSets }
@@ -88,18 +86,21 @@ public class DefaultTemplateModelFactory(
88
86
return mapper
89
87
}
90
88
91
- override fun buildSharedModel (): TemplateMap = mapOf<String , Any >(
92
- " footerMessage" to (configuration?.footerMessage?.takeIf { it.isNotEmpty() }
93
- ? : DokkaBaseConfiguration .defaultFooterMessage)
94
- )
89
+ override fun buildSharedModel (): TemplateMap {
90
+ val mapper = mutableMapOf<String , Any >()
91
+
92
+ mapper[" footerMessage" ] =
93
+ (configuration?.footerMessage?.takeIf (String ::isNotBlank) ? : DokkaBaseConfiguration .defaultFooterMessage)
95
94
96
- private fun calculateSourceUrlFromSourceLinks (): String? {
97
- val githubLinkRegex = Regex (" http(s)?://github\\ .com/([\\ w,\\ -_]+)/([\\ w,\\ -_]+)/.*" )
95
+ calculateSourceUrlFromSourceLinks()?.let { mapper[" sourceUrl" ] = it }
98
96
97
+ return mapper
98
+ }
99
+
100
+ private fun calculateSourceUrlFromSourceLinks (): String? {
99
101
fun parseGithubInfo (link : String ): Pair <String , String >? {
100
102
val (
101
103
_, // entire match
102
- _, // optional 's' in http
103
104
owner,
104
105
repo
105
106
) = githubLinkRegex.find(link)?.groupValues ? : return null
@@ -153,6 +154,10 @@ public class DefaultTemplateModelFactory(
153
154
append(resourceHtml)
154
155
}
155
156
}
157
+
158
+ private companion object {
159
+ val githubLinkRegex = Regex (" https?://github\\ .com/([\\ w,\\ -_]+)/([\\ w,\\ -_]+)/.*" )
160
+ }
156
161
}
157
162
158
163
private class PrintDirective (val generateData : () -> String ) : TemplateDirectiveModel {
0 commit comments