Skip to content

Commit d1f4e25

Browse files
committed
python: publish sphinx docs to googleapis.dev
**Background:** This is a follow-up to the PR that adds sphinx docs. Googleapis.dev hosts client library documentation for several languages as well as documentation for core packages such as google-api-core. It is owned and maintained by the Cloud DevRel Core team. **About this change:** The `kokoro/docs/publish-python.sh` script builds the docs with sphinx, then uses the [googleapis/docuploader](https://github.com/googleapis/docuploader) tool to publish to googleapis.dev. The publish script is triggered manually with a Kokoro RELEASE type job. Googlers, see go link protobuf-docs-python-design for additional internal references.
1 parent 29c83ba commit d1f4e25

File tree

5 files changed

+124
-0
lines changed

5 files changed

+124
-0
lines changed

kokoro/docs/common.cfg

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Download trampoline resources.
11+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
12+
13+
# Use the trampoline script to run in docker.
14+
build_file: "protobuf/kokoro/docs/trampoline.sh"
15+
16+
# Configure the docker image for kokoro-trampoline.
17+
env_vars: {
18+
key: "TRAMPOLINE_IMAGE"
19+
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
20+
}
21+
22+
env_vars: {
23+
key: "STAGING_BUCKET"
24+
value: "docs-staging"
25+
}
26+
27+
# Fetch the token needed for reporting release status to GitHub
28+
before_action {
29+
fetch_keystore {
30+
keystore_resource {
31+
keystore_config_id: 73713
32+
keyname: "yoshi-automation-github-key"
33+
}
34+
}
35+
}
36+
37+
before_action {
38+
fetch_keystore {
39+
keystore_resource {
40+
keystore_config_id: 73713
41+
keyname: "docuploader_service_account"
42+
}
43+
}
44+
}

kokoro/docs/publish-python.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
# Adapted from https://github.com/googleapis/google-cloud-python/blob/master/.kokoro/publish-docs.sh
3+
4+
set -eo pipefail
5+
6+
# Disable buffering, so that the logs stream through.
7+
export PYTHONUNBUFFERED=1
8+
9+
cd github/protobuf/python
10+
11+
# install package
12+
sudo apt-get update
13+
sudo apt-get -y install software-properties-common
14+
sudo add-apt-repository universe
15+
sudo apt-get update
16+
sudo apt-get -y install unzip
17+
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.2/protoc-3.11.2-linux-x86_64.zip
18+
unzip protoc-3.11.2-linux-x86_64.zip bin/protoc
19+
mv bin/protoc ../src/protoc
20+
python3.6 -m venv venv
21+
source venv/bin/activate
22+
python setup.py install
23+
24+
# install docs dependencies
25+
python -m pip install -r docs/requirements.txt
26+
27+
# build docs
28+
cd docs
29+
make html
30+
cd ..
31+
deactivate
32+
33+
python3.6 -m pip install protobuf==3.11.1 gcp-docuploader
34+
35+
# install a json parser
36+
sudo apt-get -y install jq
37+
38+
# create metadata
39+
python3.6 -m docuploader create-metadata \
40+
--name=$(jq --raw-output '.name // empty' .repo-metadata.json) \
41+
--version=$(python3 setup.py --version) \
42+
--language=$(jq --raw-output '.language // empty' .repo-metadata.json) \
43+
--distribution-name=$(python3 setup.py --name) \
44+
--product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \
45+
--github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \
46+
--issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json)
47+
48+
cat docs.metadata
49+
50+
# upload docs
51+
python3.6 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket docs-staging

kokoro/docs/python.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Tell the trampoline which build file to use.
4+
env_vars: {
5+
key: "TRAMPOLINE_BUILD_FILE"
6+
value: "github/protobuf/kokoro/docs/publish-python.sh"
7+
}

kokoro/docs/trampoline.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Copied from https://github.com/googleapis/google-cloud-python/blob/master/.kokoro/trampoline.sh
3+
4+
set -eo pipefail
5+
6+
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" || ret_code=$?
7+
8+
chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
9+
${KOKORO_GFILE_DIR}/trampoline_cleanup.sh || true
10+
11+
exit ${ret_code}

python/.repo-metadata.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "protobuf",
3+
"name_pretty": "Protocol Buffers",
4+
"product_documentation": "https://developers.google.com/protocol-buffers ",
5+
"client_documentation": "https://developers.google.com/protocol-buffers/docs/pythontutorial",
6+
"issue_tracker": "https://github.com/protocolbuffers/protobuf/issues",
7+
"release_level": "ga",
8+
"language": "python",
9+
"repo": "protocolbuffers/protobuf ",
10+
"distribution_name": "protobuf"
11+
}

0 commit comments

Comments
 (0)