Skip to content

Commit

Permalink
Add python documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigaMr authored and matevz committed Jan 13, 2025
1 parent 7a9e452 commit 56f99dc
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/ci-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- clients/js/**
- contracts/**
- clients/py/**
branches:
- main

Expand Down Expand Up @@ -127,3 +128,51 @@ jobs:
commit_message: Deploy sol API reference ${{ github.event.head_commit.message }}
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com

py-docs:
name: py-docs
runs-on: ubuntu-latest
services:
sapphire-localnet-ci:
image: ghcr.io/oasisprotocol/sapphire-localnet:latest
ports:
- 8545:8545
options: >-
--rm
--health-cmd="test -f /CONTAINER_READY"
--health-start-period=90s
defaults:
run:
working-directory: ./clients/py
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.dev.txt
pip install sphinx myst-parser
make
pip install dist/sapphire.py-*.whl
- name: Build docs
run: |
make docs
- name: Deploy to api-reference branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: clients/py/docs/build/html
publish_branch: api-reference
destination_dir: py/sapphirepy
commit_message: Deploy Python API reference ${{ github.event.head_commit.message }}
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
1 change: 1 addition & 0 deletions clients/py/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__pycache__
dist
build
docs
.mypy_cache
*.egg-info
17 changes: 16 additions & 1 deletion clients/py/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test:
$(PYTHON) -munittest discover

clean:
rm -rf sapphirepy/__pycache__ build dist sapphire.py.egg-info .mypy_cache
rm -rf sapphirepy/__pycache__ build dist sapphire.py.egg-info .mypy_cache docs

lint:
$(PYTHON) -mpylint $(MODULE) -d line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring
Expand All @@ -22,3 +22,18 @@ build: wheel

wheel:
$(PYTHON) setup.py bdist_wheel

docs:
@rm -rf docs; mkdir docs
@cd docs && sphinx-quickstart --quiet --sep --project=sapphirepy --author='[email protected]' --ext-autodoc --ext-viewcode
@sed -i "s/^copyright = .*/copyright = '$$(date +%Y), Oasis Protocol Foundation'/" docs/source/conf.py
@pip install furo
@sed -i "s/^html_theme = 'alabaster'/html_theme = 'furo'/" docs/source/conf.py
@sed -i "s/^extensions = \[/extensions = [\n 'myst_parser',/" docs/source/conf.py
@echo "source_suffix = {'.rst': 'restructuredtext', '.md': 'markdown'}" >> docs/source/conf.py
@sed -i '/Add your content/,/details/c\\n.. automodule:: sapphirepy\n :members:\n :undoc-members:\n :show-inheritance:\n\n.. include:: ../../README.md\n :parser: markdown' docs/source/index.rst
@echo "\n modules" >> docs/source/index.rst
@sphinx-apidoc -o docs/source/ $$(pip show sapphire-py | grep Location | cut -d' ' -f2)/sapphirepy
@$(MAKE) html -C docs

.PHONY: all mypy ruff test clean lint build wheel docs

0 comments on commit 56f99dc

Please sign in to comment.