diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4bd0ee0c8e..063bef8184 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,12 @@ name: continuous-integration -on: [push, pull_request] +# This prevents workflows from being run twice on PRs +# ref: https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662 +on: + push: + branches: + - main + pull_request: env: COVERAGE_THRESHOLD: 60 diff --git a/docs/conf.py b/docs/conf.py index e3ffb30321..d6c6008ebf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,6 +16,7 @@ "jupyter_sphinx", "matplotlib.sphinxext.plot_directive", "myst_nb", + # "nbsphinx", # Uncomment and comment-out MyST-NB for local testing purposes. "numpydoc", "sphinx.ext.autodoc", "sphinx.ext.autosummary", @@ -126,7 +127,6 @@ html_sidebars = { "contribute/index": [ - "search-field", "sidebar-nav-bs", "custom-template", ], # This ensures we test for custom sidebars diff --git a/docs/demo/index.rst b/docs/demo/index.rst index 0c64a810d6..04863f9e27 100644 --- a/docs/demo/index.rst +++ b/docs/demo/index.rst @@ -23,10 +23,12 @@ See the sections to the left and below to explore. api +.. Note: the caption below is intentionally long in order to test out what long captions look like. + .. toctree:: :maxdepth: 3 :numbered: - :caption: Reference and test section. This section has headers and examples that are meant for theme developers to test functionality, like this long caption header to test its behavior. + :caption: Reference and test section. Mostly meant for developers to check that things look OK. no-sidebar mult_headers diff --git a/docs/demo/pydata.md b/docs/demo/pydata.md index a11d977762..6a90576d73 100644 --- a/docs/demo/pydata.md +++ b/docs/demo/pydata.md @@ -2,8 +2,16 @@ file_format: mystnb kernelspec: name: python3 + display_name: Python 3 --- +% To test this file with nbsphinx we need to convert to ipynb. To do this: +% - Run this command: jupytext docs/demo/pydata.md --to ipynb +% - _Temporarily_ delete the pydata.md file +% - Uncomment `nbsphinx` and comment `myst_nb` in "extensions" in our conf.py file +% - Build the docs and test that the results look OK +% - Undo everything in this list to make sure we revert back to the old structure + # PyData Library Styles This theme has built-in support and special styling for several major visualization libraries in the PyData ecosystem. diff --git a/pyproject.toml b/pyproject.toml index 1d0f3d6c0c..c53f8741cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,10 @@ doc = [ "matplotlib", "numpy", "xarray", - "sphinx-design" + "sphinx-design", + # Install nbsphinx in case we want to test it locally even though we can't load + # it at the same time as MyST-NB. + "nbsphinx" ] test = [ "pytest", diff --git a/src/pydata_sphinx_theme/assets/styles/extensions/_execution.scss b/src/pydata_sphinx_theme/assets/styles/extensions/_execution.scss index 14e39569f8..19f5226969 100644 --- a/src/pydata_sphinx_theme/assets/styles/extensions/_execution.scss +++ b/src/pydata_sphinx_theme/assets/styles/extensions/_execution.scss @@ -6,36 +6,50 @@ * In the future, we might add dark theme support for specific packages. */ +// Set background of some cell outputs to white-ish to make sure colors work +// This is because many libraries make output that only looks good on white +@mixin cell-output-background { + color: var(--pst-color-on-background); + background-color: var(--pst-color-text-base); + border-radius: 0.25rem; + padding: 0.5rem; +} + // Dark theme special-cases -html[data-theme="dark"] { - // MyST-NB outputs should have a white background so content behaves the same - .bd-content div.cell_output { +html[data-theme="dark"] .bd-content { + // MyST-NB + div.cell_output { img, - div.text_html { - color: var(--pst-color-on-background); - background-color: var(--pst-color-text-base); - border-radius: 0.25rem; - padding: 0.5rem; + .text_html { + @include cell-output-background; + } + } + + // NBSphinx + .nboutput { + .output_area.rendered_html { + @include cell-output-background; + } + + .output_area.stderr { + background: var(--pst-color-danger); } } // Jupyter Sphinx div.jupyter_container { + // Background has slightly more custom background behavior because of hard-coded color border: 1px solid var(--pst-color-border); - background-color: var(--pst-color-on-background); + background-color: var(--pst-color-surface); + border-radius: 0.25rem; + div.output, div.highlight { - background-color: var(--pst-color-on-background); + border-radius: 0.25rem; } - } -} -// Jupyter Sphinx -div.jupyter_container { - border-radius: 0.25rem; - - div.output, - div.highlight { - border-radius: 0.25rem; + div.highlight { + background-color: var(--pst-color-surface); + } } } diff --git a/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss b/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss index 970acf51ed..071824c0e4 100644 --- a/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss +++ b/src/pydata_sphinx_theme/assets/styles/sections/_announcement.scss @@ -1,11 +1,11 @@ -$announcement-height: 3rem; .bd-header-announcement { - height: $announcement-height; + min-height: 3rem; width: 100%; display: flex; position: relative; align-items: center; justify-content: center; + text-align: center; padding: 0.5rem 12.5%; // Horizontal padding so the width is 75% @include media-breakpoint-down(md) { // Announcements can take a bit more width on mobile