add rough pdf transformation
This commit is contained in:
parent
d7be510325
commit
bf2d556e4b
38
publish.py
38
publish.py
|
@ -2,8 +2,10 @@
|
|||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
import urllib2
|
||||
import urlparse
|
||||
|
||||
|
@ -74,6 +76,42 @@ def publish_mallard(module, branch, directory):
|
|||
if html_files:
|
||||
os.symlink(html_files[0], index_html)
|
||||
|
||||
if not os.path.exists('../mal2latex'):
|
||||
return
|
||||
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
cache_file = os.path.join(temp_dir, '%s.cache' % module)
|
||||
cmd = ['jhbuild', '-f', jhbuildrc, 'run', 'yelp-build', 'cache', '-o', cache_file]
|
||||
cmd.extend([os.path.join(help_dir, x) for x in os.listdir(help_dir) if x.endswith('.page')])
|
||||
subprocess.call(cmd, **kws)
|
||||
|
||||
if os.path.exists(cache_file):
|
||||
latex_file = os.path.join(temp_dir, 'doc-%s.tex' % module)
|
||||
cmd = ['xsltproc', '-o', latex_file, '../mal2latex/mal2latex.xsl',
|
||||
cache_file]
|
||||
subprocess.call(cmd, **kws)
|
||||
for subdir in ('media', 'figures'):
|
||||
os.symlink(os.path.join(checkout_dir, 'help', 'fr', subdir),
|
||||
os.path.join(temp_dir, subdir))
|
||||
for admon_file in os.listdir('../mal2latex/admon'):
|
||||
if not admon_file.endswith('.pdf'):
|
||||
continue
|
||||
os.symlink(os.path.join(os.path.abspath('../mal2latex'), 'admon', admon_file),
|
||||
os.path.join(temp_dir, admon_file))
|
||||
|
||||
for i in range(3):
|
||||
cmd = ['pdflatex', '--interaction=nonstopmode',
|
||||
'-output-directory', temp_dir, latex_file]
|
||||
subprocess.call(cmd, cwd=temp_dir, **kws)
|
||||
if not os.path.exists(os.path.join(temp_dir, 'doc-%s.pdf' % module)):
|
||||
print 'failed to produce pdf for', module
|
||||
break
|
||||
else:
|
||||
fd = file(os.path.join(output_dir, 'doc-%s.pdf' % module), 'w')
|
||||
fd.write(file(os.path.join(temp_dir, 'doc-%s.pdf' % module)).read())
|
||||
fd.close()
|
||||
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
def publish_tarball(module):
|
||||
output_dir = os.path.join(web_directory, module.get('name'), 'stable')
|
||||
|
|
Loading…
Reference in New Issue