python - docs.python.org 是否使用 sphinx.ext.autodoc?

标签 python python-sphinx

看起来 sphinx.ext.autodoc 已经成为 Python 文档字符串中“JavaDoc”类注释的实际标准。

Sphinx 用于在 docs.python.org 生成文档。但它是否从 Python 源 .py 文件(使用 autodoc)读取文档字符串以呈现在 docs.python.org 上?

library section of the docs包括逐个方法的总结,但这些似乎与文本无缝衔接。它们是否与源代码中的注释保持同步?

换句话说,我是否可以在文档中找到与从解释器中查询文档字符串完全相同的文本(除了格式)?

我还没有找到这样的地方。例如,使用帮助机制查看 print 的文档字符串会产生:

>>> help(print)
Help on built-in function print in module builtins:
print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.

当我在 3.6.2 文档(与上面使用的版本相同)中查找 print 时,我找到了 different documentation for print没有任何逐个参数的描述:

print(*objects, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False)

Print objects to the text stream file, separated by sep and followed by end. sep, end, file and flush, if present, must be given as keyword arguments.

All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no objects are given, print() will just write end.

The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. Since printed arguments are converted to text strings, print() cannot be used with binary mode file objects. For these, use file.write(...) instead.

Whether output is buffered is usually determined by file, but if the flush keyword argument is true, the stream is forcibly flushed.

Changed in version 3.3: Added the flush keyword argument.

最佳答案

检查 conf.py file for the Python docs , autodoc 扩展没有配置。这些文档不使用 autodoc 或从源代码文档字符串中读取。

关于python - docs.python.org 是否使用 sphinx.ext.autodoc?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46006055/

相关文章:

python - "command-not-found==0.2.44"在 pip 的卡住中

python - 在执行数据透视时从列值中获取列标题

python - 检测客户端连接到哪个端口

svg - SVG Sphinx 继承图中缺少链接

python - 使用 sphinx 记录 python 脚本条目 (__name__ == '__main__')

python-sphinx - 在 Sphinx 中为文本 block 而不是内联跨度应用 CSS 和角色

python - 如何获取请求响应中的字符串内容?

python - 我们如何在循环中创建 selenium webdriver 对象并在循环结束后关闭窗口?

python - 我在哪里可以找到有关带有 sphinx-doc 拿破仑扩展的 Google 风格文档字符串中支持的新语法的更多信息?

python - 如何使 apidocs 在 sphinx-apidoc 中使用包而不是模块