@@ -21,6 +21,7 @@ import org.gradle.api.tasks.TaskAction
21
21
* - Deletes unnecessary files
22
22
* - Removes Class and Index headers from _toc.yaml files
23
23
* - Changes links to be appropriate for Firesite versus normal Devsite behavior
24
+ * - Fixes broken hyperlinks in `@see` blocks
24
25
* - Removes the prefix path from book_path
25
26
* - Removes the google groupId for Javadocs
26
27
* - Changes the path for _reference-head-tags at the top of html files
@@ -73,7 +74,7 @@ abstract class FiresiteTransformTask : DefaultTask() {
73
74
}
74
75
75
76
private fun File.fixHTMLFile () {
76
- val fixedContent = readText().fixBookPath().fixReferenceHeadTagsPath().fixLinks()
77
+ val fixedContent = readText().fixBookPath().fixReferenceHeadTagsPath().fixLinks().fixHyperlinksInSeeBlocks()
77
78
writeText(fixedContent)
78
79
}
79
80
@@ -92,16 +93,48 @@ abstract class FiresiteTransformTask : DefaultTask() {
92
93
* groupId. This makes the output look weird, as not all SDKs line up. So this method exists
93
94
* to correct Javadoc nav files, so that they align with internally generated docs.
94
95
*
96
+ * Example input:
97
+ * ```
98
+ * "com.google.firebase.appcheck"
99
+ * ```
95
100
* Example output:
96
101
* ```
97
- * removeGoogleGroupId("com.google.firebase.appcheck")
98
- * --> "firebase.appcheck"
102
+ * "firebase.appcheck"
99
103
* ```
100
104
*/
101
105
// TODO(b/257293594): Remove when dackka exposes configuration for this
102
106
private fun String.removeGoogleGroupId () =
103
107
remove(Regex (" (?<=\" )com.google.(?=firebase.)" ))
104
108
109
+ /* *
110
+ * Fixes broken hyperlinks in the rendered HTML
111
+ *
112
+ * Links in Dockka are currently broken in `@see` tags. This transform destructures those
113
+ * broken links and reconstructs them as they're expected to be.
114
+ *
115
+ * Example input:
116
+ * ```
117
+ * // Generated from @see <a href="git.page.link/timestamp-proto">Timestamp</a>The ref timestamp definition
118
+ * <code><a href="git.page.link/timestamp-proto">Timestamp</a>The ref timestamp definition</code></td>
119
+ * <td></td>
120
+ * ```
121
+ * Example output:
122
+ * ```
123
+ * <code><a href="git.page.link/timestamp-proto">Timestamp</a></code></td>
124
+ * <td>The ref timestamp definition</td>
125
+ * ```
126
+ */
127
+ // TODO(go/dokka-upstream-bug/2665): Remove when Dockka fixes this issue
128
+ private fun String.fixHyperlinksInSeeBlocks () =
129
+ replace(Regex (" <code><a href="(?<href>.*)">(?<link>.*)</a>(?<text>.*)</code></td>\\ s*<td></td>" )) {
130
+ val (href, link, text) = it.destructured
131
+
132
+ """
133
+ <code><a href="$href ">$link </a></code></td>
134
+ <td>$text </td>
135
+ """ .trimIndent()
136
+ }
137
+
105
138
// Our documentation does not live under the standard path expected by Dackka, especially
106
139
// between Kotlin + Javadocs
107
140
// TODO(b/243674305): Remove when dackka exposes configuration for this
0 commit comments