Skip to content

Commit 07637ee

Browse files
committed
Merge branch 'Docs'
2 parents 08f6457 + 91b9c8d commit 07637ee

24 files changed

+757
-101
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,6 @@ atlassian-ide-plugin.xml
201201
.idea/httpRequests
202202

203203
.idea/dataSources.xml
204-
test.py
204+
test.py
205+
206+
.ds_store

.idea/sendou.py.iml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ An async Python client for Sendou.ink
1818
- [x] Get Tournament Info
1919
- [x] Get Tournament Teams
2020
- [X] Get Tournament Brackets
21-
- [x] Get Tournament Match Info (*by ID not linked to bracket*)
21+
- [x] Get Tournament Match Info (*by ID not linked to bracket*)
2222

2323
## Usage
2424
```python
2525
import sendou
26+
import asyncio
2627

27-
client = sendou.Client("API_KEY")
28-
# Get Sendou's user object
29-
await client.get_user("79237403620945920")
28+
async def run():
29+
client = sendou.Client("API_KEY")
30+
player = await client.get_user("USER_ID")
31+
print(player.name)
32+
33+
asyncio.run(run())
3034
```
3135

3236
## Getting an API Key

docs/cacheConfig.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Cache Configuration
2+
3+
## Setting Expiry
4+
5+
You can set the expiry time for requests when creating a client. The default expiry time is 30 minutes.
6+
7+
The expiry time is in seconds.
8+
9+
- `-1`: No expiry
10+
- `0`: Don't cache
11+
- *Any other number*: Cache for that many seconds
12+
13+
```python
14+
import sendou
15+
import asyncio
16+
17+
async def run():
18+
client = sendou.Client("API_KEY", expiry=60)
19+
player = await client.get_user("USER_ID")
20+
print(player.name)
21+
22+
asyncio.run(run())
23+
```
24+
25+
## Advanced Configuration
26+
27+
Caching in this module is handled by [aiohttp-client-cache](https://pypi.org/project/aiohttp-client-cache/).
28+
29+
You can pass any aiohttp-client-cache CacheBackend to the client.
30+
Once you've instantiated the client by passing it through.
31+
32+
You can see the full list of backends [here](https://aiohttp-client-cache.readthedocs.io/en/stable/backends.html).
33+
34+
```python
35+
import sendou
36+
import asyncio
37+
from aiohttp_client_cache import SQLiteBackend
38+
39+
async def run():
40+
client = sendou.Client("API_KEY", expiry=60)
41+
client.cache = SQLiteBackend('demo_cache')
42+
player = await client.get_user("USER_ID")
43+
print(player.name)
44+
45+
asyncio.run(run())
46+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Installation
2+
3+
To install sendou.py, run the following command:
4+
5+
```bash
6+
pip install sendou.py
7+
```

docs/getting-started/usageGuide.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Usage Guide
2+
3+
This quickstart assumes you know how to use AsyncIO and write asynchronous code in Python.
4+
5+
## [Getting Player Info](../References/client.md#sendou.client.Client.get_tournament)
6+
7+
```python
8+
from sendou import Client
9+
client = Client("API_KEY")
10+
player = await client.get_user("USER_ID")
11+
```
12+
13+
## [Getting Calendar Entries](../References/client.md#sendou.client.Client.get_calendar)
14+
15+
```python
16+
from sendou import Client
17+
client = Client("API_KEY")
18+
tournament = await client.get_calendar("2023", "5")
19+
```
20+
21+
22+
## [Getting Tournament Info](../References/client.md#sendou.client.Client.get_tournament)
23+
24+
```python
25+
from sendou import Client
26+
client = Client("API_KEY")
27+
tournament = await client.get_tournament("TOURNAMENT_ID")
28+
```
29+
30+
### [Getting Tournament Teams](../References/models/tournament/tournament.md#sendou.models.tournament.tournament.Tournament.get_teams)
31+
32+
```python
33+
from sendou import Client
34+
client = Client("API_KEY")
35+
tournament = await client.get_tournament("TOURNAMENT_ID")
36+
teams = await tournament.get_teams()
37+
```
38+
39+
### [Get Player from Team member](../References/models/tournament/team.md#sendou.models.tournament.team.TeamMember.get_user)
40+
41+
```python
42+
from sendou import Client
43+
client = Client("API_KEY")
44+
tournament = await client.get_tournament("TOURNAMENT_ID")
45+
teams = await tournament.get_teams()
46+
for team in teams:
47+
for member in team.members:
48+
player = await member.get_player()
49+
```
50+
51+
### [Getting Tournament Bracket(s)](../References/models/tournament/tournament.md#sendou.models.tournament.tournament.TournamentBracket.get_bracket_data)
52+
53+
```python
54+
from sendou import Client
55+
client = Client("API_KEY")
56+
tournament = await client.get_tournament("TOURNAMENT_ID")
57+
for bracket in tournament.brackets:
58+
bracket_data = await bracket.get_data()
59+
```
60+
61+
## [Getting Tournament Match Info](../References/client.md#sendou.client.Client.get_tournament_matches)
62+
**Note:** This is not linked to the bracket. You need to know the match ID.
63+
64+
(*This will be updated in future when documentation is updated*)
65+
66+
```python
67+
from sendou import Client
68+
client = Client("API_KEY")
69+
match = await client.get_tournament_matches("Match_ID")
70+
```

docs/index.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Sendou.py
2+
3+
An async Python library for interacting with the [Sendou.ink](https://sendou.ink) API.
4+
5+
**Not an official library!**
6+
7+
This library is maintained by [Inkling Performance Labs Productions](https://github.com/iplsplatoon)
8+
9+
## Dependencies
10+
- aiohttp
11+
- python-dateutil
12+
13+
## Installation
14+
`pip install sendou.py`
15+
16+
## Supported Endpoints
17+
- [x] Get user
18+
- [x] Get Tournament Info
19+
- [x] Get Tournament Teams
20+
- [X] Get Tournament Brackets
21+
- [x] Get Tournament Match Info (*by ID not linked to bracket*)
22+
23+
## Usage
24+
```python
25+
import sendou
26+
import asyncio
27+
28+
async def run():
29+
client = sendou.Client("API_KEY")
30+
player = await client.get_user("USER_ID")
31+
print(player.name)
32+
33+
asyncio.run(run())
34+
```
35+
36+
## Getting an API Key
37+
To use this library, you must have an API key. You need to DM Sendou for an API Key currently.

docs/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mkdocstrings[python]
2+
mkdocs-material
3+
mkdocs
4+
mkdocs-autorefs
5+
mkdocs-gen-files
6+
pymdown-extensions

mkdocs.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
site_name: "sendou.py"
2+
repo_url: "https://github.com/IPLSplatoon/sendou.py"
3+
site_dir: "docs"
4+
5+
plugins:
6+
- autorefs
7+
- search
8+
- gen-files:
9+
scripts:
10+
- scripts/genRefPages.py
11+
- mkdocstrings:
12+
handlers:
13+
python:
14+
options:
15+
docstring_style: google
16+
theme:
17+
name: material
18+
nav:
19+
- Overview: index.md
20+
- Getting Started:
21+
- Installation: getting-started/installation.md
22+
- Usage Guide: getting-started/usageGuide.md
23+
- Cache Configuration: cacheConfig.md
24+
palette:
25+
- media: "(prefers-color-scheme)"
26+
toggle:
27+
icon: material/brightness-auto
28+
name: Switch to light mode
29+
- media: "(prefers-color-scheme: light)"
30+
scheme: default
31+
primary: teal
32+
accent: purple
33+
toggle:
34+
icon: material/weather-sunny
35+
name: Switch to dark mode
36+
- media: "(prefers-color-scheme: dark)"
37+
scheme: slate
38+
primary: black
39+
accent: lime
40+
toggle:
41+
icon: material/weather-night
42+
name: Switch to system preference
43+
44+
markdown_extensions:
45+
- attr_list
46+
- admonition
47+
- pymdownx.emoji:
48+
emoji_index: !!python/name:material.extensions.emoji.twemoji
49+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
50+
- pymdownx.keys
51+
- pymdownx.magiclink
52+
- pymdownx.snippets:
53+
base_path: [!relative $config_dir]
54+
check_paths: true
55+
- pymdownx.superfences:
56+
custom_fences:
57+
- name: mermaid
58+
class: mermaid
59+
format: !!python/name:pymdownx.superfences.fence_code_format
60+
- pymdownx.tabbed:
61+
alternate_style: true
62+
slugify: !!python/object/apply:pymdownx.slugs.slugify
63+
kwds:
64+
case: lower
65+
- pymdownx.tasklist:
66+
custom_checkbox: true
67+
- toc:
68+
permalink: "¤"

scripts/genRefPages.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pathlib import Path
2+
import mkdocs_gen_files
3+
4+
root = Path(__file__).parent.parent
5+
src = root / "sendou"
6+
7+
8+
for path in sorted(src.rglob("*.py")):
9+
module_path = path.relative_to(src).with_suffix("")
10+
if "__init__" in module_path.name:
11+
continue
12+
file_name_path = str(module_path).replace("/", ".")
13+
with mkdocs_gen_files.open(f"References/{str(module_path)}.md", "w") as fd:
14+
identifier = f"sendou.{file_name_path}"
15+
print("::: " + identifier, file=fd)

0 commit comments

Comments
 (0)