Skip to content

Commit b2a19ac

Browse files
committed
bug: dynamically get the latest version from release instead of tag
1 parent 5daab78 commit b2a19ac

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

doc/source/conf.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import time
1818
from importlib.metadata import version
1919
from pathlib import Path
20-
20+
import requests
2121
# If extensions (or modules to document with autodoc) are in another directory,
2222
# add these directories to sys.path here. If the directory is relative to the
2323
# documentation root, use Path().resolve() to make it absolute, like shown here.
@@ -68,6 +68,22 @@
6868
# |version| and |release|, also used in various other places throughout the
6969
# built documents.
7070

71+
def _get_latest_release_from_github(org: str, repo_name: str) -> str:
72+
"""Get the highest version release (including prereleases) from GitHub repository."""
73+
url = f"https://api.github.com/repos/{org}/{repo_name}/releases"
74+
response = requests.get(url)
75+
releases = response.json()
76+
valid_releases = [release for release in releases if "tag_name" in release]
77+
if not valid_releases:
78+
return "No valid releases found"
79+
latest_version_release = valid_releases[0]["tag_name"]
80+
return latest_version_release
81+
82+
# Get the latest release version from GitHub repository
83+
org = "diffpy"
84+
repo_name = "diffpy.utils"
85+
latest_verion_from_github = _get_latest_release_from_github(org, repo_name)
86+
7187
fullversion = version(project)
7288
# The short X.Y version.
7389
version = "".join(fullversion.split(".post")[:1])

src/diffpy/utils/diffraction_objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def __add__(self, other):
203203
Examples
204204
--------
205205
Add a scalar value to the yarray of a DiffractionObject instance:
206+
>>> my_do = DiffractionObject(wavelength=2 * np.pi, xarray=np.array([30, 60]), yarray=np.array([1, 2]), xtype="tth")
206207
>>> new_do = my_do + 10.1
207208
>>> new_do = 10.1 + my_do
208209

src/diffpy/utils/validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def is_number(string):
2323
True
2424
2525
>>> is_number("007")
26-
True
26+
False
2727
2828
>>> is_number("five")
2929
False

0 commit comments

Comments
 (0)