Qiskit / qiskit_sphinx_theme

A Sphinx theme and documentation guidelines for Qiskit and Qiskit Ecosystem projects
https://qisk.it/docs-guide
Apache License 2.0
14 stars 29 forks source link

qiskit-sphinx-theme

The Sphinx theme for Qiskit Ecosystem documentation.

Warning: new theme migration

In qiskit-sphinx-theme 1.14, we replaced the old qiskit_sphinx_theme based on Pytorch with the new qiskit-ecosystem theme based on Furo. The old theme was removed in qiskit-sphinx-theme 2.0.

See Migrate from old Pytorch theme to new theme for migration instructions.

Overview

This repository hosts three things:

The qiskit-ecosystem theme is used by projects in the Qiskit Ecosystem.

The example docs are a minimal Sphinx project that is used for testing the Qiskit Sphinx Theme. Every pull request will trigger a GitHub workflow that builds the example docs to make sure the changes do not introduce unintended changes.

The Qiskit Docs Guide hosts instructions, guidelines and recommendations of good documentation practices. Its intent is to help Qiskit maintainers improve the documentation of their projects. The guide is hosted online here: https://qisk.it/docs-guide.

Installation

This package is available on PyPI using:

pip install qiskit-sphinx-theme

Then, set up the theme by updating conf.py:

  1. Set html_theme = "qiskit-ecosystem"
  2. Add "qiskit_sphinx_theme" to extensions

You also likely want to set html_title in conf.py. This results in the left sidebar having a more useful and concise name, along with the page title in the browser. Most projects will want to use this in their conf.py:

# Sphinx expects you to set these already.
project = "My Project"
release = "4.12"

# This sets the title to e.g. `My Project 4.12`.
html_title = f"{project} {release}"

Enable translations

First, coordinate with the Translations team at https://github.com/qiskit-community/qiskit-translations to express your interest and to coordinate setting up the infrastructure.

Once the Translations team is ready, then update your conf.py:

For example:

extensions = [
   ...,
   "qiskit_sphinx_theme",
]

translations_list = [
    ('en', 'English'),
    ('bn_BN', 'Bengali'),
    ('fr_FR', 'French'),
    ('de_DE', 'German'),
]

docs_url_prefix = "ecosystem/finance"

Enable Previous Releases

This feature allows you to link to previous versions of the docs in the left sidebar.

First, start additionally deploying your docs to <project-prefix>/stable/<version>/, e.g. /ecosystem/finance/stable/0.5/index.html. See https://github.com/Qiskit/qiskit-experiments/blob/227867937a08075092cd11756214bee3fb1d4d3d/tools/deploy_documentation.sh#L38-L39 for an example.

Then, update your conf.py:

For example:

extensions = [
   ...,
   "qiskit_sphinx_theme",
]

html_context = {
   "version_list": ["0.4", "0.5"],
}

docs_url_prefix = "ecosystem/finance"

Use custom RST directives

The qiskit_sphinx_theme extension defines the below custom directives for you to use in RST, if you'd like. See example_docs/docs/sphinx_guide/custom_directives.rst for examples of how to use them.

Customize or disable the Ecosystem theme logo

The qiskit-ecosystem theme includes the Qiskit Ecosystem logo by default.

You can use a custom logo by adding a logo file (SVG or PNG) as a sibling to your conf.py, e.g. docs/logo.svg. Then, set html_logo in conf.py to the name of the file, e.g. html_logo = "logo.png".

When using a custom logo, you may want to disable the project's name in the sidebar by setting sidebar_hide_name in html_theme_options:

html_theme_options = {
    "sidebar_hide_name": True,
}

You can disable logos by setting disable_ecosystem_logo in html_theme_options:

html_theme_options = {
    "disable_ecosystem_logo": True,
}

Tip: suggested site structure

To keep UX/UI similar across different Qiskit packages, we encourage the following structure for you sidebar, which can be set in the toctree of your index.rst:

.. toctree::
  :hidden:

   Documentation Home <index>
   Getting Started <getting_started>
   Tutorials <tutorials/index>
   How-to Guides <how_to/index>
   API Reference <apidocs/index>
   Explanations <explanations/index>
   Release Notes <release_notes>
   GitHub <https://github.com/your-repo>

Each item in the toctree corresponds to a single .rst file, and can use internal links or external. External links will have a "new tab" icon rendered next to them.