Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Jan 26, 2024
1 parent 31bc90e commit a3258c2
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/sphinx-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v4

Expand All @@ -53,7 +53,7 @@ jobs:
python -m pip install -r docs/requirements.txt
- name: Sphinx API Documentation Generation
run: sphinx-apidoc -o docs opengsq
run: sphinx-apidoc -o docs opengsq/api

- name: Sphinx HTML Documentation Build
run: sphinx-build -b html docs docs/_build
Expand All @@ -63,7 +63,7 @@ jobs:
with:
# Upload entire repository
path: "docs/_build"

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 0 additions & 2 deletions docs/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions docs/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.rst
19 changes: 16 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@ Welcome to OpenGSQ Python's documentation!
==========================================

.. toctree::
:maxdepth: 2
:caption: Contents:
:maxdepth: 4
:caption: Get Started

Home <self>
install
usage

.. toctree::
:maxdepth: 4
:caption: API

api/modules

.. toctree::
:maxdepth: 4
:caption: Tests

modules

Indices and tables
==================
Expand Down
14 changes: 14 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Installation
============

You can install the OpenGSQ library using pip:

.. code-block:: console
(.venv) $ pip install --upgrade opengsq
Alternatively, you can install from source manually:

.. code-block:: console
(.venv) $ python setup.py install
35 changes: 35 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Usage
=====

Here's an example of how to query a server using the Source protocol:

.. code-block:: python
import asyncio
from opengsq.protocols import Source
async def main():
source = Source(host='45.147.5.5', port=27015)
info = await source.get_info()
print(info)
asyncio.run(main())
You can also use the Source Remote Console:

.. code-block:: python
import asyncio
from opengsq.exceptions import AuthenticationException
from opengsq.protocols import Source
async def main():
with Source.RemoteConsole('123.123.123.123', 27015) as rcon:
try:
await rcon.authenticate('serverRconPassword')
result = await rcon.send_command('cvarlist')
print(result)
except AuthenticationException:
print('Failed to authenticate')
asyncio.run(main())
2 changes: 1 addition & 1 deletion opengsq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""
OpenGSQ Python Library
~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~
Python library for querying game servers
Expand Down
7 changes: 0 additions & 7 deletions tests/protocols/result_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
from dataclasses import asdict, is_dataclass
import json
import os
from pathlib import Path
Expand All @@ -20,12 +19,6 @@ async def save_result(self, function_name, result, is_json=True):

if self.enable_save:
if is_json:
# if is_dataclass(result):
# result = asdict(result)
# elif isinstance(result, list):
# # set asdict to all items
# result = [asdict(item) for item in result if is_dataclass(item)]

result = json.dumps(result, indent=4, ensure_ascii=False, default=lambda o: o.__dict__)

with open(os.path.join(self.__protocol_path, f'{function_name}.{(is_json and "json" or "txt")}'), 'w', encoding='utf-8') as f:
Expand Down

0 comments on commit a3258c2

Please sign in to comment.