google-docstring-assistant

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google Docstring Assistant

Google Docstring 助手

Quick start

快速开始

  • Write docstrings using the Google Python Style Guide structure (Args, Returns, Raises, Examples, Attributes, etc.).
  • Keep sections as headers followed by indented blocks; break sections by resuming unindented text.
  • When types are annotated in code, omit them in docstrings unless clarity is improved.
  • Use
    Examples
    blocks with literal blocks (
    ::
    ) for commands or code snippets.
  • Document module-level variables consistently (all in
    Attributes
    or inline), and list TODOs in a
    Todo
    section.
  • See
    references/google_docstring_rules.md
    for full guidance and examples.
  • 遵循Google Python风格指南的结构(Args、Returns、Raises、Examples、Attributes等)编写文档字符串。
  • 章节以标题形式呈现,后跟缩进块;恢复无缩进文本即可分隔章节。
  • 当代码中已标注类型时,除非能提升清晰度,否则文档字符串中无需重复标注类型。
  • 使用
    Examples
    块搭配文字块(
    ::
    )来展示命令或代码片段。
  • 统一记录模块级变量(全部放在
    Attributes
    中或内联记录),并在
    Todo
    章节中列出待办事项。
  • 完整指南和示例请查看
    references/google_docstring_rules.md

Workflow

工作流程

  1. Choose sections
    • Functions: include
      Args
      ,
      Returns
      , and
      Raises
      as needed.
    • Modules/classes: use
      Attributes
      and
      Todo
      when relevant; keep formatting consistent.
  2. Write clearly
    • One docstring per object; keep it concise and informative.
    • Use indentation under each section header; separate sections by returning to unindented text.
    • Prefer Google-style wording; avoid duplicating annotated types unless helpful.
  3. Examples and scripts
    • Use
      Examples:
      with indented literal blocks for shell commands or code snippets.
    • Include multi-line descriptions when needed; keep formatting readable.
  1. 选择章节
    • 函数:根据需要包含
      Args
      Returns
      Raises
    • 模块/类:相关时使用
      Attributes
      Todo
      ;保持格式一致。
  2. 清晰撰写
    • 每个对象对应一个文档字符串;保持简洁且信息丰富。
    • 在每个章节标题下使用缩进;通过回到无缩进文本来分隔章节。
    • 优先使用Google风格的表述;除非有帮助,否则避免重复已标注的类型。
  3. 示例与脚本
    • 使用
      Examples:
      搭配缩进的文字块来展示Shell命令或代码片段。
    • 必要时使用多行描述;保持格式可读性。

Reference

参考资料

  • references/google_docstring_rules.md
    : full style description and examples.
  • references/google_docstring_rules.md
    :完整的风格说明和示例。