Skip to content

Commit d719e10

Browse files
authored
Fix multiline hyperlink renders (#4307)
* Replace trace hyperlink with direct link * Replace timestamp link with non multiline variant * Add transform to rectify hyperlink bugs in see blocks
1 parent 0ba9bc3 commit d719e10

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

buildSrc/src/main/java/com/google/firebase/gradle/plugins/FiresiteTransformTask.kt

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.gradle.api.tasks.TaskAction
2121
* - Deletes unnecessary files
2222
* - Removes Class and Index headers from _toc.yaml files
2323
* - Changes links to be appropriate for Firesite versus normal Devsite behavior
24+
* - Fixes broken hyperlinks in `@see` blocks
2425
* - Removes the prefix path from book_path
2526
* - Removes the google groupId for Javadocs
2627
* - Changes the path for _reference-head-tags at the top of html files
@@ -73,7 +74,7 @@ abstract class FiresiteTransformTask : DefaultTask() {
7374
}
7475

7576
private fun File.fixHTMLFile() {
76-
val fixedContent = readText().fixBookPath().fixReferenceHeadTagsPath().fixLinks()
77+
val fixedContent = readText().fixBookPath().fixReferenceHeadTagsPath().fixLinks().fixHyperlinksInSeeBlocks()
7778
writeText(fixedContent)
7879
}
7980

@@ -92,16 +93,48 @@ abstract class FiresiteTransformTask : DefaultTask() {
9293
* groupId. This makes the output look weird, as not all SDKs line up. So this method exists
9394
* to correct Javadoc nav files, so that they align with internally generated docs.
9495
*
96+
* Example input:
97+
* ```
98+
* "com.google.firebase.appcheck"
99+
* ```
95100
* Example output:
96101
* ```
97-
* removeGoogleGroupId("com.google.firebase.appcheck")
98-
* --> "firebase.appcheck"
102+
* "firebase.appcheck"
99103
* ```
100104
*/
101105
// TODO(b/257293594): Remove when dackka exposes configuration for this
102106
private fun String.removeGoogleGroupId() =
103107
remove(Regex("(?<=\")com.google.(?=firebase.)"))
104108

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>&lt;a href=&quot;git.page.link/timestamp-proto&quot;&gt;Timestamp&lt;/a&gt;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>&lt;a href=&quot;(?<href>.*)&quot;&gt;(?<link>.*)&lt;/a&gt;(?<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+
105138
// Our documentation does not live under the standard path expected by Dackka, especially
106139
// between Kotlin + Javadocs
107140
// TODO(b/243674305): Remove when dackka exposes configuration for this

firebase-firestore/src/main/java/com/google/firebase/Timestamp.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
* 9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we can convert to
3131
* and from RFC 3339 date strings.
3232
*
33-
* @see <a href="
34-
* https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto">The
35-
* reference timestamp definition</a>
33+
* @see <a href="https://git.page.link/timestamp-proto">Timestamp</a>The ref timestamp definition
3634
*/
3735
public final class Timestamp implements Comparable<Timestamp>, Parcelable {
3836

firebase-perf/src/main/java/com/google/firebase/perf/metrics/Trace.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,7 @@ public Map<String, String> getAttributes() {
689689
* Describes the kinds of special objects contained in this Parcelable's marshalled
690690
* representation.
691691
*
692-
* @see <a href="https://developer.android.com/reference/android/os/Parcelable.html">
693-
* https://developer.android.com/reference/android/os/Parcelable.html</a>
692+
* @see Parcelable
694693
* @return always returns 0.
695694
*/
696695
@Keep

0 commit comments

Comments
 (0)