mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3952: apidoc: module header is too escaped
This commit is contained in:
parent
01caa52355
commit
321b3d49cb
1
CHANGES
1
CHANGES
@ -26,6 +26,7 @@ Bugs fixed
|
|||||||
* #4472: DOCUMENTATION_OPTIONS is not defined
|
* #4472: DOCUMENTATION_OPTIONS is not defined
|
||||||
* #4491: autodoc: prefer _MockImporter over other importers in sys.meta_path
|
* #4491: autodoc: prefer _MockImporter over other importers in sys.meta_path
|
||||||
* #4490: autodoc: type annotation is broken with python 3.7.0a4+
|
* #4490: autodoc: type annotation is broken with python 3.7.0a4+
|
||||||
|
* #3952: apidoc: module header is too escaped
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -23,13 +23,15 @@ if False:
|
|||||||
# For type annotation
|
# For type annotation
|
||||||
from typing import Generator # NOQA
|
from typing import Generator # NOQA
|
||||||
|
|
||||||
symbols_re = re.compile(r'([!-/:-@\[-`{-~])')
|
symbols_re = re.compile(r'([!--/:-@\[-`{-~])') # symbols without dot(0x2e)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def escape(text):
|
def escape(text):
|
||||||
# type: (unicode) -> unicode
|
# 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
|
@contextmanager
|
||||||
|
@ -14,3 +14,5 @@ from sphinx.util.rst import escape
|
|||||||
def test_escape():
|
def test_escape():
|
||||||
assert escape(':ref:`id`') == r'\:ref\:\`id\`'
|
assert escape(':ref:`id`') == r'\:ref\:\`id\`'
|
||||||
assert escape('footnote [#]_') == r'footnote \[\#\]\_'
|
assert escape('footnote [#]_') == r'footnote \[\#\]\_'
|
||||||
|
assert escape('sphinx.application') == r'sphinx.application'
|
||||||
|
assert escape('.. toctree::') == r'\.. toctree\:\:'
|
||||||
|
Loading…
Reference in New Issue
Block a user