Ensure javadoc fix applies to Android links with anchors

This means is-external=true is removed and target=_top is
set on the <a> tag.

Without this, javadoc links to framework docs with anchors are
currently broken when viewed in the "frame view" on
exoplayer.dev/doc/reference/

Before this change:
https://developer.android.com/reference/android/media/MediaDrm.html?is-external=true#getKeyRequest-byte:A-byte:A-java.lang.String-int-java.util.HashMap-

With this change:
https://developer.android.com/reference/android/media/MediaDrm.html#getKeyRequest-byte:A-byte:A-java.lang.String-int-java.util.HashMap-

PiperOrigin-RevId: 304136858
This commit is contained in:
ibaker 2020-04-01 09:29:56 +01:00 committed by Oliver Woodman
parent 41853169a7
commit 45186ac377

View File

@ -15,8 +15,8 @@ ext.fixJavadoc = {
def javadocPath = "${project.buildDir}/docs/javadoc" def javadocPath = "${project.buildDir}/docs/javadoc"
// Fix external Android links to target the top frame. // Fix external Android links to target the top frame.
def androidRoot = "https://developer.android.com/reference/" def androidRoot = "https://developer.android.com/reference/"
def androidLink = "<a href=\"(${androidRoot}.*?)\\?is-external=true\"" def androidLink = "<a href=\"(${androidRoot}.*?)\\?is-external=true(.*)\""
def androidFixed = "<a href=\"\\1\" target=\"_top\"" def androidFixed = "<a href=\"\\1\\2\" target=\"_top\""
ant.replaceregexp(match:androidLink, replace:androidFixed, flags:'g') { ant.replaceregexp(match:androidLink, replace:androidFixed, flags:'g') {
fileset(dir: "${javadocPath}", includes: "**/*.html") fileset(dir: "${javadocPath}", includes: "**/*.html")
} }