Skip to content
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

Merged
merged 7 commits into from
Dec 16, 2017
Merged

Conversation

pcvonz
Copy link
Contributor

@pcvonz pcvonz commented Sep 1, 2017

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

@@ -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) %}
Copy link
Contributor

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.

@@ -12,3 +12,4 @@ display_version = True
navigation_depth = 4
prev_next_buttons_location = bottom
canonical_url =
titles_only = True
Copy link
Contributor

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?

Copy link
Contributor Author

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.

See here: https://github.com/sphinx-doc/sphinx/blob/cb0220de1a0d8acd00292b898d2ef03b588179b0/sphinx/environment/adapters/toctree.py#L180

The True / False setting in conf.py works because those are actually read in as booleans.

@pcvonz
Copy link
Contributor Author

pcvonz commented Sep 1, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants