Skip to content
Open
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
49 changes: 49 additions & 0 deletions sphinx-generator-wallet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Sphinx build outputs
build/
_build/

# Python virtual environments
sphinx_venv/
venv/
env/
ENV/
.venv

# Python cache files
__pycache__/
*.py[cod]
*$py.class
*.so
.mypy_cache/
.ruff_cache/
.pytest_cache/

# Distribution / packaging
.Python
*.egg-info/
dist/
downloads/
*.egg

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Sphinx doctrees (intermediate build files)
.doctrees/

# Environment variables
.env
.env.local

# Log files
*.log

# Temporary files
*.tmp
.cache/

20 changes: 20 additions & 0 deletions sphinx-generator-wallet/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)
35 changes: 35 additions & 0 deletions sphinx-generator-wallet/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
98 changes: 98 additions & 0 deletions sphinx-generator-wallet/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Generating Bittensor Wallet Python SDK Documentation with Sphinx

This folder contains the Sphinx configuration for generating documentation for the `bittensor_wallet` SDK. It imports the installed `bittensor_wallet` package (built via `pip install -e "$BTWALLET_ROOT"`) so docstrings coming from the Rust bindings can be rendered. The `BTWALLET_ROOT` environment variable must be configured to point to your local `btwallet` repository.

## Prerequisites

- Python 3.9+
- Rust toolchain (needed when building the PyO3 extension during `pip install -e "$BTWALLET_ROOT"`)
- Access to the [`developer-docs`](https://github.com/opentensor/developer-docs) repo for publishing

## Quick Start

1. **Create/activate the virtualenv**

```bash
cd sphinx-generator-wallet
python3 -m venv sphinx_venv
source sphinx_venv/bin/activate
```

2. **Install Sphinx dependencies**

```bash
pip install -r requirements.txt
```

3. **Configure Paths**

Set the `BTWALLET_ROOT` environment variable to point to your local `btwallet` repository:

```bash
export BTWALLET_ROOT=/path/to/btwallet
```

**Important:** Replace `/path/to/btwallet` with the actual path to your `btwallet` repository on your system.

4. **Install the wallet package into the env**

Install the `bittensor_wallet` package from the configured path:

```bash
pip install -e "$BTWALLET_ROOT"
```

This will build the PyO3 extension from the Rust sources and install it in editable mode.

5. **Build docs**

```bash
make html
```

6. **Open locally**
```bash
open build/html/index.html
```

## Publishing Workflow

1. (Optional) remove previous build `rm -rf build/html/`

2. Copy output into `developer-docs`. The generated docs must be copied to the `static/btwallet-api/html` folder within your `develoer docs` directory e.g.

```bash
rm -rf /path/to/developer-docs/static/btwallet-api/html
cp -r build/html /path/to/developer-docs/static/btwallet-api/html
```

3. Commit/push from the developer-docs repo.
```bash
git add static/wallet-api/html
git commit -m "Update Wallet SDK API docs"
git push
```

Link to the published docs using `[Wallet SDK API Reference](pathname:///wallet-api/html/index.html)`.

## Troubleshooting

- **`ModuleNotFoundError: bittensor_wallet`** – ensure step 4 (package installation) succeeded and the venv is activated when running `make html`. Verify that `BTWALLET_ROOT` is set correctly.

- **`BTWALLET_ROOT path does not exist`** – ensure the `BTWALLET_ROOT` environment variable points to a valid `btwallet` repository directory that contains `src/wallet.rs`.

- **`pip install -e` fails with "pyproject.toml not found"** – verify that `BTWALLET_ROOT` is set to the root of the `btwallet` repository (where `pyproject.toml` is located), not a subdirectory.

- **Rust build failures** – verify the Rust toolchain is installed and PyO3 prerequisites are met. You may need to install `maturin` first: `pip install maturin`.

- **Missing docstrings** – confirm `pip install -e "$BTWALLET_ROOT"` ran after any Rust edits; the doc fallback only applies when the package is installed in the venv. Also verify `BTWALLET_ROOT` is set correctly.

- **Start fresh** – `rm -rf build && make html`.

- **Virtual environment symlink errors** – If you see "Unable to symlink" errors when creating the venv, this is often a Homebrew Python issue on macOS. Solutions:
- Use `python3 -m venv --copies sphinx_venv` to copy files instead of symlinking
- Ensure you have write permissions: `chmod -R u+w sphinx_venv` (if venv already exists)
- Try removing the existing venv and recreating: `rm -rf sphinx_venv && python3 -m venv --copies sphinx_venv`
- If using Homebrew Python, ensure it's properly linked: `brew link python@3.14` (or your Python version)

For everything else, refer to the original `sphinx-generator/readme.md` guidance or contact the docs team.
9 changes: 9 additions & 0 deletions sphinx-generator-wallet/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Main Sphinx documentation generator
sphinx>=7.1.0

# Theme that we use for Python reference
sphinx-book-theme>=1.0.1

# Required extensions
sphinx-autoapi>=3.0.0 # For autoapi.extension
myst-parser>=2.0.0 # For MyST Markdown support
157 changes: 157 additions & 0 deletions sphinx-generator-wallet/source/_static/bittensor-custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/* CSS customized by Raj Karamchedu on 29 January 2024 */

@font-face {
font-family: "Haffer";
src: url(./fonts/Haffer-Light.ttf);
font-weight: 200;
font-style: normal;
}

@font-face {
font-family: "Haffer";
src: url(./fonts/Haffer-Medium.ttf);
font-weight: 400;
font-style: normal;
}

@font-face {
font-family: "Haffer";
src: url(./fonts/Haffer-Regular.ttf);
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: "Haffer";
src: url(./fonts/Haffer-SemiBold.ttf);
font-weight: bold;
font-style: normal;
}

@font-face {
font-family: "HafferSQ";
src: url(./fonts/HafferSQ-Light.ttf);
font-weight: 200;
font-style: normal;
}

@font-face {
font-family: "HafferSQ";
src: url(./fonts/HafferSQ-Medium.ttf);
font-weight: 400;
font-style: normal;
}

@font-face {
font-family: "HafferSQ";
src: url(./fonts/HafferSQ-Regular.ttf);
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: "HafferSQ";
src: url(./fonts/HafferSQ-SemiBold.ttf);
font-weight: bold;
font-style: normal;
}

@font-face {
font-family: "TTCommonsPro";
src: url(./fonts/TTCommonsProMonoMedium.ttf);
font-weight: 200;
font-style: normal;
}

@font-face {
font-family: "TTCommonsPro";
src: url(./fonts/TTCommonsProMonoRegular.ttf);
font-weight: 100;
font-style: normal;
}

@font-face {
font-family: "FiraCode";
src: url(./fonts/FiraCode_VariableFont_wght.ttf);
}



html {
--pst-font-family-base-system: 'Haffer', -apple-system, BlinkMacSystemFont, Segoe UI, "Helvetica Neue", Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
--pst-font-family-monospace-system: "TTCommonsPro", Menlo, Consolas, Monaco,
Liberation Mono, Lucida Console, monospace;
--pst-sidebar-font-size: 1.0rem;
--pst-font-family-base: var(--pst-font-family-base-system);
--pst-font-family-heading: var(--pst-font-family-base-system);
--pst-font-family-monospace: var(--pst-font-family-monospace-system);
--pst-color-inline-code-links: #0c0c0c;

}

html[data-theme=dark]{
--pst-color-surface: none;
--pst-color-inline-code-links: #fff;
--pst-color-target: #545454;
--pst-color-inline-code: #1fd01f;
--pst-color-table-row-hover-bg: #003200;
}


html[data-theme=light]{
--pst-color-surface: none;
--pst-color-inline-code-links: #000;
--pst-color-target: #eaebed;
--pst-color-inline-code: #0fa50f;
--pst-color-table-row-hover-bg: #ffffc0;
}

html[data-theme=dark], html[data-theme=light] {
--pst-color-primary: #838793;
}

p {
font-size: 16px !important;
}

code.xref, a code {
font-weight: normal;
}

code.literal {
background-color: none;
border: none;
}

.dropdown, .dropdown-center, .dropend, .dropstart, .dropup, .dropup-center {
position: relative;
display: none;
}

/* .search-button {
display: none;
} */

.btn-fullscreen-button {
display: none;
}

.bd-sidebar-secondary .onthispage {
display: none;
}

@media (min-width: 992px){
.bd-sidebar-primary {
flex-basis: 25%;
}
}

.bd-sidebar-secondary{
max-height: calc(100vh - var(--pst-header-height));
}

@media (min-width: 960px){
.bd-page-width {
max-width: 98rem;
}
}
Loading