From dcd5ea6d36eff10abd5bd4e1b7bd5b9493594950 Mon Sep 17 00:00:00 2001 From: Will Barnes Date: Tue, 17 Sep 2024 16:19:24 -0400 Subject: [PATCH 1/4] better version parsing for docs build --- {{ cookiecutter.package_name }}/docs/conf.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/{{ cookiecutter.package_name }}/docs/conf.py b/{{ cookiecutter.package_name }}/docs/conf.py index e595c98..c5c5355 100644 --- a/{{ cookiecutter.package_name }}/docs/conf.py +++ b/{{ cookiecutter.package_name }}/docs/conf.py @@ -6,12 +6,23 @@ import datetime +from packaging.version import Version + # -- Project information ----------------------------------------------------- # The full version, including alpha/beta/rc tags from {{ cookiecutter.module_name }} import __version__ -release = __version__ +_version_ = Version(__version__) +# NOTE: Avoid "post" appearing in version string in rendered docs +if _version_.is_postrelease: + version = release = f'{_version_.major}.{_version_.minor}.{_version_.micro}' +# NOTE: Avoid long githashes in rendered Sphinx docs +elif _version_.is_devrelease: + version = release = f'{_version_.major}.{_version_.minor}.dev{_version_.dev}' +else: + version = release = str(_version_) +is_development = _version_.is_devrelease project = "{{ cookiecutter.package_name }}" author = "{{ cookiecutter.author_name }}" From 33f857c4fd4053f75f7ccc7876fd5dc4e15c2113 Mon Sep 17 00:00:00 2001 From: Will Barnes Date: Tue, 24 Sep 2024 14:09:08 -0400 Subject: [PATCH 2/4] use base version --- {{ cookiecutter.package_name }}/docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{ cookiecutter.package_name }}/docs/conf.py b/{{ cookiecutter.package_name }}/docs/conf.py index c5c5355..1789d57 100644 --- a/{{ cookiecutter.package_name }}/docs/conf.py +++ b/{{ cookiecutter.package_name }}/docs/conf.py @@ -16,10 +16,10 @@ _version_ = Version(__version__) # NOTE: Avoid "post" appearing in version string in rendered docs if _version_.is_postrelease: - version = release = f'{_version_.major}.{_version_.minor}.{_version_.micro}' + version = release = _version_.base_version # NOTE: Avoid long githashes in rendered Sphinx docs elif _version_.is_devrelease: - version = release = f'{_version_.major}.{_version_.minor}.dev{_version_.dev}' + version = release = f'{_version_.base_version}.dev{_version_.dev}' else: version = release = str(_version_) is_development = _version_.is_devrelease From 68df6ae634405d809b40d28bd14e6b8a5b240485 Mon Sep 17 00:00:00 2001 From: Will Barnes Date: Wed, 25 Sep 2024 07:17:40 -0400 Subject: [PATCH 3/4] Update conf.py Co-authored-by: Stuart Mumford --- {{ cookiecutter.package_name }}/docs/conf.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/{{ cookiecutter.package_name }}/docs/conf.py b/{{ cookiecutter.package_name }}/docs/conf.py index 1789d57..fb8fa45 100644 --- a/{{ cookiecutter.package_name }}/docs/conf.py +++ b/{{ cookiecutter.package_name }}/docs/conf.py @@ -13,16 +13,15 @@ # The full version, including alpha/beta/rc tags from {{ cookiecutter.module_name }} import __version__ -_version_ = Version(__version__) -# NOTE: Avoid "post" appearing in version string in rendered docs -if _version_.is_postrelease: - version = release = _version_.base_version -# NOTE: Avoid long githashes in rendered Sphinx docs -elif _version_.is_devrelease: - version = release = f'{_version_.base_version}.dev{_version_.dev}' -else: - version = release = str(_version_) -is_development = _version_.is_devrelease +_version = Version(__version__) +version = release = str(_version) +# Avoid "post" appearing in version string in rendered docs +if _version.is_postrelease: + version = release = _version.base_version +# Avoid long githashes in rendered Sphinx docs +elif _version.is_devrelease: + version = release = f'{_version.base_version}.dev{_version.dev}' +is_development = _version.is_devrelease project = "{{ cookiecutter.package_name }}" author = "{{ cookiecutter.author_name }}" From 93135e04b90973a471c362fed83c8560ac0887ca Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Wed, 25 Sep 2024 13:50:09 +0100 Subject: [PATCH 4/4] Add packaging dep to docs --- {{ cookiecutter.package_name }}/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{ cookiecutter.package_name }}/pyproject.toml b/{{ cookiecutter.package_name }}/pyproject.toml index 4635dd1..5054519 100644 --- a/{{ cookiecutter.package_name }}/pyproject.toml +++ b/{{ cookiecutter.package_name }}/pyproject.toml @@ -42,6 +42,7 @@ tests = [ docs = [ "sphinx", "sphinx-automodapi", + "packaging", ] {%- if cookiecutter.project_url %}