diff --git a/doc/config.rst b/doc/config.rst index 92b53c058..35f8855ac 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -916,6 +916,15 @@ the `Dublin Core metadata `_. a chapter, but can be confusing because it mixes entries of differnet depth in one list. The default value is ``True``. +.. confval:: epub_tocscope + + This setting control the scope of the epub table of contents. The setting + can have the following values: + + * ``'default'`` -- include all toc entries that are not hidden (default) + * ``'includehidden'`` -- include all toc entries + + .. versionadded:: 1.2 .. confval:: epub_fix_images diff --git a/sphinx/builders/epub.py b/sphinx/builders/epub.py index c2d8c9ce7..6f8d9dae6 100644 --- a/sphinx/builders/epub.py +++ b/sphinx/builders/epub.py @@ -642,12 +642,13 @@ class EpubBuilder(StandaloneHTMLBuilder): """Write the metainfo file toc.ncx.""" self.info('writing %s file...' % outname) - doctree = self.env.get_and_resolve_doctree(self.config.master_doc, - self, prune_toctrees=False, includehidden=False) - refnodes = self.get_refnodes(doctree, []) - if refnodes: + if self.config.epub_tocscope == 'default': + doctree = self.env.get_and_resolve_doctree(self.config.master_doc, + self, prune_toctrees=False, includehidden=False) + refnodes = self.get_refnodes(doctree, []) self.toc_add_files(refnodes) else: + # 'includehidden' refnodes = self.refnodes navpoints = self.build_navpoints(refnodes) level = max(item['level'] for item in self.refnodes) diff --git a/sphinx/config.py b/sphinx/config.py index 496ce77f0..a59012117 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -140,6 +140,7 @@ class Config(object): epub_exclude_files = ([], 'env'), epub_tocdepth = (3, 'env'), epub_tocdup = (True, 'env'), + epub_tocscope = ('default', 'env'), epub_fix_images = (False, 'env'), epub_max_image_width = (0, 'env'), epub_show_urls = ('inline', 'html'), diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index bfc6d723b..369197675 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -335,6 +335,9 @@ epub_copyright = u'%(copyright_str)s' # Allow duplicate toc entries. #epub_tocdup = True +# Choose between 'default' and 'includehidden'. +#epub_tocscope = 'default' + # Fix unsupported image types using the PIL. #epub_fix_images = False