From 90bb30cb8f65f0b83e7cdffc67da70be4d72602d Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 30 Jul 2025 15:42:06 +0200 Subject: [PATCH] docs: set version and release from the pom.xml --- docs/source/conf.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 6a8787abcc..28318e7746 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,7 +11,10 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import xml.etree.ElementTree as ET + +from sphinx.util import logging +logger = logging.getLogger(__name__) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -40,17 +43,27 @@ master_doc = 'index' # General information about the project. -project = u'Phoebus' -copyright = u'2017, Phoebus Developers' +project = 'Phoebus' +copyright = '2017-%Y, Phoebus Developers' + +def find_phoebus_version() -> str: + try: + pom = ET.parse("../../pom.xml") + version_el = pom.find("./{http://maven.apache.org/POM/4.0.0}version") + + if version_el is not None and version_el.text is not None: + return version_el.text + else: + raise RuntimeError("Couldn't find a valid in pom.xml") + except Exception: + logger.exception("Couldn't find Phoebus version, using a default value") + return "1.0" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -# -# The short X.Y version. -version = '1.0' -# The full version, including alpha/beta/rc tags. -release = '1.0' +version = find_phoebus_version() +release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -248,6 +261,7 @@ # Create applications.rst, services.rst # by listing links to all app/**/index.rst +import os from os import walk, path import subprocess, shutil import sys, traceback