-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathjavadoc_cleanup.gradle
74 lines (56 loc) · 5.06 KB
/
javadoc_cleanup.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// remove the excessive whitespaces between method arguments in the javadocs
task javadocCleanup(dependsOn: "javadoc") doLast {
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/core/Flowable.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/core/Observable.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/core/Single.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/core/Maybe.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/core/Completable.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/flowables/ConnectableFlowable.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/observables/ConnectableObservable.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/subjects/ReplaySubject.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/processors/ReplayProcessor.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/subjects/PublishSubject.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/processors/PublishProcessor.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/subjects/AsyncSubject.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/processors/AsyncProcessor.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/subjects/BehaviorSubject.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/processors/BehaviorProcessor.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/processors/MulticastProcessor.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/subjects/UnicastSubject.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/processors/UnicastProcessor.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/plugins/RxJavaPlugins.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/parallel/ParallelFlowable.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/disposables/Disposable.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/observers/TestObserver.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/observers/BaseTestConsumer.html'))
fixJavadocFile(rootProject.file('build/docs/javadoc/io/reactivex/rxjava3/subscribers/TestSubscriber.html'))
}
def fixJavadocFile(file) {
logger.lifecycle("Cleaning up: " + file)
String fileContents = file.getText('UTF-8')
// lots of spaces after the previous method argument
fileContents = fileContents.replaceAll(",\\s{4,}", ",\n ")
// lots of spaces after the @NonNull annotations
fileContents = fileContents.replaceAll("@NonNull</a>\\s{4,}", "@NonNull</a> ")
// lots of spaces after the @Nullable annotations
fileContents = fileContents.replaceAll("@Nullable</a>\\s{4,}", "@Nullable</a> ")
// javadoc bug: duplicates the link to @NonNull for some reason
def nonNullText1 = "<a href=\"../annotations/NonNull.html\" title=\"annotation in io.reactivex.rxjava3.annotations\">@NonNull</a>"
fileContents = fileContents.replace(nonNullText1 + " " + nonNullText1, nonNullText1)
fileContents = fileContents.replace(nonNullText1 + "\n " + nonNullText1, nonNullText1)
fileContents = fileContents.replace(nonNullText1 + "\r\n " + nonNullText1, nonNullText1)
def nonNullText2 = "<a href=\"../../../../io/reactivex/rxjava3/annotations/NonNull.html\" title=\"annotation in io.reactivex.rxjava3.annotations\">@NonNull</a>"
fileContents = fileContents.replace(nonNullText2 + " " + nonNullText2, nonNullText2)
fileContents = fileContents.replace(nonNullText2 + "\n " + nonNullText2, nonNullText2)
fileContents = fileContents.replace(nonNullText2 + "\r\n " + nonNullText2, nonNullText2)
// javadoc bug: duplicates the link to @Nullable for some reason
def nullableText1 = "<a href=\"../annotations/Nullable.html\" title=\"annotation in io.reactivex.rxjava3.annotations\">@Nullable</a>"
fileContents = fileContents.replace(nullableText1 + " " + nullableText1, nullableText1)
fileContents = fileContents.replace(nullableText1 + "\n " + nullableText1, nullableText1)
fileContents = fileContents.replace(nullableText1 + "\r\n " + nullableText1, nullableText1)
def nullableText2 = "<a href=\"../../../../io/reactivex/rxjava3/annotations/Nullable.html\" title=\"annotation in io.reactivex.rxjava3.annotations\">@Nullable</a>"
fileContents = fileContents.replace(nullableText2 + " " + nullableText2, nullableText2)
fileContents = fileContents.replace(nullableText2 + "\n " + nullableText2, nullableText2)
fileContents = fileContents.replace(nullableText2 + "\r\n " + nullableText2, nullableText2)
file.setText(fileContents, 'UTF-8')
}