Skip to content

Commit 67b2b45

Browse files
committed
add docs for working with the stardog cloud package
1 parent 4c09679 commit 67b2b45

File tree

5 files changed

+126
-7
lines changed

5 files changed

+126
-7
lines changed

docs/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,20 @@
4040
# ones.
4141
extensions = [
4242
"sphinx.ext.autodoc",
43+
"sphinxcontrib.autodoc_pydantic",
4344
"sphinx_autodoc_typehints",
4445
"sphinx.ext.doctest",
4546
"sphinx.ext.viewcode",
4647
"sphinx.ext.napoleon",
4748
"recommonmark",
4849
]
4950

51+
# https://autodoc-pydantic.readthedocs.io/en/stable/users/installation.html
52+
autodoc_pydantic_model_show_json = False
53+
autodoc_pydantic_settings_show_json = False
54+
autosummary_generate = True
55+
56+
5057
# Add any paths that contain templates here, relative to this directory.
5158
templates_path = ["_templates"]
5259

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pystardog
1212

1313
README.md
1414
source/stardog
15+
source/stardog.cloud
16+
1517

1618
Indices and tables
1719
==================

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ contextlib2==21.6.0
55
requests-toolbelt==1.0.0
66
recommonmark==0.5.0
77
requests==2.31.0
8+
autodoc_pydantic==2.2.0

docs/source/stardog.cloud.rst

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Stardog Cloud
2+
###############
3+
4+
The :obj:`stardog.cloud` subpackage provides clients for accessing Stardog Cloud services, such as `Stardog Voicebox <https://stardog.ai/>`_.
5+
6+
.. list-table:: Clients
7+
:widths: 50 50
8+
:header-rows: 1
9+
10+
* - Class
11+
- Description
12+
* - :class:`stardog.cloud.client.Client`
13+
- Ideal for simple blocking operations in traditional Python applications.
14+
* - :class:`stardog.cloud.client.AsyncClient`
15+
- Suitable for async programming models, such as ``asyncio``.
16+
17+
Voicebox Integration
18+
************************
19+
20+
Access Stardog's Voicebox capabilities through an instance of :class:`stardog.cloud.voicebox.VoiceboxApp` class.
21+
22+
.. note::
23+
The :class:`stardog.cloud.voicebox.VoiceboxApp` provides both synchronous and asynchronous methods, offering the same functionality. Asynchronous methods are prefixed with `async_` and return coroutines that can be awaited, while synchronous methods return objects directly. For example, :obj:`stardog.cloud.voicebox.VoiceboxApp.async_ask` returns a coroutine, while :obj:`stardog.cloud.voicebox.VoiceboxApp.ask` returns a :class:`stardog.cloud.voicebox.VoiceboxAnswer`.
24+
25+
26+
27+
Synchronous usage
28+
========================
29+
30+
.. code-block:: python
31+
32+
from stardog.cloud.client import Client
33+
34+
with Client() as client:
35+
app = client.voicebox_app(app_api_token="your-token", client_id="your-client-id")
36+
response = app.ask(question="Your question here")
37+
38+
Asynchronous usage
39+
========================
40+
41+
42+
.. code-block:: python
43+
44+
from stardog.cloud.client import AsyncClient
45+
46+
async with AsyncClient() as client:
47+
app = client.voicebox_app(app_api_token="your-token", client_id="your-client-id")
48+
response = await app.async_ask(question="Your question here")
49+
50+
51+
Error Handling
52+
========================
53+
54+
The package raises custom exceptions defined in the :obj:`stardog.cloud.exceptions` module. These exceptions can be caught when interacting with the Stardog Cloud clients.
55+
56+
All clients raise exceptions if needed, with :class:`stardog.cloud.exceptions.StardogCloudException` serving as the base exception for any error raised.
57+
58+
.. code-block:: python
59+
60+
from stardog.cloud.exceptions import (
61+
StardogCloudException,
62+
RateLimitExceededException
63+
)
64+
65+
try:
66+
with Client() as client:
67+
app = client.voicebox_app(app_api_token="your-token", client_id="your-client-id")
68+
response = app.ask(question="Your question")
69+
except RateLimitExceededException as e:
70+
print(f"Rate limit exceeded: {e}")
71+
except StardogCloudException as e:
72+
print(f"Error occurred: {e}")
73+
74+
75+
76+
API Reference
77+
*********************
78+
79+
stardog.cloud.client
80+
============================
81+
82+
.. automodule:: stardog.cloud.client
83+
:members:
84+
:undoc-members:
85+
:show-inheritance:
86+
:special-members: __init__
87+
88+
stardog.cloud.voicebox
89+
============================
90+
91+
.. automodule:: stardog.cloud.voicebox
92+
:members:
93+
:undoc-members:
94+
:show-inheritance:
95+
:special-members: __init__
96+
97+
stardog.cloud.exceptions
98+
============================
99+
100+
.. automodule:: stardog.cloud.exceptions
101+
:members:
102+
:undoc-members:
103+
:show-inheritance:
104+
:special-members: __init__
105+

docs/source/stardog.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
Modules
2-
=======
1+
Stardog
2+
#######
3+
4+
5+
API Reference
6+
*********************
37

48
stardog.connection
5-
------------------
9+
==================
610

711
.. automodule:: stardog.connection
812
:members:
@@ -11,7 +15,7 @@ stardog.connection
1115
:special-members: __init__
1216

1317
stardog.admin
14-
-------------
18+
=============
1519

1620
.. automodule:: stardog.admin
1721
:members:
@@ -20,7 +24,7 @@ stardog.admin
2024
:special-members: __init__
2125

2226
stardog.content
23-
---------------
27+
===============
2428

2529
.. automodule:: stardog.content
2630
:members:
@@ -29,7 +33,7 @@ stardog.content
2933
:special-members: __init__
3034

3135
stardog.results
32-
---------------
36+
===============
3337

3438
.. automodule:: stardog.results
3539
:members:
@@ -38,7 +42,7 @@ stardog.results
3842
:special-members: __init__
3943

4044
stardog.exceptions
41-
------------------
45+
==================
4246

4347
.. automodule:: stardog.exceptions
4448
:members:

0 commit comments

Comments
 (0)