Python Sphinx未删除html输出中的doctest标志

Python Sphinx未删除html输出中的doctest标志,python,python-sphinx,doctest,autodoc,numpydoc,Python,Python Sphinx,Doctest,Autodoc,Numpydoc,我无法消除html输出的doctest标志(即,#doctest:+省略号)。我能够生成我想要的文档,所以那里没有错误,但它包括我想要删除的这些标志。斯芬克斯文档声称这是可能的,所以我一定是做错了什么。我的文档示例是numpy风格的,我已经尝试使用napoleon和numpydoc扩展 以下是我采取的步骤 运行sphinx快速启动(启用autodoc和doctest扩展) 运行sphinx apidoc生成.rst文件 运行make doctest(所有测试均通过) 运行makehtml 我在c

我无法消除html输出的doctest标志(即
#doctest:+省略号
)。我能够生成我想要的文档,所以那里没有错误,但它包括我想要删除的这些标志。斯芬克斯文档声称这是可能的,所以我一定是做错了什么。我的文档示例是numpy风格的,我已经尝试使用napoleon和numpydoc扩展

以下是我采取的步骤

  • 运行
    sphinx快速启动
    (启用
    autodoc
    doctest
    扩展)
  • 运行
    sphinx apidoc
    生成.rst文件
  • 运行
    make doctest
    (所有测试均通过)
  • 运行
    makehtml
  • 我在
    conf.py
    中尝试了设置
    trim\u doctest\u flags
    doctest\u test\u doctest\u blocks
    变量,但没有成功

    我是否缺少触发sphinx来删除html文档中的这些内容?我希望这是足够的信息,以得到正确的方向,因为文件看起来不错,除了这一个问题。但是,如果需要,我可以提供更多细节或示例

    更新:MCV示例(使用Sphinx 1.8.2)
    目录和文件结构

    .
    ├── trial
    │   ├── __init__.py
    │   └── trial.py
    └── trialDocs
        ├── build
        ├── Makefile
        └── source
            ├── _static
            ├── _templates
            ├── conf.py
            ├── index.rst
            ├── modules.rst
            └── trial.rst
    
    conf.py

    # -*- coding: utf-8 -*-
    #
    # Configuration file for the Sphinx documentation builder.
    import os
    import sys
    sys.path.insert(0, os.path.abspath('../../trial'))
    project = 'trial'
    copyright = '2019, trial'
    author = 'trial'
    version = ''
    release = 'trial'
    extensions = [
        'sphinx.ext.autodoc',
        'sphinx.ext.doctest',
        'sphinx.ext.napoleon',
    ]
    templates_path = ['_templates']
    source_suffix = '.rst'
    master_doc = 'index'
    language = None
    exclude_patterns = []
    pygments_style = None
    html_theme = 'alabaster'
    htmlhelp_basename = 'trialdoc'
    latex_elements = {}
    latex_documents = [(master_doc, 'trial.tex', 'trial Documentation', 'trial', 'manual'),]
    man_pages = [(master_doc, 'trial', 'trial Documentation', [author], 1)]
    texinfo_documents = [(master_doc, 'trial', 'trial Documentation', author, 'trial', 'One line description of project.', 'Miscellaneous'),]
    epub_title = project
    epub_exclude_files = ['search.html']
    doctest_global_setup = """
    from trial import *
    """
    trim_doctest_flags=True
    
    trial.rst-这是使用sphinx apidoc生成的

    trial package
    =============
    
    Module contents
    ---------------
    
    .. automodule:: trial
        :members:
        :undoc-members:
        :show-inheritance:
    
    试用版

    def withBlankline():
        """
        Use blanklines in example.
    
        Determine if sphinx will eliminate <BLANKLINE> for html.
    
        Examples
        --------
        >>> withBlankline()
        <BLANKLINE>
        blanklines above and below
        <BLANKLINE>
        """
        print()
        print('blanklines above and below')
        print()
    
    class Example():
        def __init__(self):
            pass
    
        def withEllipsis(self):
            """
            Use ellipsis in example.
    
            Determine if sphinx will eliminate # doctest: +ELLIPSIS for html.
    
            Examples
            --------
            >>> e = Example()
            >>> e.withEllipsis() # doctest: +ELLIPSIS
            abc...xyz
            """
            print('abcdefghijklmnopqrstuvwxyz')
    
    def with blankline():
    """
    在示例中使用空白行。
    确定sphinx是否将消除html。
    例子
    --------
    >>>用空格()
    上下空白线
    """
    打印()
    打印('上方和下方的空白行')
    打印()
    类示例():
    定义初始化(自):
    通过
    带省略号的def(self):
    """
    在示例中使用省略号。
    确定sphinx是否将删除html的#doctest:+省略号。
    例子
    --------
    >>>e=示例()
    >>>e.带省略号()#doctest:+省略号
    abc…xyz
    """
    打印('abcdefghijklmnopqrstuvxyz')
    
    使用
    makehtml
    sphinxbuild-bhtml源代码构建
    trial.html输出:

    根据@mzjn的评论,这似乎是一个bug,已在Sphinx 2.2.0中修复:


    问题:

    根据@mzjn的评论,这似乎是一个bug,已在Sphinx 2.2.0中修复:


    问题:

    是的,我认为您需要提供更多详细信息。我们怎么能复制这个?@mzjn没问题,我已经更新了我的问题。如果你还需要复制什么,请告诉我。谢谢,很有趣。我可以重现这个问题
    trim\u doctest\u flags
    在默认情况下为True,应该注意这个问题。我想我现在可以编写一个脚本来手动修复它。Sphinx2.2.0中修复:是的,我认为您需要提供更多细节。我们怎么能复制这个?@mzjn没问题,我已经更新了我的问题。如果你还需要复制什么,请告诉我。谢谢,很有趣。我可以重现这个问题
    trim\u doctest\u flags
    在默认情况下为True,应该注意这个问题。我想我现在可以编写一个脚本来手动修复它。在Sphinx 2.2.0中修复: