From 112df1c2e2e2dde48893a1f190160fd6b927eed4 Mon Sep 17 00:00:00 2001 From: Nicholas Landry Date: Mon, 9 Sep 2024 13:54:19 -0400 Subject: [PATCH] Fix version switching (#590) * Fix version switching * fix version number * Update contributing guide * Update conf.py --- HOW_TO_CONTRIBUTE.md | 2 +- docs/source/_static/custom.css | 2 +- docs/source/_static/version_switcher.json | 4 +-- docs/source/_templates/navbar-version.html | 1 + docs/source/conf.py | 33 ++++++++++++++++------ docs/source/index.rst | 2 +- 6 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 docs/source/_templates/navbar-version.html diff --git a/HOW_TO_CONTRIBUTE.md b/HOW_TO_CONTRIBUTE.md index db6df390d..796c871c6 100644 --- a/HOW_TO_CONTRIBUTE.md +++ b/HOW_TO_CONTRIBUTE.md @@ -25,7 +25,7 @@ Please note we have a [code of conduct](/CODE_OF_CONDUCT.md), please follow it i 1. Make sure that the Github Actions workflow runs without any errors. 2. Using the `github-changelog` package (a dependency in the [release](requirements/release.txt) requirements file), run `changelog -m xgi-org xgi [last release tag]` to get the merged pull requests with their links. Paste this into the changelog file under a new heading and edit to make more legible. Associate a GitHub username with each pull request. -3. Increase the version number in [\_\_init\_\_.py](xgi/__init__.py.py) and [conf.py](docs/source/conf.py) to the new version agreed upon by the core developers. The versioning scheme we use is [SemVer](http://semver.org/). +3. Increase the version number in [\_\_init\_\_.py](xgi/__init__.py.py) to the new version agreed upon by the core developers. The versioning scheme we use is [SemVer](http://semver.org/). 4. Commit these changes. 5. Create a new release on GitHub by selecting "Releases", then clicking "Draft a new release". Click "Choose a tag" and type "v" followed by the version number and then click "Create new tag". The release title will be this same string. Paste the contents of the CHANGELOG into the "Describe this release" field. Click "Publish release". 6. Run `python -m build` from the main folder. This will create a zipped file to upload to PyPI and save it to the "dist" folder. diff --git a/docs/source/_static/custom.css b/docs/source/_static/custom.css index b2756f62c..5c1612f97 100644 --- a/docs/source/_static/custom.css +++ b/docs/source/_static/custom.css @@ -61,5 +61,5 @@ html[data-theme="light"] table.data tbody tr:nth-child(even) { } /* Remove whitespace to the right of the xgi logo */ .bd-header .navbar-header-items__start { - width: 100px; + width: 130px; } \ No newline at end of file diff --git a/docs/source/_static/version_switcher.json b/docs/source/_static/version_switcher.json index 0b0ab048d..beb338766 100644 --- a/docs/source/_static/version_switcher.json +++ b/docs/source/_static/version_switcher.json @@ -1,7 +1,7 @@ [ { - "name": "latest", - "version": "latest", + "name": "dev", + "version": "dev", "url": "https://xgi.readthedocs.io/en/latest/" }, { diff --git a/docs/source/_templates/navbar-version.html b/docs/source/_templates/navbar-version.html new file mode 100644 index 000000000..85cac17cc --- /dev/null +++ b/docs/source/_templates/navbar-version.html @@ -0,0 +1 @@ + {{ version }} \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 07dbd0838..1035b39bb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -17,6 +17,8 @@ import requests +import xgi + sys.path.insert(0, os.path.abspath(".")) sys.path.append(os.path.join(os.path.dirname(__name__), "xgi")) @@ -24,8 +26,7 @@ # -- Project information ----------------------------------------------------- project = "XGI" copyright = f"2021-{date.today().year} XGI Developers" -release = "0.8.10" -version = release +version = xgi.__version__ # -- General configuration --------------------------------------------------- @@ -173,12 +174,33 @@ # 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 +version_match = os.environ.get("READTHEDOCS_VERSION") + +# If READTHEDOCS_VERSION doesn't exist, we're not on RTD +if not version_match: + version_match = "dev" + +# If it is an integer, we're in a PR build and the version isn't correct. +elif version_match.isdigit(): + version_match = "dev" + +# If it's "latest" → change to "dev" (that's what we want the switcher to call it) +elif version_match == "latest": + version_match = "dev" + +else: + version_match = "stable" + +if version_match == "dev": + version = "dev" + # documentation. html_theme_options = { "logo": { "image_light": "../../logo/logo.svg", "image_dark": "../../logo/logo_white.svg", }, + "navbar_start": ["navbar-logo", "navbar-version"], "navbar_end": [ "theme-switcher", "navbar-icon-links", @@ -195,18 +217,13 @@ "url": "https://twitter.com/xginets", "icon": "fab fa-twitter-square", # Font Awesome icon }, - { - "name": "Mastodon", - "url": "https://mathstodon.xyz/@xginets", - "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, + "version_match": version_match, }, } diff --git a/docs/source/index.rst b/docs/source/index.rst index 15d711254..2905e0239 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -66,7 +66,7 @@ More information about the datasets and how to load them is in the `XGI-DATA men Get involved ================== -To simply getting news and updates, you can sign up for our `mailing list `_ and follow XGI on `Twitter `_ or `Mastodon `_! +To simply getting news and updates, you can sign up for our `mailing list `_ and follow XGI on `Twitter `_! If you want to contribute, even better! The XGI community always welcomes contributions, no matter how small. For more information, see our `contribution guide `_.