Bootstrap-based sphinx theme from the PyData community
A Bootstrap-based Sphinx theme from the PyData community.
Demo site: https://pydata-sphinx-theme.readthedocs.io/en/latest/
Note: This theme is originally being developed for the pandas docs (originally named “pandas-sphinx-theme”),
but since there is uptake in other projects, we are working on making this more
generic and more easily extensible to suit the needs of the different projects.
Sites that are using this theme:
The theme is available on PyPI and conda-forge. You can install
and use as follows:
Install the pydata-sphinx-theme in your doc build environment:
pip install pydata-sphinx-theme
# or
conda install pydata-sphinx-theme --channel conda-forge
Then, in the conf.py of your sphinx docs, you update the html_theme
configuration option:
html_theme = "pydata_sphinx_theme"
And that’s it!
Well, in principle at least. In practice, there are might still be a few
pandas-specific things that are right now hard-coded in the theme. We also need
to work on better configurability and extensibility. Feedback and contributions
are very welcome!
Contributions are very welcome! Installing the development version, building
the demo docs and developing the css/js of the theme, etc, is explained in
more detail in the contributing section of the documentation:
The “layout” included in this theme is originally mainly targetted towards
documentation sites with many pages, and where putting all navigation in a
single sidebar can therefore get unwieldy.
The current layout features 3 navigation elements:
What is put where is determined by the sphinx “toctree” (and such depending on
the structure of your sphinx docs). The first level of the toctree is put in the
top navbar, and the second (and potentially) third level is put in the left
sidebar.
It should certainly be possible to make the exact used levels of the sphinx
toctree configurable.
A second aspect of the design of this theme is that we are trying to make good
use of Bootstrap features and use as much as possible actual (templated) html
and css to define the theme, instead of relying on sphinx to do custom
formatting. This should make the theming and layouts more flexible to customize.
To this end, this package includes:
BootstrapHTML5Translator,Those items also avoid writing javascript functions to “fix up” the html
generated by sphinx to make it suitable for theming.
There is already a sphinx Bootstrap theme used by some project in the community:
https://github.com/ryan-roemer/sphinx-bootstrap-theme/
Currently, the main difference is that this theme is using Bootstrap 4 instead
of 3 and provides a different default layout. At some point, it would be good to
contribute changes to that package (or at least the parts that deal with
Bootstrap and sphinx that could be shared).
The initial layout and css were inspired on the Bootstrap documentation site.