Skip to content

Commit ab7aa67

Browse files
committed
[AIT-289] docs: add autogenerated API references docs
1 parent 0b93c10 commit ab7aa67

File tree

15 files changed

+1221
-25
lines changed

15 files changed

+1221
-25
lines changed

.github/workflows/docs.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This workflow builds the documentation and creates an artifact
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
docs:
12+
runs-on: ubuntu-22.04
13+
permissions:
14+
deployments: write
15+
id-token: write
16+
contents: read
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: 'recursive'
22+
23+
- name: Set up Python 3.12
24+
uses: actions/setup-python@v5
25+
id: setup-python
26+
with:
27+
python-version: '3.12'
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v7
31+
with:
32+
enable-cache: true
33+
34+
- uses: actions/cache@v4
35+
name: Define a cache for the virtual environment based on the dependencies lock file
36+
id: cache
37+
with:
38+
path: ./.venv
39+
key: venv-${{ runner.os }}-3.12-${{ hashFiles('uv.lock') }}
40+
41+
- name: Install dependencies
42+
run: uv sync --extra docs
43+
44+
- name: Build documentation
45+
run: uv run mkdocs build
46+
47+
- name: Configure AWS Credentials
48+
uses: aws-actions/configure-aws-credentials@v4
49+
with:
50+
aws-region: eu-west-2
51+
role-to-assume: arn:aws:iam::${{ secrets.ABLY_AWS_ACCOUNT_ID_SDK }}:role/ably-sdk-builds-ably-python
52+
role-session-name: "${{ github.run_id }}-${{ github.run_number }}"
53+
54+
- name: Upload Documentation
55+
uses: ably/sdk-upload-action@v2
56+
with:
57+
sourcePath: site/
58+
githubToken: ${{ secrets.GITHUB_TOKEN }}
59+
artifactName: docs

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ test/ably/restsetup.py.orig
5757
.idea/**/*
5858
ably/sync/**
5959
test/ably/sync/**
60+
site/

docs/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Documentation
2+
3+
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/).
4+
5+
## Building the Documentation
6+
7+
### Prerequisites
8+
9+
- Python 3.12 or higher (documentation tools require Python 3.12+)
10+
- Install documentation dependencies: `uv sync --extra docs`
11+
12+
### Build HTML Documentation
13+
14+
```bash
15+
# Build the documentation
16+
uv run mkdocs build
17+
18+
# The generated HTML will be in the site/ directory
19+
```
20+
21+
### Serve Documentation Locally
22+
23+
```bash
24+
# Start a local development server
25+
uv run mkdocs serve
26+
27+
# Open http://127.0.0.1:8000/ in your browser
28+
```
29+
30+
The development server automatically rebuilds the documentation when you make changes to the source files.
31+
32+
## Documentation Structure
33+
34+
- `docs/` - Documentation source files (Markdown)
35+
- `index.md` - Home page
36+
- `api/` - API reference documentation
37+
- `mkdocs.yml` - MkDocs configuration
38+
- `site/` - Generated HTML documentation (gitignored)
39+
40+
## How It Works
41+
42+
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:
43+
44+
```markdown
45+
::: ably.rest.rest.AblyRest
46+
```
47+
48+
This automatically generates formatted documentation including:
49+
- Class and method signatures
50+
- Docstrings
51+
- Type hints
52+
- Parameters and return types

docs/api/auth.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Authentication
2+
3+
The Auth class handles authentication with Ably, supporting API keys, tokens, and token generation.
4+
5+
## Auth
6+
7+
::: ably.rest.auth.Auth
8+
9+
## Token Details
10+
11+
::: ably.types.tokendetails.TokenDetails
12+
13+
## Token Request
14+
15+
::: ably.types.tokenrequest.TokenRequest
16+
17+
## Capability
18+
19+
::: ably.types.capability.Capability

docs/api/channels.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Channels
2+
3+
Channels provide the interface for publishing and subscribing to messages in Ably.
4+
5+
## REST Channels
6+
7+
### Channels Collection
8+
9+
::: ably.rest.channel.Channels
10+
11+
### REST Channel
12+
13+
::: ably.rest.channel.Channel
14+
15+
## Realtime Channels
16+
17+
### Channels Collection
18+
19+
::: ably.realtime.realtime_channel.Channels
20+
21+
### Realtime Channel
22+
23+
::: ably.realtime.realtime_channel.RealtimeChannel
24+
25+
## Presence
26+
27+
::: ably.realtime.realtimepresence.RealtimePresence

docs/api/messages.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Messages
2+
3+
Message types represent the data sent through Ably channels.
4+
5+
## Message
6+
7+
The core message type for pub/sub messaging.
8+
9+
::: ably.types.message.Message
10+
11+
## Message Operations
12+
13+
Support for mutable messages (update, delete, append operations).
14+
15+
### MessageVersion
16+
17+
::: ably.types.message.MessageVersion
18+
19+
### MessageAction
20+
21+
::: ably.types.message.MessageAction
22+
23+
### MessageOperation
24+
25+
::: ably.types.operations.MessageOperation
26+
27+
### PublishResult
28+
29+
::: ably.types.operations.PublishResult
30+
31+
### UpdateDeleteResult
32+
33+
::: ably.types.operations.UpdateDeleteResult
34+
35+
## Presence Message
36+
37+
::: ably.types.presence.PresenceMessage

docs/api/overview.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# API Reference Overview
2+
3+
The Ably Python SDK provides two main client interfaces:
4+
5+
## Core Clients
6+
7+
### [REST Client](rest.md)
8+
9+
The REST client (`AblyRest`) provides synchronous access to Ably's REST API:
10+
11+
- Publish messages to channels
12+
- Query message history
13+
- Manage channel lifecycle
14+
- Retrieve statistics
15+
- Token authentication
16+
17+
Use the REST client when you need simple request/response operations without maintaining a persistent connection.
18+
19+
### [Realtime Client](realtime.md)
20+
21+
The Realtime client (`AblyRealtime`) maintains a persistent connection to Ably:
22+
23+
- Subscribe to channels and receive messages in real-time
24+
- Publish messages
25+
- Monitor connection state
26+
- Track presence
27+
- Receive live updates
28+
29+
Use the Realtime client for applications that need live updates and bidirectional communication.
30+
31+
## Key Components
32+
33+
### [Authentication](auth.md)
34+
35+
The `Auth` class handles authentication with Ably, supporting:
36+
37+
- API key authentication
38+
- Token authentication
39+
- Token generation and renewal
40+
41+
### [Channels](channels.md)
42+
43+
Channel interfaces provide access to messaging functionality:
44+
45+
- REST channels for publishing and history
46+
- Realtime channels for subscribing to messages
47+
- Channel state management
48+
49+
### [Messages](messages.md)
50+
51+
Message types represent the data sent through Ably:
52+
53+
- `Message` - Standard pub/sub messages
54+
- `PresenceMessage` - Presence state changes
55+
- Encoding and encryption support
56+
57+
### [Types](types.md)
58+
59+
Core data types and configuration:
60+
61+
- `ClientOptions` - Client configuration
62+
- `TokenDetails` - Authentication tokens
63+
- `Stats` - Usage statistics
64+
- Channel and connection options
65+
66+
### [Utilities](util.md)
67+
68+
Utility functions and helpers:
69+
70+
- Exception types
71+
- Encoding/decoding utilities
72+
- Cryptographic functions
73+
74+
## Client Capabilities
75+
76+
Both clients share common capabilities:
77+
78+
- **Auto-reconnection**: Automatic connection recovery
79+
- **Message queueing**: Queues messages during disconnection
80+
- **Type safety**: Full type hints for IDE support
81+
- **Async/await support**: Native async support in Realtime client
82+
- **Error handling**: Comprehensive error types

docs/api/realtime.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Realtime Client
2+
3+
The Realtime client maintains a persistent connection to Ably, enabling you to subscribe to channels and receive messages in real-time.
4+
5+
## AblyRealtime
6+
7+
::: ably.realtime.realtime.AblyRealtime
8+
9+
## Realtime Channels
10+
11+
::: ably.realtime.realtime_channel.Channels
12+
13+
## Realtime Channel
14+
15+
::: ably.realtime.realtime_channel.RealtimeChannel
16+
17+
## Connection
18+
19+
::: ably.realtime.connection.Connection

docs/api/rest.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# REST Client
2+
3+
The REST client provides synchronous access to Ably's REST API for publishing messages, querying history, and managing channels.
4+
5+
## AblyRest
6+
7+
::: ably.rest.rest.AblyRest
8+
9+
## REST Channels
10+
11+
::: ably.rest.channel.Channels
12+
13+
## REST Channel
14+
15+
::: ably.rest.channel.Channel

docs/api/types.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Types
2+
3+
Core data types and configuration options.
4+
5+
## Client Options
6+
7+
::: ably.types.options.Options
8+
9+
## Auth Options
10+
11+
::: ably.types.authoptions.AuthOptions
12+
13+
## Channel Options
14+
15+
::: ably.realtime.realtime_channel.ChannelOptions
16+
17+
## Token Details
18+
19+
::: ably.types.tokendetails.TokenDetails
20+
21+
## Token Request
22+
23+
::: ably.types.tokenrequest.TokenRequest
24+
25+
## Stats
26+
27+
::: ably.types.stats.Stats
28+
29+
## Device Details
30+
31+
::: ably.types.device.DeviceDetails
32+
33+
## Push Channel Subscription
34+
35+
::: ably.types.channelsubscription.PushChannelSubscription
36+
37+
## VCDiff Decoder
38+
39+
::: ably.types.options.VCDiffDecoder

0 commit comments

Comments
 (0)