From 6b1c5489a2c364cf269ef174447e524bd23ca560 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Tue, 19 Jan 2021 10:42:27 +0100 Subject: [PATCH 1/2] fix(build): Only change VersionDirective if supported The VersionChange class is not available in older versions of sphinx, so we just disable it Fixes #2356 --- CHANGELOG.md | 2 ++ doc/conf.py | 46 +++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf5eb9d0..19083c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Build +- Support older python sphinx versions again ([`#2356`](https://github.com/polybar/polybar/issues/2356)) ## [3.5.4] - 2021-01-07 ### Fixed diff --git a/doc/conf.py b/doc/conf.py index 94d10cbe..9bd12125 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -15,9 +15,7 @@ import os from pathlib import Path import datetime -from typing import List -from docutils.nodes import Node -from sphinx.domains.changeset import VersionChange +import sphinx import packaging.version def get_version(root_path): @@ -32,8 +30,6 @@ def get_version(root_path): raise RuntimeError("No version found in {}".format(path)) - - # -- Project information ----------------------------------------------------- project = 'Polybar User Manual' @@ -221,20 +217,32 @@ epub_exclude_files = ['search.html'] # The 'versionadded' and 'versionchanged' directives are overridden. suppress_warnings = ['app.add_directive'] -def setup(app): - app.add_directive('deprecated', VersionDirective) - app.add_directive('versionadded', VersionDirective) - app.add_directive('versionchanged', VersionDirective) +# It is not exactly clear in which version the VersionChange class was +# introduced, but we know it is available in at least 1.8.5. +# This feature is mainly needed for the online docs on readthedocs for the docs +# built from master, documentation built for proper releases should not even +# mention unreleased changes. Because of that it's not that important that this +# is added to local builds. +if packaging.version.parse(sphinx.__version__) >= packaging.version.parse("1.8.5"): -class VersionDirective(VersionChange): - """ - Overwrites the Sphinx directive for versionchanged, versionadded, and - deprecated and adds an unreleased tag to versions that are not yet released - """ - def run(self) -> List[Node]: - directive_version = packaging.version.parse(self.arguments[0]) + from typing import List + from docutils.nodes import Node + from sphinx.domains.changeset import VersionChange - if directive_version > version_txt: - self.arguments[0] += " (unreleased)" + def setup(app): + app.add_directive('deprecated', VersionDirective) + app.add_directive('versionadded', VersionDirective) + app.add_directive('versionchanged', VersionDirective) - return super().run() + class VersionDirective(VersionChange): + """ + Overwrites the Sphinx directive for versionchanged, versionadded, and + deprecated and adds an unreleased tag to versions that are not yet released + """ + def run(self) -> List[Node]: + directive_version = packaging.version.parse(self.arguments[0]) + + if directive_version > version_txt: + self.arguments[0] += " (unreleased)" + + return super().run() From 1d033edaae8fe40ed3cbe2b80687cac0813837fb Mon Sep 17 00:00:00 2001 From: patrick96 Date: Mon, 1 Mar 2021 21:33:03 +0100 Subject: [PATCH 2/2] Release 3.5.5 --- CHANGELOG.md | 4 +++- version.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19083c9c..44988bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [3.5.5] - 2021-03-01 ### Build - Support older python sphinx versions again ([`#2356`](https://github.com/polybar/polybar/issues/2356)) @@ -22,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Empty color values are no longer treated as invalid and no longer produce an error. -[Unreleased]: https://github.com/polybar/polybar/compare/3.5.4...HEAD +[Unreleased]: https://github.com/polybar/polybar/compare/3.5.5...HEAD +[3.5.5]: https://github.com/polybar/polybar/releases/tag/3.5.5 [3.5.4]: https://github.com/polybar/polybar/releases/tag/3.5.4 [3.5.3]: https://github.com/polybar/polybar/releases/tag/3.5.3 diff --git a/version.txt b/version.txt index 094129b6..207bcec8 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ # Polybar version information # Update this on every release # This is used to create the version string if a git repo is not available -3.5.4 +3.5.5