Skip to content

Commit dceba7d

Browse files
authored
Merge 32a7c1f into ffca832
2 parents ffca832 + 32a7c1f commit dceba7d

File tree

3 files changed

+14
-52
lines changed

3 files changed

+14
-52
lines changed

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

Lines changed: 2 additions & 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+
referencePath.set("/docs/reference/android")
297298
referenceHeadTagsPath.set("docs/reference/android")
298299
dackkaFiles.set(project.childFile(separatedFilesDirectory, "android"))
299300
outputDirectory.set(project.childFile(targetDirectory, "android"))
@@ -303,6 +304,7 @@ abstract class DackkaPlugin : Plugin<Project> {
303304
dependsOnAndMustRunAfter("separateKotlindoc")
304305

305306
referenceHeadTagsPath.set("docs/reference/kotlin")
307+
referencePath.set("/docs/reference/kotlin")
306308
dackkaFiles.set(project.childFile(separatedFilesDirectory, "kotlin"))
307309
outputDirectory.set(project.childFile(targetDirectory, "kotlin"))
308310
}

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.gradle.api.tasks.TaskAction
1919
* More specifically, it:
2020
* - Deletes unnecessary files
2121
* - Removes Class and Index headers from _toc.yaml files
22-
* - Appends /docs/ to hyperlinks in html files
22+
* - Changes links to be appropriate for Firesite versus normal Devsite behavior
2323
* - Removes the prefix path from book_path
2424
* - Removes the firebase prefix from all links
2525
* - Changes the path for _reference-head-tags at the top of html files
@@ -36,6 +36,9 @@ abstract class FiresiteTransformTask : DefaultTask() {
3636
@get:Input
3737
abstract val referenceHeadTagsPath: Property<String>
3838

39+
@get:Input
40+
abstract val referencePath: Property<String>
41+
3942
@get:OutputDirectory
4043
abstract val outputDirectory: Property<File>
4144

@@ -65,15 +68,21 @@ abstract class FiresiteTransformTask : DefaultTask() {
6568
}
6669

6770
private fun File.fixHTMLFile() {
68-
val fixedContent = readText().fixBookPath().fixHyperlinks().removeLeadingFirebaseDomainInLinks().fixReferenceHeadTagsPath()
71+
val fixedContent = readText().fixBookPath().fixReferenceHeadTagsPath().fixLinks()
6972
writeText(fixedContent)
7073
}
7174

7275
private fun File.fixYamlFile() {
73-
val fixedContent = readText().removeClassHeader().removeIndexHeader().removeLeadingFirebaseDomainInLinks()
76+
val fixedContent = readText().removeClassHeader().removeIndexHeader().fixLinks()
7477
writeText(fixedContent)
7578
}
7679

80+
// Our documentation does not live under the standard path expected by Dackka, especially
81+
// between Kotlin + Javadocs
82+
// TODO(b/243674305): Remove when dackka exposes configuration for this
83+
private fun String.fixLinks() =
84+
replace(Regex("(?<=\")/reference[^\"]*?(?=/com/google/firebase)"), referencePath.get())
85+
7786
// We utilize difference reference head tags between Kotlin and Java docs
7887
// TODO(b/248316730): Remove when dackka exposes configuration for this
7988
private fun String.fixReferenceHeadTagsPath() =
@@ -92,11 +101,6 @@ abstract class FiresiteTransformTask : DefaultTask() {
92101
private fun String.fixBookPath() =
93102
remove(Regex("(?<=setvar book_path ?%})(.+)(?=/_book.yaml\\{% ?endsetvar)"))
94103

95-
// Our documentation lives under /docs/reference/ versus the expected /reference/
96-
// TODO(b/243674305): Remove when dackka exposes configuration for this
97-
private fun String.fixHyperlinks() =
98-
replace(Regex("(?<=href=\")(/)(?=reference/.*\\.html)"), "/docs/")
99-
100104
// The documentation will work fine without this. This is primarily to make sure that links
101105
// resolve to their local counter part. Meaning when the docs are staged, they will resolve to
102106
// staged docs instead of prod docs- and vise versa.

kotlindoc/package-lists/firebase/package-list

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)