diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-03-23 00:21:04 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-03-23 12:40:14 +0000 |
commit | 3e7bee583604e3422c05f807a69d0a73afedfa59 (patch) | |
tree | c1382f471b2b2265ff3e225ccef55fe771d3aba2 /sphinx/apidoc.py | |
parent | 895014cd7168fdef9c3552c4a3bb818615a39fce (diff) | |
download | sphinx-git-3e7bee583604e3422c05f807a69d0a73afedfa59.tar.gz |
Fix issues with trailing underscores in heading names
Fixes #1451, using the approach in 8d96c90fc6ca7805ba7a8e8fd80cc74da7caf46c
Diffstat (limited to 'sphinx/apidoc.py')
-rw-r--r-- | sphinx/apidoc.py | 7 |
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 |