Skip to content

Commit

Permalink
Add version switcher, favicon, and context-dependent logo (#586)
Browse files Browse the repository at this point in the history
* Add version switcher, favicon, and context-dependent logo

* Update custom.css

* Update logo.png

* Response to review

* slim down navbar

* Update custom.css

* Update docs/source/conf.py

Co-authored-by: Maxime Lucas <[email protected]>

---------

Co-authored-by: Maxime Lucas <[email protected]>
  • Loading branch information
nwlandry and maximelucas authored Sep 9, 2024
1 parent 4d26fc8 commit 5b08511
Show file tree
Hide file tree
Showing 13 changed files with 394 additions and 18 deletions.
11 changes: 10 additions & 1 deletion docs/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,14 @@ html[data-theme="light"] table.data tbody tr:nth-child(odd) {
}

html[data-theme="light"] table.data tbody tr:nth-child(even) {
background-color: #f2f2f2; /* Lighter gray */
background-color: #ffffff; /* Lighter gray */
}

/* Fixed width for the navbar items */
.bd-header ul.navbar-nav {
width: 475px;
}
/* Remove whitespace to the right of the xgi logo */
.bd-header .navbar-header-items__start {
width: 100px;
}
Binary file added docs/source/_static/x.ico
Binary file not shown.
42 changes: 32 additions & 10 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@

import os
import sys
from datetime import date, datetime

import requests

sys.path.insert(0, os.path.abspath("."))
sys.path.append(os.path.join(os.path.dirname(__name__), "xgi"))


# -- Project information -----------------------------------------------------
project = "XGI"
copyright = "2021-2024 XGI Developers"
copyright = f"2021-{date.today().year} XGI Developers"
release = "0.8.10"
version = release
today = "02-09-2024"

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

Expand Down Expand Up @@ -65,9 +67,9 @@
html_static_path = ["_static"]
html_css_files = ["custom.css"]
html_js_files = ["table.js"]

html_favicon = "_static/x.ico"
# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = "1.3"
needs_sphinx = "6.2.1"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
Expand All @@ -88,6 +90,7 @@
"nbsphinx_link",
]


# Automatically generate stub pages when using the .. autosummary directive
autosummary_generate = True
autosummary_generate_overwrite = False
Expand Down Expand Up @@ -115,9 +118,18 @@

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
r = requests.get("https://api.github.com/repos/xgi-org/xgi/releases/latest")

if r.ok:
release_date = (
datetime.fromisoformat(r.json()["published_at"]).date().strftime("%b %d, %Y")
)
else:
raise Exception(f"Error: HTTP response {r.status_code}")

today = release_date
# Else, today_fmt is used as the format for a strftime call.
today_fmt = "%B %d, %Y"
# today_fmt = "%B %d, %Y"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -163,10 +175,15 @@

# documentation.
html_theme_options = {
"logo": {
"image_light": "../../logo/logo.svg",
"image_dark": "../../logo/logo_white.svg",
},
"navbar_end": [
"theme-switcher",
"navbar-icon-links",
], # Place the social links at the end of the navbar
"version-switcher",
],
"icon_links": [
{
"name": "GitHub",
Expand All @@ -184,6 +201,13 @@
"icon": "fa-brands fa-mastodon", # Font Awesome icon
},
],
"header_links_before_dropdown": 4,
"switcher": {
"json_url": (
"https://xgi.readthedocs.io/en/latest/_static/version_switcher.json"
),
"version_match": "latest" if "dev" in version else version,
},
}


Expand All @@ -201,9 +225,7 @@

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = ["_static"]
# html_static_path = ["_static"]

html_logo = "../../logo/logo.svg"
html_static_path = ["_static"]

html_show_sphinx = True

Expand Down
9 changes: 7 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

.. image:: ../../logo/logo.svg
.. image:: ../../logo/logo.png
:class: only-light
:width: 200

.. image:: ../../logo/logo_white.png
:class: only-dark
:width: 200

.. toctree::
Expand All @@ -10,9 +15,9 @@
user_guides
api_reference
xgi-data
gallery
contribute
using-xgi
gallery


.. button-link:: https://github.com/xgi-org/xgi/releases/tag/v0.8.10
Expand Down
Binary file modified logo/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo/logo_tight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo/logo_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 177 additions & 0 deletions logo/logo_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo/x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5b08511

Please sign in to comment.