Giter Club home page Giter Club logo

qiskit_sphinx_theme's Introduction

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:

  • qiskit-ecosystem theme (located in the src/ folder)
  • example docs (located in the example_docs/ folder)
  • Qiskit Docs Guide (located in the docs_guide/ folder)

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:

  • Ensure that qiskit_sphinx_theme is in the extensions setting.
  • Set the option translations_list to a list of pairs of the locale code and the language name, e.g. [..., ("de_DE", "German")].
  • Set the option docs_url_prefix to your project's URL prefix, like ecosystem/finance.

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:

  • Ensure that qiskit_sphinx_theme is in the extensions setting.
  • Add to the option html_context an entry for version_list with a list of the prior versions, e.g. ["0.4", "0.5"].
    • Each of these versions must be deployed with the above stable/<version> URL scheme.
    • You can manually set this, or some projects write a Sphinx extension to dynamically compute the value.
    • You should only put prior versions in this list, not the current release.
  • Set the option docs_url_prefix to your project's URL prefix, like ecosystem/finance.

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.

  • qiskit-card
  • qiskit-call-to-action-item and qiskit-call-to-action-grid

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.

qiskit_sphinx_theme's People

Contributors

1ucian0 avatar airwoodix avatar arnaucasau avatar coruscating avatar delapuente avatar eric-arellano avatar frankharkins avatar garrison avatar guillermo-mijares-vilarino avatar huangjunye avatar jakelishman avatar javabster avatar karlaspuldaro avatar maldoalberto avatar mtreinish avatar nonhermitian avatar paniash avatar taalexander avatar y4izus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

qiskit_sphinx_theme's Issues

Set up COS deployment

As a Qiskit docs dev,
I need to be able to deploy html files from this repository to COS when work is merged into main
So that frontend development work can be more efficient (i.e. decoupled from qiskit releases)

As a Qiskit docs dev,
I need the deployment process to documented
So that I can understand the process better and be onboarded quicker

Improve README

The README for this repo should be able to tell maintaienrs of other qiskit repos how to set up their /docs folder so that they are pulling in this theme correctly and not overriding the styles

The readme should include:

  • explanation of what the theme provides (top bar, left side bar, footer, optional analytics)
  • how to install the theme and set up their docs folder structure
  • users should NOT override the theme with their own files (i.e. their _templates folder should be empty)
  • user's conf.py must include a html_context variable including analytics_enabled, e.g.
html_context = {
     'analytics_enabled': True
}

Table header columns do not line wrap or scale horizontally

Table header columns with long header text do not seem to be formatting correctly. For example from: https://qiskit.org/documentation/release_notes.html the text for Qiskit Metpackage Version overlaps with qiskit-terra

image (7)

I've seen this happen on other tables too. I think we just need either line wrap or fix the column width scaling. (it's interesting on my browser it initially looks fine at first, but only overlaps when it renders the grey bar for alternating lines)

Create a standard sidebar structure in `layout.html`

The layout.html should have a standard structure that can be pulled in by all qiskit repos.

Current plan:

[language dropdown]

[search box]

Qiskit {Repo Name} Documentation
   Overview
   Getting Started
   Tutorials
   How to Guides
   API Reference
   FAQs
   Release Notes
   GitHub

[previous releases list]

Open questions for discussion:

  • Should we require every page listed above or just some or none?
  • Which pages should we insist be there and which should be optional?
  • Should we allow individual repos to add their own links to the sidebar list?

cc: @HuangJunye @agebbie

Content audit for qiskit documentation

Content on documentation comes from different repos and in different ways, so we need to know where those files live:

In addition, the idea is to organize the documentation following the structure proposed by divio. Right now we have 3 types of documentation: API References, getting started files and tutorials. First one is attached to the code but the second and third ones are on different folders. We would like to know if those tutorials and getting started files fits the tutorials definition given on divio or if they belongs to any of the other categories: API References, how-to guides or explanations.

A proposal is to come up with a summary with this structure (I've added an example):

Project Tutorial Source File Doc type
Qiskit Nature Electronic Structure Link on qiskit-nature repo Tutorial

Where:

  • Project can be:
    • Qiskit core
    • Qiskit machine learning
    • Qiskit nature
    • Qiskit finance
    • Qiskit optimization
    • Qiskit experiments
    • Qiskit dynamics
    • Qiskit metal
    • Qiskit partners
  • Tutorial is the name of the tutorial and point to the page under qiskit.org/documentation. If the tutorial is under a category, you can add it too
  • Source file is the name to the repo where the tutorial lives and point to its code file
  • Doc Type can be:
    • API Reference
    • Tutorial
    • How-to guide
    • Explanation

There is a lot of content to review, so I'm gonna split this task in smaller ones

Migrate Deprecation Policy page from metapackage to `qiskit_sphinx_theme`

This file in the metapackage defines the content for https://qiskit.org/documentation/deprecation_policy.html.

It would be better if this page could be refactored into an .html file that could be kept here and deployed straight to IBM COS.

Converting to html and removing the sphinx build from the equation will make this easier to maintain and allow us to develop more complex frontend features in futures that are not well supported by .rst

Create a tutorial example

On Qiskit docs 2.0 we would like to divide documentation in different types using the divio framework. For that, we are working on a tutorials audit to see what kind of documentation we already have. It's not been easy because no file fits 100% the framework.

Following @HuangJunye suggestion, having an example of every type of documentation could help us with the categorization.

The idea is convert one of the tutorials we already have in one that follows divio framework. It would be nice to have both to compare the old and the new in order to understand what we need for that update. If we already have an example of tutorial, please, you could just add the link :)

Single Dispatch function type annotations overlap with function signature

In Qiskit/rustworkx#241 I'm adding a dispatch API that runs type specific functions based on the input type. These are built using the functools single dispatch decorator: https://docs.python.org/3/library/functools.html#functools.singledispatch

With the qiskit_sphinx_docs theme this render the signature for each supported input type separately and list the input type as an annotation on this dispatched argument, to each signature which is good way to show the supported types and any differences between them. But the input type is not spaced correctly and looks like it's not even part of the signature string so it overlaps with other text in the function signature making it hard to read. For example:

Screenshot_2021-01-27_11-48-40

Migrate Contributing Guide page from metapackage to `qiskit_sphinx_theme`

This file in the metapackage defines the content for https://qiskit.org/documentation/contributing_to_qiskit.html.

It would be better if this page could be refactored into an .html file that could be kept here and deployed straight to IBM COS.

Converting to html and removing the sphinx build from the equation will make this easier to maintain and allow us to develop more complex frontend features in futures that are not well supported by .rst

Feedback buttons in Tutorials (and similar places)

What is the expected behavior?

It would be great to get user feedback directly in places where they interact with our code. One option could be to add a feedback button in the Qiskit tutorials (or how-tos once we have them) that would send users to an airtable/feedback form/GitHub repo. That way users don't have to actively search for a place to give feedback but we make it very easy and we can get information that's fresh out of the oven 😄

Jupyter notebooks should support buttons/links and maybe we can use the same interface for feedback we use in other places (like qiskit.org).

Migrate 'QC in a nutshell' page from metapackage to `qiskit_sphinx_theme`

This file in the metapackage defines the content for https://qiskit.org/documentation/qc_intro.html.

It would be better if this page could be refactored into an html file that could be kept here and deployed straight to IBM COS.

Converting to html and removing the sphinx build from the equation will make this easier to maintain and allow us to develop more complex frontend features in futures that are not well supported by .rst

Add unified top menu bar to `layout.html`

A new unified top menu for qiskit.org is being developed including an extended dropdown for documentation. The web component development is being tracked here.

Once the top menu component is complete this should be integrated into the theme here in the layout.html

As a Qiskit User I need to know that the sidebar options and search bar are specific to the repo I am currently viewing

The new Runtime tutorials sidebar looks great, but if we are going to have the same style of sidebar for each package, perhaps we need a way of indicating in the sidebar (e,g. a subheading or something) that those links and search bar are for that specific repo. Otherwise for example a user might think they are searching through the whole docs site when in reality they are only seeing info for a specific package. I suggest doing something like this:

Image

API doc "methods" level docstring keywords are not rendered with special headings

Environment

  • Qiskit Terra version:
  • Python version:
  • Operating system:

What is happening?

In the "Class" level docstring, "Parameters", "Returns", "Raises" keywords are rendered nicely while this is not true in the "methods" level docstrings

https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.html

image

https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.combine.html
image

How can we reproduce the issue?

Go to API reference, choose a class and then a method, for example: https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.combine.html

What should happen?

API doc "methods" level docstring keywords should be rendered with special headings similar to "Class" level dosctring.

Any suggestions?

I am still not familiar with the doc building process yet but I suspect this is something we can address in https://github.com/Qiskit/qiskit_sphinx_theme Please move the issue to that repo if it is more appropriate

As a user, I would like to have just one top menu across all the qiskit.org domain pages

Right now, the top menu under qiskit.org change between the home page and the documentation page. In addition, inside the documentation page, the top menu changes 11 times. We need to have just one top menu in order to improve the UX and also the maintainability (just one place to update instead of 12).

Needed tasks:

  • [Design] Create a prototype for the top menu
  • [Dev] Implement the top menu as web component and serve it on a cdn
  • [Dev] Add the web component to the qiskit.org project
  • [Dev] Add the web component to the qiskit sphinx theme
  • [Dev] Remove top menu from the Qiskit/qiskit repo
  • [Dev] Remove top menu from the Qiskit/qiskit-nature repo
  • [Dev] Remove top menu from the Qiskit/qiskit-finance repo
  • [Dev] Remove top menu from the Qiskit/qiskit-optimization repo
  • [Dev] Remove top menu from the Qiskit/qiskit-machine-learning repo
  • [Dev] Remove top menu from the Qiskit/qiskit-metal repo
  • [Dev] Remove top menu from the Qiskit/qiskit-dynamics repo
  • [Dev] Remove top menu from the Qiskit/qiskit-experiments repo
  • [Dev] Remove top menu from the Qiskit-Partners/mthree repo
  • [Dev] Remove top menu from the Qiskit-Partners/qiskit-ionq repo

Add Right to Left support for Qiskit Documentation

Who are we building this for?

Few Qiskit enthusiasts have reached out to volunteer to translate the Qiskit Documentation to Urdu any right to left language scripts.

“Wants to”

The current documentation theme - Qiskit sphinx theme doesn't support RTL languages.

“So that”:

The team can focus better in translating and increasing the reach of Qiskit among the community speaking languages that use right to left scripts.

Migrate metapackage `docs/index.rst` to `qiskit_sphinx_theme` repo

This file in the metapackage defines the content for the main landing page for qiskit.org/documentation.

It would be better if this page could be refactored into an html file that could be kept here and deployed straight to IBM COS.

Converting to html and removing the sphinx build from the equation will make this easier to maintain and allow us to develop more complex frontend features in futures that are not well supported by .rst

Add more info to the README file

We can provide more info related with the project in order to give an overview of it. I could include, for example, directory structure, technology used, how to modify the theme, ...

Create an explanation example

On Qiskit docs 2.0 we would like to divide documentation in different types using the divio framework. For that, we are working on a tutorials audit to see what kind of documentation we already have. It's not been easy because no file fits 100% the framework.

Following @HuangJunye suggestion, having an example of every type of documentation could help us with the categorization.

The idea is convert one of the tutorials we already have in an explanation that follows divio framework. It would be nice to have both to compare the old and the new in order to understand what we need for that update. If we already have an example of explanation, please, you could just add the link :)

Create a How-To example

On Qiskit docs 2.0 we would like to divide documentation in different types using the divio framework. For that, we are working on a tutorials audit to see what kind of documentation we already have. It's not been easy because no file fits 100% the framework.

Following @HuangJunye suggestion, having an example of every type of documentation could help us with the categorization.

The idea is convert one of the tutorials we already have in a How-To that follows divio framework. It would be nice to have both to compare the old and the new in order to understand what we need for that update. If we already have an example of How-To, please, you could just add the link :)

Migrate Maintainers Guide page from metapackage to `qiskit_sphinx_theme`

This file in the metapackage defines the content for https://qiskit.org/documentation/maintainers_guide.html.

It would be better if this page could be refactored into an .html file that could be kept here and deployed straight to IBM COS.

Converting to html and removing the sphinx build from the equation will make this easier to maintain and allow us to develop more complex frontend features in futures that are not well supported by .rst

Add Segment to the qiskit documentation page

Requires some investigation, but would be great to add segment tracking to the sphinx theme layout.html.

Set up should be dynamic enough to handle each qiskit repo pulling in the layout.html

(description updated 22 Aug by @javabster)

Decouple top menu structure from content

In the theme, the top menu structure and its content are in the same file so is not possible to reuse the layout if we need a different content. It would be nice to have this two things decoupled and start reusing layouts instead of creating new ones

Automatically add permalink to Dropdown and Tabs components created by `sphinx-design`

The theme adds permalinks to section headers by default but not for components that are created by sphinx-design such as Dropdown and Tabs. It would be great to add permalinks to those components as well so that those sections can be directly referred to elsewhere.

A use case is the dropdown in the Supplementary Information section of qiskit.circuit module level documentation page.

image

In Qiskit/qiskit#8443, we are adding another dropdown. Dropdown are great for hidden unnecessary information by default.

Dropdown in sphinx-design are implemented as the standard HTML <details> and <summary> tags. Below is the source code of the dropdown in qiskit.circuit module level documentation page.

<details class="sd-sphinx-override sd-dropdown sd-card sd-mb-3 sd-fade-in-slide-down">
<summary class="sd-summary-title sd-card-header">
Quantum Circuit Properties<div class="sd-summary-down docutils">
<svg version="1.1" width="1.5em" height="1.5em" class="sd-octicon sd-octicon-chevron-down" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M5.22 8.72a.75.75 0 000 1.06l6.25 6.25a.75.75 0 001.06 0l6.25-6.25a.75.75 0 00-1.06-1.06L12 14.44 6.28 8.72a.75.75 0 00-1.06 0z"></path></svg></div>
<div class="sd-summary-up docutils">
<svg version="1.1" width="1.5em" height="1.5em" class="sd-octicon sd-octicon-chevron-up" viewBox="0 0 24 24" aria-hidden="true"><path fill-rule="evenodd" d="M18.78 15.28a.75.75 0 000-1.06l-6.25-6.25a.75.75 0 00-1.06 0l-6.25 6.25a.75.75 0 101.06 1.06L12 9.56l5.72 5.72a.75.75 0 001.06 0z"></path></svg></div>
</summary><div class="sd-summary-content sd-card-body docutils">
...
...
</details>

This is how section links are implemented. I think it's pretty standard, but I have on idea about HTML and CSS ><.

<section id="supplementary-information">
<h2>Supplementary Information<a class="headerlink" href="[#supplementary-information](view-source:file:///Users/junye/Documents/GitHub/qiskit-dev/terra-repos/qiskit-terra-2/docs/_build/html/apidocs/circuit.html#supplementary-information)" title="Permalink to this heading"></a></h2>
...
...
</section>

Show level 3 headings in "table of content" on the right hand side of the page

Currently only 2 levels of headings are shown. For example: https://qiskit.org/documentation/apidoc/circuit.html
image

Level 1 is used and only used by the title of the page and therefore only level 2 headings are useful. It should be great to show level 3 headings as well to give more information for users to navigate.

For the same example page: https://qiskit.org/documentation/apidoc/circuit.html, showing level 3 headings will show the subsections under "Quantum Circuit API":

  • Quantum Circuit API
    • Quantum Circuit Construction
    • Gates and Instructions
    • Control Flow Operations
    • Parametric Quantum Circuits
    • Random Circuits

Links to sub headings not present

Back when we used the rtd theme there was a nice feature where a section, subsection, etc would have a pilcrow next to it which would give a direct link to that. Since moving the qiskit documentation to the qiskit_sphinx_theme this doesn't seem to exist anymore. It's an issue for me primarily in the release notes https://qiskit.org/documentation/release_notes.html#notable-changes where its very useful to have a direct link to the section notes for a particular release to point someone to it.

Default values for attributes in API reference should display original case instead of All Caps

Default values for attributes in API reference should display original case instead of All Caps, because some arguments are case sensitive.

For example, name_format = re.compile("[a-z][a-zA-Z0-9_]*") in QuantumRegister is displayed as name_format = re.compile('[A-Z][A-ZA-Z0-9_]*')

image

I am not sure where to fix in the theme to address this. It could also be not due to the theme. In that case, please transfer the issue to the appropriate repo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.