Skip to content

Commit efaab69

Browse files
authored
tweak documentation a little + change how cms version is defined (#1671)
* make the docs' version automatically match the cms version * define the version in pyproject.toml instead of __init__.py * show version in sidebar, make sidebar scroll with the page
1 parent 18efb50 commit efaab69

4 files changed

Lines changed: 14 additions & 23 deletions

File tree

cms/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
]
4747

4848

49-
__version__ = "1.6.dev0"
50-
51-
5249
# Instantiate or import these objects.
5350

5451

@@ -79,3 +76,7 @@
7976
get_service_address, get_service_shards, contest_id_from_args, \
8077
default_argument_parser
8178
from .plugin import plugin_list
79+
80+
# Define version here for backwards compatibility, just in case anything reads it.
81+
import importlib.metadata
82+
__version__ = importlib.metadata.version("cms")

docs/conf.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import sys
1515
import os
16+
import tomllib
1617

1718
# If extensions (or modules to document with autodoc) are in another directory,
1819
# add these directories to sys.path here. If the directory is relative to the
@@ -54,8 +55,9 @@
5455
#
5556
# See: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-version
5657
#
57-
version = "1.5"
58-
release = "1.5.1"
58+
with open("../pyproject.toml", 'rb') as f:
59+
version = tomllib.load(f)['project']['version']
60+
release = version
5961

6062
# The language for content autogenerated by Sphinx. Refer to documentation
6163
# for a list of supported languages.
@@ -101,7 +103,10 @@
101103
# Theme options are theme-specific and customize the look and feel of a theme
102104
# further. For a list of options available for each theme, see the
103105
# documentation.
104-
#html_theme_options = {}
106+
html_theme_options = {
107+
'fixed_sidebar': True,
108+
'description': "Version " + version,
109+
}
105110

106111
# Add any paths that contain custom themes here, relative to this directory.
107112
#html_theme_path = []

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[project]
2-
dynamic = ["version", "entry-points", "scripts"]
2+
dynamic = ["entry-points", "scripts"]
33
name = "cms"
4+
version = "1.6.dev0"
45
license = "AGPL-3.0-or-later"
56
maintainers = [ { name = "The CMS development team", email = "contestms@googlegroups.com" } ]
67
readme = "README.md"

setup.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
2929
"""
3030

31-
import os
32-
import re
33-
3431
from setuptools import setup, find_packages
3532
from setuptools.command.build import build
3633

@@ -92,18 +89,6 @@
9289
],
9390
}
9491

95-
96-
def find_version():
97-
"""Return the version string obtained from cms/__init__.py"""
98-
path = os.path.join("cms", "__init__.py")
99-
with open(path, "rt", encoding="utf-8") as f:
100-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
101-
f.read(), re.M)
102-
if version_match is not None:
103-
return version_match.group(1)
104-
raise RuntimeError("Unable to find version string.")
105-
106-
10792
# We piggyback the translation catalogs compilation onto build since
10893
# the po and mofiles will be part of the package data for cms.locale,
10994
# which is collected at this stage.
@@ -113,7 +98,6 @@ class build_with_l10n(build):
11398

11499
setup(
115100
name="cms",
116-
version=find_version(),
117101
packages=find_packages(),
118102
package_data=PACKAGE_DATA,
119103
cmdclass={"build": build_with_l10n},

0 commit comments

Comments
 (0)