Update documentation

This commit is contained in:
2025-12-08 19:53:03 +03:00
parent 183f069766
commit 22970f7115
6 changed files with 164 additions and 95 deletions
@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Argenta \n" "Project-Id-Version: Argenta \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-12-04 20:39+0300\n" "POT-Creation-Date: 2025-12-08 19:48+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n" "Language: en\n"
@@ -35,10 +35,10 @@ msgstr ""
#: ../../root/api/command/index.rst:8 #: ../../root/api/command/index.rst:8
msgid "" msgid ""
"``Command`` инкапсулирует всю информацию о команде: её триггер (ключевое " "``Command`` инкапсулирует всю информацию о команде: её триггер (ключевое "
"слово для вызова), описание, набор флагов и список псевдонимов." "слово для вызова), описание, набор флагов и множество псевдонимов."
msgstr "" msgstr ""
"``Command`` encapsulates all information about a command: its trigger " "``Command`` encapsulates all information about a command: its trigger "
"(keyword for invocation), description, set of flags, and list of aliases." "(keyword for invocation), description, set of flags, and set of aliases."
#: ../../root/api/command/index.rst:13 #: ../../root/api/command/index.rst:13
msgid "Инициализация" msgid "Инициализация"
@@ -73,8 +73,8 @@ msgstr ""
"``Flag`` object or a ``Flags`` collection." "``Flag`` object or a ``Flags`` collection."
#: ../../root/api/command/index.rst:28 #: ../../root/api/command/index.rst:28
msgid "``aliases``: Список строковых псевдонимов для основного триггера." msgid "``aliases``: Множество строковых псевдонимов для основного триггера."
msgstr "``aliases``: List of string aliases for the main trigger." msgstr "``aliases``: Set of string aliases for the main trigger."
#: ../../root/api/command/index.rst:30 ../../root/api/command/index.rst:108 #: ../../root/api/command/index.rst:30 ../../root/api/command/index.rst:108
msgid "**Атрибуты:**" msgid "**Атрибуты:**"
@@ -107,8 +107,8 @@ msgstr ""
"during initialization." "during initialization."
#: ../../root/api/command/index.rst:46 #: ../../root/api/command/index.rst:46
msgid "Список строковых псевдонимов. Пуст, если псевдонимы не заданы." msgid "Множество строковых псевдонимов. Пуст, если псевдонимы не заданы."
msgstr "List of string aliases. Empty if no aliases are defined." msgstr "Set of string aliases. Empty if no aliases are defined."
#: ../../root/api/command/index.rst:48 #: ../../root/api/command/index.rst:48
msgid "**Пример использования:**" msgid "**Пример использования:**"
@@ -119,8 +119,8 @@ msgid ""
"Подробнее про флаги: :ref:`Flags <root_api_command_flags>` и :ref:`Флаги " "Подробнее про флаги: :ref:`Flags <root_api_command_flags>` и :ref:`Флаги "
"команд <root_flags>`." "команд <root_flags>`."
msgstr "" msgstr ""
"More about flags: :ref:`Flags <root_api_command_flags>` and :ref:`Command " "More about flags: :ref:`Flags <root_api_command_flags>` and :ref:`Command"
"flags <root_flags>`." " flags <root_flags>`."
#: ../../root/api/command/index.rst:59 #: ../../root/api/command/index.rst:59
msgid "Регистрация команд" msgid "Регистрация команд"
+47 -24
View File
@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Argenta \n" "Project-Id-Version: Argenta \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-12-02 22:27+0300\n" "POT-Creation-Date: 2025-12-08 19:48+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n" "Language: en\n"
@@ -30,8 +30,9 @@ msgid ""
"набора функций." "набора функций."
msgstr "" msgstr ""
"``Router`` is the main building block for organizing logic in an " "``Router`` is the main building block for organizing logic in an "
"application. Its purpose is to group related commands and their handlers. " "application. Its purpose is to group related commands and their handlers."
"Each router represents a logical container for a specific set of functions." " Each router represents a logical container for a specific set of "
"functions."
#: ../../root/api/router.rst:8 #: ../../root/api/router.rst:8
msgid "" msgid ""
@@ -56,8 +57,8 @@ msgid ""
"``title``: Необязательный заголовок для группы команд. Отображается в " "``title``: Необязательный заголовок для группы команд. Отображается в "
"списке доступных команд, помогая пользователю ориентироваться." "списке доступных команд, помогая пользователю ориентироваться."
msgstr "" msgstr ""
"``title``: Optional title for the command group. Displayed in the list of " "``title``: Optional title for the command group. Displayed in the list of"
"available commands to help users navigate." " available commands to help users navigate."
#: ../../root/api/router.rst:24 #: ../../root/api/router.rst:24
msgid "" msgid ""
@@ -67,11 +68,11 @@ msgid ""
"используется статическая разделительная линия. Подробнее см. в разделе " "используется статическая разделительная линия. Подробнее см. в разделе "
":ref:`Переопределение стандартного вывода <root_redirect_stdout>`." ":ref:`Переопределение стандартного вывода <root_redirect_stdout>`."
msgstr "" msgstr ""
"``disable_redirect_stdout``: If ``True``, disables ``stdout`` capture for " "``disable_redirect_stdout``: If ``True``, disables ``stdout`` capture for"
"all commands in this router. This is necessary for interactive commands " " all commands in this router. This is necessary for interactive commands "
"(e.g., with ``input()``). When capture is disabled, a static separator line " "(e.g., with ``input()``). When capture is disabled, a static separator "
"is automatically used. See :ref:`Overriding standard output <root_redirect_stdout>` " "line is automatically used. See :ref:`Overriding standard output "
"for more details." "<root_redirect_stdout>` for more details."
#: ../../root/api/router.rst:29 #: ../../root/api/router.rst:29
msgid "Регистрация команд" msgid "Регистрация команд"
@@ -82,7 +83,8 @@ msgid ""
"Для регистрации команды и привязки к ней обработчика используется " "Для регистрации команды и привязки к ней обработчика используется "
"декоратор ``@command``." "декоратор ``@command``."
msgstr "" msgstr ""
"The ``@command`` decorator is used to register a command and bind a handler to it." "The ``@command`` decorator is used to register a command and bind a "
"handler to it."
#: ../../root/api/router.rst:35 #: ../../root/api/router.rst:35
msgid "Декоратор для регистрации функции как обработчика команды." msgid "Декоратор для регистрации функции как обработчика команды."
@@ -98,9 +100,9 @@ msgid ""
"Может быть строкой, которая станет триггером (без возможности настройки " "Может быть строкой, которая станет триггером (без возможности настройки "
"флагов и описания)." "флагов и описания)."
msgstr "" msgstr ""
"A ``Command`` instance describing the trigger, flags, and command description. " "A ``Command`` instance describing the trigger, flags, and command "
"Can be a string that will become the trigger (without the ability to configure " "description. Can be a string that will become the trigger (without the "
"flags and description)." "ability to configure flags and description)."
#: ../../root/api/router.rst:39 #: ../../root/api/router.rst:39
msgid "**Пример использования:**" msgid "**Пример использования:**"
@@ -130,12 +132,13 @@ msgstr ""
#: ../../root/api/router.rst:57 #: ../../root/api/router.rst:57
msgid "" msgid ""
"Вы можете добавлять свои команды в этот роутер. Для этого импортируйте " "Вы можете добавлять свои команды в этот роутер. Для этого используйте "
"``argenta.router.defaults.system_router`` и используйте его декоратор " "атрибут ``.system_router`` у созданного экхемпляра ``Orchestrator`` и "
"``@command``." "используйте его декоратор ``@command``."
msgstr "" msgstr ""
"You can add your own commands to this router. To do this, import " "You can add your own commands to this router. To do this, use the "
"``argenta.router.defaults.system_router`` and use its ``@command`` decorator." "``.system_router`` attribute of the created ``Orchestrator`` instance "
"and use its ``@command`` decorator."
#: ../../root/api/router.rst:62 #: ../../root/api/router.rst:62
msgid "Возможные исключения" msgid "Возможные исключения"
@@ -146,15 +149,16 @@ msgid ""
"При регистрации команд и флагов в ``Router`` могут возникнуть следующие " "При регистрации команд и флагов в ``Router`` могут возникнуть следующие "
"исключения:" "исключения:"
msgstr "" msgstr ""
"The following exceptions may occur when registering commands and flags in ``Router``:" "The following exceptions may occur when registering commands and flags in"
" ``Router``:"
#: ../../root/api/router.rst:68 #: ../../root/api/router.rst:68
msgid "" msgid ""
"Выбрасывается, если триггер команды в ``Command`` содержит пробелы. " "Выбрасывается, если триггер команды в ``Command`` содержит пробелы. "
"Триггеры должны быть одним словом." "Триггеры должны быть одним словом."
msgstr "" msgstr ""
"Raised if the command trigger in ``Command`` contains spaces. " "Raised if the command trigger in ``Command`` contains spaces. Triggers "
"Triggers must be a single word." "must be a single word."
#: ../../root/api/router.rst:70 #: ../../root/api/router.rst:70
msgid "**Неправильно:** ``Command(\"add user\")``" msgid "**Неправильно:** ``Command(\"add user\")``"
@@ -173,7 +177,8 @@ msgstr ""
"Raised if duplicate names were used when defining flags for a command. " "Raised if duplicate names were used when defining flags for a command. "
"Flag names within a single command must be unique." "Flag names within a single command must be unique."
#: ../../root/api/router.rst:78 #: ../../root/api/router.rst:78 ../../root/api/router.rst:96
#: ../../root/api/router.rst:115
msgid "**Пример, вызывающий исключение:**" msgid "**Пример, вызывающий исключение:**"
msgstr "**Example that raises an exception:**" msgstr "**Example that raises an exception:**"
@@ -182,5 +187,23 @@ msgid ""
"Возникает, если обработчик команды не принимает обязательный аргумент " "Возникает, если обработчик команды не принимает обязательный аргумент "
"``Response``." "``Response``."
msgstr "" msgstr ""
"Raised if the command handler does not accept the required ``Response`` argument." "Raised if the command handler does not accept the required ``Response`` "
"argument."
#: ../../root/api/router.rst:94
msgid ""
"Возникает, если при регистрации команд в роутере были использованы "
"дублирующиеся триггеры. Каждая команда должна иметь уникальный триггер в "
"рамках одного роутера."
msgstr ""
"Raised if duplicate triggers were used when registering commands in the "
"router. Each command must have a unique trigger within a single router."
#: ../../root/api/router.rst:113
msgid ""
"Возникает, если при регистрации команд были использованы дублирующиеся "
"алиасы. Алиасы должны быть уникальны в рамках всего роутера."
msgstr ""
"Raised if duplicate aliases were used when registering commands. Aliases "
"must be unique within the entire router."
@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Argenta \n" "Project-Id-Version: Argenta \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-12-04 20:39+0300\n" "POT-Creation-Date: 2025-12-08 19:48+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n" "Language: en\n"
@@ -46,17 +46,22 @@ msgstr ""
"``Router``) if your commands:" "``Router``) if your commands:"
#: ../../root/redirect_stdout.rst:15 #: ../../root/redirect_stdout.rst:15
msgid "" msgid "✓ Используют ``input()`` для интерактивного ввода данных от пользователя"
"✓ Используют ``input()`` для интерактивного ввода данных от пользователя " msgstr "✓ Use ``input()`` for interactive user input"
"✓ Используют прогресс-бары (``tqdm``, ``rich.progress``) ✓ Выводят данные"
" в реальном времени (streaming, логи) ✓ Используют библиотеки, которые "
"напрямую работают с ``stdout``"
msgstr ""
"✓ Use ``input()`` for interactive user input ✓ Use progress bars "
"(``tqdm``, ``rich.progress``) ✓ Output data in real-time (streaming, "
"logs) ✓ Use libraries that work directly with ``stdout``"
#: ../../root/redirect_stdout.rst:20 #: ../../root/redirect_stdout.rst:17
msgid "✓ Используют прогресс-бары (``tqdm``, ``rich.progress``)"
msgstr "✓ Use progress bars (``tqdm``, ``rich.progress``)"
#: ../../root/redirect_stdout.rst:19
msgid "✓ Выводят данные в реальном времени (streaming, логи)"
msgstr "✓ Output data in real-time (streaming, logs)"
#: ../../root/redirect_stdout.rst:21
msgid "✓ Используют библиотеки, которые напрямую работают с ``stdout``"
msgstr "✓ Use libraries that work directly with ``stdout``"
#: ../../root/redirect_stdout.rst:23
msgid "" msgid ""
"Для обычных команд с ``print()`` перехват можно оставить включённым — это" "Для обычных команд с ``print()`` перехват можно оставить включённым — это"
" не влияет на их работу." " не влияет на их работу."
@@ -64,11 +69,11 @@ msgstr ""
"For regular commands with ``print()``, interception can be left enabled —" "For regular commands with ``print()``, interception can be left enabled —"
" it does not affect their operation." " it does not affect their operation."
#: ../../root/redirect_stdout.rst:25 #: ../../root/redirect_stdout.rst:28
msgid "Механизм перехвата ``stdout``" msgid "Механизм перехвата ``stdout``"
msgstr "``stdout`` Interception Mechanism" msgstr "``stdout`` Interception Mechanism"
#: ../../root/redirect_stdout.rst:27 #: ../../root/redirect_stdout.rst:30
msgid "" msgid ""
"По умолчанию ``Argenta`` перехватывает весь текст, выводимый в ``stdout``" "По умолчанию ``Argenta`` перехватывает весь текст, выводимый в ``stdout``"
" внутри обработчика команды. Это необходимо для реализации **динамических" " внутри обработчика команды. Это необходимо для реализации **динамических"
@@ -83,15 +88,15 @@ msgstr ""
"draw the top and bottom borders. This approach creates a neat interface " "draw the top and bottom borders. This approach creates a neat interface "
"where the command output is \"wrapped\" in a frame fitted to its content." "where the command output is \"wrapped\" in a frame fitted to its content."
#: ../../root/redirect_stdout.rst:29 #: ../../root/redirect_stdout.rst:32
msgid "Пример приложения с динамической разделительной линией:" msgid "Пример приложения с динамической разделительной линией:"
msgstr "Example of an application with a dynamic dividing line:" msgstr "Example of an application with a dynamic dividing line:"
#: ../../root/redirect_stdout.rst:31 #: ../../root/redirect_stdout.rst:34
msgid "Example of an application with a dynamic dividing line" msgid "Example of an application with a dynamic dividing line"
msgstr "Example of an application with a dynamic dividing line" msgstr "Example of an application with a dynamic dividing line"
#: ../../root/redirect_stdout.rst:34 #: ../../root/redirect_stdout.rst:37
msgid "" msgid ""
"Как вы можете заметить, разделительная линия ровно той же длины, что и " "Как вы можете заметить, разделительная линия ровно той же длины, что и "
"самая длинная строка в выводе." "самая длинная строка в выводе."
@@ -99,15 +104,15 @@ msgstr ""
"As you can see, the dividing line is exactly the same length as the " "As you can see, the dividing line is exactly the same length as the "
"longest line in the output." "longest line in the output."
#: ../../root/redirect_stdout.rst:36 #: ../../root/redirect_stdout.rst:39
msgid "То же приложение с статической линией:" msgid "То же приложение с статической линией:"
msgstr "The same application with a static line:" msgstr "The same application with a static line:"
#: ../../root/redirect_stdout.rst:38 #: ../../root/redirect_stdout.rst:41
msgid "Example of an application with a static dividing line" msgid "Example of an application with a static dividing line"
msgstr "Example of an application with a static dividing line" msgstr "Example of an application with a static dividing line"
#: ../../root/redirect_stdout.rst:41 #: ../../root/redirect_stdout.rst:44
msgid "" msgid ""
"В этом примере разделительная линия имеет фиксированную длину (по " "В этом примере разделительная линия имеет фиксированную длину (по "
"умолчанию 25 символов)." "умолчанию 25 символов)."
@@ -115,11 +120,11 @@ msgstr ""
"In this example, the dividing line has a fixed length (25 characters by " "In this example, the dividing line has a fixed length (25 characters by "
"default)." "default)."
#: ../../root/redirect_stdout.rst:46 #: ../../root/redirect_stdout.rst:49
msgid "Побочные эффекты перехвата ``stdout``" msgid "Побочные эффекты перехвата ``stdout``"
msgstr "Side Effects of ``stdout`` Interception" msgstr "Side Effects of ``stdout`` Interception"
#: ../../root/redirect_stdout.rst:48 #: ../../root/redirect_stdout.rst:51
msgid "" msgid ""
"Побочный эффект этого механизма проявляется при использовании функций, " "Побочный эффект этого механизма проявляется при использовании функций, "
"которые последовательно выводят текст в консоль и ожидают ввод от " "которые последовательно выводят текст в консоль и ожидают ввод от "
@@ -129,7 +134,7 @@ msgstr ""
"sequentially output text to the console and expect user input. A classic " "sequentially output text to the console and expect user input. A classic "
"example is the standard ``input()`` function." "example is the standard ``input()`` function."
#: ../../root/redirect_stdout.rst:57 #: ../../root/redirect_stdout.rst:60
msgid "" msgid ""
"При включённом перехвате ``stdout`` текст (например, ``\"Введите ваше " "При включённом перехвате ``stdout`` текст (например, ``\"Введите ваше "
"имя: \"``) **не будет выведен в консоль немедленно**. Он попадёт в буфер " "имя: \"``) **не будет выведен в консоль немедленно**. Он попадёт в буфер "
@@ -141,11 +146,11 @@ msgstr ""
" into a buffer and appear only after the handler finishes, along with the" " into a buffer and appear only after the handler finishes, along with the"
" rest of the output. This can confuse the user." " rest of the output. This can confuse the user."
#: ../../root/redirect_stdout.rst:62 #: ../../root/redirect_stdout.rst:65
msgid "Отключение перехвата ``stdout`` с помощью ``disable_redirect_stdout``" msgid "Отключение перехвата ``stdout`` с помощью ``disable_redirect_stdout``"
msgstr "Disabling ``stdout`` Interception with ``disable_redirect_stdout``" msgstr "Disabling ``stdout`` Interception with ``disable_redirect_stdout``"
#: ../../root/redirect_stdout.rst:64 #: ../../root/redirect_stdout.rst:67
msgid "" msgid ""
"Чтобы решить эту проблему, в конструкторе ``Router`` предусмотрен " "Чтобы решить эту проблему, в конструкторе ``Router`` предусмотрен "
"специальный аргумент:" "специальный аргумент:"
@@ -153,11 +158,11 @@ msgstr ""
"To solve this problem, the ``Router`` constructor provides a special " "To solve this problem, the ``Router`` constructor provides a special "
"argument:" "argument:"
#: ../../root/redirect_stdout.rst:66 #: ../../root/redirect_stdout.rst:69
msgid "**disable_redirect_stdout** (``bool``, по умолчанию ``False``)" msgid "**disable_redirect_stdout** (``bool``, по умолчанию ``False``)"
msgstr "**disable_redirect_stdout** (``bool``, default ``False``)" msgstr "**disable_redirect_stdout** (``bool``, default ``False``)"
#: ../../root/redirect_stdout.rst:68 #: ../../root/redirect_stdout.rst:71
msgid "" msgid ""
"Если при создании роутера установить ``disable_redirect_stdout=True``, " "Если при создании роутера установить ``disable_redirect_stdout=True``, "
"механизм перехвата ``stdout`` будет отключён для всех его обработчиков." "механизм перехвата ``stdout`` будет отключён для всех его обработчиков."
@@ -165,11 +170,11 @@ msgstr ""
"If you set ``disable_redirect_stdout=True`` when creating a router, the " "If you set ``disable_redirect_stdout=True`` when creating a router, the "
"``stdout`` interception mechanism will be disabled for all its handlers." "``stdout`` interception mechanism will be disabled for all its handlers."
#: ../../root/redirect_stdout.rst:70 ../../root/redirect_stdout.rst:100 #: ../../root/redirect_stdout.rst:73 ../../root/redirect_stdout.rst:103
msgid "**Пример использования:**" msgid "**Пример использования:**"
msgstr "**Usage example:**" msgstr "**Usage example:**"
#: ../../root/redirect_stdout.rst:76 #: ../../root/redirect_stdout.rst:79
msgid "" msgid ""
"В этом случае ``input()`` будет работать как обычно, и пользователь сразу" "В этом случае ``input()`` будет работать как обычно, и пользователь сразу"
" увидит приглашение к вводу." " увидит приглашение к вводу."
@@ -177,11 +182,11 @@ msgstr ""
"In this case, ``input()`` will work as usual, and the user will " "In this case, ``input()`` will work as usual, and the user will "
"immediately see the input prompt." "immediately see the input prompt."
#: ../../root/redirect_stdout.rst:81 #: ../../root/redirect_stdout.rst:84
msgid "Типы разделительных линий" msgid "Типы разделительных линий"
msgstr "Types of Dividing Lines" msgstr "Types of Dividing Lines"
#: ../../root/redirect_stdout.rst:83 #: ../../root/redirect_stdout.rst:86
msgid "" msgid ""
"``Argenta`` поддерживает два типа разделителей, которые настраиваются при" "``Argenta`` поддерживает два типа разделителей, которые настраиваются при"
" инициализации ``App``:" " инициализации ``App``:"
@@ -189,11 +194,11 @@ msgstr ""
"``Argenta`` supports two types of dividers, which are configured during " "``Argenta`` supports two types of dividers, which are configured during "
"``App`` initialization:" "``App`` initialization:"
#: ../../root/redirect_stdout.rst:85 #: ../../root/redirect_stdout.rst:88
msgid "**``DynamicDividingLine()``**" msgid "**``DynamicDividingLine()``**"
msgstr "**``DynamicDividingLine()``**" msgstr "**``DynamicDividingLine()``**"
#: ../../root/redirect_stdout.rst:86 #: ../../root/redirect_stdout.rst:89
msgid "" msgid ""
"Поведение по умолчанию. Длина линии динамически подстраивается под самый " "Поведение по умолчанию. Длина линии динамически подстраивается под самый "
"длинный текст в выводе." "длинный текст в выводе."
@@ -201,7 +206,7 @@ msgstr ""
"Default behavior. The line length dynamically adjusts to the longest text" "Default behavior. The line length dynamically adjusts to the longest text"
" in the output." " in the output."
#: ../../root/redirect_stdout.rst:87 #: ../../root/redirect_stdout.rst:90
msgid "" msgid ""
"Требует включённого перехвата ``stdout`` " "Требует включённого перехвата ``stdout`` "
"(``disable_redirect_stdout=False`` в роутере)." "(``disable_redirect_stdout=False`` в роутере)."
@@ -209,11 +214,11 @@ msgstr ""
"Requires enabled ``stdout`` interception " "Requires enabled ``stdout`` interception "
"(``disable_redirect_stdout=False`` in the router)." "(``disable_redirect_stdout=False`` in the router)."
#: ../../root/redirect_stdout.rst:89 #: ../../root/redirect_stdout.rst:92
msgid "**``StaticDividingLine(length: int = 25)``**" msgid "**``StaticDividingLine(length: int = 25)``**"
msgstr "**``StaticDividingLine(length: int = 25)``**" msgstr "**``StaticDividingLine(length: int = 25)``**"
#: ../../root/redirect_stdout.rst:90 #: ../../root/redirect_stdout.rst:93
msgid "" msgid ""
"Линия имеет фиксированную длину (по умолчанию 25 символов), которую можно" "Линия имеет фиксированную длину (по умолчанию 25 символов), которую можно"
" задать через аргумент ``length``." " задать через аргумент ``length``."
@@ -221,7 +226,7 @@ msgstr ""
"The line has a fixed length (25 characters by default), which can be set " "The line has a fixed length (25 characters by default), which can be set "
"via the ``length`` argument." "via the ``length`` argument."
#: ../../root/redirect_stdout.rst:91 #: ../../root/redirect_stdout.rst:94
msgid "" msgid ""
"Используется принудительно для роутеров с " "Используется принудительно для роутеров с "
"``disable_redirect_stdout=True``, так как без перехвата вывода невозможно" "``disable_redirect_stdout=True``, так как без перехвата вывода невозможно"
@@ -230,11 +235,11 @@ msgstr ""
"Used forcibly for routers with ``disable_redirect_stdout=True``, as it is" "Used forcibly for routers with ``disable_redirect_stdout=True``, as it is"
" impossible to determine dynamic length without output interception." " impossible to determine dynamic length without output interception."
#: ../../root/redirect_stdout.rst:96 #: ../../root/redirect_stdout.rst:99
msgid "Настройка разделительной линии в ``App``" msgid "Настройка разделительной линии в ``App``"
msgstr "Configuring the Dividing Line in ``App``" msgstr "Configuring the Dividing Line in ``App``"
#: ../../root/redirect_stdout.rst:98 #: ../../root/redirect_stdout.rst:101
msgid "" msgid ""
"Вы можете глобально задать тип разделителя для всего приложения через " "Вы можете глобально задать тип разделителя для всего приложения через "
"аргумент ``dividing_line`` в конструкторе ``App``." "аргумент ``dividing_line`` в конструкторе ``App``."
@@ -242,63 +247,63 @@ msgstr ""
"You can globally set the divider type for the entire application via the " "You can globally set the divider type for the entire application via the "
"``dividing_line`` argument in the ``App`` constructor." "``dividing_line`` argument in the ``App`` constructor."
#: ../../root/redirect_stdout.rst:109 #: ../../root/redirect_stdout.rst:112
msgid "Итоговое поведение" msgid "Итоговое поведение"
msgstr "Resulting Behavior" msgstr "Resulting Behavior"
#: ../../root/redirect_stdout.rst:115 #: ../../root/redirect_stdout.rst:118
msgid "``disable_redirect_stdout`` на ``Router``" msgid "``disable_redirect_stdout`` на ``Router``"
msgstr "``disable_redirect_stdout`` on ``Router``" msgstr "``disable_redirect_stdout`` on ``Router``"
#: ../../root/redirect_stdout.rst:116 #: ../../root/redirect_stdout.rst:119
msgid "Тип линии в ``App``" msgid "Тип линии в ``App``"
msgstr "Line type in ``App``" msgstr "Line type in ``App``"
#: ../../root/redirect_stdout.rst:117 #: ../../root/redirect_stdout.rst:120
msgid "Фактическое поведение" msgid "Фактическое поведение"
msgstr "Actual behavior" msgstr "Actual behavior"
#: ../../root/redirect_stdout.rst:118 #: ../../root/redirect_stdout.rst:121
msgid "``input()`` работает корректно?" msgid "``input()`` работает корректно?"
msgstr "Does ``input()`` work correctly?" msgstr "Does ``input()`` work correctly?"
#: ../../root/redirect_stdout.rst:119 ../../root/redirect_stdout.rst:123 #: ../../root/redirect_stdout.rst:122 ../../root/redirect_stdout.rst:126
msgid "``False`` (по умолчанию)" msgid "``False`` (по умолчанию)"
msgstr "``False`` (default)" msgstr "``False`` (default)"
#: ../../root/redirect_stdout.rst:120 ../../root/redirect_stdout.rst:128 #: ../../root/redirect_stdout.rst:123 ../../root/redirect_stdout.rst:131
msgid "``DynamicDividingLine``" msgid "``DynamicDividingLine``"
msgstr "``DynamicDividingLine``" msgstr "``DynamicDividingLine``"
#: ../../root/redirect_stdout.rst:121 #: ../../root/redirect_stdout.rst:124
msgid "Динамическая линия, длина по содержимому" msgid "Динамическая линия, длина по содержимому"
msgstr "Dynamic line, length by content" msgstr "Dynamic line, length by content"
#: ../../root/redirect_stdout.rst:122 ../../root/redirect_stdout.rst:126 #: ../../root/redirect_stdout.rst:125 ../../root/redirect_stdout.rst:129
msgid "Нет" msgid "Нет"
msgstr "No" msgstr "No"
#: ../../root/redirect_stdout.rst:124 ../../root/redirect_stdout.rst:132 #: ../../root/redirect_stdout.rst:127 ../../root/redirect_stdout.rst:135
msgid "``StaticDividingLine``" msgid "``StaticDividingLine``"
msgstr "``StaticDividingLine``" msgstr "``StaticDividingLine``"
#: ../../root/redirect_stdout.rst:125 ../../root/redirect_stdout.rst:133 #: ../../root/redirect_stdout.rst:128 ../../root/redirect_stdout.rst:136
msgid "Статическая линия указанной длины" msgid "Статическая линия указанной длины"
msgstr "Static line of specified length" msgstr "Static line of specified length"
#: ../../root/redirect_stdout.rst:127 ../../root/redirect_stdout.rst:131 #: ../../root/redirect_stdout.rst:130 ../../root/redirect_stdout.rst:134
msgid "``True``" msgid "``True``"
msgstr "``True``" msgstr "``True``"
#: ../../root/redirect_stdout.rst:129 #: ../../root/redirect_stdout.rst:132
msgid "**Принудительно статическая линия** (длина по умолч.)" msgid "**Принудительно статическая линия** (длина по умолч.)"
msgstr "**Forcibly static line** (default length)" msgstr "**Forcibly static line** (default length)"
#: ../../root/redirect_stdout.rst:130 ../../root/redirect_stdout.rst:134 #: ../../root/redirect_stdout.rst:133 ../../root/redirect_stdout.rst:137
msgid "Да" msgid "Да"
msgstr "Yes" msgstr "Yes"
#: ../../root/redirect_stdout.rst:136 #: ../../root/redirect_stdout.rst:139
msgid "" msgid ""
"Таким образом, для интерактивных команд, требующих ввода от пользователя," "Таким образом, для интерактивных команд, требующих ввода от пользователя,"
" отключайте перехват ``stdout`` на уровне роутера. Для всех остальных " " отключайте перехват ``stdout`` на уровне роутера. Для всех остальных "
+4 -4
View File
@@ -5,7 +5,7 @@ Command
``Command`` — это основная единица функциональности в приложении. Каждая команда связывает хэндлер с триггером, введя который он будет вызван для обработки. ``Command`` — это основная единица функциональности в приложении. Каждая команда связывает хэндлер с триггером, введя который он будет вызван для обработки.
``Command`` инкапсулирует всю информацию о команде: её триггер (ключевое слово для вызова), описание, набор флагов и список псевдонимов. ``Command`` инкапсулирует всю информацию о команде: её триггер (ключевое слово для вызова), описание, набор флагов и множество псевдонимов.
----- -----
@@ -18,14 +18,14 @@ Command
__init__(self, trigger: str, *, __init__(self, trigger: str, *,
description: str | None = None, description: str | None = None,
flags: Flag | Flags = DEFAULT_WITHOUT_FLAGS, flags: Flag | Flags = DEFAULT_WITHOUT_FLAGS,
aliases: list[str] | list[Never] = DEFAULT_WITHOUT_ALIASES) -> None aliases: set[str] = DEFAULT_WITHOUT_ALIASES) -> None
Создаёт новую команду для регистрации в роутере. Создаёт новую команду для регистрации в роутере.
* ``trigger``: Строковый триггер, который пользователь вводит для вызова команды. Является основным идентификатором. * ``trigger``: Строковый триггер, который пользователь вводит для вызова команды. Является основным идентификатором.
* ``description``: Необязательное описание, объясняющее назначение команды. Отображается в справке. * ``description``: Необязательное описание, объясняющее назначение команды. Отображается в справке.
* ``flags``: Набор флагов для настройки поведения. Может быть одиночным объектом ``Flag`` или коллекцией ``Flags``. * ``flags``: Набор флагов для настройки поведения. Может быть одиночным объектом ``Flag`` или коллекцией ``Flags``.
* ``aliases``: Список строковых псевдонимов для основного триггера. * ``aliases``: Множество строковых псевдонимов для основного триггера.
**Атрибуты:** **Атрибуты:**
@@ -43,7 +43,7 @@ Command
.. py:attribute:: aliases .. py:attribute:: aliases
Список строковых псевдонимов. Пуст, если псевдонимы не заданы. Множество строковых псевдонимов. Пуст, если псевдонимы не заданы.
**Пример использования:** **Пример использования:**
+39 -1
View File
@@ -54,7 +54,7 @@ Router
Предопределённый экземпляр ``Router`` с базовыми системными командами (по умолчанию — команда выхода). Имеет заголовок **«System points:»**, который можно переопределить в ``App``. Предопределённый экземпляр ``Router`` с базовыми системными командами (по умолчанию — команда выхода). Имеет заголовок **«System points:»**, который можно переопределить в ``App``.
Вы можете добавлять свои команды в этот роутер. Для этого импортируйте ``argenta.router.defaults.system_router`` и используйте его декоратор ``@command``. Вы можете добавлять свои команды в этот роутер. Для этого используйте атрибут ``.system_router`` у созданного экхемпляра ``Orchestrator`` и используйте его декоратор ``@command``.
----- -----
@@ -89,3 +89,41 @@ Router
Возникает, если обработчик команды не принимает обязательный аргумент ``Response``. Возникает, если обработчик команды не принимает обязательный аргумент ``Response``.
.. py:exception:: RepeatedTriggerNameException
Возникает, если при регистрации команд в роутере были использованы дублирующиеся триггеры. Каждая команда должна иметь уникальный триггер в рамках приложения.
**Пример, вызывающий исключение:**
.. code-block:: python
:linenos:
router = Router()
@router.command(Command("start"))
def start_handler(response: Response) -> None:
pass
@router.command(Command("start")) # Duplicate trigger!
def another_start_handler(response: Response) -> None:
pass
.. py:exception:: RepeatedAliasNameException
Возникает, если при регистрации команд были использованы дублирующиеся алиасы. Алиасы должны быть уникальны в рамках всего приложения.
**Пример, вызывающий исключение:**
.. code-block:: python
:linenos:
router = Router()
@router.command(Command("start", aliases={"s", "run"}))
def start_handler(response: Response) -> None:
pass
@router.command(Command("begin", aliases={"s"})) # Duplicate alias "s"!
def begin_handler(response: Response) -> None:
pass
+7 -4
View File
@@ -12,10 +12,13 @@
Отключайте перехват ``stdout`` (``disable_redirect_stdout=True`` в ``Router``), если ваши команды: Отключайте перехват ``stdout`` (``disable_redirect_stdout=True`` в ``Router``), если ваши команды:
✓ Используют ``input()`` для интерактивного ввода данных от пользователя ✓ Используют ``input()`` для интерактивного ввода данных от пользователя
✓ Используют прогресс-бары (``tqdm``, ``rich.progress``)
Выводят данные в реальном времени (streaming, логи) Используют прогресс-бары (``tqdm``, ``rich.progress``)
✓ Используют библиотеки, которые напрямую работают с ``stdout``
✓ Выводят данные в реальном времени (streaming, логи)
✓ Используют библиотеки, которые напрямую работают с ``stdout``
Для обычных команд с ``print()`` перехват можно оставить включённым — это не влияет на их работу. Для обычных команд с ``print()`` перехват можно оставить включённым — это не влияет на их работу.