Commits

Christoph Mewes committed 777e1c7

improved docs version detection

  • Participants
  • Parent commits 21903e4
  • Branches 4.3

Comments (0)

Files changed (1)

File docs/conf.py

 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os, yaml, datetime
+import sys, os, json, datetime, re
+from subprocess import Popen, PIPE
 
 # 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
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 
-f = open('../static.yml')
-dataMap = yaml.load(f)
-f.close()
+process = Popen(["hg", "branch"], stdout=PIPE)
+branch = process.communicate()[0].strip()
 
-v = dataMap['version'].split('.')
-v += ['0', '0']
+if branch == 'default' or re.match('^\d\.(\d|x)', branch) == None:
+    branch = 'dev-' + branch
+    f = open('../composer.json')
+    dataMap = json.load(f)
+    f.close()
+
+    if branch in dataMap['extra']['branch-alias']:
+        v = re.split('[.-]', dataMap['extra']['branch-alias'][branch])
+        v += ['x', 'x']
+    else:
+        v = ['?', '?', '?']
+else:
+    v = branch.split('.')
+    v += ['x', 'x']
+
 [major, minor, bugfix] = v[:3]
 
-version = major           # The short X.Y version.
-release = '.'.join(v[:3]) # The full version, including alpha/beta/rc tags.
+version = major            # The short X.Y version.
+release = '.'.join(v[:2])  # The full version, including alpha/beta/rc tags.
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.