Sphinx autodoc 模拟导入导致未记录的对象

Sphinx autodoc mock imports results in undocumented object

我正在尝试记录来自模拟导入的常量 (foo.FOO)

foo.py

"""Foo module."""


from asdf import qwerty


FOO = qwerty.FOO
"""Foo constant."""


ASDF = 1
"""ASDF."""


def foo():
    """Return foo :py:const:`foo.FOO` :py:const:`foo.ASDF`."""
    return FOO

conf.py

import os
import sys
sys.path.insert(0, os.path.abspath(os.pardir))

project = 'sphinx'
copyright = '2021, sphinx'
author = 'sphinx'

extensions = ['sphinx.ext.autodoc']
templates_path = ['_templates']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']

autodoc_mock_imports = ['asdf']
nitpicky = True

#nitpick_ignore = [
#    ('py:class', 'foo.FOO'),
#]

当我 运行 make html SPHINXOPTS=-Ea 我得到了生成的文档。

但我希望当我模拟导入时记录 foo.FOO(见上图)。

狮身人面像:4.3.0

这是功能还是错误?

这实际上是一个错误,已经修复https://github.com/sphinx-doc/sphinx/pull/9905