feat(docs): localize documentation to Russian and update Makefile for Sphinx

This commit is contained in:
deesiigneer
2026-01-17 19:02:11 +00:00
parent 4fc530caeb
commit 6da906e0d1
5 changed files with 65 additions and 79 deletions

View File

@@ -5,8 +5,8 @@
# from the environment for the first two. # from the environment for the first two.
SPHINXOPTS ?= SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build SPHINXBUILD ?= sphinx-build
SOURCEDIR = source SOURCEDIR = .
BUILDDIR = build BUILDDIR = _build
# Put it first so that "make" without argument is like "make help". # Put it first so that "make" without argument is like "make help".
help: help:
@@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new # Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile %: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@@ -1,25 +1,25 @@
.. currentmodule:: pyspapi .. currentmodule:: pyspapi
API Reference Справочник API
=============== ===============
The following section outlines the API of pyspapi. В следующем разделе описывается API pyspapi.
Version Info Информация о версии
--------------------- ---------------------
There are two main ways to query version information. Существует два основных способа запроса информации о версии.
.. data:: version_info .. data:: version_info
A named tuple that is similar to :obj:`py:sys.version_info`. Именованный кортеж, аналогичный :obj:`py:sys.version_info`.
Just like :obj:`py:sys.version_info` the valid values for ``releaselevel`` are Как и в :obj:`py:sys.version_info`, допустимые значения для ``releaselevel`` это
'alpha', 'beta', 'candidate' and 'final'. 'alpha', 'beta', 'candidate' и 'final'.
.. data:: __version__ .. data:: __version__
A string representation of the version. Строковое представление версии.
``pyspapi`` ``pyspapi``
----------- -----------

View File

@@ -1,59 +1,44 @@
from re import search, MULTILINE from importlib.metadata import version as pkg_version
import os import os
import sys
project = "pyspapi"
author = "deesiigneer"
copyright = "2022, deesiigneer"
project = 'pyspapi' version = pkg_version("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 release = version
# -- General configuration
sys.path.insert(0, os.path.abspath(".."))
extensions = [ extensions = [
'sphinx.ext.duration', "sphinx.ext.duration",
'sphinx.ext.doctest', "sphinx.ext.doctest",
'sphinx.ext.autodoc', "sphinx.ext.autodoc",
'sphinx.ext.autosummary', "sphinx.ext.autosummary",
'sphinx.ext.intersphinx', "sphinx.ext.intersphinx",
] ]
autodoc_member_order = "bysource" autosummary_generate = True
autodoc_typehinta = "none"
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
}
version_match = os.environ.get("READTHEDOCS_VERSION") version_match = os.environ.get("READTHEDOCS_VERSION")
json_url = f"https://pyspapi.readthedocs.io/ru/{version_match}/_static/switcher.json" json_url = f"https://pyspapi.readthedocs.io/ru/{version_match}/_static/switcher.json"
intersphinx_disabled_domains = ['std']
language = 'en' language = "ru"
locale_dirs = ["locale/"]
exclude_patterns = [] exclude_patterns = []
html_static_path = ["_static"] html_static_path = ["_static"]
html_theme = "pydata_sphinx_theme" html_theme = "pydata_sphinx_theme"
html_logo = "./images/logo.png" html_logo = "./images/logo.png"
html_favicon = "./images/logo.ico" html_favicon = "./images/logo.ico"
html_theme_options = { html_theme_options = {
"external_links": [ "external_links": [
{ {
"url": "https://github.com/deesiigneer/pyspapi/releases", "url": "https://github.com/deesiigneer/pyspapi/releases",
"name": "Changelog", "name": "Changelog",
},
{
"url": "https://github.com/sp-worlds/api-docs/wiki",
"name": "SPWorlds API Docs",
} }
], ],
"icon_links": [ "icon_links": [
@@ -61,24 +46,27 @@ html_theme_options = {
"name": "GitHub", "name": "GitHub",
"url": "https://github.com/deesiigneer/pyspapi", "url": "https://github.com/deesiigneer/pyspapi",
"icon": "fab fa-brands fa-github", "icon": "fab fa-brands fa-github",
"type": "fontawesome" "type": "fontawesome",
}, },
{ {
"name": "Discord", "name": "Discord",
"url": "https://discord.gg/VbyHaKRAaN", "url": "https://discord.gg/VbyHaKRAaN",
"icon": "fab fa-brands fa-discord", "icon": "fab fa-brands fa-discord",
"type": "fontawesome" "type": "fontawesome",
}, },
{ {
"name": "PyPi", "name": "PyPI",
"url": "https://pypi.org/project/pyspapi/", "url": "https://pypi.org/project/pyspapi/",
"icon": "fab fa-brands fa-python", "icon": "fab fa-brands fa-python",
"type": "fontawesome" "type": "fontawesome",
} },
], ],
"header_links_before_dropdown": 4, "header_links_before_dropdown": 4,
"show_toc_level": 1, "show_toc_level": 1,
"navbar_start": ["navbar-logo"], "navbar_start": ["navbar-logo"],
"navigation_with_keys": True, "navigation_with_keys": True,
"switcher": {
"json_url": json_url,
"version_match": version_match,
},
} }
html_css_files = ["custom.css"]

View File

@@ -1,35 +1,34 @@
:theme_html_remove_secondary_sidebar: :theme_html_remove_secondary_sidebar:
Welcome to pyspapi Добро пожаловать в pyspapi
=================== ===========================
API wrapper for SP servers written in Python. Обертка API для SPWorlds серверов, написанная на Python.
Getting started Начало работы
--------------- ---------------
Is this your first time using the library? This is the place to get started! Вы впервые используете библиотеку? Это место, с которого нужно начать!
- **First steps:** :ref:`Quickstart <quickstart>` - **Первые шаги:** :ref:`Быстрый старт <quickstart>`
- **Examples:** Many examples are available in the `examples directory <https://github.com/deesiigneer/pyspapi/tree/main/examples/>`_. - **Примеры:** Много примеров доступно в `папке примеров <https://github.com/deesiigneer/pyspapi/tree/main/examples/>`_.
Getting help Получение помощи
------------ ------------------
If you're having trouble with something, these resources might help. Если у вас есть проблемы с чем-то, эти ресурсы могут помочь.
- Ask questions in `Discord <https://discord.gg/VbyHaKRAaN>`_ server. - Задавайте вопросы на сервере `Discord <https://discord.gg/VbyHaKRAaN>`_.
- If you're looking for something specific, try the :ref:`searching <search>`. - Если вы ищете что-то конкретное, попробуйте :ref:`поиск <search>`.
- Report bugs in the `issue tracker <https://github.com/deesiigneer/pyspapi/issues>`_. - Сообщайте об ошибках в `трекер проблем <https://github.com/deesiigneer/pyspapi/issues>`_.
- Ask in `GitHub discussions page <https://github.com/deesiigneer/pyspapi/discussions>`_.
Manuals Руководства
------- -----------
These pages go into great detail about everything the API can do. Эти страницы подробно описывают все, что может сделать API.
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
api api
quickstart quickstart

View File

@@ -4,17 +4,17 @@
.. currentmodule:: pyspapi .. 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 .. code-block:: python
@@ -30,7 +30,6 @@ It looks something like this:
loop = get_event_loop() loop = get_event_loop()
loop.run_until_complete(main()) loop.run_until_complete(main())
Make sure not to name it ``pyspapi`` as that'll conflict with the library. Убедитесь, что вы не называете его ``pyspapi``, так как это вызовет конфликт с библиотекой.
Вы можете найти больше примеров в `папке примеров <https://github.com/deesiigneer/pyspapi/tree/main/examples/>`_ на GitHub.
You can find more examples in the `examples directory <https://github.com/deesiigneer/pyspapi/tree/main/examples/>`_ on GitHub.