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

Add version switcher, favicon, and context-dependent logo #586

Merged
merged 7 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
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;
}
13 changes: 13 additions & 0 deletions docs/source/_static/version_switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"name": "latest",
"version": "latest",
"url": "https://xgi.readthedocs.io/en/latest/"
},
{
"name": "stable",
"version":"stable",
"url": "https://xgi.readthedocs.io/en/stable/",
"preferred": true
}
]
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")
nwlandry marked this conversation as resolved.
Show resolved Hide resolved
)
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,
Copy link
Collaborator

@maximelucas maximelucas Sep 9, 2024

Choose a reason for hiding this comment

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

Any way of having 5 and keeping the Gallery visible (not in dropdown)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The issue was that I wanted everything on one line even when the user wasn't in full-screen, which is basically impossible unless the navbar is slimmed down. So I will keep it like it is for now, and then change it later if need be.

"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
Loading