diff --git a/composer.json b/composer.json index 93b0f86..2f9b194 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "erebot/api": "^0.7.1" }, "require-dev": { - "erebot/buildenv": "^1.1.0", + "erebot/buildenv": "^1.4.0", "erebot/testenv": "^1.1.2", "erebot/generic-doc": "*" }, diff --git a/composer.lock b/composer.lock index e22b214..ee5051d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "65806c3397fcff03d3b97f3c18e8934f", + "content-hash": "00e4d27e13e5d2c543e8fcbbbd679087", "packages": [ { "name": "erebot/api", @@ -424,16 +424,16 @@ }, { "name": "erebot/buildenv", - "version": "1.3.1", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/Erebot/Buildenv.git", - "reference": "2ce8dfe61ee7e58e9e7bdf6130ac9db7608d3f7b" + "reference": "cb89a65bf6ad1175f3c15abc96030ffff46e6915" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Erebot/Buildenv/zipball/2ce8dfe61ee7e58e9e7bdf6130ac9db7608d3f7b", - "reference": "2ce8dfe61ee7e58e9e7bdf6130ac9db7608d3f7b", + "url": "https://api.github.com/repos/Erebot/Buildenv/zipball/cb89a65bf6ad1175f3c15abc96030ffff46e6915", + "reference": "cb89a65bf6ad1175f3c15abc96030ffff46e6915", "shasum": "" }, "require": { @@ -469,7 +469,7 @@ "keywords": [ "Erebot" ], - "time": "2017-03-22T21:42:24+00:00" + "time": "2017-05-06T13:37:33+00:00" }, { "name": "erebot/dom", diff --git a/docs/src/conf.py b/docs/src/conf.py index 2c2b2e8..40a57b2 100644 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -1,172 +1,34 @@ # -*- coding: utf-8 -*- import os -from os.path import join, dirname -import sys -import glob -import shutil -import urllib -import fnmatch -from datetime import datetime -from subprocess import call, Popen, PIPE - -try: - import simplejson as json -except ImportError: - import json +import stat +from os.path import join, abspath +from subprocess import call def prepare(globs, locs): - # Where are we? + # RTD defaults the current working directory to where conf.py resides. + # In our case, that means /docs/src/. cwd = os.getcwd() - root = os.path.abspath(join(cwd, '..', '..')) - deps = os.path.abspath(join(cwd, dirname(__file__), 'php-requirements.txt')) - - git = Popen('which git 2> %s' % os.devnull, shell=True, - stdout=PIPE).stdout.read().strip() - doxygen = Popen('which doxygen 2> %s' % os.devnull, shell=True, - stdout=PIPE).stdout.read().strip() - - locs['rtd_slug'] = os.path.basename(os.path.dirname(os.path.dirname(root))) - locs['rtd_version'] = os.path.basename(root) - pybabel = join(root, '..', '..', 'envs', locs['rtd_version'], 'bin', 'pybabel') - builder = sys.argv[sys.argv.index('-b') + 1] - - print "builder:", builder - print "git version:" - call([git, '--version']) - print "doxygen version:" - call([doxygen, '--version']) - print "pybabel version:" - call([pybabel, '--version']) - - print "Building version %s for %s in %s..." % ( - locs['rtd_version'], - locs['rtd_slug'], - root - ) + root = abspath(join(cwd, '..', '..')) os.chdir(root) - # Figure several configuration values from git. - origin = Popen([git, 'config', '--local', 'remote.origin.url'], - stdout=PIPE).stdout.read().strip() - git_tag = Popen([git, 'describe', '--tags', '--exact', '--first-parent'], - stdout=PIPE).communicate()[0].strip() - git_hash = Popen([git, 'rev-parse', 'HEAD'], - stdout=PIPE).communicate()[0].strip() - - origin = origin.replace(':', '/').split('/') - vendor = origin[-2] - project = origin[-1] - if project.endswith('.git'): - project = project[:-4] - os.environ['SPHINX_PROJECT'] = project - if git_tag: - os.environ['SPHINX_VERSION'] = git_tag - os.environ['SPHINX_RELEASE'] = git_tag - else: - commit = Popen([git, 'describe', '--always', '--first-parent'], - stdout=PIPE).communicate()[0].strip() - os.environ['SPHINX_VERSION'] = 'latest' - os.environ['SPHINX_RELEASE'] = 'latest-%s' % (commit, ) - locs['tags'].add('devel') - - # Common dependencies - dependencies = [ - ('git://github.com/Erebot/Buildenv.git', 'vendor/erebot/buildenv'), - ('git://github.com/fpoirotte/PHPNatives4Doxygen', 'vendor/fpoirotte/natives4doxygen'), - ] + # Download the PHP binary & composer.phar if necessary + base = 'https://github.com/Erebot/Buildenv/releases/download/1.4.0' + for f in ('php', 'composer.phar'): + call(['curl', '-L', '-z', f, '-o', f, '%s/%s' % (base, f)]) - # Project-specific dependencies - try: - with open(deps, 'r') as fd: - dependencies += [line.split() for line in fd.readlines()] - except: - pass + # Make sure the PHP interpreter is executable + os.chmod('./php', stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) - # Clone or update dependencies - for repository, path in dependencies: - path = join(root, path) - if not os.path.isdir(path): - os.makedirs(path) - print "Cloning %s into %s..." % (repository, path) - call([git, 'clone', repository, path]) - elif os.path.isdir(join(path, '.git')): - os.chdir(path) - print "Updating clone of %s in %s..." % (repository, path) - call([git, 'checkout', 'master']) - call([git, 'pull']) - os.chdir(root) + # Call composer to download/update dependencies as necessary + os.environ['COMPOSER_CACHE_DIR'] = './cache' + call(['./php', 'composer.phar', 'update', '-n', '--ignore-platform-reqs', + '--no-progress'], env=os.environ) - composer = json.load(open(join(root, 'composer.json'), 'r')) - - if builder == 'readthedocs': - # Run doxygen - call([doxygen, join(root, 'Doxyfile')], env={ - 'COMPONENT_NAME': os.environ['SPHINX_PROJECT'], - 'COMPONENT_VERSION': os.environ['SPHINX_VERSION'], - 'COMPONENT_BRIEF': composer.get('description', ''), - }) - - # Copy API doc to final place, - # overwriting files as necessary. - try: - shutil.rmtree(join(root, 'build')) - except OSError: - pass - os.mkdir(join(root, 'build')) - shutil.move( - join(root, 'docs', 'api', 'html'), - join(root, 'build', 'apidoc'), - ) - try: - shutil.move( - join(root, '%s.tagfile.xml' % - os.environ['SPHINX_PROJECT']), - join(root, 'build', 'apidoc', '%s.tagfile.xml' % - os.environ['SPHINX_PROJECT']) - ) - except OSError: - pass - - # Copy translations for generic docs to catalogs folder. - gen_i18n = join(root, 'docs', 'src', 'generic', 'i18n', '.')[:-1] - for translation in glob.iglob(join(gen_i18n, '*')): - target_dir = join( - root, 'docs', 'i18n', - translation[len(gen_i18n):], - 'LC_MESSAGES', 'generic' - ) - translation = join(translation, 'LC_MESSAGES', 'generic') - shutil.rmtree(target_dir, ignore_errors=True) - shutil.copytree(translation, target_dir) - - # Compile translation catalogs. - for locale_dir in glob.iglob(join(root, 'docs', 'i18n', '*')): - for base, dirnames, filenames in os.walk(locale_dir): - for po in fnmatch.filter(filenames, '*.po'): - po = join(base, po) - mo = po[:-3] + '.mo' - call([pybabel, 'compile', '-f', '--statistics', - '-i', po, '-o', mo]) - - # Load the real Sphinx configuration file. + # Load the second-stage configuration file. os.chdir(cwd) - real_conf = join(root, 'vendor', 'erebot', 'buildenv', 'sphinx', 'conf.py') - print "Including real configuration file (%s)..." % (real_conf, ) - execfile(real_conf, globs, locs) - - # Patch configuration afterwards. - # - Theme - locs.setdefault('html_extra_path', []).append(join(root, 'build')) - locs['html_theme'] = 'haiku' - # - I18N - locs.setdefault('locale_dirs', []).insert(0, join(root, 'docs', 'i18n')) - # - misc. - locs['rst_prolog'] = locs.get('rst_prolog', '') + \ - '\n .. _`this_commit`: https://github.com/%s/%s/commit/%s\n' % ( - vendor, - project, - git_hash, - ) + conf = join(root, 'vendor', 'erebot', 'buildenv', 'sphinx', 'rtd.py') + print "Including the second configuration file (%s)..." % (conf, ) + execfile(conf, globs, locs) prepare(globals(), locals())