Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Commit 751ccf3

Browse files
authored
docs: cloud rad java doc generation (#1336)
* test: adding javadocv3 docfx generatiion * chore: removing options * chore: update build file * chore: update path * chore: adding readme and docfx prefix * chore: fix comment * test: remove from maven publishing
1 parent fc7169d commit 751ccf3

File tree

3 files changed

+125
-3
lines changed

3 files changed

+125
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# cloud-rad production
4+
env_vars: {
5+
key: "STAGING_BUCKET_V2"
6+
value: "docs-staging-v2"
7+
}
8+
9+
# Configure the docker image for kokoro-trampoline
10+
env_vars: {
11+
key: "TRAMPOLINE_IMAGE"
12+
value: "gcr.io/cloud-devrel-kokoro-resources/java11"
13+
}
14+
15+
env_vars: {
16+
key: "TRAMPOLINE_BUILD_FILE"
17+
value: "github/gax-java/.kokoro/release/publish_javadoc11.sh"
18+
}
19+
20+
before_action {
21+
fetch_keystore {
22+
keystore_resource {
23+
keystore_config_id: 73713
24+
keyname: "docuploader_service_account"
25+
}
26+
}
27+
}
28+
29+
# Downloads docfx doclet resource. This will be in ${KOKORO_GFILE_DIR}/<doclet name>
30+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/docfx"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
# Copyright 2019 Google Inc.
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+
set -eo pipefail
17+
18+
if [[ -z "${CREDENTIALS}" ]]; then
19+
CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account
20+
fi
21+
22+
if [[ -z "${STAGING_BUCKET_V2}" ]]; then
23+
echo "Need to set STAGING_BUCKET environment variable"
24+
exit 1
25+
fi
26+
27+
# work from the git root directory
28+
pushd $(dirname "$0")/../../
29+
30+
# install docuploader package
31+
python3 -m pip install gcp-docuploader
32+
33+
NAME=gax
34+
VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3)
35+
36+
# build the docs
37+
./gradlew javadocCombinedV3
38+
39+
# copy README to tmp_docs dir and rename index.md
40+
cp README.md tmp_docs/index.md
41+
42+
pushd tmp_docs
43+
44+
# create metadata
45+
python3 -m docuploader create-metadata \
46+
--name ${NAME} \
47+
--version ${VERSION} \
48+
--language java
49+
50+
# upload docs
51+
python3 -m docuploader upload . \
52+
--credentials ${CREDENTIALS} \
53+
--staging-bucket ${STAGING_BUCKET_V2} \
54+
--destination-prefix docfx
55+
56+
popd

build.gradle

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ subprojects {
173173
exclude('**/*Test.java')
174174
}
175175

176-
// JavaDoc
176+
// JavaDocV1 html
177177
// -------
178178

179179
task javadocJar(type: Jar) {
@@ -193,6 +193,26 @@ subprojects {
193193
}
194194
}
195195

196+
// JavaDocV3 - docFX
197+
// -------
198+
199+
task javadocJarV3(type: Jar) {
200+
classifier = 'javadoc'
201+
from javadoc
202+
}
203+
204+
javadoc.options {
205+
encoding = 'UTF-8'
206+
links 'https://docs.oracle.com/javase/7/docs/api/'
207+
208+
if (JavaVersion.current().isJava8Compatible()) {
209+
addStringOption('Xdoclint:all,-missing', '-quiet')
210+
}
211+
if (JavaVersion.current().isJava11Compatible()) {
212+
addStringOption('-release', '7')
213+
}
214+
}
215+
196216
// Test jar
197217
// --------
198218

@@ -382,9 +402,8 @@ subprojects {
382402
}
383403
}
384404

385-
// JavaDoc
405+
// JavaDocV1 html
386406
// -------
387-
388407
task javadocCombined(type: Javadoc) {
389408
source subprojects.collect {project -> project.sourceSets.main.allJava }
390409
classpath = files(subprojects.collect {project -> project.sourceSets.main.compileClasspath})
@@ -401,6 +420,23 @@ clean {
401420
delete 'tmp_docs/'
402421
}
403422

423+
// JavaDocV3 docFX
424+
// -------
425+
task javadocCombinedV3(type: Javadoc) {
426+
source subprojects.collect {project -> project.sourceSets.main.allJava }
427+
classpath = files(subprojects.collect {project -> project.sourceSets.main.compileClasspath})
428+
destinationDir = new File(projectDir, 'tmp_docs')
429+
430+
options.addStringOption('encoding', 'UTF-8')
431+
options.addStringOption("doclet", "com.microsoft.doclet.DocFxDoclet")
432+
options.docletpath = [file(System.getenv('KOKORO_GFILE_DIR') + "/docfx-doclet-1.0-SNAPSHOT-jar-with-dependencies-172556.jar")]
433+
}
434+
435+
clean {
436+
delete 'tmp_gh-pages/'
437+
delete 'tmp_docs/'
438+
}
439+
404440
// Release
405441
// =======
406442

0 commit comments

Comments
 (0)