Skip to content

Commit

Permalink
Merge pull request #39 from 201st-Luka/new-features
Browse files Browse the repository at this point in the history
New features
  • Loading branch information
201st-Luka authored Sep 13, 2023
2 parents d594a87 + 9585869 commit 51f6f00
Show file tree
Hide file tree
Showing 88 changed files with 438 additions and 89 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: doc generation
on:
push:
branches:
- master
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install -r requirements-docs.txt
- run: mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 PyClasher
Copyright (c) 2023 - Present 201st-Luka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
54 changes: 54 additions & 0 deletions doc_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import shutil


def get_project_dir() -> str:
return "/" + os.getcwd().strip("docs/doc_autogen.py")


def create_markdown_structure(package_path, output_path):
"""
Create a directory structure mirroring the Python package structure, with
markdown files containing '::: pyclasher.path.filename' for each module.
Args:
package_path (str): The path to the Python package.
output_path (str): The path where the directory structure and markdown files will be generated.
"""
for dirpath, dirnames, filenames in os.walk(package_path):
relative_dir = os.path.relpath(dirpath, package_path)
output_dir = os.path.join(output_path, relative_dir)
os.makedirs(output_dir, exist_ok=True)

for filename in filenames:
if filename.endswith('.py') and filename != "__init__.py":
module_name = os.path.splitext(filename)[0]
import_path = (
"pyclasher." +
os.path.join(relative_dir if relative_dir != '.'
else '',
module_name)
).replace('/', '.')
markdown_content = f"::: {import_path}\n"

markdown_file_path = os.path.join(output_dir,
f"{module_name}.md")

with open(markdown_file_path, 'w') as markdown_file:
print(f"Creating docs for {import_path}")
markdown_file.write(markdown_content)


if __name__ == '__main__':
project_dir = get_project_dir()

doc_dir = os.path.join(project_dir, "docs")

api_ref_dir = os.path.join(doc_dir, "docs/API Reference")
pyclasher_dir = os.path.join(project_dir, "pyclasher")

shutil.rmtree(api_ref_dir)

os.mkdir(api_ref_dir)

create_markdown_structure(pyclasher_dir, api_ref_dir)
1 change: 1 addition & 0 deletions docs/API Reference/api/bulk_requests/abc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.bulk_requests.abc
1 change: 1 addition & 0 deletions docs/API Reference/api/bulk_requests/b_player.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.bulk_requests.b_player
1 change: 1 addition & 0 deletions docs/API Reference/api/models/abc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.abc
1 change: 1 addition & 0 deletions docs/API Reference/api/models/base_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.base_models
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_builder_base_ranking_list
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_capital_raid_seasons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_capital_raid_seasons
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_capital_ranking_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_capital_ranking_list
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_list
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_member.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_member
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_member_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_member_list
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_ranking_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_ranking_list
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_war.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_war
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_war_league_group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_war_league_group
1 change: 1 addition & 0 deletions docs/API Reference/api/models/clan_war_log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.clan_war_log
1 change: 1 addition & 0 deletions docs/API Reference/api/models/enums.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.enums
1 change: 1 addition & 0 deletions docs/API Reference/api/models/gold_pass_season.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.gold_pass_season
1 change: 1 addition & 0 deletions docs/API Reference/api/models/labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.labels
1 change: 1 addition & 0 deletions docs/API Reference/api/models/language.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.language
1 change: 1 addition & 0 deletions docs/API Reference/api/models/leagues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.leagues
1 change: 1 addition & 0 deletions docs/API Reference/api/models/location.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.location
1 change: 1 addition & 0 deletions docs/API Reference/api/models/login/login_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.login.login_models
1 change: 1 addition & 0 deletions docs/API Reference/api/models/misc/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.misc.api
1 change: 1 addition & 0 deletions docs/API Reference/api/models/misc/posts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.misc.posts
1 change: 1 addition & 0 deletions docs/API Reference/api/models/misc/responses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.misc.responses
1 change: 1 addition & 0 deletions docs/API Reference/api/models/misc/war_status.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.misc.war_status
1 change: 1 addition & 0 deletions docs/API Reference/api/models/player.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.player
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.player_builder_base_ranking_list
1 change: 1 addition & 0 deletions docs/API Reference/api/models/player_house.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.player_house
1 change: 1 addition & 0 deletions docs/API Reference/api/models/player_ranking_clan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.player_ranking_clan
1 change: 1 addition & 0 deletions docs/API Reference/api/models/player_ranking_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.player_ranking_list
1 change: 1 addition & 0 deletions docs/API Reference/api/models/season.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.season
1 change: 1 addition & 0 deletions docs/API Reference/api/models/war_clan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.models.war_clan
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/abc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.abc
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/builder_base_league.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.builder_base_league
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/builder_base_leagues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.builder_base_leagues
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/capital_league.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.capital_league
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/capital_league_seasons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.capital_league_seasons
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/capital_rankings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.capital_rankings
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_builder_base_rankings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_capital_raid_seasons
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan_current_war.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_current_war
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_currentwar_leaguegroup
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan_labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_labels
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan_members.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_members
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan_rankings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_rankings
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan_search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_search
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan_war_log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_war_log
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/clan_warleagues_wars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.clan_warleagues_wars
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/gold_pass.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.gold_pass
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/league.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.league
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/league_season.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.league_season
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/league_seasons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.league_seasons
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/leagues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.leagues
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/location.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.location
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/locations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.locations
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/player.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.player
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.player_builder_base_rankings
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/player_labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.player_labels
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/player_rankings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.player_rankings
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/war_league.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.war_league
1 change: 1 addition & 0 deletions docs/API Reference/api/requests/war_leagues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.api.requests.war_leagues
1 change: 1 addition & 0 deletions docs/API Reference/client/client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.client.client
1 change: 1 addition & 0 deletions docs/API Reference/client/request_consumer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.client.request_consumer
1 change: 1 addition & 0 deletions docs/API Reference/client/request_queue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.client.request_queue
1 change: 1 addition & 0 deletions docs/API Reference/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.exceptions
1 change: 1 addition & 0 deletions docs/API Reference/utils/exectimer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.utils.exectimer
1 change: 1 addition & 0 deletions docs/API Reference/utils/functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.utils.functions
1 change: 1 addition & 0 deletions docs/API Reference/utils/login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.utils.login
1 change: 1 addition & 0 deletions docs/API Reference/utils/request_methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: pyclasher.utils.request_methods
42 changes: 42 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[![Discord][discord_shield]][discord_url] ![Last commit][last_commit_shield]

# PyClasher

PyClasher is the name of the asynchronous ClashOfClans API. It is
an object-oriented wrapper client that provides easy access to the
requested data.

---
## Features
- Asynchronous and parallel requesting
- Possibility to use multiple tokens and to login via email address and
password of the ClashOfClans developer portal
- Control over the number of requests per second and the number of used tokens
- Open source
- Type hinted
- Supports Python 3.8 -> 3.11

---

## Installation

It is possible to install the package from GitHib releases. You can use the
following command to add PyClasher to your library:
```bash
pip install git+https://github.com/201st-Luka/PyClasher.git@v1.0.0-alpha1
```

---

## Disclaimer
This material is unofficial and is not endorsed by Supercell. For more
information see Supercell's Fan Content Policy:
www.supercell.com/fan-content-policy.



<!---links--->
[discord_shield]: https://img.shields.io/badge/Discord-blue?logo=discord&logoColor=white
[discord_url]: https://discord.gg/j2PAF9Wru8
[last_commit_shield]: https://img.shields.io/github/last-commit/201st-Luka/HeadhunterBot
[headhunterbot_url]: https://github.com/201st-Luka/HeadhunterBot
71 changes: 71 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
site_name: PyClasher
site_url: https://201st-Luka.github.io/pyclasher/
copyright: Copyright &copy; Copyright (c) 2023 - Present 201st-Luka
repo_url: https://github.com/201st-Luka/PyClasher
repo_name: 201st-Luka/PyClasher
docs_dir: docs

theme:
name: material
features:
- navigation.tabs
- navigation.tabs.sticky
- navigation.instant
- navigation.tracking
- navigation.path
- navigation.prune
- navigation.top
- search.suggest
- search.share
- search.highlight
- content.tabs.link
- content.code.annotation
- content.code.copy
language: en
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
primary: indigo
accent: orange
toggle:
icon: material/brightness-7
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: indigo
accent: orange
toggle:
icon: material/brightness-3
name: Switch to light mode
icon: fontawesome/brands/github

plugins:
- search:
lang: en
- git-committers:
repository: 201st-Luka/PyClasher
branch: master
token: !!python/object/apply:os.getenv ["MKDOCS_GIT_COMMITTERS_APIKEY"]
- mkdocstrings:
enabled: true
custom_templates: templates
default_handler: python
handlers:
python:
options:
show_source: true
- awesome-pages

extra:
version:
provider: mike
social:
- icon: fontawesome/brands/discord
link: https://discord.gg/j2PAF9Wru8
name: Become part of the 201st Community
- icon: fontawesome/brands/github
link: https://github.com/201st-Luka/PyClasher
name: PyClasher on GitHub

watch:
- pyclasher
2 changes: 1 addition & 1 deletion pyclasher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.. author:: 201st-Luka
"""

__version__ = '1.0.0-alpha1'
__version__ = '1.0.0'

from .api import *
from .client import Client
Expand Down
13 changes: 13 additions & 0 deletions pyclasher/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
All client modules are in this package
"""

from .client import Client
from .request_queue import PQueue
from .request_consumer import PConsumer

__all__ = (
"Client",
"PQueue",
"PConsumer"
)
Loading

0 comments on commit 51f6f00

Please sign in to comment.