Skip to content

Commit de47276

Browse files
authored
fix: add dokka and fix doc generation (#1249)
1 parent b5d5a6a commit de47276

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

.github/workflows/docs.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2023 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+
# A workflow that updates the gh-pages branch whenever a new release is made
16+
name: Update documentation
17+
18+
on:
19+
push:
20+
branches: [ main ]
21+
repository_dispatch:
22+
types: [gh-pages]
23+
workflow_dispatch:
24+
25+
jobs:
26+
gh-page-sync:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
31+
- name: Checkout Repo
32+
uses: actions/checkout@v2
33+
34+
- name: Gradle Wrapper Validation
35+
uses: gradle/[email protected]
36+
37+
- name: Set up JDK 17
38+
uses: actions/[email protected]
39+
with:
40+
java-version: '17'
41+
distribution: 'temurin'
42+
43+
# Run dokka and create tar
44+
- name: Generate documentation
45+
run: |
46+
./gradlew dokkaHtml
47+
48+
echo "Creating tar for generated docs"
49+
cd $GITHUB_WORKSPACE/build/dokka/html && tar cvf ~/android-maps-utils-docs.tar .
50+
51+
echo "Unpacking tar into gh-pages branch"
52+
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
53+
cd $GITHUB_WORKSPACE && git checkout gh-pages && tar xvf ~/android-maps-utils-docs.tar
54+
55+
# Commit changes and create a PR
56+
- name: PR Changes
57+
uses: peter-evans/create-pull-request@v3
58+
with:
59+
token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }}
60+
commit-message: 'docs: Update docs'
61+
author: googlemaps-bot <[email protected]>
62+
committer: googlemaps-bot <[email protected]>
63+
labels: docs
64+
title: 'docs: Update docs'
65+
body: |
66+
Updated GitHub pages with latest from `./gradlew dokkaHtml`.
67+
branch: googlemaps-bot/update_gh_pages

build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ buildscript {
2828
classpath 'com.mxalbert.gradle:jacoco-android:0.2.1'
2929
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
3030
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
31+
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.9.0"
3132
}
3233
}
3334

35+
3436
allprojects {
3537
repositories {
3638
google()
@@ -104,9 +106,9 @@ subprojects { project ->
104106
}
105107

106108
tasks.register('javadocJar', Jar) {
107-
dependsOn javadoc
109+
dependsOn dokkaHtml
108110
archiveClassifier = 'javadoc'
109-
from javadoc.destinationDir
111+
from dokkaHtml.outputDirectory
110112
}
111113

112114
publishing {

library/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
plugins {
1717
id 'kotlin-android'
18+
id 'org.jetbrains.dokka'
1819
}
1920

2021
android {

0 commit comments

Comments
 (0)