From 08bcce19dba4ded5de9ec4c6dca71d00e3aa7f0a Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Mon, 29 Dec 2025 23:50:10 +0800 Subject: [PATCH] docs: add code style guide in English, Japanese, and Chinese --- docs/.vitepress/config.mts | 3 +++ docs/en/plugin/dev/style.md | 15 +++++++++++++++ docs/ja/plugin/dev/style.md | 15 +++++++++++++++ docs/zh/plugin/dev/style.md | 15 +++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 docs/en/plugin/dev/style.md create mode 100644 docs/ja/plugin/dev/style.md create mode 100644 docs/zh/plugin/dev/style.md diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 28befe3cd..fe128e821 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -230,6 +230,7 @@ export default defineConfig({ { text: "消息平台实体", link: "/zh/plugin/dev/apis/messages" }, ], }, + { text: "代码规范", link: "/zh/plugin/dev/style" }, { text: "迁移指南", link: "/zh/plugin/dev/migration" }, { text: "分发插件", collapsed: true, @@ -513,6 +514,7 @@ export default defineConfig({ { text: "Message Platform Entities", link: "/en/plugin/dev/apis/messages" }, ], }, + { text: "Code Style", link: "/en/plugin/dev/style" }, { text: "Migration Guide", link: "/en/plugin/dev/migration" }, { text: "Distribute Plugin", collapsed: true, @@ -773,6 +775,7 @@ export default defineConfig({ { text: "メッセージプラットフォームエンティティ", link: "/ja/plugin/dev/apis/messages" }, ], }, + { text: "コードスタイル", link: "/ja/plugin/dev/style" }, { text: "移行ガイド", link: "/ja/plugin/dev/migration" }, { text: "プラグインを配布", collapsed: true, diff --git a/docs/en/plugin/dev/style.md b/docs/en/plugin/dev/style.md new file mode 100644 index 000000000..ac229fbd3 --- /dev/null +++ b/docs/en/plugin/dev/style.md @@ -0,0 +1,15 @@ +# Code Style Guide + +## Logging + +In plugins, please use the `logging` module to record logs, do not use `print` statements (this will cause logs to not be output in the container environment). + +```python +import logging + +logger = logging.getLogger(__name__) # Import logging module at the beginning of any Python file and define logger object + +logger.info('This is an info message') # Use logger.info to record info level logs +logger.warning('This is a warning message') +logger.error('This is an error message') +``` \ No newline at end of file diff --git a/docs/ja/plugin/dev/style.md b/docs/ja/plugin/dev/style.md new file mode 100644 index 000000000..24378c0ef --- /dev/null +++ b/docs/ja/plugin/dev/style.md @@ -0,0 +1,15 @@ +# コードスタイルガイド + +## ロギング + +プラグインでは、`logging`モジュールを使用してログを記録してください。`print`文を使用しないでください(これはコンテナ環境でログが出力されなくなります)。 + +```python +import logging + +logger = logging.getLogger(__name__) # 任意の Python ファイルの先頭で logging モジュールをインポートし、logger オブジェクトを定義します + +logger.info('This is an info message') # logger.info を使用して info レベルのログを記録します +logger.warning('This is a warning message') +logger.error('This is an error message') +``` \ No newline at end of file diff --git a/docs/zh/plugin/dev/style.md b/docs/zh/plugin/dev/style.md new file mode 100644 index 000000000..6cf7a691f --- /dev/null +++ b/docs/zh/plugin/dev/style.md @@ -0,0 +1,15 @@ +# 代码规范指南 + +## 日志记录 + +在插件中请使用`logging`模块记录日志,不要使用`print`语句(这将导致容器环境中无法输出日志)。 + +```python +import logging + +logger = logging.getLogger(__name__) # 在任何 Python 文件的开头导入 logging 模块,并定义 logger 对象 + +logger.info('This is an info message') # 使用 logger.info 记录信息级别日志 +logger.warning('This is a warning message') +logger.error('This is an error message') +```