Skip to content

Commit

Permalink
Merge branch 'Docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
vlee489 committed Jul 1, 2024
2 parents 08f6457 + 91b9c8d commit 07637ee
Show file tree
Hide file tree
Showing 24 changed files with 757 additions and 101 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,6 @@ atlassian-ide-plugin.xml
.idea/httpRequests

.idea/dataSources.xml
test.py
test.py

.ds_store
7 changes: 7 additions & 0 deletions .idea/sendou.py.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ An async Python client for Sendou.ink
- [x] Get Tournament Info
- [x] Get Tournament Teams
- [X] Get Tournament Brackets
- [x] Get Tournament Match Info (*by ID not linked to bracket*)
- [x] Get Tournament Match Info (*by ID not linked to bracket*)

## Usage
```python
import sendou
import asyncio

client = sendou.Client("API_KEY")
# Get Sendou's user object
await client.get_user("79237403620945920")
async def run():
client = sendou.Client("API_KEY")
player = await client.get_user("USER_ID")
print(player.name)

asyncio.run(run())
```

## Getting an API Key
Expand Down
46 changes: 46 additions & 0 deletions docs/cacheConfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Cache Configuration

## Setting Expiry

You can set the expiry time for requests when creating a client. The default expiry time is 30 minutes.

The expiry time is in seconds.

- `-1`: No expiry
- `0`: Don't cache
- *Any other number*: Cache for that many seconds

```python
import sendou
import asyncio

async def run():
client = sendou.Client("API_KEY", expiry=60)
player = await client.get_user("USER_ID")
print(player.name)

asyncio.run(run())
```

## Advanced Configuration

Caching in this module is handled by [aiohttp-client-cache](https://pypi.org/project/aiohttp-client-cache/).

You can pass any aiohttp-client-cache CacheBackend to the client.
Once you've instantiated the client by passing it through.

You can see the full list of backends [here](https://aiohttp-client-cache.readthedocs.io/en/stable/backends.html).

```python
import sendou
import asyncio
from aiohttp_client_cache import SQLiteBackend

async def run():
client = sendou.Client("API_KEY", expiry=60)
client.cache = SQLiteBackend('demo_cache')
player = await client.get_user("USER_ID")
print(player.name)

asyncio.run(run())
```
7 changes: 7 additions & 0 deletions docs/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Installation

To install sendou.py, run the following command:

```bash
pip install sendou.py
```
70 changes: 70 additions & 0 deletions docs/getting-started/usageGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Usage Guide

This quickstart assumes you know how to use AsyncIO and write asynchronous code in Python.

## [Getting Player Info](../References/client.md#sendou.client.Client.get_tournament)

```python
from sendou import Client
client = Client("API_KEY")
player = await client.get_user("USER_ID")
```

## [Getting Calendar Entries](../References/client.md#sendou.client.Client.get_calendar)

```python
from sendou import Client
client = Client("API_KEY")
tournament = await client.get_calendar("2023", "5")
```


## [Getting Tournament Info](../References/client.md#sendou.client.Client.get_tournament)

```python
from sendou import Client
client = Client("API_KEY")
tournament = await client.get_tournament("TOURNAMENT_ID")
```

### [Getting Tournament Teams](../References/models/tournament/tournament.md#sendou.models.tournament.tournament.Tournament.get_teams)

```python
from sendou import Client
client = Client("API_KEY")
tournament = await client.get_tournament("TOURNAMENT_ID")
teams = await tournament.get_teams()
```

### [Get Player from Team member](../References/models/tournament/team.md#sendou.models.tournament.team.TeamMember.get_user)

```python
from sendou import Client
client = Client("API_KEY")
tournament = await client.get_tournament("TOURNAMENT_ID")
teams = await tournament.get_teams()
for team in teams:
for member in team.members:
player = await member.get_player()
```

### [Getting Tournament Bracket(s)](../References/models/tournament/tournament.md#sendou.models.tournament.tournament.TournamentBracket.get_bracket_data)

```python
from sendou import Client
client = Client("API_KEY")
tournament = await client.get_tournament("TOURNAMENT_ID")
for bracket in tournament.brackets:
bracket_data = await bracket.get_data()
```

## [Getting Tournament Match Info](../References/client.md#sendou.client.Client.get_tournament_matches)
**Note:** This is not linked to the bracket. You need to know the match ID.

(*This will be updated in future when documentation is updated*)

```python
from sendou import Client
client = Client("API_KEY")
match = await client.get_tournament_matches("Match_ID")
```
37 changes: 37 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Sendou.py

An async Python library for interacting with the [Sendou.ink](https://sendou.ink) API.

**Not an official library!**

This library is maintained by [Inkling Performance Labs Productions](https://github.com/iplsplatoon)

## Dependencies
- aiohttp
- python-dateutil

## Installation
`pip install sendou.py`

## Supported Endpoints
- [x] Get user
- [x] Get Tournament Info
- [x] Get Tournament Teams
- [X] Get Tournament Brackets
- [x] Get Tournament Match Info (*by ID not linked to bracket*)

## Usage
```python
import sendou
import asyncio

async def run():
client = sendou.Client("API_KEY")
player = await client.get_user("USER_ID")
print(player.name)

asyncio.run(run())
```

## Getting an API Key
To use this library, you must have an API key. You need to DM Sendou for an API Key currently.
6 changes: 6 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdocstrings[python]
mkdocs-material
mkdocs
mkdocs-autorefs
mkdocs-gen-files
pymdown-extensions
68 changes: 68 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
site_name: "sendou.py"
repo_url: "https://github.com/IPLSplatoon/sendou.py"
site_dir: "docs"

plugins:
- autorefs
- search
- gen-files:
scripts:
- scripts/genRefPages.py
- mkdocstrings:
handlers:
python:
options:
docstring_style: google
theme:
name: material
nav:
- Overview: index.md
- Getting Started:
- Installation: getting-started/installation.md
- Usage Guide: getting-started/usageGuide.md
- Cache Configuration: cacheConfig.md
palette:
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: teal
accent: purple
toggle:
icon: material/weather-sunny
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: black
accent: lime
toggle:
icon: material/weather-night
name: Switch to system preference

markdown_extensions:
- attr_list
- admonition
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.keys
- pymdownx.magiclink
- pymdownx.snippets:
base_path: [!relative $config_dir]
check_paths: true
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
- pymdownx.tabbed:
alternate_style: true
slugify: !!python/object/apply:pymdownx.slugs.slugify
kwds:
case: lower
- pymdownx.tasklist:
custom_checkbox: true
- toc:
permalink: "¤"
15 changes: 15 additions & 0 deletions scripts/genRefPages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pathlib import Path
import mkdocs_gen_files

root = Path(__file__).parent.parent
src = root / "sendou"


for path in sorted(src.rglob("*.py")):
module_path = path.relative_to(src).with_suffix("")
if "__init__" in module_path.name:
continue
file_name_path = str(module_path).replace("/", ".")
with mkdocs_gen_files.open(f"References/{str(module_path)}.md", "w") as fd:
identifier = f"sendou.{file_name_path}"
print("::: " + identifier, file=fd)
Loading

0 comments on commit 07637ee

Please sign in to comment.