Skip to content

Commit

Permalink
get release / version info from setuptools_scm (#1674)
Browse files Browse the repository at this point in the history
* get release / version info from setuptools_scm

* adding version in custom footer
  • Loading branch information
andrewkern authored Jan 31, 2025
1 parent bf1fb81 commit d877cf3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.footer {
margin-top: 20px;
text-align: center;
font-size: 0.9em;
color: #737373;
}
5 changes: 5 additions & 0 deletions docs/_templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "!footer.html" %}
{% block extrafooter %}
{{ super() }}
<div class="footer">Version: {{ version }} ({{ release }})</div>
{% endblock %}
34 changes: 28 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# 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 datetime
import os
import sys
from setuptools_scm import get_version

sys.path.insert(0, os.path.abspath(".."))
# Add the path for local extensions
Expand All @@ -22,13 +24,16 @@
# -- Project information -----------------------------------------------------

project = "stdpopsim"
copyright = "2019-2022, PopSim Consortium"
copyright = f"2019-{datetime.datetime.now().year}, PopSim Consortium"
author = "PopSim Consortium"

# The short X.Y version
version = ""
# The full version, including alpha/beta/rc tags
release = "0.2.0"
# get the release version from the setuptools_scm
try:
release = get_version(root="..", relative_to=__file__)
version = ".".join(release.split(".")[:2])
except Exception:
release = "unknown"
version = "unknown"


# -- General configuration ---------------------------------------------------
Expand All @@ -41,6 +46,7 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
Expand Down Expand Up @@ -93,13 +99,29 @@
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
html_context = {
"display_github": True,
"version": version,
"release": release,
}
html_theme_options = {
"version_selector": True,
}

# Show the version number in the navigation bar
html_show_sphinx = True
html_show_version = True

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

# Add custom CSS to style the footer
html_css_files = [
"custom.css",
]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
Expand Down

0 comments on commit d877cf3

Please sign in to comment.