@@ -19,7 +19,7 @@ import org.gradle.api.tasks.TaskAction
19
19
* More specifically, it:
20
20
* - Deletes unnecessary files
21
21
* - 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
23
23
* - Removes the prefix path from book_path
24
24
* - Removes the firebase prefix from all links
25
25
* - Changes the path for _reference-head-tags at the top of html files
@@ -36,6 +36,9 @@ abstract class FiresiteTransformTask : DefaultTask() {
36
36
@get:Input
37
37
abstract val referenceHeadTagsPath: Property <String >
38
38
39
+ @get:Input
40
+ abstract val referencePath: Property <String >
41
+
39
42
@get:OutputDirectory
40
43
abstract val outputDirectory: Property <File >
41
44
@@ -65,15 +68,21 @@ abstract class FiresiteTransformTask : DefaultTask() {
65
68
}
66
69
67
70
private fun File.fixHTMLFile () {
68
- val fixedContent = readText().fixBookPath().fixHyperlinks ().removeLeadingFirebaseDomainInLinks().fixReferenceHeadTagsPath ()
71
+ val fixedContent = readText().fixBookPath().fixReferenceHeadTagsPath ().fixLinks ()
69
72
writeText(fixedContent)
70
73
}
71
74
72
75
private fun File.fixYamlFile () {
73
- val fixedContent = readText().removeClassHeader().removeIndexHeader().removeLeadingFirebaseDomainInLinks ()
76
+ val fixedContent = readText().removeClassHeader().removeIndexHeader().fixLinks ()
74
77
writeText(fixedContent)
75
78
}
76
79
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
+
77
86
// We utilize difference reference head tags between Kotlin and Java docs
78
87
// TODO(b/248316730): Remove when dackka exposes configuration for this
79
88
private fun String.fixReferenceHeadTagsPath () =
@@ -92,11 +101,6 @@ abstract class FiresiteTransformTask : DefaultTask() {
92
101
private fun String.fixBookPath () =
93
102
remove(Regex (" (?<=setvar book_path ?%})(.+)(?=/_book.yaml\\ {% ?endsetvar)" ))
94
103
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
-
100
104
// The documentation will work fine without this. This is primarily to make sure that links
101
105
// resolve to their local counter part. Meaning when the docs are staged, they will resolve to
102
106
// staged docs instead of prod docs- and vise versa.
0 commit comments