From 6da906e0d1317c87e4a21337bd5b39a8b57510df Mon Sep 17 00:00:00 2001 From: deesiigneer Date: Sat, 17 Jan 2026 19:02:11 +0000 Subject: [PATCH] feat(docs): localize documentation to Russian and update Makefile for Sphinx --- docs/Makefile | 6 ++-- docs/api.rst | 16 +++++------ docs/conf.py | 68 +++++++++++++++++++-------------------------- docs/index.rst | 35 ++++++++++++----------- docs/quickstart.rst | 19 ++++++------- 5 files changed, 65 insertions(+), 79 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index 269cadc..d4bb2cb 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build +SOURCEDIR = . +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @@ -17,4 +17,4 @@ help: # 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 + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/api.rst b/docs/api.rst index 8994dc6..a61e9a0 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,25 +1,25 @@ .. 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 - 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 - 'alpha', 'beta', 'candidate' and 'final'. + Как и в :obj:`py:sys.version_info`, допустимые значения для ``releaselevel`` это + 'alpha', 'beta', 'candidate' и 'final'. .. data:: __version__ - A string representation of the version. + Строковое представление версии. ``pyspapi`` ----------- diff --git a/docs/conf.py b/docs/conf.py index be3728d..5ea1e78 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,59 +1,44 @@ -from re import search, MULTILINE +from importlib.metadata import version as pkg_version import os -import sys +project = "pyspapi" +author = "deesiigneer" +copyright = "2022, deesiigneer" -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. +version = pkg_version("pyspapi") release = version -# -- General configuration - -sys.path.insert(0, os.path.abspath("..")) - - extensions = [ - 'sphinx.ext.duration', - 'sphinx.ext.doctest', - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.intersphinx', + "sphinx.ext.duration", + "sphinx.ext.doctest", + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", ] -autodoc_member_order = "bysource" -autodoc_typehinta = "none" - -intersphinx_mapping = { - 'python': ('https://docs.python.org/3/', None), - 'sphinx': ('https://www.sphinx-doc.org/en/master/', None), -} +autosummary_generate = True version_match = os.environ.get("READTHEDOCS_VERSION") json_url = f"https://pyspapi.readthedocs.io/ru/{version_match}/_static/switcher.json" -intersphinx_disabled_domains = ['std'] -language = 'en' -locale_dirs = ["locale/"] + +language = "ru" 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", + }, + { + "url": "https://github.com/sp-worlds/api-docs/wiki", + "name": "SPWorlds API Docs", } ], "icon_links": [ @@ -61,24 +46,27 @@ html_theme_options = { "name": "GitHub", "url": "https://github.com/deesiigneer/pyspapi", "icon": "fab fa-brands fa-github", - "type": "fontawesome" + "type": "fontawesome", }, { "name": "Discord", "url": "https://discord.gg/VbyHaKRAaN", "icon": "fab fa-brands fa-discord", - "type": "fontawesome" + "type": "fontawesome", }, { - "name": "PyPi", + "name": "PyPI", "url": "https://pypi.org/project/pyspapi/", "icon": "fab fa-brands fa-python", - "type": "fontawesome" - } + "type": "fontawesome", + }, ], "header_links_before_dropdown": 4, "show_toc_level": 1, "navbar_start": ["navbar-logo"], "navigation_with_keys": True, + "switcher": { + "json_url": json_url, + "version_match": version_match, + }, } -html_css_files = ["custom.css"] diff --git a/docs/index.rst b/docs/index.rst index e2105d0..590264c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,35 +1,34 @@ :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 ` -- **Examples:** Many examples are available in the `examples directory `_. +- **Первые шаги:** :ref:`Быстрый старт ` +- **Примеры:** Много примеров доступно в `папке примеров `_. -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 `_. +- Задавайте вопросы на сервере `Discord `_. +- Если вы ищете что-то конкретное, попробуйте :ref:`поиск `. +- Сообщайте об ошибках в `трекер проблем `_. -Manuals -------- +Руководства +----------- -These pages go into great detail about everything the API can do. +Эти страницы подробно описывают все, что может сделать API. .. toctree:: :maxdepth: 1 api - quickstart \ No newline at end of file + quickstart diff --git a/docs/quickstart.rst b/docs/quickstart.rst index a743cca..86f69be 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -4,17 +4,17 @@ .. 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 @@ -30,7 +30,6 @@ It looks something like this: loop = get_event_loop() loop.run_until_complete(main()) -Make sure not to name it ``pyspapi`` as that'll conflict with the library. +Убедитесь, что вы не называете его ``pyspapi``, так как это вызовет конфликт с библиотекой. - -You can find more examples in the `examples directory `_ on GitHub. \ No newline at end of file +Вы можете найти больше примеров в `папке примеров `_ на GitHub. \ No newline at end of file