BUG: Fix autosummary of members with a trailing underscore

This commit is contained in:
Eric Wieser
2017-03-25 21:16:28 +00:00
parent a92f406739
commit 804891c4a1
8 changed files with 72 additions and 8 deletions

View File

@@ -4,4 +4,5 @@
:toctree:
dummy_module
underscore_module_
sphinx

View File

@@ -0,0 +1,12 @@
"""
module with trailing underscores everywhere
"""
class class_(object):
""" Class """
def method_(_arg):
""" Method """
pass
def function_(_arg):
""" Function """
pass

View File

@@ -13,6 +13,8 @@ from six import iteritems, StringIO
from sphinx.ext.autosummary import mangle_signature
from util import etree_parse
import pytest
html_warnfile = StringIO()
@@ -103,3 +105,24 @@ def test_get_items_summary(app, status, warning):
'Test function take an argument ended with underscore.',
'dummy_module.func')
assert autosummary_items['func'] == func_attrs
def str_content(elem):
if elem.text is not None:
return elem.text
else:
return ''.join(str_content(e) for e in elem)
@pytest.mark.sphinx('xml', **default_kw)
def test_escaping(app, status, warning):
from xml.etree import ElementTree
app.builder.build_all()
outdir = app.builder.outdir
docpage = outdir / 'underscore_module_.xml'
assert docpage.exists()
title = etree_parse(docpage).find('section/title')
assert str_content(title) == 'underscore_module_'