-
Notifications
You must be signed in to change notification settings - Fork 45
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
initial python docs for bdk #635
Open
bitkarrot
wants to merge
6
commits into
bitcoindevkit:master
Choose a base branch
from
bitkarrot:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
48a60c2
initial python docs attemp
bitkarrot 646d442
Merge branch 'master' into master
bitkarrot fa839e2
fix some api.rst underline too short
bitkarrot 52c6f21
fix path issue
bitkarrot fb10b5c
build docs and ignore warnings
bitkarrot 52514d2
remove auto generated docs
bitkarrot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build Python API Docs Website | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v3 | ||
|
||
- name: "Set up Python" | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9.x' | ||
|
||
- name: "Install dependencies" | ||
run: | | ||
cd ./bdk-python/ | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install sphinx sphinx-rtd-theme | ||
|
||
- name: "Build Python API documentation" | ||
run: | | ||
cd ./bdk-python/ | ||
python scripts/generate_docs.py | ||
sphinx-build -b html -W --keep-going docs/ docs/_build/html | ||
|
||
# - name: "Upload Python website" | ||
# uses: actions/upload-artifact@v4 | ||
# with: | ||
# name: artifact-python-api-docs | ||
# path: /home/runner/work/bdk-ffi/bdk-ffi/bdk-python/docs/_build/html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ src/bdkpython/*.so | |
build/ | ||
|
||
testing-setup-py-simple-example.py | ||
venv | ||
env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
API Reference | ||
============ | ||
|
||
.. currentmodule:: bdkpython | ||
|
||
Core Types | ||
---------- | ||
|
||
.. autoclass:: Amount | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: FeeRate | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: Address | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Wallet Operations | ||
----------------- | ||
|
||
.. autoclass:: TxBuilder | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: BumpFeeTxBuilder | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: Psbt | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: ElectrumClient | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: EsploraClient | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: Wallet | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Utilities | ||
--------- | ||
|
||
.. autoclass:: Mnemonic | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: Descriptor | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: DescriptorSecretKey | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: DescriptorPublicKey | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: ChangeSet | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
Exceptions | ||
---------- | ||
|
||
.. autoclass:: InternalError | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: FeeRateError | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import sys | ||
sys.path.insert(0, os.path.abspath('..')) | ||
|
||
# Configuration file for the Sphinx documentation builder. | ||
project = 'BDK Python' | ||
copyright = '2024, Bitcoin Dev Kit' | ||
author = 'Bitcoin Dev Kit' | ||
|
||
# The full version, including alpha/beta/rc tags | ||
release = '0.1.0' | ||
|
||
# Add any Sphinx extension module names here, as strings | ||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.napoleon', | ||
'sphinx.ext.viewcode', | ||
] | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
# The theme to use for HTML and HTML Help pages. | ||
html_theme = 'sphinx_rtd_theme' | ||
|
||
# Add any paths that contain custom static files (such as style sheets) | ||
html_static_path = ['_static'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Welcome to BDK Python's documentation! | ||
======================================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
api | ||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pytest==7.1.2 | ||
tox==3.25.1 | ||
sphinx | ||
sphinx-rtd-theme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
import re | ||
|
||
# Define the directory where the Python source files are located | ||
src_dir = 'src/bdkpython' | ||
|
||
# Define the output file for the API documentation | ||
output_file = 'docs/api.rst' | ||
|
||
# Define categories and corresponding classes | ||
categories = { | ||
"Core Types": ["Amount", "FeeRate", "Address"], | ||
"Wallet Operations": ["TxBuilder", "BumpFeeTxBuilder", "Psbt", "Blockchain", "ElectrumClient", "EsploraClient", "Wallet"], | ||
"Utilities": ["Mnemonic", "Descriptor", "DescriptorSecretKey", "DescriptorPublicKey", "ChangeSet"], | ||
"Exceptions": ["InternalError", "FeeRateError"] | ||
} | ||
|
||
# Regex pattern to match class definitions | ||
class_pattern = re.compile(r'^class ([A-Za-z][A-Za-z0-9_]*)') | ||
|
||
# Scan the source directory for Python files and extract public classes | ||
public_classes = {} | ||
for root, _, files in os.walk(src_dir): | ||
for file in files: | ||
if file.endswith('.py'): | ||
with open(os.path.join(root, file), 'r') as f: | ||
for line in f: | ||
match = class_pattern.match(line) | ||
if match: | ||
class_name = match.group(1) | ||
# Only consider classes not starting with underscore | ||
if not class_name.startswith('_'): | ||
public_classes[class_name] = root | ||
|
||
# Generate the RST content | ||
rst_content = "API Reference\n============\n\n.. currentmodule:: bdkpython\n\n" | ||
|
||
for category, class_list in categories.items(): | ||
rst_content += f"{category}\n{'-' * len(category)}\n\n" | ||
for class_name in class_list: | ||
if class_name in public_classes: | ||
rst_content += f".. autoclass:: {class_name}\n :members:\n :undoc-members:\n :show-inheritance:\n\n" | ||
|
||
# Write the RST content to the output file | ||
with open(output_file, 'w') as f: | ||
f.write(rst_content) | ||
|
||
print(f"API documentation has been generated in {output_file}") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
categories are specified here. see index for all methods.