Skip to content

Switch documentation to pydata-sphinx-theme #8708

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

Merged
merged 13 commits into from
Apr 26, 2025

Conversation

TomNicholas
Copy link
Member

@TomNicholas TomNicholas commented Feb 5, 2024

How might we want to move headers/sections around to take advantage of now having a navigation bar at the top? Adding an explicit link to the tutorial.xarray.dev site would be good.

PR Docs Preview Link for convenience: https://xray--8708.org.readthedocs.build/en/8708/

@TomNicholas
Copy link
Member Author

Docs build failed because we fail on warnings:

preparing documents... WARNING: unsupported theme option 'repository_url' given
WARNING: unsupported theme option 'repository_branch' given
WARNING: unsupported theme option 'path_to_docs' given
WARNING: unsupported theme option 'use_repository_button' given
WARNING: unsupported theme option 'use_issues_button' given
WARNING: unsupported theme option 'home_page_in_toc' given
WARNING: unsupported theme option 'extra_footer' given

@scottyhq
Copy link
Contributor

I just came across this trying to sort out #10223! Experimenting locally, that issue seems fixed by simply gutting the custom style file https://github.com/pydata/xarray/blob/main/doc/_static/style.css in favor of relying on newer theme defaults

However, it seems probably a good time to also update the theme since executable_book_theme is not seeing as much development (xref https://executablebooks.org/en/latest/blog/2024-05-20-jupyter-book-myst/#what-this-means-for-jupyter-book-v1-users) as pydata_sphinx_theme (which it explicitly pins):
https://github.com/executablebooks/sphinx-book-theme/blob/23f6936ae956428463f2ec97eebc2fe68bdd344b/pyproject.toml#L40

Ok if I just take over this PR? Or should I start a fresh one?

@TomNicholas
Copy link
Member Author

Do as you see fit @scottyhq !

FYI I think there are other discussion about the much more radical idea of using MyST for the docs. But that would be a big project...

@github-actions github-actions bot added CI Continuous Integration tools dependencies Pull requests that update a dependency file labels Apr 21, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe most of this is making adjustments to the previous theme, and I found that simply removing most of it does fix #10223 (the issue of strange sidebar behavior with varying theme size). You can see that is remedied by making this browser window narrower https://xray--8708.org.readthedocs.build/en/8708/getting-started-guide/quick-overview.html

@@ -37,119 +37,119 @@

def _dsplot(plotfunc):
commondoc = """
Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

Took me an annoying long time to figure out that decreasing the indention on these solved the following sphinx/autodoc warnings:

/Users/scotthenderson/GitHub/xarray/xarray/xarray/plot/accessor.py:docstring of xarray.plot.accessor.DatasetPlotAccessor.quiver:7: CRITICAL: Unexpected section title.

Parameters
----------
xarray/plot/accessor.py:docstring of xarray.plot.accessor.DatasetPlotAccessor.quiver:11: ERROR: Unexpected indentation.
xarray/plot/accessor.py:docstring of xarray.plot.accessor.DatasetPlotAccessor.quiver:12: WARNING: Block quote ends without a blank line; unexpected unindent.
xarray/plot/accessor.py:docstring of xarray.plot.accessor.DatasetPlotAccessor.quiver:117: WARNING: Inline strong start-string without end-string.

@scottyhq
Copy link
Contributor

scottyhq commented Apr 21, 2025

OK, RTD is happy and I think this is looking pretty good. Would be great for others to review the preview, given the look and feel is different, albeit pretty similar to the past!

https://xray--8708.org.readthedocs.build/en/8708/

How might we want to move headers/sections around to take advantage of now having a navigation bar at the top?

I didn't adjust this, and it is a fairly significant change. (Edit: now modified). There is no longer a left-side primary sidebar with categorized sections on the landing page, instead currently all the TOC links listed in the index end up in the top bar https://github.com/pydata/xarray/blob/main/doc/index.rst. It is possible to configure how many links are on the top bar before the 'More' dropdown https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/header-links.html#navigation-bar-dropdown-links

@scottyhq scottyhq requested review from dcherian and keewis April 21, 2025 12:39
@dcherian
Copy link
Contributor

Very nice! Thanks @scottyhq

The API reference navigation is a weird: https://xray--8708.org.readthedocs.build/en/8708/api.html . Seems like what's on the right should be on the left.

@dcherian
Copy link
Contributor

This is also probably a good time to change the top-level "tutorials link" to link to https://tutorial.xarray.dev

@scottyhq
Copy link
Contributor

scottyhq commented Apr 21, 2025

The API reference navigation is a weird: https://xray--8708.org.readthedocs.build/en/8708/api.html . Seems like what's on the right should be on the left.

I thought that initially too. But it's essentially how the current docs are structured (https://docs.xarray.dev/en/v2025.03.1/api.html), it's just that the current docs have the persistent left-hand sidebar to navigate the entire site.

Seems possible to do more "section" subdivisions though to accomplish this, for example, see the Pandas API landing page:
https://pandas.pydata.org/docs/reference/index.html

@scottyhq
Copy link
Contributor

scottyhq commented Apr 21, 2025

How might we want to move headers/sections around to take advantage of now having a navigation bar at the top?

I wanted to add a bit more discussion and a concrete proposal for this. I think given the restructured theme it would be good to tweak the existing structure before merging this (just re-organize, not rewriting). To begin, here is a quick survey of "top bars":

Pandas:

Getting started - User Guide - API reference - Development - Release notes

Scipy:

Installing - User Guide - API reference - Building from source - Development - Release notes

Numpy:

User Guide - API reference - Building from source - Development - Release notes - Learn

More.. NEPS

Scikit-learn:

Install - User Guide - API - Examples - Community

More… getting_started - whats_new - Glossary - Development - FAQ - support - related_projects - roadmap - Governance - about

matplotlib:

Plot types - User guide - Tutorials - Examples - Reference - Contribute

Xarray this PR:

Getting Started - User Guide - Gallery - Tutorials & Videos - API Reference

More.. How do I .. - Getting Help - Ecosystem - Contributing Guide - Xarray Internals - Development Roadmap - Team - Developers Meeting - What’s New - GitHub repository - GitHub discussions - StackOverflow


Proposal: Keep 4-6 main categories only in top bar, move the rest under respective sections:

Getting Started - User Guide - API Reference - Developer Guide

Developer Guide -> Contributing Guide, Xarray Internals, Development Roadmap, Developers Meeting, Team, What’s New

User Guide -> Gallery, Tutorials & Videos, How do I…, Getting Help, Ecosystem, Discussions, StackOverflow

After writing this out I thought it could be nice to keep the ‘Gallery’ and ‘Getting Help’ as their own sections in the top bar… Obviously many ways to do it, but I think keeping the main sections to a minimum (<6) is appealing. Thoughts? Also pinging @andrewendlinger because I saw you had some nice suggestions in #10236 and your perspective would be appreciated!

@dcherian
Copy link
Contributor

I like your "Developer Guide" top-level though perhaps call it "Contribute" (low-confidence suggestion).

Getting Help - How do I - GitHub repository - GitHub discussions - StackOverflow

These could be under the "Getting Help" (or even "Help") top-level heading (which is currently just one page. I think it's nice to surface this as top-level instead of expecting people to click in to User Guide to find it.

@andrewendlinger
Copy link
Contributor

Thanks for including me :) The new structure design is great!

I agree, the current pile up inside "More" is probably too much / redundant.

Also, since the Tutorials website is so neat, I would keep it at the top for a dedicated shout out.

So something like that?


Getting Started User Guide Tutorials Gallery API Reference Contribute
  • Getting Started

    • Overview: Why xarray?
    • Installation
    • xarray Quick Start (former 'quick overview')
    • Getting Started Tutorials (links to tutorials)
    • Getting Help
      • Getting Help
      • FAQ
      • Community (stackoverflow, discussions etc.)
  • User Guide

  • Tutorials

  • Gallery

  • API Reference

  • Contribute

    • Contributing Guide
    • Xarray Internals
    • Development Roadmap
    • Developers Meeting
    • Team
    • What’s New

Btw, https://matplotlib.org also has a nice structure.

.. ipython:: python
.. jupyter-execute::
Copy link
Contributor

Choose a reason for hiding this comment

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

It was really quite straightforward to do this, and the resulting quickstart page in my opinion looks a lot more inviting for new users! I'd be happy to fully convert the other docs in a separate PR if people like it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The html output instead of the raw string is amazing!

@scottyhq scottyhq requested a review from benbovy April 24, 2025 19:23
@benbovy
Copy link
Member

benbovy commented Apr 25, 2025

I haven't been looking at the changes here in depth, but from quick inspection of the rendered docs this looks great! (at least in light mode for now).

Two comments:

  • The release notes (what's new) page is hardly reachable / discoverable via "Contribute". In all other projects referenced above (pandas, numpy, scipy and matplotlib) there's a direct link in the top bar of their documentation.

  • It's out of scope of this PR and may be addressed later, but IMO the "Contribute > Xarray internals" section could be reworked as currently it looks a bit like a catch-all section. More specifically, the pages about extending Xarray (accessors, IO backends, indexes...) could be more visible too. Perhaps move these into a new "Advanced Guide" or "Extending Xarray" top-level section? Technically those pages can be viewed as "contributing" to the Xarray ecosystem, but I rather view the "Contribute" section (and "Xarray internals") as helping to contribute to Xarray itself.

@benbovy
Copy link
Member

benbovy commented Apr 25, 2025

The only social link shown in the top bar is twitter. I'd be in favor of either add other social links like https://bsky.app/profile/xarray.bsky.social (maybe the Xarray-dev Discord server as well?) there, or only keep the github link to avoid cluttering the top bar (and add all social links elsewhere).

@scottyhq
Copy link
Contributor

scottyhq commented Apr 25, 2025

The release notes (what's new) page is hardly reachable / discoverable via "Contribute".

I agree that often-visited pages should be easy to reach! In general I think it's good to mimic but not copy the other major libraries. I view the top bar more as 'category' subsections each having many pages, rather than links to a specific page.W
While I don't have a strong preference either way, what about putting a link in the 'Useful links' instead? Could probably remove 'Mailing List' there as it's not really used much anymore? (Also the top bar collapses on small screens):
Screenshot 2025-04-25 at 10 28 12

It's out of scope of this PR and may be addressed later, but IMO the "Contribute > Xarray internals" section could be reworked as currently it looks a bit like a catch-all section.

Agreed! I'd be happy to tackle more re-org to that section as well as the API section as separate stand-alone PRs. I found that I was needing to restrain myself from too many changes... it's easy to get a bit carried away with a docs refresh :)

I'd be in favor of either add other social links like https://bsky.app/profile/xarray.bsky.social (maybe the Xarray-dev Discord server as well?) there, or only keep the github link to avoid cluttering the top bar (and add all social links elsewhere).

Yeah, I don't use these much, so am in favor of just the GitHub link

@benbovy
Copy link
Member

benbovy commented Apr 25, 2025

Personally it often frustrates me when I can't quickly navigate to the release notes of any library in general, but I'm curious about others opinion on this! From what I see, the "release notes" page often gets special treatment at the same level as the top-level categories (for a good reason IMO). It could be linked as well in "Useful Links" (duplicate links are good), or like in astropy right next to the version number.

@scottyhq
Copy link
Contributor

From what I see, the "release notes" page often gets special treatment at the same level as the top-level categories (for a good reason IMO). It could be linked as well in "Useful Links" (duplicate links are good), or like in astropy right next to the version number.

Sounds good. Also, I liked the astropy approach of linking next to the version number! So I changed both and added a separate social media page. I'm pretty happy with this as-is now, but of course open to other modifications. After merging this one I think it'd be great to improve upon different sections one at a time (@andrewendlinger, I did not implement all your suggestions, but I think they are great so a separate PR would be very welcome).

Copy link
Contributor

@dcherian dcherian left a comment

Choose a reason for hiding this comment

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

This is a great step forward!

@scottyhq scottyhq changed the title Try pydata-sphinx-theme in docs Switch documentation to pydata-sphinx-theme Apr 25, 2025
@dcherian dcherian enabled auto-merge (squash) April 26, 2025 17:06
@dcherian dcherian merged commit 7426ce7 into pydata:main Apr 26, 2025
32 checks passed
dcherian added a commit that referenced this pull request Apr 27, 2025
* main: (76 commits)
  Update how-to-add-new-backend.rst (#10240)
  Support extension array indexes (#9671)
  Switch documentation to pydata-sphinx-theme (#8708)
  Bump codecov/codecov-action from 5.4.0 to 5.4.2 in the actions group (#10239)
  Fix mypy, min-versions CI, xfail Zarr tests (#10255)
  Remove `test_dask_layers_and_dependencies` (#10242)
  Fix: Docs generation create temporary files that are not cleaned up. (#10238)
  opendap / dap4 support for pydap backend (#10182)
  Add RangeIndex (#10076)
  Fix mypy (#10232)
  Fix doctests (#10230)
  Fix broken Sphinx Roles (#10225)
  `DatasetView.map` fix `keep_attrs` (#10219)
  Add datatree repr asv (#10214)
  CI: Automatic PR labelling is back (#10201)
  Fixes dimension order in `xarray.Dataset.to_stacked_array` (#10205)
  Fix references to core classes in docs (#10207)
  Update pre-commit hooks (#10208)
  add `scipy-stubs` as extra `[types]` dependency (#10202)
  Fix sparse dask repr test (#10200)
  ...
dcherian added a commit to dcherian/xarray that referenced this pull request Apr 29, 2025
* main:
  Fix convert calendar on non-temporal data in datasets (pydata#10268)
  BinGrouper: reduce indirection (pydata#10270)
  Fix reduction by subset of grouper dimensions (pydata#10258)
  Shorten text repr for ``DataTree`` (pydata#10139)
  Fix benchmarks runners (pydata#10265)
  Fix infinite recursion when calling `np.fix` (pydata#10248)
  BinGrouper: Support setting labels when provided with IntervalIndex (pydata#10259)
  Avoid stacking when grouping by chunked array (pydata#10254)
  Improve alignment checks (pydata#10251)
  Update how-to-add-new-backend.rst (pydata#10240)
  Support extension array indexes (pydata#9671)
  Switch documentation to pydata-sphinx-theme (pydata#8708)
  Bump codecov/codecov-action from 5.4.0 to 5.4.2 in the actions group (pydata#10239)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration tools dependencies Pull requests that update a dependency file topic-documentation topic-plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why did you go to the sphinx-book-theme instead of the pydata-sphinx-theme ?
5 participants