Skip to content

Commit

Permalink
Tweak RTD conf file
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoirotte committed Dec 21, 2016
1 parent ac5bfe2 commit 414a54e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-

import os
import sys
import glob
import shutil
import urllib
import fnmatch
from datetime import datetime
from subprocess import call, Popen, PIPE

try:
Expand Down Expand Up @@ -43,8 +45,10 @@ def prepare(globs, locs):

# 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).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()
project = origin.rpartition('/')[2]
if project.endswith('.git'):
Expand All @@ -54,7 +58,7 @@ def prepare(globs, locs):
os.environ['SPHINX_VERSION'] = git_tag
os.environ['SPHINX_RELEASE'] = git_tag
else:
commit = Popen(['git', 'describe', '--always', '--first-parent'],
commit = Popen([git, 'describe', '--always', '--first-parent'],
stdout=PIPE).communicate()[0].strip()
os.environ['SPHINX_VERSION'] = 'latest'
os.environ['SPHINX_RELEASE'] = 'latest-%s' % (commit, )
Expand All @@ -73,7 +77,7 @@ def prepare(globs, locs):
os.makedirs(path)
print "Cloning %s into %s..." % (repository, path)
call([git, 'clone', repository, path])
else:
elif os.path.isdir(os.path.join(path, '.git')):
os.chdir(path)
print "Updating clone of %s in %s..." % (repository, path)
call([git, 'checkout', 'master'])
Expand Down Expand Up @@ -148,6 +152,13 @@ def prepare(globs, locs):
locs['locale_dirs'] = []
locs['locale_dirs'].insert(0, os.path.join(root, 'docs', 'i18n'))

if 'rst_prolog' not in locs:
locs['rst_prolog'] = ''
locs['rst_prolog'] += '\n .. _`this_commit`: https://github.com/%s/commit/%s\n' % (
project,
git_hash,
)

# - Custom roles
if 'doxylinks' in locs and 'api' in locs['doxylinks']:
locs['doxylinks']['api'] = (
Expand Down

0 comments on commit 414a54e

Please sign in to comment.