Source code for xanadu_sphinx_theme
"""
This module registers the Xanadu Sphinx Theme. For more information, see
https://www.sphinx-doc.org/en/master/development/theming.html
"""
from pathlib import Path
from importlib_resources import files
from ._version import __version__
from .directives import (
BioDirective,
CommunityCardDirective,
DetailsDirective,
GalleryItemDirective,
IndexCardDirective,
RelatedDemoDirective,
TitleCardDirective,
YouTubeVideoDirective,
)
[docs]def templates_dir():
"""Returns the directory path containing provided Autosummary
templates.
To use this in your theme, add the following to your ``conf.py``
configuration file:
.. code-block:: python
import xanadu_sphinx_theme
templates_path = [xanadu_sphinx_theme.templates_dir()]
"""
return str(files("xanadu_sphinx_theme").joinpath("templates"))
def _set_theme_default(app, key, value):
"""Set a theme option when it is missing or empty in theme.conf."""
if not app.config["html_theme_options"].get(key):
app.config["html_theme_options"][key] = value
[docs]def setup(app):
"""See https://www.sphinx-doc.org/en/master/extdev/appapi.html."""
cwd = Path(__file__).resolve().parent
app.add_html_theme("xanadu", str(cwd))
for section in [
"about",
"links",
"policies",
"social_icons",
"newsletter",
"xanadu",
"copyright",
]:
_set_theme_default(app, f"footer_{section}", XANADU_FOOTER.get(f"footer_{section}"))
directives = {
"bio": BioDirective,
"community-card": CommunityCardDirective,
"details": DetailsDirective,
"gallery-item": GalleryItemDirective,
"index-card": IndexCardDirective,
"related": RelatedDemoDirective,
"title-card": TitleCardDirective,
"youtube-video": YouTubeVideoDirective,
}
for name, cls in directives.items():
app.add_directive(name, cls)
XANADU_FOOTER = {
"footer_newsletter": {
"title": "Stay updated with our newsletter",
"description": "Get the latest quantum updates delivered to your inbox.",
"href": "https://xanadu.us17.list-manage.com/subscribe?u=725f07a1d1a4337416c3129fd&id=294b062630",
"cta": "Join the list",
},
"footer_about": {
"title": "Xanadu",
"icon": "https://assets.cloud.pennylane.ai/pennylane_website/generic/xanadu-logo.png",
"href": "https://xanadu.ai",
"description": """\
Located in the heart of downtown Toronto, we've brought together
exceptional minds from around the world to build quantum computers
that are useful and available to people everywhere.
""",
},
"footer_links": [
{
"title": "PennyLane",
"links": [
{
"name": "Home",
"href": "https://pennylane.ai/",
},
{
"name": "Learn",
"href": "https://pennylane.ai/qml",
},
{
"name": "Demonstrations",
"href": "https://pennylane.ai/qml/demonstrations",
},
{
"name": "Documentation",
"href": "https://docs.pennylane.ai/",
},
{
"name": "GitHub",
"href": "https://github.com/PennyLaneAI/pennylane",
"external": True,
},
{
"name": "Twitter",
"href": "https://twitter.com/pennylaneai",
"external": True,
},
{
"name": "Blog",
"href": "https://pennylane.ai/blog",
},
],
},
{
"title": "Strawberry Fields",
"links": [
{
"name": "Home",
"href": "https://strawberryfields.ai/",
"external": True,
},
{
"name": "Photonics",
"href": "https://strawberryfields.ai/photonics",
"external": True,
},
{
"name": "Demonstrations",
"href": "https://strawberryfields.ai/photonics/demonstrations.html",
"external": True,
},
{
"name": "Documentation",
"href": "https://strawberryfields.readthedocs.io/",
"external": True,
},
{
"name": "GitHub",
"href": "https://github.com/XanaduAI/strawberryfields",
"external": True,
},
],
},
{
"title": "Xanadu",
"links": [
{
"name": "Home",
"href": "https://xanadu.ai/",
"external": True,
},
{
"name": "About",
"href": "https://xanadu.ai/about/",
"external": True,
},
{
"name": "Hardware",
"href": "https://xanadu.ai/photonics",
"external": True,
},
{
"name": "Careers",
"href": "https://xanadu.ai/careers/",
"external": True,
},
{
"name": "Forum",
"href": "https://discuss.pennylane.ai/",
"external": True,
},
{
"name": "Blog",
"href": "https://xanadu.ai/blog",
"external": True,
},
],
},
],
"footer_social_icons": [
{
"name": "LinkedIn",
"icon": "bxl bx-linkedin",
"href": "https://linkedin.com/company/xanaduai/",
},
{
"name": "GitHub",
"icon": "bxl bx-github",
"href": "https://github.com/XanaduAI",
},
{
"name": "Twitter",
"icon": "bxl bx-twitter-x",
"href": "https://twitter.com/xanaduai",
},
{
"name": "Discourse",
"icon": "bxl bx-discourse",
"href": "https://discuss.pennylane.ai",
},
{
"name": "Slack",
"icon": "bxl bx-slack",
"href": "https://u.strawberryfields.ai/slack",
},
{
"name": "RSS",
"icon": "bx bx-rss",
"href": "https://xanadu.ai/blog",
},
],
"footer_taglines": [],
"footer_policies": [],
"footer_xanadu": {
"title": "Xanadu",
"icon": "https://assets.cloud.pennylane.ai/pennylane_website/generic/xanadu-logo.png",
"href": "https://xanadu.ai",
},
"footer_copyright": {},
}
_modules/xanadu_sphinx_theme
Download Python script
Download Notebook
View on GitHub