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

ENH: adding sphinx sidebars functionality #248

Merged
merged 6 commits into from
Sep 29, 2020

Conversation

choldgraf
Copy link
Collaborator

@choldgraf choldgraf commented Sep 11, 2020

Apparently I had time to figure this out after all :-)

This PR makes this theme use the html_sidebars functionality of Sphinx. The default behavior is the same, but now if users modify html_sidebars, then the results will show up in their site.

closes #244 (and maybe addresses some of the other sidebar issues?)

I'm pretty sure the failing test is the same jupyter-sphinx bug @jorisvandenbossche mentioned elsewhere

and see here for a page where I added a custom sidebar! https://pydata-sphinx-theme--248.org.readthedocs.build/en/248/contributing.html

@choldgraf
Copy link
Collaborator Author

ping to @jorisvandenbossche - let me know if you want me to self-merge this kinda thing but I feel like it's good practice to have at least another pair of 👀 on things...

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for figuring this out. It's indeed good to follow a bit more sphinx' templating capabilties


``pydata_sphinx_theme`` provides two new sidebar items by default:

- ``nav-bs.html`` - a bootstrap-friendly navigation section
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can use some more clear name like sidebar-nav ? (Because "nav" could also be about the navbar)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "bs" is for bootstrap I suppose? (in my head it's "boots-trap", but I realize now that is wrong :-))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I figured the bs- makes sense just to make it clear that it's a theme-specific thing. I guess we could also use pydata-sidebar-nav or something? Though if you're fine with bs- I'd probably just stick with that...

Copy link
Collaborator Author

@choldgraf choldgraf Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would you like me to do here? do you prefer a re-name? Are you 👍 on sidebar-nav-bs?

Copy link
Collaborator Author

@choldgraf choldgraf Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to sidebar-nav-bs and the search one to sidebar-search-bs in case that's what you wanted, LMK if you prefer something different

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's not be too picky about the names;)

# Update templates for sidebar
pkgdir = os.path.abspath(os.path.dirname(__file__))
path_templates = os.path.join(pkgdir, "_templates")
app.config.templates_path.append(path_templates)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering about this one: is there some documentation in sphinx that this is the recommended way to add custom templates as a package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, well it's documented in a way that suggests you could add to it to increase the search scope for templates: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-templates_path

and it seems this is how Sphinx adds templates in its own codebase, e.g.: https://github.com/sphinx-doc/sphinx/blob/cc25bac26445688c50efb9b8d5f30571940e27bd/sphinx/ext/autosummary/generate.py#L644

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's how they do it for the built-in extensions, that's certainly fine!

@jorisvandenbossche jorisvandenbossche changed the title adding sphinx sidebars functionality ENH: adding sphinx sidebars functionality Sep 26, 2020
@jorisvandenbossche
Copy link
Member

@choldgraf can you merge master or rebase, seems to be a conflict with theme.conf

@choldgraf
Copy link
Collaborator Author

done! let's see if tests pass

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a small fixup, now it's green!

@jorisvandenbossche jorisvandenbossche merged commit bdf8224 into pydata:master Sep 29, 2020
Vinnl added a commit to inrupt/solid-client-js that referenced this pull request Oct 12, 2020
See pydata/pydata-sphinx-theme#248

Co-authored-by: Kay Kim <kay.kim@inrupt.com>
Vinnl added a commit to inrupt/solid-client-js that referenced this pull request Oct 12, 2020
See pydata/pydata-sphinx-theme#248

Co-authored-by: Kay Kim <kay.kim@inrupt.com>
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.

Use the Sphinx sidebars function
2 participants