summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/config.rst6
-rw-r--r--sphinx/builders/epub.py2
-rw-r--r--sphinx/config.py1
-rw-r--r--sphinx/quickstart.py3
4 files changed, 12 insertions, 0 deletions
diff --git a/doc/config.rst b/doc/config.rst
index e4693d84..50aacc4e 100644
--- a/doc/config.rst
+++ b/doc/config.rst
@@ -701,6 +701,12 @@ the `Dublin Core metadata <http://dublincore.org/>`_.
A list of files that are generated/copied in the build directory but should
not be included in the epub file. The default value is ``[]``.
+.. confval:: epub_tocdepth
+
+ The depth of the table of contents in the file :file:`toc.ncx`. It should
+ be an integer greater than zero. The default value is 3. Note: A deeply
+ nested table of contents may be difficult to navigate.
+
.. _latex-options:
diff --git a/sphinx/builders/epub.py b/sphinx/builders/epub.py
index e78f807e..0e4529e5 100644
--- a/sphinx/builders/epub.py
+++ b/sphinx/builders/epub.py
@@ -355,6 +355,8 @@ class EpubBuilder(StandaloneHTMLBuilder):
file = node['refuri'].split('#')[0]
if file in self.ignored_files:
continue
+ if node['level'] > self.config.epub_tocdepth:
+ continue
if node['level'] == level:
navlist.append(self.new_navpoint(node, level))
elif node['level'] == level + 1:
diff --git a/sphinx/config.py b/sphinx/config.py
index 5fe3f63f..e7e05169 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -112,6 +112,7 @@ class Config(object):
epub_pre_files = ([], 'env'),
epub_post_files = ([], 'env'),
epub_exclude_files = ([], 'env'),
+ epub_tocdepth = (3, 'env'),
# LaTeX options
latex_documents = ([], None),
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index faea2c2e..a7b80dd5 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -254,6 +254,9 @@ latex_documents = [
# A list of files that should not be packed into the epub file.
#epub_exclude_files = []
+
+# The depth of the table of contents in toc.ncx.
+#epub_tocdepth = 3
'''
INTERSPHINX_CONFIG = '''