Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add python client #460

Merged
merged 1 commit into from
Jan 13, 2025
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
40 changes: 40 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,42 @@ 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
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 wheel
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

matevz marked this conversation as resolved.
Show resolved Hide resolved
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
Loading