Skip to main content

Bootstrap-based Sphinx theme from the PyData community

Project description

pydata-sphinx-theme

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:

Installation and usage

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!

Theme development

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: https://pydata-sphinx-theme.readthedocs.io/en/latest/contributing.html

How is this theme working?

The html layout

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:

  • A top navbar with top-level navigation
  • A left sidebar with subsequent navigation up to single pages
  • A right sidebar with a local "On this page" table of contents

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.

Implementation details

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:

  • A BootstrapHTML5Translator, subclassing sphinx' translator, but overriding certain elements to generate Bootstrap-compatible html. Currently, this includes: converting admonitions to Bootstrap "alert" classes, and updating the classes used for html tables.
  • A sphinx event to add navigation objects into the html context which is available in the html (jinja2) templates. This allows to put the structure of the navigation elements in the actual layout, instead of having to rely on the hard-coded formatting of sphinx (this is inspired on the navigation objects of mkdocs: https://www.mkdocs.org/user-guide/custom-themes/#nav). We would love to see this added to sphinx itself (instead of needing a sphinx event), but for now did not yet get any reaction from the sphinx developers.

Those items also avoid writing javascript functions to "fix up" the html generated by sphinx to make it suitable for theming.

What's the difference with bootstrap-sphinx-theme ?

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydata-sphinx-theme-0.2.1.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydata_sphinx_theme-0.2.1-py2.py3-none-any.whl (38.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pydata-sphinx-theme-0.2.1.tar.gz.

File metadata

  • Download URL: pydata-sphinx-theme-0.2.1.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

File hashes

Hashes for pydata-sphinx-theme-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fe492687c2430cede47ca988f19a390835b6a38282218c667636bd444bd40f74
MD5 21486c291a98f85edd418591ab88735a
BLAKE2b-256 fbaaeebe877bb7ae9bb4de2a5369716989c90e6a82da8e0691f66a84dc25754d

See more details on using hashes here.

File details

Details for the file pydata_sphinx_theme-0.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pydata_sphinx_theme-0.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

File hashes

Hashes for pydata_sphinx_theme-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 69bf02267b68c4e4605c358dff2231e27be9981bd68e270e1a81f171f803b643
MD5 a63b19a3d4b727c33021769c1bfbd075
BLAKE2b-256 a0de71e91801dffe63beee30521f8da1a843dda42c5484bad8007d183e6c5800

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page