mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #1462: autosummary warns for namedtuple with attribute with trailing underscore
This commit is contained in:
parent
37bb9c2c33
commit
8d96c90fc6
1
CHANGES
1
CHANGES
@ -13,6 +13,7 @@ Bugs fixed
|
||||
* #2899: Fix ``hasdoc()`` function in Jinja2 template. It can detect ``genindex``, ``search`` collectly.
|
||||
* #2901: Fix epub result: skip creating links from image tags to original image files.
|
||||
* #2917: inline code is hyphenated on HTML
|
||||
* #1462: autosummary warns for namedtuple with attribute with trailing underscore
|
||||
|
||||
Release 1.4.6 (released Aug 20, 2016)
|
||||
=====================================
|
||||
|
@ -67,6 +67,7 @@ from docutils import nodes
|
||||
|
||||
import sphinx
|
||||
from sphinx import addnodes
|
||||
from sphinx.util import rst
|
||||
from sphinx.util.compat import Directive
|
||||
from sphinx.pycode import ModuleAnalyzer, PycodeError
|
||||
from sphinx.ext.autodoc import Options
|
||||
@ -367,7 +368,7 @@ class Autosummary(Directive):
|
||||
for name, sig, summary, real_name in items:
|
||||
qualifier = 'obj'
|
||||
if 'nosignatures' not in self.options:
|
||||
col1 = ':%s:`%s <%s>`\ %s' % (qualifier, name, real_name, sig)
|
||||
col1 = ':%s:`%s <%s>`\ %s' % (qualifier, name, real_name, rst.escape(sig))
|
||||
else:
|
||||
col1 = ':%s:`%s <%s>`' % (qualifier, name, real_name)
|
||||
col2 = summary
|
||||
|
18
sphinx/util/rst.py
Normal file
18
sphinx/util/rst.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
sphinx.util.rst
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
reST helper functions.
|
||||
|
||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
symbols_re = re.compile('([!-/:-@\[-`{-~])')
|
||||
|
||||
|
||||
def escape(text):
|
||||
return symbols_re.sub(r'\\\1', text)
|
@ -69,3 +69,7 @@ class C:
|
||||
'''
|
||||
This is a nested inner class docstring
|
||||
'''
|
||||
|
||||
|
||||
def func(arg_):
|
||||
"""Test function take an argument ended with underscore."""
|
||||
|
16
tests/test_util_rst.py
Normal file
16
tests/test_util_rst.py
Normal file
@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
test_util_rst
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Tests sphinx.util.rst functions.
|
||||
|
||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
from sphinx.util.rst import escape
|
||||
|
||||
|
||||
def test_escape():
|
||||
assert escape(':ref:`id`') == '\:ref\:\`id\`'
|
||||
assert escape('footnote [#]_') == 'footnote \[\#\]\_'
|
Loading…
Reference in New Issue
Block a user