Skip to content

Docs: Fix xarray Dataset double-rendering in MkDocs#100

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/improve-xarray-dataset-rendering
Draft

Docs: Fix xarray Dataset double-rendering in MkDocs#100
Copilot wants to merge 2 commits intomainfrom
copilot/improve-xarray-dataset-rendering

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

In the rendered docs, plan.open_dataset() output displayed both the plain-text fallback and the interactive HTML repr simultaneously (before, below):

Before: both text fallback and HTML repr visible

Root cause: xarray embeds a <style> block in its HTML repr to hide .xr-text-repr-fallback and show .xr-wrap. The MkDocs Material theme's <pre> rules have higher specificity than xarray's bare .xr-text-repr-fallback { display: none }, so the text fallback leaks through. The xr-wrap div shows correctly because xarray uses !important there, but not on the fallback.

Fixdocs/stylesheets/extra.css:

  • Add .md-content .xr-text-repr-fallback { display: none !important } to win the specificity battle against the Material theme's pre rules
  • Add .md-content .xr-wrap { display: block !important } as an explicit guard
  • Map --xr-* color variables to MkDocs Material equivalents (--md-default-fg-color, --md-code-bg-color, etc.) — xarray's CSS expects Jupyter's --jp-* variables which are absent in MkDocs, so without this the widget renders with incorrect colors in both light and dark mode

After the fix, only the interactive collapsible xarray widget is shown, matching the Jupyter notebook experience.

Original prompt

This section details on the original issue you should resolve

<issue_title>Docs: somthing wrong with rendering of xarray output</issue_title>
<issue_description>Task: Improve xarray Dataset rendering. Preferably how it looks in jupyter notebook

ds = plan.open_dataset(0)
ds

is outputing this. It is showing both print(ds) and a garbled html version of the xarray output

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: eeholmes <2545978+eeholmes@users.noreply.github.com>
Copilot AI changed the title [WIP] [DOCS-123] Improve xarray output rendering in Jupyter notebook Docs: Fix xarray Dataset double-rendering in MkDocs Mar 13, 2026
Copilot AI requested a review from eeholmes March 13, 2026 01:16
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.

Docs: somthing wrong with rendering of xarray output

2 participants