@@ -6,6 +6,7 @@ import org.gradle.api.provider.Property
6
6
import org.gradle.api.tasks.CacheableTask
7
7
import org.gradle.api.tasks.Input
8
8
import org.gradle.api.tasks.InputDirectory
9
+ import org.gradle.api.tasks.Optional
9
10
import org.gradle.api.tasks.OutputDirectory
10
11
import org.gradle.api.tasks.PathSensitive
11
12
import org.gradle.api.tasks.PathSensitivity
@@ -21,7 +22,7 @@ import org.gradle.api.tasks.TaskAction
21
22
* - Removes Class and Index headers from _toc.yaml files
22
23
* - Changes links to be appropriate for Firesite versus normal Devsite behavior
23
24
* - Removes the prefix path from book_path
24
- * - Removes the firebase prefix from all links
25
+ * - Removes the google groupId for Javadocs
25
26
* - Changes the path for _reference-head-tags at the top of html files
26
27
*
27
28
* **Please note:**
@@ -39,6 +40,10 @@ abstract class FiresiteTransformTask : DefaultTask() {
39
40
@get:Input
40
41
abstract val referencePath: Property <String >
41
42
43
+ @get:Input
44
+ @get:Optional
45
+ abstract val removeGoogleGroupId: Property <Boolean >
46
+
42
47
@get:OutputDirectory
43
48
abstract val outputDirectory: Property <File >
44
49
@@ -73,10 +78,30 @@ abstract class FiresiteTransformTask : DefaultTask() {
73
78
}
74
79
75
80
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
+ }
77
84
writeText(fixedContent)
78
85
}
79
86
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
+
80
105
// Our documentation does not live under the standard path expected by Dackka, especially
81
106
// between Kotlin + Javadocs
82
107
// TODO(b/243674305): Remove when dackka exposes configuration for this
@@ -100,11 +125,4 @@ abstract class FiresiteTransformTask : DefaultTask() {
100
125
// TODO(b/243674303): Remove when dackka exposes configuration for this
101
126
private fun String.fixBookPath () =
102
127
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)" ))
110
128
}
0 commit comments