mirror of https://github.com/polybar/polybar.git
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
This commit is contained in:
parent
fdc670a9dd
commit
6b1c5489a2
|
@ -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
|
||||
|
|
46
doc/conf.py
46
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()
|
||||
|
|
Loading…
Reference in New Issue