-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add titles_only option to the toc #456
Conversation
sphinx_rtd_theme/layout.html
Outdated
@@ -131,7 +131,7 @@ | |||
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=True) %} | |||
{% set global_toc = toctree(maxdepth=theme_navigation_depth|int, collapse=theme_collapse_navigation, includehidden=True, titles_only=theme_titles_only) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the two-space indentation was mistakenly removed here.
sphinx_rtd_theme/theme.conf
Outdated
@@ -12,3 +12,4 @@ display_version = True | |||
navigation_depth = 4 | |||
prev_next_buttons_location = bottom | |||
canonical_url = | |||
titles_only = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the default value should likely be kept to False
as it used to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I looked into this and that option is being read in as a string. So, it doesn't matter if you put "True" or "False", it'll still read True since they're both strings. An empty string will register as False though.
The True / False setting in conf.py works because those are actually read in as booleans.
I did some digging and found that the way the config parser in sphinx work is based on strings, booleans don't regsiter. From what I understand, all the boolean values in the theme.conf file that are set to a value are going to be interpreted as True. Only an empty value (empty string) returns False. So, the titles_only option I've added in the theme.conf file wont interfere with the current style since by default it is set to an empty string. All the other values that are set to False in the theme.conf file I believe are actually True. |
I believe this fixes issue: #312
It makes it so the table of contents only generates entries for the titles, instead of each heading within a page. From the sphinx doc: "If you want only the titles of documents in the tree to show up, not other headings of the same level, you can use the titlesonly option:"[1]
[1] Sphinx doc on toctree directive