Skip to content
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.

Commit

Permalink
Replace pycodestyle with Black and Isort (#1689)
Browse files Browse the repository at this point in the history
* Replace pycodestyle with Black and Isort

* Get rid of wheel in pyproject.toml

* Also format `tools/`

* Exclude benchmarks

* Review feedback

* Use isort 5.11 because 5.12 drops Py37 support

* Review feedback
  • Loading branch information
Eric-Arellano committed Apr 13, 2023
1 parent 087b980 commit c0f35fb
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 367 deletions.
129 changes: 67 additions & 62 deletions docs/conf.py
Expand Up @@ -22,55 +22,58 @@
import os
import sys

sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath("."))

import custom_extensions
from custom_directives import (IncludeDirective, GalleryItemDirective,
CustomGalleryItemDirective, CustomCalloutItemDirective,
CustomCardItemDirective)
import url_redirects

from custom_directives import (
CustomCalloutItemDirective,
CustomCardItemDirective,
CustomGalleryItemDirective,
GalleryItemDirective,
IncludeDirective,
)

# -- General configuration ---------------------------------------------------

project = 'Qiskit'
project = "Qiskit"
copyright = f"2017-{datetime.date.today().year}, Qiskit Development Team"
author = 'Qiskit Development Team'
author = "Qiskit Development Team"

# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = '0.42.1'
release = "0.42.1"

rst_prolog = """
.. |version| replace:: {0}
""".format(release)
""".format(
release
)

extensions = [
'sphinx.ext.napoleon',
'sphinx.ext.autodoc',
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.extlinks',
'jupyter_sphinx',
'nbsphinx',
'sphinx_design',
'sphinx_reredirects',
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.extlinks",
"jupyter_sphinx",
"nbsphinx",
"sphinx_design",
"sphinx_reredirects",
"matplotlib.sphinxext.plot_directive",
]

redirects = url_redirects.determine_redirects()

nbsphinx_timeout = 300
nbsphinx_execute = os.getenv('QISKIT_DOCS_BUILD_TUTORIALS', 'never')
nbsphinx_widgets_path = ''
html_sourcelink_suffix = ''
exclude_patterns = ['_build', '**.ipynb_checkpoints']
nbsphinx_execute = os.getenv("QISKIT_DOCS_BUILD_TUTORIALS", "never")
nbsphinx_widgets_path = ""
html_sourcelink_suffix = ""
exclude_patterns = ["_build", "**.ipynb_checkpoints"]

nbsphinx_thumbnails = {
'**': '_static/no_image.png'
}
nbsphinx_thumbnails = {"**": "_static/no_image.png"}

nbsphinx_prolog = """
{% set docname = env.doc2path(env.docname, base=None) %}
Expand All @@ -91,26 +94,26 @@
"tabs-color-label-active": "rgb(138, 63, 252)",
"tabs-color-label-inactive": "rgb(221, 225, 230)",
}
templates_path = ['_templates']
templates_path = ["_templates"]

source_suffix = '.rst'
master_doc = 'index'
source_suffix = ".rst"
master_doc = "index"

# Number figures, tables and code-blocks if they have a caption.
numfig = True
# Available keys are 'figure', 'table', 'code-block' and 'section'. '%s' is the number.
numfig_format = {'table': 'Table %s'}
numfig_format = {"table": "Table %s"}
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"

# For Adding Locale
locale_dirs = ['locale/'] # path is example but recommended.
gettext_compact = False # optional.
locale_dirs = ["locale/"] # path is example but recommended.
gettext_compact = False # optional.

pygments_style = 'colorful'
pygments_style = "colorful"

# Whether module names are included in crossrefs of functions, classes, etc.
add_module_names = False
Expand All @@ -119,46 +122,47 @@
# (e.g., if this is set to ['foo.'], then foo.bar is shown under B, not F).
# This can be handy if you document a project that consists of a single
# package. Works only for the HTML builder currently.
modindex_common_prefix = ['qiskit.']

modindex_common_prefix = ["qiskit."]


# -- Configuration for extlinks extension ------------------------------------
# Refer to https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
extlinks = {
'pull_terra': ('https://github.com/Qiskit/qiskit-terra/pull/%s', '#'),
'pull_aer': ('https://github.com/Qiskit/qiskit-aer/pull/%s', '#'),
'pull_ibmq-provider': ('https://github.com/Qiskit/qiskit-ibmq-provider/pull/%s', '#')
"pull_terra": ("https://github.com/Qiskit/qiskit-terra/pull/%s", "#"),
"pull_aer": ("https://github.com/Qiskit/qiskit-aer/pull/%s", "#"),
"pull_ibmq-provider": ("https://github.com/Qiskit/qiskit-ibmq-provider/pull/%s", "#"),
}

# -- Options for HTML output -------------------------------------------------

html_theme = "qiskit_sphinx_theme"
html_theme_options = {
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': True,
"logo_only": False,
"display_version": True,
"prev_next_buttons_location": "bottom",
"style_external_links": True,
# Toc options
'collapse_navigation': True,
'sticky_navigation': True,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False,
"collapse_navigation": True,
"sticky_navigation": True,
"navigation_depth": 4,
"includehidden": True,
"titles_only": False,
}
html_static_path = ['_static']
html_css_files = ['custom.css', 'gallery.css']
html_favicon = 'images/favicon.ico'
html_last_updated_fmt = '%Y/%m/%d'
html_context = {'analytics_enabled': os.getenv('QISKIT_ENABLE_ANALYTICS', False)} # enable segment analytics for qiskit.org/documentation
html_static_path = ["_static"]
html_css_files = ["custom.css", "gallery.css"]
html_favicon = "images/favicon.ico"
html_last_updated_fmt = "%Y/%m/%d"
html_context = {
"analytics_enabled": os.getenv("QISKIT_ENABLE_ANALYTICS", False)
} # enable segment analytics for qiskit.org/documentation

# -- Options for Autosummary and Autodoc ------------------------------------
# Note that setting autodoc defaults here may not have as much of an effect as you may expect; any
# documentation created by autosummary uses a template file (in autosummary in the templates path),
# which likely overrides the autodoc defaults.
autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = 'both'
autoclass_content = "both"

# Move type hints from signatures to the parameter descriptions (except in overload cases, where
# that's not possible).
Expand All @@ -174,15 +178,16 @@

# -- Extension configuration -------------------------------------------------


def setup(app):
app.add_directive('includenodoc', IncludeDirective)
app.add_directive('galleryitem', GalleryItemDirective)
app.add_directive('customgalleryitem', CustomGalleryItemDirective)
app.add_directive('customcarditem', CustomCardItemDirective)
app.add_directive('customcalloutitem', CustomCalloutItemDirective)
app.add_directive("includenodoc", IncludeDirective)
app.add_directive("galleryitem", GalleryItemDirective)
app.add_directive("customgalleryitem", CustomGalleryItemDirective)
app.add_directive("customcarditem", CustomCardItemDirective)
app.add_directive("customcalloutitem", CustomCalloutItemDirective)
custom_extensions.load_api_sources(app)
custom_extensions.load_tutorials(app)
app.setup_extension('versionutils')
app.connect('build-finished', custom_extensions.clean_api_source)
app.connect('build-finished', custom_extensions.clean_tutorials)
app.connect('source-read', custom_extensions.deprecate_ibmq_provider)
app.setup_extension("versionutils")
app.connect("build-finished", custom_extensions.clean_api_source)
app.connect("build-finished", custom_extensions.clean_tutorials)
app.connect("source-read", custom_extensions.deprecate_ibmq_provider)

0 comments on commit c0f35fb

Please sign in to comment.