Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify conf.py and RST to prep for Furo vs Pytorch config #268

Merged
merged 6 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 38 additions & 112 deletions example_docs/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,27 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=invalid-name
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

"""
Sphinx documentation builder
"""
import os
import sys

# This allows autodoc to find the `api_example` folder and
# for us to register our `docs.language_utils` extension.
sys.path.insert(0, os.path.abspath(".."))

# -- Project information -----------------------------------------------------
project = 'Qiskit sphinx theme'
copyright = '2020, Qiskit Development Team' # pylint: disable=redefined-builtin
project_copyright = '2020, Qiskit Development Team'
author = 'Qiskit Development Team'
language = "en"
release = "9.99"

import qiskit_sphinx_theme

release = qiskit_sphinx_theme.__version__
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now hardcode the release version. I don't think it makes a big difference having the actual version vs. 9.99 in these example docs.

I can add this back if you disagree though


html_theme = 'qiskit_sphinx_theme' # use the theme in subdir 'theme'
templates_path = ['_templates']

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

# This allows including custom CSS and HTML templates.
html_static_path = ['_static']
templates_path = ['_templates']
html_css_files = ['gallery.css']

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

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Sphinx should ignore these patterns when building.
exclude_patterns = ['_build', '**.ipynb_checkpoints']

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.napoleon',
'sphinx.ext.autodoc',
Expand All @@ -76,96 +43,55 @@
"nbsphinx",
]

# -----------------------------------------------------------------------------
# Autodoc
# -----------------------------------------------------------------------------

# Keep aligned with Terra.
autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = "both"
autodoc_typehints = "description"
autodoc_typehints_description_target = "documented_params"


# If true, figures, tables and code-blocks are automatically numbered if they
# have a caption.
numfig = True

# A dictionary mapping 'figure', 'table', 'code-block' and 'section' to
# strings that are used for format of figure numbers. As a special character,
# %s will be replaced to figure number.
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"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', '**.ipynb_checkpoints']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'colorful'

# A boolean that decides whether module names are prepended to all object names
# (for object types where a “module” of some kind is defined), e.g. for
# py:function directives.
add_module_names = False
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted this. It didn't do anything in the example docs. I think it was copy pasta from another repo.


# A list of prefixes that are ignored for sorting the Python module index
# (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.']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted this. It didn't do anything in the example docs. I think it was copy pasta from another repo.


# -- Configuration for extlinks extension ------------------------------------
# Refer to https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html


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

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#

#html_sidebars = {'**': ['globaltoc.html']}
html_last_updated_fmt = '%Y/%m/%d'

html_theme = 'qiskit_sphinx_theme'
html_theme_options = {
'logo_only': True,
'display_version': True,
'prev_next_buttons_location': 'bottom',
}

# qiskit package specific variables
html_context = {
# toggle analytics
# Add "Was this page useful?" to the footer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is technically true specifically for this example docs conf.py but in production (i.e. for pages live at qiskit.org domains) this also tracks data relating to page views. I'm not sure if we really need to specify the difference in functionality in the comment here or not 🤔 I guess we've probably explained it enough in the README, but I get nervous sometimes about ensuring we're being as transparent as possible about data/analytics tracking. I'd say it would be a nice-to-have to explicitly mention the analytics/data tracking element of this here, but it's not blocking the PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix this in a follow up PR :)

'analytics_enabled': True,

# dummy list for versions
# Users of the theme can set prior version numbers. They'll
# show up in the sidebar under the "Previous Versions" section.
'version_list': [0.1, 0.2, 0.3],

# make captioned headings into dropdowns
# This allows docs authors to have folders that can be
# closed and opened in the left sidebar.
'expandable_sidebar': True
}

# Sets a better style for code syntax highlighting.
pygments_style = 'colorful'

# This allows RST files to put `|version|` in their file and
# have it updated with the release set in conf.py.
rst_prolog = f"""
.. |version| replace:: {release}
"""

# Options for autodoc. These reflect the values from Terra.
autosummary_generate = True
autosummary_generate_overwrite = False
autoclass_content = "both"
autodoc_typehints = "description"
autodoc_typehints_description_target = "documented_params"

# -----------------------------------------------------------------------------
# nbsphinx
# -----------------------------------------------------------------------------
# This adds numbers to the captions for figures, tables,
# and code blocks.
numfig = True
numfig_format = {
'table': 'Table %s'
}

# Settings for Jupyter notebooks.
nbsphinx_execute = "never"
nbsphinx_thumbnails = {
"sphinx_guide/notebook": "_static/no_image.png",
}


# set up custom extension for languages
def setup(app):
app.setup_extension('docs.language_utils')
"""Entry point for Sphinx extensions."""
app.setup_extension('docs.language_utils')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corresponds to the sys.path change from above.

3 changes: 0 additions & 3 deletions example_docs/docs/sphinx_guide/lists.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
Lists
=====


.. contents:: Table of Contents

Enumerated Lists
----------------

Expand Down
4 changes: 0 additions & 4 deletions example_docs/docs/sphinx_guide/paragraph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
Paragraph Level Markup
**********************

.. contents:: Table of Contents

Inline Markup
=============

Expand Down Expand Up @@ -238,8 +236,6 @@ Directives
Contents
--------

.. contents:: :local:

These are just a sample of the many reStructuredText Directives. For others, please see:
http://docutils.sourceforge.net/docs/ref/rst/directives.html.

Expand Down
2 changes: 0 additions & 2 deletions example_docs/docs/sphinx_guide/structural.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Generic formatting
==================

.. contents:: Table of Contents

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec lorem neque, interdum in ipsum nec,
finibus dictum velit. Ut eu efficitur arcu, id aliquam erat. In sit amet diam gravida, imperdiet tellus eu,
gravida nisl. Praesent aliquet odio eget libero elementum, quis rhoncus tellus tincidunt.
Expand Down