Skip to content

Commit

Permalink
Add python documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigaMr committed Dec 2, 2024
1 parent a4069ee commit 7f9f772
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
50 changes: 50 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,52 @@ 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 sapphirepy/requirements.txt
pip install -r sapphirepy/requirements.dev.txt
pip install sphinx sphinx-rtd-theme myst-parser
make
pip install dist/sapphire.py-*.whl
- name: Build docs
run: |
cd docs
make html
- name: Deploy to api-reference branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html
publish_branch: api-reference
destination_dir: py
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
20 changes: 20 additions & 0 deletions clients/py/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
39 changes: 39 additions & 0 deletions clients/py/docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'sapphirepy'
copyright = '2024, Oasis Protocol'
author = '[email protected]'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

# docs/source/conf.py
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'myst_parser' # This is the correct extension name
]

# Add these settings for Markdown support
source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
}

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']
25 changes: 25 additions & 0 deletions clients/py/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. sapphirepy documentation master file, created by
sphinx-quickstart on Mon Dec 2 10:44:52 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
sapphirepy documentation
========================




.. automodule:: sapphirepy
:members:
:undoc-members:
:show-inheritance:

.. include:: ../../README.md
:parser: markdown

.. toctree::
:maxdepth: 2
:caption: Contents:

modules

7 changes: 7 additions & 0 deletions clients/py/docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sapphirepy
==========

.. toctree::
:maxdepth: 4

sapphirepy
3 changes: 3 additions & 0 deletions clients/py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@
url="https://github.com/oasisprotocol/sapphire-paratime",
version="0.3.0",
zip_safe=True,
package_data={
'sapphirepy': ['docs/*.html'], # Include all HTML docs
},
)

0 comments on commit 7f9f772

Please sign in to comment.