Fix #3952: apidoc: module header is too escaped

This commit is contained in:
Takeshi KOMIYA 2018-01-28 18:58:58 +09:00
parent 01caa52355
commit 321b3d49cb
3 changed files with 7 additions and 2 deletions

View File

@ -26,6 +26,7 @@ Bugs fixed
* #4472: DOCUMENTATION_OPTIONS is not defined
* #4491: autodoc: prefer _MockImporter over other importers in sys.meta_path
* #4490: autodoc: type annotation is broken with python 3.7.0a4+
* #3952: apidoc: module header is too escaped
Testing
--------

View File

@ -23,13 +23,15 @@ if False:
# For type annotation
from typing import Generator # NOQA
symbols_re = re.compile(r'([!-/:-@\[-`{-~])')
symbols_re = re.compile(r'([!--/:-@\[-`{-~])') # symbols without dot(0x2e)
logger = logging.getLogger(__name__)
def escape(text):
# type: (unicode) -> unicode
return symbols_re.sub(r'\\\1', text) # type: ignore
text = symbols_re.sub(r'\\\1', text) # type: ignore
text = re.sub(r'^\.', r'\.', text) # escape a dot at top
return text
@contextmanager

View File

@ -14,3 +14,5 @@ from sphinx.util.rst import escape
def test_escape():
assert escape(':ref:`id`') == r'\:ref\:\`id\`'
assert escape('footnote [#]_') == r'footnote \[\#\]\_'
assert escape('sphinx.application') == r'sphinx.application'
assert escape('.. toctree::') == r'\.. toctree\:\:'