-
Notifications
You must be signed in to change notification settings - Fork 329
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
maybe fix missing sidebar? #1632
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,11 +35,14 @@ | |
def get_unrendered_local_toctree( | ||
app: Sphinx, pagename: str, startdepth: int, collapse: bool = True, **kwargs | ||
): | ||
""".""" | ||
if "includehidden" not in kwargs: | ||
kwargs["includehidden"] = False | ||
"""Get the "local" (starting at `startdepth`) TOC tree containing the current page. | ||
|
||
This is similar to `context["toctree"](**kwargs)` in sphinx templating, | ||
but using the startdepth-local instead of global TOC tree. | ||
""" | ||
kwargs.setdefault("includehidden", True) | ||
if kwargs.get("maxdepth") == "": | ||
kwargs.pop("maxdepth") | ||
|
||
toctree = TocTree(app.env) | ||
if sphinx.version_info[:2] >= (7, 2): | ||
|
@@ -47,7 +50,7 @@ | |
|
||
ancestors = [*_get_toctree_ancestors(app.env.toctree_includes, pagename)] | ||
else: | ||
ancestors = toctree.get_toctree_ancestors(pagename) | ||
try: | ||
indexname = ancestors[-startdepth] | ||
except IndexError: | ||
|
@@ -457,12 +460,10 @@ | |
doctree = self.env.tocs[indexname].deepcopy() | ||
|
||
toctrees = [] | ||
if "includehidden" not in kwargs: | ||
kwargs["includehidden"] = True | ||
kwargs.setdefault("includehidden", True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unrelated simplification that I noticed in passing |
||
if "maxdepth" not in kwargs or not kwargs["maxdepth"]: | ||
kwargs["maxdepth"] = 0 | ||
else: | ||
kwargs["maxdepth"] = int(kwargs["maxdepth"]) | ||
kwargs["maxdepth"] = int(kwargs["maxdepth"]) | ||
drammock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kwargs["collapse"] = collapse | ||
|
||
# TODO: use `doctree.findall(addnodes.toctree)` once docutils min version >=0.18.1 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is the key change. it was copy/pasted from its old place within
index_toctree
in #1609 and I don't really know why it was previously settingFalse
as the default. I'm not even sure that we should be forcing it here; it might be better to leave it unset (or better yet: to use the theme settingsidebar_includehidden
)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.
My feeling is that
includehidden
is sensible to default to True, so I'm +1 on this. A common use-case is to usehidden
to not show the TOCtree on the page but people do want it in the sidebar.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.
Yes but see #1551
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.
That just means we need it to be possible to not include them, but doesn't change your opinion that the default should be to show them, right?
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.
Agreed the default behviour is to include them in all the other theme I know so Users (and us) would be surprised not to see the complete toctree in the sidebar (again by default)
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.
Yes. But that means we need to use
theme_sidebar_includehidden
somewhere where is currently not being used, so that it ends up in these kwargs. I think it will work to do that inlayout.html
as in the linked PR but I haven't had time to do thorough testing/debugging yet.But it's helpful to know that this fixes things for @lwasser --- it means we're on the right track