Skip to content

Commit

Permalink
Merge pull request #12 from AJXD2/feature/docs
Browse files Browse the repository at this point in the history
Feature/docs
  • Loading branch information
AJXD2 authored Dec 18, 2024
2 parents db5018c + d2c7225 commit ff3dcb9
Show file tree
Hide file tree
Showing 16 changed files with 571 additions and 37 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# .github/workflows/documentation.yml
name: documentation

on:
push:
branches:
- main # Set this to your default branch
pull_request:
branches:
- main

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs-material mkdocstrings[python] # Add any other dependencies you need
- name: Deploy documentation
run: mkdocs gh-deploy --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions docs/api/constants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Constants

::: helldivepy.constants
options:
show_source: false
5 changes: 5 additions & 0 deletions docs/api/enums.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Enums

::: helldivepy.enums
options:
show_source: false
5 changes: 5 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# API Reference

::: helldivepy
options:
show_source: false
5 changes: 5 additions & 0 deletions docs/api/models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Models

::: helldivepy.models
options:
show_source: false
5 changes: 5 additions & 0 deletions docs/api/routes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Routes

::: helldivepy.api
options:
show_source: false
5 changes: 5 additions & 0 deletions docs/api/utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Utils

::: helldivepy.utils
options:
show_source: false
Binary file added docs/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
icon: material/human-greeting
---
# Helldive.py

[![PyPI](https://img.shields.io/pypi/v/helldivepy.svg?label=PyPI&color=blue)](https://pypi.org/project/helldivepy/)
![PyPI - Downloads](https://img.shields.io/pypi/dm/helldivepy?color=brightgreen)
![GitHub License](https://img.shields.io/github/license/ajxd2/helldive.py?color=yellow)
[![Python Versions](https://img.shields.io/pypi/pyversions/helldivepy.svg?color=orange)](https://pypi.org/project/helldivepy/)
![GitHub contributors](https://img.shields.io/github/contributors/ajxd2/helldive.py?color=ff69b4)

> A simple Python library for diving deep into the [Helldivers Community API](https://github.com/helldivers-2/api) and [Diveharder API](https://github.com/helldivers-2/diveharder_api.py).
---

## 🌟 Features

- **Easy API Access**: Communicate with the Helldivers Community API and Diveharder API without breaking a sweat.
- **Typed Data**: Get structured, easily readable data like dispatches, planets, and more!
- **Perfect for Projects**: Ideal for projects, bots, or just exploring Helldivers data.

---

## 🔗 Links
- [Get Started](installation.md)
- [DiveHarder](https://github.com/helldivers-2/diveharder_api.py)
- [Community API](https://github.com/helldivers-2/api)
- [API discussion Discord](https://discord.gg/MThYGMCqgp)
106 changes: 106 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
icon: material/download
---
# 🚀 Get Started

## ⚙️ Installation

=== "Pip"

```sh
pip install helldivepy
```
=== "Poetry"
??? note "Poetry"
Install poetry [here](https://python-poetry.org/docs/#installation).
```sh
poetry add helldivepy
```

=== "UV"
??? note "UV"
Install UV [here](https://docs.astral.sh/uv/getting-started/installation/).

```sh
uv add helldivepy
```

Example code

=== "Without Rich"

```py
from helldivepy import ApiClient
client = ApiClient(
user_agent="Hello-World",
user_contact="example@example.com | discord:exampleuser123",
)

print(client.get_war_info().model_dump())
>>>
{
'started': datetime.datetime(2024, 1, 23, 20, 5, 13, tzinfo=TzInfo(UTC)),
'ended': datetime.datetime(2028, 2, 8, 20, 4, 55, tzinfo=TzInfo(UTC)),
'now': datetime.datetime(1970, 11, 6, 14, 59, 50, tzinfo=TzInfo(UTC)),
'client_version': '0.3.0',
'factions': ['Humans', 'Terminids', 'Automaton', 'Illuminate'],
'impact_multiplier': 0.034382936,
'statistics': {
'missions_won': 370390368,
'missions_lost': 37224925,
'mission_time': 1047433682627,
'terminid_kills': 79906866134,
'automaton_kills': 31552895947,
'illuminate_kills': 3705435035,
'bullets_fired': 571067857117,
'bullets_hit': 645369797775,
'time_played': 1047433682627,
'deaths': 2564546790,
'revives': 2,
'friendlies': 361359530,
'mission_success_rate': 90.0,
'accuracy': 100,
'player_count': 111316
}
}

```

=== "With rich"

```py
from helldivepy import ApiClient
from rich import print

client = ApiClient(
user_agent="Hello-World",
user_contact="example@example.com | discord:exampleuser123",
)

print(client.get_war_info())
>>> WarInfo(
started=datetime.datetime(2024, 1, 23, 20, 5, 13, tzinfo=TzInfo(UTC)),
ended=datetime.datetime(2028, 2, 8, 20, 4, 55, tzinfo=TzInfo(UTC)),
now=datetime.datetime(1970, 11, 6, 14, 24, 40, tzinfo=TzInfo(UTC)),
client_version='0.3.0',
factions=['Humans', 'Terminids', 'Automaton', 'Illuminate'],
impact_multiplier=0.03595309,
statistics=Statistics(
missions_won=370353637,
missions_lost=37219878,
mission_time=1047300170684,
terminid_kills=79904593412,
automaton_kills=31551843355,
illuminate_kills=3687632552,
bullets_fired=570972530827,
bullets_hit=645273266867,
time_played=1047300170684,
deaths=2564288334,
revives=2,
friendlies=361317130,
mission_success_rate=90.0,
accuracy=100,
player_count=102995
)
)
```
13 changes: 13 additions & 0 deletions docs/links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
icon: material/link
---

# 🔗 Links

A list of links that may come in handy when using this lib or other parts of the community API.

- [PyPi project](https://pypi.org/project/helldivepy/)
- [DiveHarder](https://github.com/helldivers-2/diveharder_api.py)
- [Community API](https://github.com/helldivers-2/api)
- [Comuunity Github](https://github.com/helldivers-2/)
- [API discussion Discord](https://discord.gg/MThYGMCqgp)
7 changes: 7 additions & 0 deletions helldivepy/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ def parse(cls, value):


class CampaignTypes(BetterEnum):
"""Types of campaigns in the game"""

LIBERATION_DEFENSE = 0
RECON = 1
STORY = 2


class ValueTypes(BetterEnum):
"""Types of values returned from the major order/assignments endpoint."""

RACE = 1
UNKNOWN = 2
TARGET_COUNT = 3
Expand All @@ -31,10 +34,14 @@ class ValueTypes(BetterEnum):


class RewardTypes(BetterEnum):
"""Types of rewards given out by the major order/assignments."""

MEDALS = 1


class AssignmentTypes(BetterEnum):
"""Types of assignments."""

ERADICATE = 3
LIBERATION = 11
DEFENSE = 12
Expand Down
Loading

0 comments on commit ff3dcb9

Please sign in to comment.