Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMaster3558 committed Aug 28, 2023
1 parent 1f81e57 commit 7e5572a
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 45 deletions.
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -4,6 +4,10 @@ aiointeractions
An async Discord HTTP Interactions wrapper for `discord.py` built with `aiohttp`.


.. image:: /docs/_static/logo.png
:alt: The aiointeractions logo


Documentation
-------------
https://aiointeractions.readthedocs.io/
Expand Down
Binary file added docs/_static/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Expand Up @@ -3,4 +3,4 @@ Changelog

v2.0.0
~~~~~~
See :doc:`migrating_to_v2`
See :doc:`migrating to v2 <migrating_to_v2>`
30 changes: 28 additions & 2 deletions docs/conf.py
Expand Up @@ -26,7 +26,7 @@
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinxawesome_theme']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx_copybutton', 'sphinx_tabs.tabs']

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
Expand All @@ -35,8 +35,34 @@
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinxawesome_theme'
html_theme = 'shibuya'
html_static_path = ['_static']

html_theme_options = {
'light_css_variables': {
'--sy-rc-theme': '0, 72, 186',
},
'dark_css_variables': {
'--sy-rc-theme': '225, 191, 0',
},
'nav_links': [
{
'title': 'PyPi',
'url': 'https://pypi.org/projects/aiointeractions',
'summary': 'You can install aiointeractions here!'
}
],
'github_url': 'https://github.com/TheMaster3558/aiointeractions',
'youtube_url': 'https://www.youtube.com/channel/UCEbHD3v3kPmVdlQ74FkUkGw'
}

html_context = {
'source_type': 'github',
'source_user': 'TheMaster3558',
'source_repo': 'aiointeractions',
}

html_logo = '_static/logo.png'


autodoc_typehints = 'none'
15 changes: 13 additions & 2 deletions docs/getting_started.rst
Expand Up @@ -14,9 +14,20 @@ The only dependency is `discord.py`
Installing
----------

.. code:: shell

$ pip install aiointeractions
.. tabs::

.. group-tab:: Linux/MacOS

.. code:: shell
$ python -m pip install -U aiointeractions
.. group-tab:: Windows

.. code:: shell
$ py -m pip install -U aiointeractions
Example
Expand Down
81 changes: 42 additions & 39 deletions docs/migrating_to_v2.rst
Expand Up @@ -3,65 +3,68 @@ Migrating to v2

Deprecation of :meth:`InteractionsApp.start()`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The start() method is being removed in favor of aiohttp's asynchronous start methods.
The reason behind this is the start() method uses ``aiohttp.web._run_app()`` which is a private method
The ``start()`` method is being removed in favor of aiohttp's asynchronous start methods.
The reason behind this is the ``start()`` method uses ``aiohttp.web._run_app()`` which is a private method
so it's best to move away from using undocumented methods.

**Old**

.. code:: py
.. tabs::

import asyncio
.. group-tab:: Old

import aiointeractions
from aiohttp import web
.. code:: py
client = discord.Client(...)
app = aiointeractions.InteractionsApp(client, ...)
import asyncio
async def main():
async with client:
await app.start('token')
import aiointeractions
from aiohttp import web
asyncio.run(main())
client = discord.Client(...)
app = aiointeractions.InteractionsApp(client, ...)
async def main():
async with client:
await app.start('token')
**New**
asyncio.run(main())
.. code:: py
import asyncio
.. group-tab:: New

import aiointeractions
from aiohttp import web
.. code:: py
client = discord.Client(...)
app = aiointeractions.InteractionsApp(client, ...)
import asyncio
async def main():
async with client:
await app.setup('token')
# if you would like to call setup() after the web server is started like app.run()
# do this instead of await app.setup('token')
#
# import functools
# app.app.on_startup.append(functools.partial(app.setup, 'token'))
import aiointeractions
from aiohttp import web
runner = web.AppRunner(app.app)
await runner.setup()
site = web.TCPSite(runner)
await site.start()
client = discord.Client(...)
app = aiointeractions.InteractionsApp(client, ...)
try:
while True:
await asyncio.sleep(3600)
finally:
await runner.cleanup()
async def main():
async with client:
await app.setup('token')
# if you would like to call setup() after the web server is started like app.run()
# do this instead of await app.setup('token')
#
# import functools
# app.app.on_startup.append(functools.partial(app.setup, 'token'))
asyncio.run(main())
runner = web.AppRunner(app.app)
await runner.setup()
site = web.TCPSite(runner)
await site.start()
try:
while True:
await asyncio.sleep(3600)
finally:
await runner.cleanup()
Addition of :meth`InteractionsApp.setup()`
asyncio.run(main())
Addition of :meth:`InteractionsApp.setup()`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This new method logs in the discord client and fetches verification keys.
This method is automatically called in :meth:`InteractionsApp.run()` so only use it if you are using alternative start methods
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -35,7 +35,7 @@ keywords = ["discord"]


[project.optional-dependencies]
docs = ["sphinxawesome_theme"]
docs = ["shibuya", "sphinx-copybutton", "sphinx-tabs"]
tests = ["pytest", "pytest-asyncio", "pytest-aiohttp"]


Expand Down

0 comments on commit 7e5572a

Please sign in to comment.