summaryrefslogtreecommitdiff
path: root/sphinx/apidoc.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-03-26 11:52:15 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2017-03-26 11:52:15 +0900
commit8f9dd6499207be2f3291a0982ed02e418730ef5e (patch)
treef24c345eac1c6d9e0f7e5e1f1c7e7fe10c1fd411 /sphinx/apidoc.py
parentd53204aa46712983c90313b071602cf48b79e679 (diff)
parentc57e47e0424be5d742ee6d5daf913274c6da069f (diff)
downloadsphinx-git-8f9dd6499207be2f3291a0982ed02e418730ef5e.tar.gz
Merge branch 'stable'
Diffstat (limited to 'sphinx/apidoc.py')
-rw-r--r--sphinx/apidoc.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py
index 4533e5103..24ed874b0 100644
--- a/sphinx/apidoc.py
+++ b/sphinx/apidoc.py
@@ -11,7 +11,7 @@
Copyright 2008 Société des arts technologiques (SAT),
http://www.sat.qc.ca/
- :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
@@ -23,9 +23,10 @@ from os import path
from six import binary_type
from fnmatch import fnmatch
-from sphinx.util.osutil import FileAvoidWrite, walk
from sphinx import __display_version__
from sphinx.quickstart import EXTENSIONS
+from sphinx.util import rst
+from sphinx.util.osutil import FileAvoidWrite, walk
if False:
# For type annotation
@@ -74,9 +75,11 @@ def write_file(name, text, opts):
f.write(text)
-def format_heading(level, text):
- # type: (int, unicode) -> unicode
+def format_heading(level, text, escape=True):
+ # type: (int, unicode, bool) -> unicode
"""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)
@@ -161,7 +164,7 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs, is_
def create_modules_toc_file(modules, opts, name='modules'):
# type: (List[unicode], Any, unicode) -> None
"""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