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
59 changes: 59 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow builds the documentation and creates an artifact

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
docs:
runs-on: ubuntu-22.04
permissions:
deployments: write
id-token: write
contents: read

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

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

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- uses: actions/cache@v4
name: Define a cache for the virtual environment based on the dependencies lock file
id: cache
with:
path: ./.venv
key: venv-${{ runner.os }}-3.12-${{ hashFiles('uv.lock') }}

- name: Install dependencies
run: uv sync --extra docs

- name: Build documentation
run: uv run mkdocs build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-2
role-to-assume: arn:aws:iam::${{ secrets.ABLY_AWS_ACCOUNT_ID_SDK }}:role/ably-sdk-builds-ably-python
role-session-name: "${{ github.run_id }}-${{ github.run_number }}"

- name: Upload Documentation
uses: ably/sdk-upload-action@v2
with:
sourcePath: site/
githubToken: ${{ secrets.GITHUB_TOKEN }}
artifactName: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ test/ably/restsetup.py.orig
.idea/**/*
ably/sync/**
test/ably/sync/**
site/
52 changes: 52 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Documentation

This directory contains the source files for the Ably Python SDK documentation, built using [MkDocs](https://www.mkdocs.org/) and [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/).

## Building the Documentation

### Prerequisites

- Python 3.12 or higher (documentation tools require Python 3.12+)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our .tool-version still lists python 3.9, we should change it to a version which can run all the development tasks

- Install documentation dependencies: `uv sync --extra docs`

### Build HTML Documentation

```bash
# Build the documentation
uv run mkdocs build

# The generated HTML will be in the site/ directory
```

### Serve Documentation Locally

```bash
# Start a local development server
uv run mkdocs serve

# Open http://127.0.0.1:8000/ in your browser
```

The development server automatically rebuilds the documentation when you make changes to the source files.

## Documentation Structure

- `docs/` - Documentation source files (Markdown)
- `index.md` - Home page
- `api/` - API reference documentation
- `mkdocs.yml` - MkDocs configuration
- `site/` - Generated HTML documentation (gitignored)

## How It Works

The documentation uses [mkdocstrings](https://mkdocstrings.github.io/) to automatically generate API documentation from Python docstrings. The special `:::` syntax in Markdown files tells mkdocstrings to extract and render documentation from Python modules:

```markdown
::: ably.rest.rest.AblyRest
```

This automatically generates formatted documentation including:
- Class and method signatures
- Docstrings
- Type hints
- Parameters and return types
19 changes: 19 additions & 0 deletions docs/api/auth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Authentication

The Auth class handles authentication with Ably, supporting API keys, tokens, and token generation.

## Auth

::: ably.rest.auth.Auth

## Token Details

::: ably.types.tokendetails.TokenDetails

## Token Request

::: ably.types.tokenrequest.TokenRequest

## Capability

::: ably.types.capability.Capability
27 changes: 27 additions & 0 deletions docs/api/channels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Channels

Channels provide the interface for publishing and subscribing to messages in Ably.

## REST Channels

### Channels Collection

::: ably.rest.channel.Channels

### REST Channel

::: ably.rest.channel.Channel

## Realtime Channels

### Channels Collection

::: ably.realtime.realtime_channel.Channels

### Realtime Channel

::: ably.realtime.realtime_channel.RealtimeChannel

## Presence

::: ably.realtime.realtimepresence.RealtimePresence
37 changes: 37 additions & 0 deletions docs/api/messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Messages

Message types represent the data sent through Ably channels.

## Message

The core message type for pub/sub messaging.

::: ably.types.message.Message

## Message Operations

Support for mutable messages (update, delete, append operations).

### MessageVersion

::: ably.types.message.MessageVersion

### MessageAction

::: ably.types.message.MessageAction

### MessageOperation

::: ably.types.operations.MessageOperation

### PublishResult

::: ably.types.operations.PublishResult

### UpdateDeleteResult

::: ably.types.operations.UpdateDeleteResult

## Presence Message

::: ably.types.presence.PresenceMessage
82 changes: 82 additions & 0 deletions docs/api/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# API Reference Overview
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have to say, the model for building this seems not ideal? like all we really need to do is say what our public exports are (AblyRest and AblyRealtime). from there a tool like this should be able to walk the public API and skip anything that starts with an underscore. i think having to declare every class in these markdown files is a pain to keep in sync with the source code and inevitably someone will forget to update it when they make a change.


The Ably Python SDK provides two main client interfaces:

## Core Clients

### [REST Client](rest.md)

The REST client (`AblyRest`) provides synchronous access to Ably's REST API:

- Publish messages to channels
- Query message history
- Manage channel lifecycle
- Retrieve statistics
- Token authentication

Use the REST client when you need simple request/response operations without maintaining a persistent connection.

### [Realtime Client](realtime.md)

The Realtime client (`AblyRealtime`) maintains a persistent connection to Ably:

- Subscribe to channels and receive messages in real-time
- Publish messages
- Monitor connection state
- Track presence
- Receive live updates

Use the Realtime client for applications that need live updates and bidirectional communication.

## Key Components

### [Authentication](auth.md)

The `Auth` class handles authentication with Ably, supporting:

- API key authentication
- Token authentication
- Token generation and renewal

### [Channels](channels.md)

Channel interfaces provide access to messaging functionality:

- REST channels for publishing and history
- Realtime channels for subscribing to messages
- Channel state management

### [Messages](messages.md)

Message types represent the data sent through Ably:

- `Message` - Standard pub/sub messages
- `PresenceMessage` - Presence state changes
- Encoding and encryption support

### [Types](types.md)

Core data types and configuration:

- `ClientOptions` - Client configuration
- `TokenDetails` - Authentication tokens
- `Stats` - Usage statistics
- Channel and connection options

### [Utilities](util.md)

Utility functions and helpers:

- Exception types
- Encoding/decoding utilities
- Cryptographic functions

## Client Capabilities

Both clients share common capabilities:

- **Auto-reconnection**: Automatic connection recovery
- **Message queueing**: Queues messages during disconnection
- **Type safety**: Full type hints for IDE support
- **Async/await support**: Native async support in Realtime client
- **Error handling**: Comprehensive error types
19 changes: 19 additions & 0 deletions docs/api/realtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Realtime Client

The Realtime client maintains a persistent connection to Ably, enabling you to subscribe to channels and receive messages in real-time.

## AblyRealtime

::: ably.realtime.realtime.AblyRealtime

## Realtime Channels

::: ably.realtime.realtime_channel.Channels

## Realtime Channel

::: ably.realtime.realtime_channel.RealtimeChannel

## Connection

::: ably.realtime.connection.Connection
15 changes: 15 additions & 0 deletions docs/api/rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# REST Client

The REST client provides synchronous access to Ably's REST API for publishing messages, querying history, and managing channels.
Comment on lines +1 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Find the AblyRest implementation
echo "=== Searching for AblyRest class definition ==="
find . -name "*.py" -type f | xargs grep -l "class AblyRest" | head -5

# Check the rest module structure
echo "=== REST module files ==="
find . -path "*/ably/rest*" -name "*.py" -type f | head -20

Repository: ably/ably-python

Length of output: 836


🏁 Script executed:

#!/bin/bash

echo "=== AblyRest class in rest.py ==="
cat -n ./ably/rest/rest.py | head -100

echo ""
echo "=== Checking for async methods in rest.py ==="
rg -n "async def|def " ./ably/rest/rest.py | head -30

Repository: ably/ably-python

Length of output: 5611


🏁 Script executed:

#!/bin/bash

echo "=== Checking Channel class methods ==="
rg -n "async def|def " ./ably/rest/channel.py | grep -E "(publish|history)" | head -10

echo ""
echo "=== Full method signatures around publish and history ==="
rg -B 2 "async def (publish|history)" ./ably/rest/channel.py

Repository: ably/ably-python

Length of output: 1240


Update documentation to reflect asynchronous access, not synchronous.

Line 3 claims the REST client provides "synchronous access," but the implementation shows all major methods (publish(), history(), stats(), etc.) are async functions requiring await. Update the description to accurately state the client provides asynchronous access.

🤖 Prompt for AI Agents
In `@docs/api/rest.md` around lines 1 - 3, Update the REST client documentation
header to state the client provides asynchronous (not synchronous) access;
replace the phrase "synchronous access" with "asynchronous access" and
optionally note that major methods such as publish(), history(), stats(), and
other API methods are async and should be awaited so readers understand the need
to use await with these functions.


## AblyRest

::: ably.rest.rest.AblyRest

## REST Channels

::: ably.rest.channel.Channels
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have ably.rest.channel.Channels in here twice


## REST Channel

::: ably.rest.channel.Channel
39 changes: 39 additions & 0 deletions docs/api/types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Types

Core data types and configuration options.

## Client Options

::: ably.types.options.Options

## Auth Options

::: ably.types.authoptions.AuthOptions

## Channel Options

::: ably.realtime.realtime_channel.ChannelOptions

## Token Details

::: ably.types.tokendetails.TokenDetails

## Token Request

::: ably.types.tokenrequest.TokenRequest

## Stats

::: ably.types.stats.Stats

## Device Details

::: ably.types.device.DeviceDetails

## Push Channel Subscription

::: ably.types.channelsubscription.PushChannelSubscription

## VCDiff Decoder

::: ably.types.options.VCDiffDecoder
27 changes: 27 additions & 0 deletions docs/api/util.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Utilities

Utility functions, cryptographic helpers, and exception types.

## Exceptions

### AblyException

::: ably.util.exceptions.AblyException

### AblyAuthException

::: ably.util.exceptions.AblyAuthException

### IncompatibleClientIdException

::: ably.util.exceptions.IncompatibleClientIdException

## Cryptographic Utilities

### CipherParams

::: ably.util.crypto.CipherParams

## VCDiff Decoder

::: ably.vcdiff.default_vcdiff_decoder.AblyVCDiffDecoder
Loading
Loading