Skip to content

Commit

Permalink
Add building of Python Client SDK Docs
Browse files Browse the repository at this point in the history
Build the docs and link to them from developers.libra.org

(similar to what we do with the Rust Crate Docs)
  • Loading branch information
JoelMarcey authored and bors-libra committed Nov 4, 2020
1 parent f62ac57 commit 1f4e490
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions developers.libra.org/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# OSX
*.DS_Store
venv

# Installer logs

Expand All @@ -18,3 +19,4 @@ docs/crates/*
docs/community/coding-guidelines.md
docs/community/contributing.md
website/static/docs/rustdocs/
website/static/docs/python-client-sdk-docs/
44 changes: 42 additions & 2 deletions developers.libra.org/scripts/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
# run this script from the project root using `./scripts/build_docs.sh`

function usage() {
echo "Usage: $0 [-b] [-r]"
echo "Usage: $0 [-b] [-r] [-p]"
echo ""
echo "Build Libra documentation."
echo ""
echo " -b Build static version of documentation (otherwise start server)"
echo ""
echo " -r Build Libra Rust crate documentation"
echo ""
echo " -p Build Libra Python Client SDK documentation"
echo ""
}

function install_rustup {
Expand All @@ -26,8 +28,19 @@ function install_rustup {
fi
}

function install_python {
echo "Installing Python 3......"
if python3 --version &>/dev/null; then
echo "Python 3 is already installed"
else
echo "Install Python 3 from https://www.python.org/"
exit 1
fi
}

BUILD_STATIC=false
BUILD_RUSTDOCS=false
BUILD_PYTORCH_SDK_DOCS=false

if [[ "$(basename $PWD)" != "developers.libra.org" ]]; then
echo "Didn't pass directory check."
Expand All @@ -40,7 +53,7 @@ if [[ "$(basename $PWD)" != "developers.libra.org" ]]; then
exit 1
fi

while getopts 'hbr' flag; do
while getopts 'hbrp' flag; do
case "${flag}" in
h)
usage;
Expand All @@ -52,6 +65,9 @@ while getopts 'hbr' flag; do
r)
BUILD_RUSTDOCS=true
;;
p)
BUILD_PYTORCH_SDK_DOCS=true
;;
*)
usage;
exit 0;
Expand Down Expand Up @@ -117,6 +133,30 @@ if [[ $BUILD_RUSTDOCS == true ]]; then
cp -r $RUSTDOC_DIR $DOCUSAURUS_RUSTDOC_DIR
fi

if [[ $BUILD_PYTORCH_SDK_DOCS == true ]]; then
echo "-----------------------------------"
echo "Generating PyTorch Client SDK Docs"
echo "-----------------------------------"

echo "Checking for Python"
install_python

echo "Installing libra-client-sdk"
python3 -m venv ./venv

./venv/bin/pip install --upgrade pip
./venv/bin/pip install libra-client-sdk pdoc3

echo "Create directory for docs"
rm -rf website/static/docs/python-client-sdk-docs/
mkdir -p website/static/docs/python-client-sdk-docs/

echo "Generating doc from libra-client-sdk"
source ./venv/bin/activate && pdoc3 libra --html -o website/static/docs/python-client-sdk-docs/

rm -rf venv
fi

echo "-----------------------------------"
echo "Building Docusaurus 🦖"
echo "-----------------------------------"
Expand Down
1 change: 1 addition & 0 deletions developers.libra.org/website/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const siteConfig = {
{ href: 'https://libra.org/developers/', label: 'Overview' },
{ doc: 'welcome-to-libra', label: 'Libra Docs' },
{ href: '/docs/rustdocs/', label: 'Libra Rust Crates' },
{ href: '/docs/python-client-sdk-docs/libra/', label: 'Libra Python Client SDK' },
{ href: 'https://lip.libra.org', label: 'Governance' },
{ href: 'https://community.libra.org', label: 'Community' },
{ href: 'https://github.com/libra/libra', label: 'GitHub', external: true },
Expand Down

0 comments on commit 1f4e490

Please sign in to comment.