Skip to content

Commit e66507d

Browse files
committed
1 parent aae1542 commit e66507d

File tree

6 files changed

+169
-0
lines changed

6 files changed

+169
-0
lines changed

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.common.collect.ImmutableMap;
2222
import com.google.firebase.gradle.plugins.apiinfo.GenerateApiTxtFileTask;
2323
import com.google.firebase.gradle.plugins.apiinfo.ApiInformationTask;
24+
import com.google.firebase.gradle.plugins.apiinfo.GenerateStubsTask;
2425
import com.google.firebase.gradle.plugins.apiinfo.GetMetalavaJarTask;
2526
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
2627

@@ -126,6 +127,14 @@ private static void setupApiInformationAnalysis(Project project, LibraryExtensio
126127
}
127128
task.dependsOn("getMetalavaJar");
128129
});
130+
131+
project.getTasks().register("docStubs", GenerateStubsTask.class, task -> {
132+
task.setMetalavaJarPath(metalavaOutputJarFile.getAbsolutePath());
133+
task.setOutputDir(new File(project.getBuildDir(), "doc-stubs"));
134+
task.dependsOn("getMetalavaJar");
135+
136+
task.setSourceDirs(android.getSourceSets().getByName("main").getJava().getSrcDirs());
137+
});
129138
}
130139

131140
private static void setupStaticAnalysis(
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.gradle.plugins.apiinfo;
16+
17+
import java.io.File;
18+
import java.util.Arrays;
19+
import java.util.Collection;
20+
import java.util.stream.Collectors;
21+
import org.gradle.api.DefaultTask;
22+
import org.gradle.api.tasks.Input;
23+
import org.gradle.api.tasks.InputFiles;
24+
import org.gradle.api.tasks.OutputDirectory;
25+
import org.gradle.api.tasks.TaskAction;
26+
27+
public abstract class GenerateStubsTask extends DefaultTask {
28+
@Input
29+
public abstract String getMetalavaJarPath();
30+
31+
public abstract void setMetalavaJarPath(String path);
32+
33+
@InputFiles
34+
public abstract Collection<File> getSourceDirs();
35+
36+
public abstract void setSourceDirs(Collection<File> dirs);
37+
38+
@OutputDirectory
39+
public abstract File getOutputDir();
40+
41+
public abstract void setOutputDir(File dir);
42+
43+
@TaskAction
44+
public void run() {
45+
String sourcePath =
46+
getSourceDirs().stream().map(File::getAbsolutePath).collect(Collectors.joining(":"));
47+
48+
getProject()
49+
.javaexec(
50+
spec -> {
51+
spec.setMain("-jar");
52+
spec.setArgs(
53+
Arrays.asList(
54+
getMetalavaJarPath(),
55+
"--quiet",
56+
"--source-path",
57+
sourcePath,
58+
"--include-annotations",
59+
"--doc-stubs",
60+
getOutputDir().getAbsolutePath()));
61+
});
62+
}
63+
}

kotlindoc/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Tooling to generate Kotlin documentation.
2+
3+
This module contains configuration for generating Kotlindoc that is hosted at
4+
[firebase.github.io](https://firebase.github.io/firebase-android-sdk/reference/kotlin/firebase-ktx/).
5+
6+
To generate documentation for all "supported" SDKs(ones that have Kotlin extensions) run:
7+
8+
```bash
9+
./gradlew :kotlindoc:dokka
10+
```
11+
12+
To generate documentation for a subset of SDKs run:
13+
14+
```bash
15+
./gradlew -PkotlindocProjects=":firebase-common,:firebase-firestore" :kotlindoc:dokka
16+
```
17+
18+
The output will be located in `kotlindoc/build/dokka/html`.
19+
20+
To update the live reference, create a PR with the contents of the above directory into the `gh-pages` branch.

kotlindoc/kotlindoc.gradle

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'kotlin-android'
4+
id 'org.jetbrains.dokka-android' version '0.9.18'
5+
}
6+
7+
android {
8+
compileSdkVersion project.targetSdkVersion
9+
defaultConfig {
10+
minSdkVersion project.minSdkVersion
11+
targetSdkVersion project.targetSdkVersion
12+
}
13+
}
14+
15+
configurations {
16+
dokkapath
17+
dokkapath.description = "dokka project classpath"
18+
}
19+
20+
def ALL_SUPPORTED_PROJECTS = [
21+
':firebase-common',
22+
':firebase-config',
23+
':firebase-firestore',
24+
':firebase-functions',
25+
':firebase-storage',
26+
]
27+
28+
29+
def PROJECTS_TO_DOCUMENT = (project.findProperty('kotlindocProjects')?.split(',') ?: ALL_SUPPORTED_PROJECTS).collect {
30+
project(it)
31+
}
32+
33+
def javaDeps = PROJECTS_TO_DOCUMENT
34+
def kotlinDeps = javaDeps.collect {
35+
project("$it.path:ktx")
36+
}
37+
38+
dokka {
39+
moduleName = "firebase-ktx"
40+
outputDirectory = "$buildDir/dokka/html"
41+
outputFormat = "html"
42+
processConfigurations = []
43+
44+
javaDeps.each { Project p ->
45+
dependsOn "$p.path:docStubs"
46+
sourceRoot {
47+
path = "$p.buildDir/doc-stubs"
48+
}
49+
}
50+
afterEvaluate {
51+
sourceDirs = files(kotlinDeps.collect {
52+
"$it.projectDir/src/main/kotlin"
53+
})
54+
}
55+
56+
externalDocumentationLink {
57+
url = new URL('https://developer.android.com/reference/kotlin')
58+
}
59+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2019 Google LLC -->
3+
<!-- -->
4+
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
5+
<!-- you may not use this file except in compliance with the License. -->
6+
<!-- You may obtain a copy of the License at -->
7+
<!-- -->
8+
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
9+
<!-- -->
10+
<!-- Unless required by applicable law or agreed to in writing, software -->
11+
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
12+
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
13+
<!-- See the License for the specific language governing permissions and -->
14+
<!-- limitations under the License. -->
15+
16+
<manifest package="com.google.firebase.kotlindoc" />

subprojects.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ transport
3030
transport:transport-api
3131
transport:transport-backend-cct
3232
transport:transport-runtime
33+
34+
kotlindoc

0 commit comments

Comments
 (0)