简体   繁体   English

Sphinx autodoc 模拟导入导致未记录的 object

[英]Sphinx autodoc mock imports results in undocumented object

I am trying to document constants derived from mocked imports (foo.FOO)我正在尝试记录从模拟导入(foo.FOO)派生的常量

foo.py 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'),
#]

在此处输入图像描述

When I run make html SPHINXOPTS=-Ea I get the resulting documentation.当我运行make html SPHINXOPTS=-Ea ,我得到了生成的文档。

But I would expect that when I mock the import that foo.FOO is documented (see picture above).但我希望当我模拟 foo.FOO 的导入时(见上图)。

Sphinx: 4.3.0狮身人面像:4.3.0

Is this a feature or a Bug?这是功能还是错误?

This was actually a bug and has been fixed https://github.com/sphinx-doc/sphinx/pull/9905这实际上是一个错误并已修复https://github.com/sphinx-doc/sphinx/pull/9905

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM