Skip to content

Commit 07fa659

Browse files
authored
Merge a3455b4 into f6a79df
2 parents f6a79df + a3455b4 commit 07fa659

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ abstract class DackkaPlugin : Plugin<Project> {
294294
val transformJavadoc = project.tasks.register<FiresiteTransformTask>("firesiteTransformJavadoc") {
295295
dependsOnAndMustRunAfter("separateJavadoc")
296296

297+
removeGoogleGroupId.set(true)
297298
referencePath.set("/docs/reference/android")
298299
referenceHeadTagsPath.set("docs/reference/android")
299300
dackkaFiles.set(project.childFile(separatedFilesDirectory, "android"))

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

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.gradle.api.provider.Property
66
import org.gradle.api.tasks.CacheableTask
77
import org.gradle.api.tasks.Input
88
import org.gradle.api.tasks.InputDirectory
9+
import org.gradle.api.tasks.Optional
910
import org.gradle.api.tasks.OutputDirectory
1011
import org.gradle.api.tasks.PathSensitive
1112
import org.gradle.api.tasks.PathSensitivity
@@ -21,7 +22,7 @@ import org.gradle.api.tasks.TaskAction
2122
* - Removes Class and Index headers from _toc.yaml files
2223
* - Changes links to be appropriate for Firesite versus normal Devsite behavior
2324
* - Removes the prefix path from book_path
24-
* - Removes the firebase prefix from all links
25+
* - Removes the google groupId for Javadocs
2526
* - Changes the path for _reference-head-tags at the top of html files
2627
*
2728
* **Please note:**
@@ -39,6 +40,10 @@ abstract class FiresiteTransformTask : DefaultTask() {
3940
@get:Input
4041
abstract val referencePath: Property<String>
4142

43+
@get:Input
44+
@get:Optional
45+
abstract val removeGoogleGroupId: Property<Boolean>
46+
4247
@get:OutputDirectory
4348
abstract val outputDirectory: Property<File>
4449

@@ -73,10 +78,30 @@ abstract class FiresiteTransformTask : DefaultTask() {
7378
}
7479

7580
private fun File.fixYamlFile() {
76-
val fixedContent = readText().removeClassHeader().removeIndexHeader().fixLinks()
81+
val fixedContent = readText().removeClassHeader().removeIndexHeader().fixLinks().let {
82+
if (removeGoogleGroupId.getOrElse(false)) it.removeGoogleGroupId() else it
83+
}
7784
writeText(fixedContent)
7885
}
7986

87+
/**
88+
* Removes the leading `com.google` group id from strings in the file
89+
*
90+
* We have internal SDKs that generate their docs outside the scope of this plugin. The Javadoc
91+
* variant of those SDks is typically generated with metalava- which does *not* provide the
92+
* groupId. This makes the output look weird, as not all SDKs line up. So this method exists
93+
* to correct Javadoc nav files, so that they align with internally generated docs.
94+
*
95+
* Example output:
96+
* ```
97+
* removeGoogleGroupId("com.google.firebase.appcheck")
98+
* --> "firebase.appcheck"
99+
* ```
100+
*/
101+
// TODO(b/257293594): Remove when dackka exposes configuration for this
102+
private fun String.removeGoogleGroupId() =
103+
remove(Regex("(?<=\")com.google.(?=firebase.)"))
104+
80105
// Our documentation does not live under the standard path expected by Dackka, especially
81106
// between Kotlin + Javadocs
82107
// TODO(b/243674305): Remove when dackka exposes configuration for this
@@ -100,11 +125,4 @@ abstract class FiresiteTransformTask : DefaultTask() {
100125
// TODO(b/243674303): Remove when dackka exposes configuration for this
101126
private fun String.fixBookPath() =
102127
remove(Regex("(?<=setvar book_path ?%})(.+)(?=/_book.yaml\\{% ?endsetvar)"))
103-
104-
// The documentation will work fine without this. This is primarily to make sure that links
105-
// resolve to their local counter part. Meaning when the docs are staged, they will resolve to
106-
// staged docs instead of prod docs- and vise versa.
107-
// TODO(b/243673063): Remove when dackka exposes configuration for this
108-
private fun String.removeLeadingFirebaseDomainInLinks() =
109-
remove(Regex("(?<=\")(https://firebase\\.google\\.com)(?=/docs/reference)"))
110128
}

0 commit comments

Comments
 (0)