changeset 49:5c0f26a21e81

Determine "release" dynamically from the package's "__version__"
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 26 Apr 2026 15:34:55 +0200
parents fcc34b24ded7
children e6354e3abbec
files docs/conf.py
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/docs/conf.py	Sun Apr 26 15:06:58 2026 +0200
+++ b/docs/conf.py	Sun Apr 26 15:34:55 2026 +0200
@@ -3,13 +3,27 @@
 # For the full list of built-in configuration values, see the documentation:
 # https://www.sphinx-doc.org/en/master/usage/configuration.html
 
+import ast
+import io
+import re
+
 # -- Project information -----------------------------------------------------
 # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
 
 project = 'Pygments Pseudocode Lexer'
 copyright = '2026, Franz Glasner'
 author = 'Franz Glasner'
-release = '2.0.1'
+# Determine "release" dynamically from the package's "__version__"
+with io.open("../pygments_lexer_pseudocode2/__init__.py",
+             "rt",
+             encoding="utf-8") as relfp:
+    release = ast.literal_eval(
+        re.search(r"""^\s*__version__\s*=\s*(("|')[^"']*\2)""",
+                  relfp.read(),
+                  re.MULTILINE)
+        .group(1)
+        )
+del relfp    
 
 # -- General configuration ---------------------------------------------------
 # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration