Skip to content

Commit

Permalink
Merge pull request #29 from mgrover1/add-version-switcher
Browse files Browse the repository at this point in the history
ENH: Add version switcher
  • Loading branch information
mgrover1 committed Jan 4, 2024
2 parents 06c8d1b + b444857 commit 234cc92
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
11 changes: 5 additions & 6 deletions cmweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@
* plasmidis
"""
from pkg_resources import DistributionNotFound, get_distribution

from importlib.metadata import version, PackageNotFoundError
from . import cm, cm_colorblind # noqa

# Get the version
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
__version__ = '0.0.0' # pragma: no cover
__version__ = version('cmweather')
except PackageNotFoundError:
# package is not installed
pass
11 changes: 11 additions & 0 deletions docs/source/_static/pst-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"version": "dev",
"url": "https://cmweather.readthedocs.io/en/dev"
},
{
"version": "latest",
"url": "https://cmweather.readthedocs.io/en/latest/",
"is_latest": true
}
]
23 changes: 20 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import datetime
import os
import re
import sys

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -92,9 +93,19 @@
# built documents.
#
# The short X.Y version.
version = cmweather.__version__.split('+')[0]
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
verinfo = cmweather.__version__
parsed_version = re.search(r'(?P<full>(?P<base>\d+\.\d+)\.?\w*)', verinfo).groupdict()

# The short X.Y version.
version = parsed_version['base']
if '+' in verinfo:
version += 'dev'
# The full version, including alpha/beta/rc tags.
release = cmweather.__version__
release = parsed_version['full']

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -143,7 +154,13 @@
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
html_theme_options = {
'navbar_start': ['navbar-logo', 'version-switcher'],
'switcher': {
'json_url': 'https://raw.githubusercontent.com/mgrover1/cmweather/add-version-switcher/docs/source/_static/pst-versions.json',
'version_match': 'dev' if 'dev' in version else f'v{version}',
},
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
description='A library of useful colormaps when visualizing weather and climate data, with numerous color vision deficiency friendly options',
install_requires=requirements,
setup_requires='setuptools_scm',
setup_requires=['setuptools', 'wheel', 'setuptools_scm'],
license='MIT license',
long_description=long_description,
include_package_data=True,
Expand All @@ -44,6 +44,5 @@
zip_safe=False,
use_scm_version={
'version_scheme': 'post-release',
'local_scheme': 'dirty-tag',
},
)

0 comments on commit 234cc92

Please sign in to comment.