document-public-apis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Document Public APIs

公共API文档化

This skill documents undocumented public APIs in PyTorch by removing entries from the coverage ignore lists in
docs/source/conf.py
and adding Sphinx autodoc directives (e.g.,
autosummary
,
currentmodule
,
autoclass
,
automodule
) to the corresponding
.md
or
.rst
doc source files in
docs/source/
.
"Documenting" means adding autodoc directives to doc source files — NEVER modifying Python source code. Do not add or edit docstrings in
.py
files. Do not read or inspect Python source files. Sphinx will pull whatever docstring exists (or render an empty entry if none exists). Your only job is to add the correct directive to the correct doc file.
本技能通过从
docs/source/conf.py
中的覆盖率忽略列表移除条目,向
docs/source/
目录下对应的.md或.rst文档源文件添加Sphinx autodoc指令(例如
autosummary
currentmodule
autoclass
automodule
),来为PyTorch中未被文档化的公共API补充文档。
“文档化”指向文档源文件添加autodoc指令——绝对不要修改Python源码。 不要在.py文件中添加或编辑docstring,不要读取或检查Python源文件。Sphinx会自动拉取已存在的所有docstring(如果不存在则渲染为空条目)。你的唯一任务是向正确的文档文件添加正确的指令。

Overview

概述

docs/source/conf.py
contains two lists that suppress Sphinx coverage warnings for undocumented APIs:
  • coverage_ignore_functions
    : undocumented functions
  • coverage_ignore_classes
    : undocumented classes
Entries are organized by module comment groups. Each group has a module label comment followed by the function/class names that belong to that module:
python
coverage_ignore_functions = [
    # torch.ao.quantization.fx.convert              <-- module label comment
    "convert",                                       # <-- entries belonging to this module
    "convert_custom_module",
    "convert_standalone_module",
    "convert_weighted_module",
    # torch.ao.quantization.fx.fuse                 <-- next module group
    "fuse",
    # torch.nn.functional
    "assert_int_or_pair",  # looks unintentionally public   <-- entry with inline comment
    "constant",  # deprecated                                <-- entry with inline comment
]
There are two kinds of comments:
  • Module label comments (
    # torch.ao.quantization.fx.convert
    ): these label which module the entries below belong to. They appear on their own line before a group of entries.
  • Inline comments (
    # deprecated
    ,
    # documented as adaptive_max_pool1d
    ): these appear after a string entry on the same line and explain why the entry is in the ignore list.
The module label comment directly tells you:
  1. Which module the functions belong to
  2. Where to add them in the docs (e.g.,
    # torch.ao.quantization.fx.convert
    → the functions go under
    torch.ao.quantization.fx.convert
    in the doc file)
docs/source/conf.py
包含两个列表,用于抑制Sphinx对未文档化API的覆盖率警告:
  • coverage_ignore_functions
    :未文档化的函数
  • coverage_ignore_classes
    :未文档化的类
条目按模块注释组组织。每个组都有一个模块标签注释,后面跟着属于该模块的函数/类名:
python
coverage_ignore_functions = [
    # torch.ao.quantization.fx.convert              <-- 模块标签注释
    "convert",                                       # <-- 属于该模块的条目
    "convert_custom_module",
    "convert_standalone_module",
    "convert_weighted_module",
    # torch.ao.quantization.fx.fuse                 <-- 下一个模块组
    "fuse",
    # torch.nn.functional
    "assert_int_or_pair",  # 看起来是非故意公开的   <-- 带行内注释的条目
    "constant",  # 已废弃                                <-- 带行内注释的条目
]
有两种注释类型:
  • 模块标签注释
    # torch.ao.quantization.fx.convert
    ):标注下方条目所属的模块,单独占一行,位于一组条目之前。
  • 行内注释
    # deprecated
    # documented as adaptive_max_pool1d
    ):跟在字符串条目同一行的后面,解释该条目被加入忽略列表的原因
模块标签注释会直接告诉你:
  1. 这些函数所属的模块
  2. 你要在文档的哪个位置添加它们(例如
    # torch.ao.quantization.fx.convert
    → 这些函数要放在文档文件的
    torch.ao.quantization.fx.convert
    分类下)

Instructions

操作指南

Each invocation of this skill processes one batch of module groups. Pick one or more complete module groups from the ignore lists, document their functions, and verify.
每次调用本技能处理一批模块组。从忽略列表中选择一个或多个完整的模块组,为其函数补充文档,然后进行验证。

Step 1: Select module groups to document

步骤1:选择要文档化的模块组

Read
docs/source/conf.py
and select one or more complete module groups to document. A module group is a module label comment and all entries beneath it up to the next module label comment. Process entire groups — never split a group across batches.
For example, selecting the
torch.ao.quantization.fx.convert
group means taking all of:
python
undefined
读取
docs/source/conf.py
,选择一个或多个完整的模块组进行文档化。模块组指的是一个模块标签注释,以及它下方到下一个模块标签注释之前的所有条目。必须处理完整的组——绝对不要把一个组拆分到不同批次处理。
例如,选择
torch.ao.quantization.fx.convert
组意味着你需要选取以下所有条目:
python
undefined

torch.ao.quantization.fx.convert

torch.ao.quantization.fx.convert

"convert", "convert_custom_module", "convert_standalone_module", "convert_weighted_module",

Work through the lists top-to-bottom. Choose enough groups to make meaningful progress (aim for 5–15 functions total, but always include complete groups even if that means going slightly over).

**Check inline comments before including an entry.** Some entries have inline comments that indicate they should not be documented:

- `# deprecated` — The function is deprecated. Leave it in the ignore list.
- `# documented as <other_name>` — Already documented under a different name. Leave it.
- `# looks unintentionally public` — Probably not meant to be public API. Leave it.
- `# legacy helper for ...` — Same as deprecated. Leave it.
- `# utility function` - Leave it.

If a module group has a **mix** of regular entries and entries with inline comments, still process the group — but only comment out the regular entries. Leave entries with inline comments untouched in the ignore list.
"convert", "convert_custom_module", "convert_standalone_module", "convert_weighted_module",

从上到下遍历列表,选择足够的组来取得有意义的进展(目标是总计5-15个函数,但如果完整组的数量略超过这个范围也可以全部包含)。

**包含条目之前请先检查行内注释。** 部分条目的行内注释表明它们不应该被文档化:

- `# deprecated` — 该函数已废弃,保留在忽略列表中。
- `# documented as <other_name>` — 已以其他名称被文档化,保留在忽略列表中。
- `# looks unintentionally public` — 可能不属于公开API,保留在忽略列表中。
- `# legacy helper for ...` — 和已废弃相同,保留在忽略列表中。
- `# utility function` — 保留在忽略列表中。

如果一个模块组同时包含普通条目和带行内注释的条目,仍然可以处理该组——但仅注释掉普通条目,带行内注释的条目保持原样留在忽略列表中。

Step 2: Present the batch to the user

步骤2:向用户展示待处理批次

Before making any edits, present the selected module groups and their functions to the user. Show them organized by module:
Module: torch.ao.quantization.fx.convert
  - convert
  - convert_custom_module
  - convert_standalone_module
  - convert_weighted_module

Module: torch.ao.quantization.fx.fuse
  - fuse
Then use the
AskUserQuestion
tool to let the user confirm, with options like:
  • "Proceed with this batch"
  • "Skip some entries" (user can specify which to remove)
  • "Pick a different batch"
进行任何编辑之前,向用户展示选中的模块组及其包含的函数,按模块组织展示:
模块: torch.ao.quantization.fx.convert
  - convert
  - convert_custom_module
  - convert_standalone_module
  - convert_weighted_module

模块: torch.ao.quantization.fx.fuse
  - fuse
然后使用
AskUserQuestion
工具让用户确认,提供如下选项:
  • "继续处理该批次"
  • "跳过部分条目"(用户可以指定要移除的条目)
  • "选择其他批次"

Step 3: Comment out entries in conf.py

步骤3:注释掉conf.py中的对应条目

After the user confirms, edit
docs/source/conf.py
and comment out (do not delete) the selected entries. Use a
#
prefix on each string entry line:
python
undefined
用户确认后,编辑
docs/source/conf.py
注释掉(不要删除)选中的条目。在每个字符串条目前添加
#
前缀:
python
undefined

torch.ao.quantization.fx.convert

torch.ao.quantization.fx.convert

"convert",

"convert",

"convert_custom_module",

"convert_custom_module",

"convert_standalone_module",

"convert_standalone_module",

"convert_weighted_module",

"convert_weighted_module",


This preserves the original entries so they can be restored if verification fails.

这样可以保留原始条目,方便验证失败时恢复。

Step 4: Run Sphinx coverage

步骤4:运行Sphinx覆盖率检查

bash
cd docs && make coverage
Ignore the terminal output of
make coverage
.
It often contains unrelated tracebacks and errors from Sphinx extensions (e.g.,
onnx_ir
,
katex
,
sphinxcontrib
) that have nothing to do with coverage. The only thing that matters is whether
docs/build/coverage/python.txt
was generated. Read that file to see the specific undocumented APIs.
The format of
python.txt
lists each undocumented API as:
torch.ao.quantization.fx.convert
   * convert
   * convert_custom_module
   * convert_standalone_module
   * convert_weighted_module
Not all commented-out functions will appear in
python.txt
.
Some may already be documented elsewhere. This is fine — only add directives for functions that actually appear in
python.txt
.
If
make coverage
fails due to missing dependencies, first run:
bash
cd docs && pip install -r requirements.txt
bash
cd docs && make coverage
忽略
make coverage
的终端输出。
输出中经常包含Sphinx扩展(例如
onnx_ir
katex
sphinxcontrib
)的无关报错和回溯,和覆盖率检查无关。唯一需要关注的是
docs/build/coverage/python.txt
是否生成。读取该文件可以查看具体的未文档化API。
python.txt
的格式会列出每个未文档化API:
torch.ao.quantization.fx.convert
   * convert
   * convert_custom_module
   * convert_standalone_module
   * convert_weighted_module
不是所有被注释掉的函数都会出现在
python.txt
中。
部分可能已经在其他地方被文档化,这是正常情况——仅为实际出现在
python.txt
中的函数添加指令即可。
如果
make coverage
因依赖缺失失败,先运行:
bash
cd docs && pip install -r requirements.txt

Step 5: Add documentation directives

步骤5:添加文档指令

For each function listed in
python.txt
, use the module label comment from
conf.py
to determine where it should be added. The module comment gives you the full module path, which maps to a doc source file and a section within that file.
对于
python.txt
中列出的每个函数,使用
conf.py
中的模块标签注释确定应该添加的位置。模块注释会给出完整的模块路径,对应到文档源文件以及文件中的某个章节。

Finding the correct doc file

查找正确的文档文件

The module comment maps to a doc source file in
docs/source/
. When unsure, search for other functions from the same module:
bash
grep -rn "torch.module_name" docs/source/*.md docs/source/*.rst
Or list candidate files:
bash
ls docs/source/*module_name*
If no doc file exists for a submodule, check whether a parent module's doc file has a section for it (e.g.,
backends.md
has sections for
torch.backends.cuda
,
torch.backends.cudnn
, etc.). If not, add a new section to the parent file following existing patterns.
模块注释对应
docs/source/
下的一个文档源文件。不确定的话,可以搜索同一模块的其他函数:
bash
grep -rn "torch.module_name" docs/source/*.md docs/source/*.rst
或者列出候选文件:
bash
ls docs/source/*module_name*
如果子模块没有对应的文档文件,检查父模块的文档文件是否有对应的章节(例如
backends.md
包含
torch.backends.cuda
torch.backends.cudnn
等章节)。如果没有,按照现有模式在父文件中添加新章节。

Adding the directives

添加指令

Read the target doc file first and match the exact patterns already used there. Do not invent new patterns or use bare
autofunction
with fully qualified names — always use the proper hierarchical structure with
automodule
,
currentmodule
, and short names. Do not use
. py:module::
since that just suppresses errors and doesn't actually document the function. Look at other files that match the target file's format (e.g.,
.md
vs.
.rst
) under
docs/source/
to see examples.
There are two file formats. Match the one used in the target file.
Pattern A — MyST Markdown files (
.md
):
Used in files like
accelerator.md
,
backends.md
,
cuda.md
.
The hierarchical structure uses
automodule
to register the module,
currentmodule
to set context, then short names:
markdown
undefined
先阅读目标文档文件,匹配文件中已使用的 exact 模式。不要发明新模式,也不要使用带全限定名的裸
autofunction
——始终使用包含
automodule
currentmodule
和短名称的正确层级结构。不要使用
. py:module::
,因为它只是抑制错误,并不会实际文档化函数。可以参考
docs/source/
下同格式(.md或.rst)的其他文件作为示例。
有两种文件格式,匹配目标文件使用的格式即可。
模式A — MyST Markdown文件(.md): 用于
accelerator.md
backends.md
cuda.md
等文件。
层级结构使用
automodule
注册模块,
currentmodule
设置上下文,然后使用短名称:
markdown
undefined

torch.ao.quantization.fx.convert

torch.ao.quantization.fx.convert

.. automodule:: torch.ao.quantization.fx.convert
.. currentmodule:: torch.ao.quantization.fx.convert
.. autofunction:: convert
.. autofunction:: convert_custom_module

For `autosummary` blocks (used in some files instead of individual directives):

```markdown
```{eval-rst}
.. autosummary::
    :toctree: generated
    :nosignatures:

    existing_function
    your_new_function
`` `
For classes:
markdown
```{eval-rst}
.. autoclass:: YourClass
    :members:
`` `
Pattern B — reStructuredText files (
.rst
):
Used in files like
torch.rst
,
nn.rst
.
Same hierarchical structure without the markdown fences:
rst
torch.ao.quantization.fx.convert
---------------------------------

.. automodule:: torch.ao.quantization.fx.convert

.. currentmodule:: torch.ao.quantization.fx.convert

.. autosummary::
    :toctree: generated
    :nosignatures:

    convert
    convert_custom_module
    convert_standalone_module
    convert_weighted_module
For individual directives:
rst
.. automodule:: torch.submodule

.. currentmodule:: torch.submodule

.. autofunction:: function_name

.. autoclass:: ClassName
    :members:
Key rules:
  • The module label comment from
    conf.py
    (e.g.,
    # torch.ao.quantization.fx.convert
    ) tells you exactly which
    automodule
    and
    currentmodule
    to use.
  • Always set
    .. automodule::
    and
    .. currentmodule::
    before documenting functions from a module.
  • Use short names (e.g.,
    convert
    , not
    torch.ao.quantization.fx.convert.convert
    ) after
    currentmodule
    is set.
  • If the module already has an
    automodule
    /
    currentmodule
    in the file, don't add another — just add your function under the existing one.
  • Match whichever style the file already uses (
    autosummary
    blocks vs. individual
    autofunction
    directives).
.. automodule:: torch.ao.quantization.fx.convert
.. currentmodule:: torch.ao.quantization.fx.convert
.. autofunction:: convert
.. autofunction:: convert_custom_module

如果文件中使用`autosummary`块(部分文件用它替代单个指令):

```markdown
```{eval-rst}
.. autosummary::
    :toctree: generated
    :nosignatures:

    existing_function
    your_new_function
`` `
类的处理方式:
markdown
```{eval-rst}
.. autoclass:: YourClass
    :members:
`` `
模式B — reStructuredText文件(.rst): 用于
torch.rst
nn.rst
等文件。
相同的层级结构,不需要Markdown围栏:
rst
torch.ao.quantization.fx.convert
---------------------------------

.. automodule:: torch.ao.quantization.fx.convert

.. currentmodule:: torch.ao.quantization.fx.convert

.. autosummary::
    :toctree: generated
    :nosignatures:

    convert
    convert_custom_module
    convert_standalone_module
    convert_weighted_module
单个指令的写法:
rst
.. automodule:: torch.submodule

.. currentmodule:: torch.submodule

.. autofunction:: function_name

.. autoclass:: ClassName
    :members:
核心规则:
  • conf.py
    中的模块标签注释(例如
    # torch.ao.quantization.fx.convert
    )会明确告诉你要使用的
    automodule
    currentmodule
    值。
  • 文档化模块下的函数之前,始终先设置
    .. automodule::
    .. currentmodule::
  • 设置
    currentmodule
    后使用短名称(例如
    convert
    ,而不是
    torch.ao.quantization.fx.convert.convert
    )。
  • 如果文件中该模块已经有
    automodule
    /
    currentmodule
    ,不要重复添加——直接在现有条目下添加你的函数即可。
  • 匹配文件已使用的风格(
    autosummary
    块还是单个
    autofunction
    指令)。

Placing in the right section

放在正确的章节

Read the target doc file and find the appropriate section. If the module already has a section (e.g.,
## torch.backends.cuda
in
backends.md
), add the functions there. If no section exists yet, create one following the existing section patterns in the file. Group all functions from the same module group together.
阅读目标文档文件,找到合适的章节。如果该模块已经有对应章节(例如
backends.md
中的
## torch.backends.cuda
),把函数添加到该章节下。如果还没有对应章节,按照文件中现有章节的模式创建一个。将同一模块组的所有函数放在一起。

Step 6: Verify with coverage

步骤6:通过覆盖率检查验证

Run coverage again:
bash
cd docs && make coverage
Ignore the terminal output — only read
docs/build/coverage/python.txt
. Verification passes when
python.txt
contains zero undocumented functions across ALL modules. It should only have the statistics table with 100% coverage and 0 undocumented for every module. For example:
Undocumented Python objects
===========================

Statistics
----------

+---------------------------+----------+--------------+
| Module                    | Coverage | Undocumented |
+===========================+==========+==============+
| torch                     | 100.00%  | 0            |
+---------------------------+----------+--------------+
| torch.accelerator         | 100.00%  | 0            |
+---------------------------+----------+--------------+
If any module shows undocumented functions (coverage below 100% or undocumented count > 0), verification has failed.
If verification succeeds (zero undocumented across all modules): Go to Step 7.
If verification fails (any undocumented functions remain): Read
docs/build/coverage/python.txt
to see which functions are still listed as undocumented. Common issues include:
  • Wrong doc file: the function was added to the wrong
    .md
    /
    .rst
    file. Move the directive to the correct file.
  • Wrong directive type: e.g., used
    autofunction
    for a class, or
    autoclass
    for a function. Fix the directive.
  • Wrong module path in the directive: e.g.,
    torch.foo.bar
    should be
    torch.foo.baz.bar
    . Correct the qualified name.
  • Function added to an
    autosummary
    block with the wrong
    currentmodule
    : make sure the
    .. currentmodule::
    directive above the block matches.
  • Missing
    automodule
    for a submodule that hasn't been registered yet. Add a
    .. automodule:: torch.submodule
    directive before documenting functions from that submodule.
Fix the doc directive based on the error, then re-run
make coverage
. Repeat until verification passes.
If a function still fails after multiple attempts, stop and show the error to the user. Present the function name and the error, then use the
AskUserQuestion
tool with options like:
  • "Uncomment it to restore to ignore list (skip for now)"
  • "Try a different approach"
  • "Investigate further"
再次运行覆盖率检查:
bash
cd docs && make coverage
忽略终端输出——仅读取
docs/build/coverage/python.txt
。当
python.txt
所有模块的未文档化函数数量为0时,验证通过。文件应该只包含覆盖率100%、所有模块未文档化数量为0的统计表格。例如:
未文档化Python对象
===========================

统计信息
----------

+---------------------------+----------+--------------+
| 模块                    | 覆盖率 | 未文档化数量 |
+===========================+==========+==============+
| torch                     | 100.00%  | 0            |
+---------------------------+----------+--------------+
| torch.accelerator         | 100.00%  | 0            |
+---------------------------+----------+--------------+
如果任何模块显示存在未文档化函数(覆盖率低于100%或未文档化数量>0),则验证失败。
如果验证成功(所有模块未文档化数量为0): 进入步骤7。
如果验证失败(仍存在未文档化函数): 读取
docs/build/coverage/python.txt
查看哪些函数仍被列为未文档化。常见问题包括:
  • 文档文件错误:函数被添加到了错误的.md/.rst文件中。将指令移动到正确的文件。
  • 指令类型错误:例如对类使用了
    autofunction
    ,对函数使用了
    autoclass
    。修复指令类型。
  • 指令中的模块路径错误:例如
    torch.foo.bar
    应该是
    torch.foo.baz.bar
    。修正全限定名。
  • 函数被添加到
    autosummary
    块时使用了错误的
    currentmodule
    :确保块上方的
    .. currentmodule::
    指令匹配。
  • 未注册的子模块缺少
    automodule
    指令。在文档化该子模块的函数之前添加
    .. automodule:: torch.submodule
    指令。
根据错误修复文档指令,然后重新运行
make coverage
。重复直到验证通过。
如果多次尝试后函数仍然验证失败,停止并向用户展示错误。展示函数名和错误,然后使用
AskUserQuestion
工具提供如下选项:
  • "取消注释恢复到忽略列表(暂时跳过)"
  • "尝试其他方法"
  • "进一步调查"

Step 7: Report progress

步骤7:报告进度

Present a progress summary to the user showing:
  • Which module groups were processed and how many functions were documented
  • Which functions were skipped or restored to the ignore list (and why)
  • How many entries remain in
    coverage_ignore_functions
    and
    coverage_ignore_classes
向用户展示进度摘要,包含以下内容:
  • 处理了哪些模块组,文档化了多少个函数
  • 哪些函数被跳过或恢复到忽略列表(以及原因)
  • coverage_ignore_functions
    coverage_ignore_classes
    中还剩多少条目

Step 8: Clean up commented-out entries in conf.py

步骤8:清理conf.py中被注释掉的条目

Now that verification has passed, delete the commented-out string entries from Step 3. These are lines that start with
# "
inside
coverage_ignore_functions
and
coverage_ignore_classes
. Commented-out string entries always contain quotes — that's how you distinguish them from module label comments:
python
undefined
现在验证已通过,删除步骤3中被注释掉的字符串条目。这些是
coverage_ignore_functions
coverage_ignore_classes
中以
# "
开头的行。被注释掉的字符串条目始终包含引号——你可以通过这一点和模块标签注释区分:
python
undefined

"disable_global_flags", <-- commented-out string entry (has quotes) → DELETE

"disable_global_flags", <-- 被注释的字符串条目(有引号)→ 删除

torch.backends <-- module label comment (no quotes) → KEEP if it has active entries

torch.backends <-- 模块标签注释(无引号)→ 如果还有有效条目则保留


Also delete any module label comments that no longer have active entries beneath them (i.e., all their entries were either commented out and now deleted, or had inline comments and were left in place but the module label is otherwise empty).

同时删除下方已经没有有效条目的模块标签注释(即该组的所有条目要么被注释后删除,要么带行内注释保留但模块标签下已空)。

Important notes

重要注意事项

  • Follow the steps exactly as written. Do not add extra investigation steps like importing Python modules to check docstrings, inspecting source code to verify function signatures, or running any commands not specified in the instructions. The
    make coverage
    step is the only verification needed — let it tell you what's wrong.
  • Never modify Python source files (
    .py
    ).
    This skill only edits
    docs/source/conf.py
    and doc source files (
    .md
    /
    .rst
    ) in
    docs/source/
    . Do not add or edit docstrings, do not read Python source to check function signatures, do not inspect implementations.
  • Entries are commented out in Step 3, verified in Step 6, and cleaned up in Step 8 after verification passes. Never delete uncommented entries directly.
  • Read inline comments on entries before deciding to document them. Entries marked
    # deprecated
    ,
    # documented as ...
    ,
    # looks unintentionally public
    , or
    # legacy helper
    should stay in the ignore list.
  • The
    coverage_ignore_functions
    list uses bare function names (not fully qualified), so the same name can appear multiple times for different modules. Use the module label comment above each entry to identify which module it belongs to. Be careful during Step 8 cleanup to only delete the correct commented-out lines — commented-out string entries have quotes (
    # "func_name",
    ), module label comments do not.
  • Always match the existing style of the target doc file — don't mix
    .md
    style directives into
    .rst
    files or vice versa.
  • Use the module label comment (e.g.,
    # torch.ao.quantization.fx.convert
    ) as the primary guide for both the
    automodule
    /
    currentmodule
    directives and for finding the right section in the doc file.
  • Always process complete module groups — never split a group across invocations.
  • 严格按照书面步骤执行。 不要添加额外的调查步骤,例如导入Python模块检查docstring、检查源码验证函数签名,或者运行本指南未指定的任何命令。
    make coverage
    步骤是唯一需要的验证方式——让它告诉你问题所在。
  • 绝对不要修改Python源文件(.py)。 本技能仅编辑
    docs/source/conf.py
    docs/source/
    下的文档源文件(.md/.rst)。不要添加或编辑docstring,不要读取Python源码检查函数签名,不要检查实现。
  • 条目在步骤3中被注释,步骤6中验证,验证通过后在步骤8中清理。绝对不要直接删除未被注释的条目。
  • 决定是否文档化条目之前读取行内注释。标记为
    # deprecated
    # documented as ...
    # looks unintentionally public
    # legacy helper
    的条目应该留在忽略列表中。
  • coverage_ignore_functions
    列表使用纯函数名(不是全限定名),因此同一个名称可能在不同模块下多次出现。使用每个条目上方的模块标签注释确定其所属模块。步骤8清理时要小心,仅删除正确的被注释行——被注释的字符串条目有引号
    # "func_name",
    ),模块标签注释没有。
  • 始终匹配目标文档文件的现有风格——不要把.md风格的指令混入.rst文件,反之亦然。
  • 使用模块标签注释(例如
    # torch.ao.quantization.fx.convert
    )作为
    automodule
    /
    currentmodule
    指令以及查找文档中正确章节的主要参考。
  • 始终处理完整的模块组——绝对不要把一个组拆分到不同调用中处理。