Skip to content

Commit

Permalink
Edited conf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Shihab Suliman committed Apr 3, 2024
1 parent e1f1f9f commit 24b796a
Showing 1 changed file with 39 additions and 65 deletions.
104 changes: 39 additions & 65 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
# Configuration file for the Sphinx documentation builder.
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import sys
from pathlib import Path
from subprocess import check_output
from pkg_resources import require


import requests

import PandABlocks

require("sphinx_rtd_theme")
require("matplotlib")
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, ROOT)
import pandablocks

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

# General information about the project.
project = "PandABlocks.github.io"

# The full version, including alpha/beta/rc tags.
release = PandABlocks.__version__
release = pandablocks.__version__

# The short X.Y version.
if "+" in release:
# Not on a tag, use branch name
root = Path(__file__).absolute().parent.parent
F = Path(__file__).absolute().parent.parent
git_branch = check_output("git branch --show-current".split(), cwd=root)
version = git_branch.decode().strip()
else:
Expand All @@ -52,12 +44,13 @@
"sphinx_copybutton",
# For the card element
"sphinx_design",
# Timing plots
'matplotlib.sphinxext.plot_directive',
'common.python.sphinx_timing_directive',

# So we can write markdown files
"myst_parser",
]

# So we can use the ::: syntax
myst_enable_extensions = ["colon_fence"]

# If true, Sphinx will warn about all references where the target cannot
# be found.
nitpicky = True
Expand Down Expand Up @@ -94,9 +87,6 @@
# role, that is, for text marked up `like this`
default_role = "any"

# The suffix of source filenames.
source_suffix = ".rst"

# The master toctree document.
master_doc = "index"

Expand All @@ -110,20 +100,10 @@

# This means you can link things like `str` and `asyncio` to the relevant
# docs in the python documentation.
intersphinx_mapping = dict(python=("https://docs.python.org/3/", None))
intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}

# A dictionary of graphviz graph attributes for inheritance diagrams.
inheritance_graph_attrs = dict(rankdir="TB")

# Common links that should be available on every page
rst_epilog = """
.. _Diamond Light Source: http://www.diamond.ac.uk
.. _black: https://github.com/psf/black
.. _flake8: https://flake8.pycqa.org/en/latest/
.. _isort: https://github.com/PyCQA/isort
.. _mypy: http://mypy-lang.org/
.. _pre-commit: https://pre-commit.com/
"""
inheritance_graph_attrs = {"rankdir": "TB"}

# Ignore localhost links for periodic check that links in docs are valid
linkcheck_ignore = [r"http://localhost:\d+/"]
Expand All @@ -139,8 +119,8 @@
# a list of builtin themes.
#
html_theme = "pydata_sphinx_theme"
github_repo = project
github_user = "PandABlocks"
github_repo = "PandABlocks.github.io"
github_user = "shihab-dls"
switcher_json = f"https://{github_user}.github.io/{github_repo}/switcher.json"
switcher_exists = requests.get(switcher_json).ok
if not switcher_exists:
Expand All @@ -155,44 +135,38 @@
# Theme options for pydata_sphinx_theme
# We don't check switcher because there are 3 possible states for a repo:
# 1. New project, docs are not published so there is no switcher
# 2. Existing project with latest skeleton, switcher exists and works
# 3. Existing project with old skeleton that makes broken switcher,
# 2. Existing project with latest copier template, switcher exists and works
# 3. Existing project with old copier template that makes broken switcher,
# switcher exists but is broken
# Point 3 makes checking switcher difficult, because the updated skeleton
# Point 3 makes checking switcher difficult, because the updated copier template
# will fix the switcher at the end of the docs workflow, but never gets a chance
# to complete as the docs build warns and fails.
html_theme_options = dict(
logo=dict(
text=project,
),
use_edit_page_button=True,
github_url=f"https://github.com/{github_user}/{github_repo}",
icon_links=[
dict(
name="PyPI",
url=f"https://pypi.org/project/{project}",
icon="fas fa-cube",
)
],
switcher=dict(
json_url=switcher_json,
version_match=version,
),
check_switcher=False,
navbar_end=["theme-switcher", "icon-links", "version-switcher"],
external_links=[
dict(
name="Release Notes",
url=f"https://github.com/{github_user}/{github_repo}/releases",
)
html_theme_options = {
"logo": {
"text": project,
},
"use_edit_page_button": True,
"github_url": f"https://github.com/{github_user}/{github_repo}",
"icon_links": [
{
"name": "PyPI",
"url": f"https://pypi.org/project/{project}",
"icon": "fas fa-cube",
}
],
navigation_with_keys=True,
)
"switcher": {
"json_url": switcher_json,
"version_match": version,
},
"check_switcher": False,
"navbar_end": ["theme-switcher", "icon-links", "version-switcher"],
"navigation_with_keys": False,
}

# A dictionary of values to pass into the template engine’s context for all pages
html_context = {
"github_user": github_user,
"github_repo": project,
"github_repo": github_repo,
"github_version": version,
"doc_path": "docs",
}
Expand All @@ -204,5 +178,5 @@
html_show_copyright = False

# Logo
html_logo = 'images/PandA-logo-for-black-background.svg'
html_favicon = "images/PandA-logo.ico"
html_logo = "images/PandA-logo-for-black-background.svg"
html_favicon = "images/favicon.ico"

0 comments on commit 24b796a

Please sign in to comment.