You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2022/05/09 07:16:35 UTC
[pulsar-site] 03/06: api scripts
This is an automated email from the ASF dual-hosted git repository.
urfree pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
commit b7b31b3ea45eba8673e015d3557048dcf86d8332
Author: Li Li <ur...@apache.org>
AuthorDate: Mon May 9 14:42:39 2022 +0800
api scripts
Signed-off-by: Li Li <ur...@apache.org>
---
site2/tools/api/python/README.md | 34 ++++++++++++++++++
site2/tools/api/python/build-docs-in-docker.sh | 42 ++++++++++++++++++++++
.../api/python/generate-python-client-docs.sh | 30 ++++++++++++++++
3 files changed, 106 insertions(+)
diff --git a/site2/tools/api/python/README.md b/site2/tools/api/python/README.md
new file mode 100644
index 00000000000..8a969d114da
--- /dev/null
+++ b/site2/tools/api/python/README.md
@@ -0,0 +1,34 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+# Pulsar Client Generated Docs
+
+Pulsar's Python docs used to be generated for every wesbite build, but this is unnecessary. We now generate
+the docs for each version by running the [build-docs-in-docker.sh](./build-docs-in-docker.sh) script in this
+directory.
+
+## Example
+
+When starting in the root directory of the project, you can run:
+
+```shell
+PULSAR_VERSION=2.8.3 ./site2/tools/python-client/build-docs-in-docker.sh
+```
\ No newline at end of file
diff --git a/site2/tools/api/python/build-docs-in-docker.sh b/site2/tools/api/python/build-docs-in-docker.sh
new file mode 100755
index 00000000000..b11cbb0147c
--- /dev/null
+++ b/site2/tools/api/python/build-docs-in-docker.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+set -e
+
+BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-apachepulsar/pulsar-build}"
+# Use python 3.8 for now because it works for 2.7, 2.8, and 2.9.
+PYTHON_VERSION="${PYTHON_VERSION:-3.8}"
+PYTHON_SPEC="${PYTHON_SPEC:-cp38-cp38}"
+# ROOT_DIR should be an absolute path so that Docker accepts it as a valid volumes path
+ROOT_DIR=`cd $(dirname $0)/../../../..; pwd`
+cd $ROOT_DIR
+
+echo "Build Python docs for python version $PYTHON_VERSION, spec $PYTHON_SPEC, and pulsar version ${PULSAR_VERSION}"
+
+IMAGE=$BUILD_IMAGE_NAME:manylinux-$PYTHON_SPEC
+
+echo "Using image: $IMAGE"
+
+VOLUME_OPTION=${VOLUME_OPTION:-"-v $ROOT_DIR:/pulsar"}
+COMMAND="/pulsar/site2/tools/api/python/generate-python-client-docs.sh"
+DOCKER_CMD="docker run -e PULSAR_VERSION=${PULSAR_VERSION} --entrypoint ${COMMAND} -i ${VOLUME_OPTION} ${IMAGE}"
+
+$DOCKER_CMD
diff --git a/site2/tools/api/python/generate-python-client-docs.sh b/site2/tools/api/python/generate-python-client-docs.sh
new file mode 100755
index 00000000000..ee1f9e89bce
--- /dev/null
+++ b/site2/tools/api/python/generate-python-client-docs.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+set -e
+
+PULSAR_VERSION="${PULSAR_VERSION:-2.9.1}"
+
+python -m pip install --upgrade pip
+
+pip install pdoc
+pip install pulsar-client==${PULSAR_VERSION}
+pdoc pulsar -o /pulsar/site2/website/static/api/python/${PULSAR_VERSION}
\ No newline at end of file