Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@

# 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.
## 3.0.0 and Later

## Example
Releases start from 3.0.0 uses [`pydoctor`](https://github.com/twisted/pydoctor) to generate API docs.

When starting in the root directory of the project, you can run:
When starting in the root directory of the `pulsar-site` project, you can run:

```shell
PULSAR_VERSION=2.8.3 ./site2/tools/python-client/build-docs-in-docker.sh
```
PULSAR_VERSION=3.0.0 ./site2/tools/apidoc/python/pydoctor-generator.sh
```

## Before 3.0.0

Releases before 3.0.0 uses [`pdoc`](https://github.com/mitmproxy/pdoc) to generate API docs.

When starting in the root directory of the `pulsar-site` project, you can run:

```shell
PULSAR_VERSION=2.8.3 ./site2/tools/apidoc/python/pdoc-generator.sh
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
#


set -e
set -x -e

PULSAR_VERSION="${PULSAR_VERSION:-2.9.1}"
if [ -z "$PULSAR_VERSION" ]; then
echo "PULSAR_VERSION must be set."
exit 1
fi

python -m pip install --upgrade pip

pip install pdoc
pip install -U pdoc
pip install pulsar-client==${PULSAR_VERSION}
pdoc pulsar -o /pulsar/site2/website-next/static/api/python/${PULSAR_VERSION}
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,27 @@
#


set -e
set -x -e

if [ -z "$PULSAR_VERSION" ]; then
echo "PULSAR_VERSION must be set."
exit 1
fi

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
IMAGE=$BUILD_IMAGE_NAME:manylinux-$PYTHON_SPEC

# 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"
COMMAND="/pulsar/site2/tools/apidoc/python/pdoc-generator-helper.sh"
DOCKER_CMD="docker run -e PULSAR_VERSION=${PULSAR_VERSION} --entrypoint ${COMMAND} -i ${VOLUME_OPTION} ${IMAGE}"

$DOCKER_CMD
38 changes: 38 additions & 0 deletions site2/tools/apidoc/python/pydoctor-generator-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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 -x -e

if [ -z "$PULSAR_VERSION" ]; then
echo "PULSAR_VERSION must be set."
exit 1
fi

python -m pip install --upgrade pip

pip install -U pydoctor
git clone https://github.com/apache/pulsar-client-python --single-branch --branch v$PULSAR_VERSION
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @merlimat @BewareMyPower @RobertIndie this line depends on that for each Python client release, we create a vX.Y.Z tag. I notice that C++ client does it so make this assumption.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the overall script by hardcoding the tag as main locally.

pydoctor --make-html \
--html-viewsource-base=https://github.com/apache/pulsar-client-python/tree/v$PULSAR_VERSION \
--docformat=numpy --theme=readthedocs \
--intersphinx=https://docs.python.org/3/objects.inv \
--html-output=/pulsar/site2/website-next/static/api/python/${PULSAR_VERSION} \
pulsar-client-python/pulsar
45 changes: 45 additions & 0 deletions site2/tools/apidoc/python/pydoctor-generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that these two script files duplicate each other. But since scripts are less combinable, and this is a specific small scope, I'd like to keep it simple stupid :)

#
# 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 -x -e

if [ -z "$PULSAR_VERSION" ]; then
echo "PULSAR_VERSION must be set."
exit 1
fi

BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-apachepulsar/pulsar-build}"
PYTHON_VERSION="${PYTHON_VERSION:-3.8}"
PYTHON_SPEC="${PYTHON_SPEC:-cp38-cp38}"
IMAGE=$BUILD_IMAGE_NAME:manylinux-$PYTHON_SPEC

# 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}"
echo "Using image: $IMAGE"

VOLUME_OPTION=${VOLUME_OPTION:-"-v $ROOT_DIR:/pulsar"}
COMMAND="/pulsar/site2/tools/apidoc/python/pydoctor-generator-helper.sh"
DOCKER_CMD="docker run -e PULSAR_VERSION=${PULSAR_VERSION} --entrypoint ${COMMAND} -i ${VOLUME_OPTION} ${IMAGE}"

$DOCKER_CMD