summaryrefslogtreecommitdiff
path: root/sphinx/apidoc.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-03-25 22:16:42 +0900
committerGitHub <noreply@github.com>2017-03-25 22:16:42 +0900
commita92f40673934521bfbffc76f905f93b4caf45907 (patch)
treee49ef5dabec18c0799dec07e1de42ee11379039e /sphinx/apidoc.py
parent895014cd7168fdef9c3552c4a3bb818615a39fce (diff)
parenta7397a21fe2079ae2727ac987221d015b424c38a (diff)
downloadsphinx-git-a92f40673934521bfbffc76f905f93b4caf45907.tar.gz
Merge pull request #3581 from eric-wieser/patch-1
Fix issues with trailing underscores in heading names
Diffstat (limited to 'sphinx/apidoc.py')
-rw-r--r--sphinx/apidoc.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py
index 19a711370..a8e819acd 100644
--- a/sphinx/apidoc.py
+++ b/sphinx/apidoc.py
@@ -25,6 +25,7 @@ from fnmatch import fnmatch
from sphinx.util.osutil import FileAvoidWrite, walk
from sphinx import __display_version__
+from sphinx.util import rst
# automodule options
if 'SPHINX_APIDOC_OPTIONS' in os.environ:
@@ -67,8 +68,10 @@ def write_file(name, text, opts):
f.write(text)
-def format_heading(level, text):
+def format_heading(level, text, escape=True):
"""Create a heading of <level> [1, 2 or 3 supported]."""
+ if escape:
+ text = rst.escape(text)
underlining = ['=', '-', '~', ][level - 1] * len(text)
return '%s\n%s\n\n' % (text, underlining)
@@ -149,7 +152,7 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs, is_
def create_modules_toc_file(modules, opts, name='modules'):
"""Create the module's index."""
- text = format_heading(1, '%s' % opts.header)
+ text = format_heading(1, '%s' % opts.header, escape=False)
text += '.. toctree::\n'
text += ' :maxdepth: %s\n\n' % opts.maxdepth