diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..329c815 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,19 @@ +version: 2 +formats: [] + +build: + image: latest + +sphinx: + configuration: docs/conf.py + fail_on_warning: false + builder: html + +python: + version: "3.8" + install: + - method: pip + path: . + extra_requirements: + - docs + - requirements: docs/requirements.txt diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..269cadc --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/docs/_static/404.png b/docs/_static/404.png new file mode 100644 index 0000000..1d0ccfc Binary files /dev/null and b/docs/_static/404.png differ diff --git a/docs/_static/custom.css b/docs/_static/custom.css new file mode 100644 index 0000000..9c82d71 --- /dev/null +++ b/docs/_static/custom.css @@ -0,0 +1,19 @@ +/* Background of stable should be green */ +#version_switcher a[data-version-name*="stable"] { + position: relative; +} + +#version_switcher a[data-version-name*="stable"] span { + color: var(--pst-color-success); +} + +#version_switcher a[data-version-name*="stable"] span:before { + content: ""; + width: 100%; + height: 100%; + position: absolute; + left: 0; + top: 0; + background-color: var(--pst-color-success); + opacity: 0.1; +} diff --git a/docs/_static/switcher.json b/docs/_static/switcher.json new file mode 100644 index 0000000..20360df --- /dev/null +++ b/docs/_static/switcher.json @@ -0,0 +1,12 @@ +[ + { + "name": "latest", + "version": "latest", + "url": "https://pyspapi.readthedocs.io/en/latest/" + }, + { + "name": "stable", + "version": "stable", + "url": "https://pyspapi.readthedocs.io/en/stable/" + } +] diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000..ef74c95 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,74 @@ +.. py:currentmodule:: pyspapi + +API Reference +=============== + +The following section outlines the API of pyspapi. + +Version Info +--------------------- + +There are two main ways to query version information. + +.. data:: version_info + + A named tuple that is similar to :obj:`py:sys.version_info`. + + Just like :obj:`py:sys.version_info` the valid values for ``releaselevel`` are + 'alpha', 'beta', 'candidate' and 'final'. + +.. data:: __version__ + + A string representation of the version. + +``pyspapi`` +----------- + +``SPAPI`` +~~~~~ +.. autoclass:: SPAPI + :members: + + .. automethod:: SPAPI.event() + :decorator: + + .. automethod:: SPAPI.check_user_access + :decorator: + + .. automethod:: SPAPI.get_user + :decorator: + + .. automethod:: SPAPI.get_users + :decorator: + + .. automethod:: SPAPI.payment + :decorator: + + .. automethod:: SPAPI.transaction + :decorator: + + .. automethod:: SPAPI.webhook_verify + :decorator: + +MojangAPI +~~~~~ +.. autoclass:: MojangAPI + :members: + + .. automethod:: SPAPI.event() + :decorator: + + .. automethod:: SPAPI.get_name_history + :decorator: + + .. automethod:: SPAPI.get_profile + :decorator: + + .. automethod:: SPAPI.get_username + :decorator: + + .. automethod:: SPAPI.get_uuid + :decorator: + + .. automethod:: SPAPI.get_uuids + :decorator: diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..fa02ff1 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,76 @@ +from re import search, MULTILINE + +project = 'pyspapi' +copyright = '2022, deesiigneer' +author = 'deesiigneer' +with open("../pyspapi/__init__.py") as f: + match = search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), MULTILINE) + + if not match or match.group(1) is None: + raise RuntimeError("The version could not be resolved") + + version = match.group(1) + +# The full version, including alpha/beta/rc tags. +release = version + +# -- General configuration + +extensions = [ + 'sphinx.ext.duration', + 'sphinx.ext.doctest', + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', +] + +intersphinx_mapping = { + 'python': ('https://docs.python.org/3/', None), + 'sphinx': ('https://www.sphinx-doc.org/en/master/', None), +} +intersphinx_disabled_domains = ['std'] +language = None +locale_dirs = ["locale/"] +exclude_patterns = [] +html_static_path = ["_static"] +html_theme = "pydata_sphinx_theme" +html_logo = "./images/logo.png" +html_favicon = "./images/logo.ico" +html_theme_options = { + "external_links": [ + { + "url": "https://github.com/deesiigneer/pyspapi/releases", + "name": "Changelog", + } + ], + "icon_links": [ + { + "name": "GitHub", + "url": "https://github.com/deesiigneer/pyspapi", + "icon": "fab fa-brands fa-github", + "type": "fontawesome" + }, + { + "name": "Discord", + "url": "https://discord.gg/VbyHaKRAaN", + "icon": "fab fa-brands fa-discord", + "type": "fontawesome" + }, + { + "name": "PyPi", + "url": "https://pypi.org/project/pyspapi/", + "icon": "fab fa-brands fa-python", + "type": "fontawesome" + } + ], + "header_links_before_dropdown": 4, + "show_toc_level": 1, + "navbar_start": ["navbar-logo", "version-switcher"], + "switcher": { + "json_url": "https://pyspapi.readthedocs.io/en/latest/_static/switcher.json", + "version_match": "latest" + }, + "navigation_with_keys": True, +} +html_css_files = ["custom.css"] + diff --git a/docs/images/logo.ico b/docs/images/logo.ico new file mode 100644 index 0000000..bd07e2a Binary files /dev/null and b/docs/images/logo.ico differ diff --git a/docs/images/logo.png b/docs/images/logo.png new file mode 100644 index 0000000..12c0cfd Binary files /dev/null and b/docs/images/logo.png differ diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..e2105d0 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,35 @@ +:theme_html_remove_secondary_sidebar: + +Welcome to pyspapi +=================== + +API wrapper for SP servers written in Python. + +Getting started +--------------- + +Is this your first time using the library? This is the place to get started! + +- **First steps:** :ref:`Quickstart ` +- **Examples:** Many examples are available in the `examples directory `_. + +Getting help +------------ + +If you're having trouble with something, these resources might help. + +- Ask questions in `Discord `_ server. +- If you're looking for something specific, try the :ref:`searching `. +- Report bugs in the `issue tracker `_. +- Ask in `GitHub discussions page `_. + +Manuals +------- + +These pages go into great detail about everything the API can do. + +.. toctree:: + :maxdepth: 1 + + api + quickstart \ No newline at end of file diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..5394189 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd \ No newline at end of file diff --git a/docs/quickstart.rst b/docs/quickstart.rst new file mode 100644 index 0000000..9e6f906 --- /dev/null +++ b/docs/quickstart.rst @@ -0,0 +1,28 @@ +:orphan: + +.. _quickstart: + +.. currentmodule:: pyspapi + +Quickstart +========== + +This page gives a brief introduction to the library. + +Checking balance +------------- + +Let's output the amount of money remaining in the card account to the console. + +It looks something like this: + +.. code-block:: python + + import pyspapi + + print(pyspapi.SPAPI(card_id='card_id', token='token').balance) + +Make sure not to name it ``pyspapi`` as that'll conflict with the library. + + +You can find more examples in the `examples directory `_ on GitHub. \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..93f9b35 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +pydata_sphinx_theme \ No newline at end of file