# -*- coding: utf-8 -*-

import datetime, re, json
from subprocess import Popen, PIPE

process = Popen(["hg", "branch"], stdout=PIPE)
branch = process.communicate()[0].strip()

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[:2])  # The full version, including alpha/beta/rc tags.

source_suffix        = '.rst'
master_doc           = 'index'
project              = u'realURL2'
copyright            = u'%s, webvariants GbR' % (datetime.date.today().year)
version              = major
release              = '.'.join(v[:3])
language             = 'de'
exclude_patterns     = ['_build']
pygments_style       = 'default'
html_theme           = 'nature'
html_title           = "%s v%s Dokumentation" % (project, release)
html_favicon         = 'favicon.ico'
html_static_path     = ['_static']
html_use_smartypants = True
