Skip to content

Commit

Permalink
Update RTD conf
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoirotte committed Dec 31, 2016
1 parent ad6626e commit 9c9c744
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def prepare(globs, locs):
stdout=PIPE).communicate()[0].strip()
git_hash = Popen([git, 'rev-parse', 'HEAD'],
stdout=PIPE).communicate()[0].strip()
project = origin.rpartition('/')[2]
vendor, project = origin.rpartition(':')[2].split('/')[-2:]
if project.endswith('.git'):
project = project[:-4]
os.environ['SPHINX_PROJECT'] = project
Expand Down Expand Up @@ -92,23 +92,28 @@ def prepare(globs, locs):

# Remove extra files/folders.
try:
print "Removing %s ..." % join(root, 'build')
shutil.rmtree(join(root, 'build'))
except OSError:
pass
except OSError, e:
print "Could not delete build folder recursively"
print "Error was: %s" % str(e)
os.mkdir(join(root, 'build'))
shutil.move(
join(root, 'docs', 'api', 'html'),
join(root, 'build', 'apidoc'),
)
try:
print "Moving %s to %s ..." % (
join(root, '%s.tagfile.xml' % os.environ['SPHINX_PROJECT']),
join(root, 'build', 'apidoc', '%s.tagfile.xml' % os.environ['SPHINX_PROJECT']),
)
shutil.move(
join(root, '%s.tagfile.xml' %
os.environ['SPHINX_PROJECT']),
join(root, 'build', 'apidoc', '%s.tagfile.xml' %
os.environ['SPHINX_PROJECT'])
join(root, '%s.tagfile.xml' % os.environ['SPHINX_PROJECT']),
join(root, 'build', 'apidoc', '%s.tagfile.xml' % os.environ['SPHINX_PROJECT'])
)
except OSError:
pass
print "Could not move the tagfile to its final destination"
print "Error was: %s" % str(e)

# Copy translations for generic docs to catalogs folder.
gen_i18n = join(root, 'docs', 'src', 'generic', 'i18n', '.')[:-1]
Expand All @@ -120,6 +125,7 @@ def prepare(globs, locs):
)
translation = join(translation, 'LC_MESSAGES', 'generic')
shutil.rmtree(target_dir, ignore_errors=True)
print "Copying %s/ to %s/ ..." % (translation, target_dir)
shutil.copytree(translation, target_dir)

# Compile translation catalogs.
Expand All @@ -128,6 +134,7 @@ def prepare(globs, locs):
for po in fnmatch.filter(filenames, '*.po'):
po = join(base, po)
mo = po[:-3] + '.mo'
print "Compiling %s into %s ..." % (po, mo)
call([pybabel, 'compile', '-f', '--statistics',
'-i', po, '-o', mo])

Expand All @@ -142,7 +149,6 @@ def prepare(globs, locs):
if 'html_extra_path' not in locs:
locs['html_extra_path'] = []
locs['html_extra_path'].append(join(root, 'build'))
locs['html_theme'] = 'haiku'

# - I18N
if 'locale_dirs' not in locs:
Expand All @@ -151,7 +157,8 @@ def prepare(globs, locs):

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

0 comments on commit 9c9c744

Please sign in to comment.