From bf9faa98f0cb64aa3536528231ad9a3f48e819ac Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 15 Dec 2017 21:15:39 -0800 Subject: [PATCH] Add titles_only option to the toc (#456) * Add titles_only option * Add titles_only to readme * Add titles_only to readme * Convert Strings to bool Fixes #312 --- README.rst | 2 ++ demo_docs/source/conf.py | 1 + sphinx_rtd_theme/layout.html | 5 ++++- sphinx_rtd_theme/theme.conf | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a661c6e7..be882b22 100644 --- a/README.rst +++ b/README.rst @@ -99,6 +99,7 @@ file of this repository, and can be defined in your project's ``conf.py`` via 'sticky_navigation': True, 'navigation_depth': 4, 'includehidden': True, + 'titles_only': False } The following options are available: @@ -124,6 +125,7 @@ These effect how we display the Table of Contents in the side bar. You can read * ``collapse_navigation`` With this enabled, you will lose the `[+]` drop downs next to each section in the sidebar. This is useful for _very large_ documents. * ``sticky_navigation`` This causes the sidebar to scroll with the main page content as you scroll the page. * ``includehidden`` Specifies if the sidebar includes toctrees marked with the `:hidden:` option +* ``titles_only`` If True, removes headers within a page from the sidebar. Page-level configuration ------------------------ diff --git a/demo_docs/source/conf.py b/demo_docs/source/conf.py index a9502bc1..e748895a 100644 --- a/demo_docs/source/conf.py +++ b/demo_docs/source/conf.py @@ -111,6 +111,7 @@ html_theme = 'sphinx_rtd_theme' html_theme_options = { # 'sticky_navigation': True # Set to False to disable the sticky nav while scrolling. # 'logo_only': True, # if we have a html_logo below, this shows /only/ the logo with no title text + # 'titles_only': False # If True, it'll remove headers within a page from the sidebar. } # Add any paths that contain custom themes here, relative to this directory. diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index f5979e2c..965cc45c 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -133,7 +133,10 @@ toctree is empty. Skip building this for now. #} {% if 'singlehtml' not in builder %} - {% set global_toc = toctree(maxdepth=theme_navigation_depth|int, collapse=theme_collapse_navigation, includehidden=theme_includehidden) %} + {% set global_toc = toctree(maxdepth=theme_navigation_depth|int, + collapse=theme_collapse_navigation|tobool, + includehidden=theme_includehidden|tobool, + titles_only=theme_titles_only|tobool) %} {% endif %} {% if global_toc %} {{ global_toc }} diff --git a/sphinx_rtd_theme/theme.conf b/sphinx_rtd_theme/theme.conf index 0bee2d55..47c4dae5 100644 --- a/sphinx_rtd_theme/theme.conf +++ b/sphinx_rtd_theme/theme.conf @@ -11,6 +11,7 @@ collapse_navigation = False sticky_navigation = True navigation_depth = 4 includehidden = True +titles_only = logo_only = display_version = True prev_next_buttons_location = bottom