Skip PDF version of manual for Japanese

Getting a useable Japanese PDF out of Sphinx+LaTeX is a nightmare
This commit is contained in:
Kovid Goyal 2022-05-31 08:17:17 +05:30
parent 5f8e533045
commit 46cc7dc6c2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 23 additions and 21 deletions

View File

@ -42,29 +42,31 @@ def build_manual(language, base):
sb = partial(sphinx_build, language, base) sb = partial(sphinx_build, language, base)
onlinedir = sb(t='online') onlinedir = sb(t='online')
epubdir = sb('myepub', 'epub') epubdir = sb('myepub', 'epub')
latexdir = sb('latex', 'latex') pdf_ok = language not in ('ja',)
pwd = os.getcwd() if pdf_ok:
os.chdir(latexdir) latexdir = sb('latex', 'latex')
pwd = os.getcwd()
os.chdir(latexdir)
def run_cmd(cmd): def run_cmd(cmd):
p = subprocess.Popen(cmd, stdout=open(os.devnull, 'wb'), stdin=subprocess.PIPE) p = subprocess.Popen(cmd, stdout=open(os.devnull, 'wb'), stdin=subprocess.PIPE)
p.stdin.close() p.stdin.close()
return p.wait() return p.wait()
try: try:
for i in range(3): for i in range(3):
run_cmd(['xelatex', '-interaction=nonstopmode', 'calibre.tex']) run_cmd(['xelatex', '-interaction=nonstopmode', 'calibre.tex'])
run_cmd(['makeindex', '-s', 'python.ist', 'calibre.idx']) run_cmd(['makeindex', '-s', 'python.ist', 'calibre.idx'])
for i in range(2): for i in range(2):
run_cmd(['xelatex', '-interaction=nonstopmode', 'calibre.tex']) run_cmd(['xelatex', '-interaction=nonstopmode', 'calibre.tex'])
if not os.path.exists('calibre.pdf'): if not os.path.exists('calibre.pdf'):
print('Failed to build pdf file, see calibre.log in the latex directory', file=sys.stderr) print('Failed to build pdf file, see calibre.log in the latex directory', file=sys.stderr)
raise SystemExit(1) raise SystemExit(1)
finally: finally:
os.chdir(pwd) os.chdir(pwd)
pdf_dest = j(onlinedir, 'calibre.pdf')
shutil.copyfile(j(latexdir, 'calibre.pdf'), pdf_dest)
epub_dest = j(onlinedir, 'calibre.epub') epub_dest = j(onlinedir, 'calibre.epub')
pdf_dest = j(onlinedir, 'calibre.pdf')
shutil.copyfile(j(epubdir, 'calibre.epub'), epub_dest) shutil.copyfile(j(epubdir, 'calibre.epub'), epub_dest)
shutil.copyfile(j(latexdir, 'calibre.pdf'), pdf_dest)
epub_to_azw3(epub_dest) epub_to_azw3(epub_dest)

View File

@ -164,7 +164,7 @@ class Manual(Command):
languages = opts.language or list( languages = opts.language or list(
json.load(open(self.j(base, 'locale', 'completed.json'), 'rb')) json.load(open(self.j(base, 'locale', 'completed.json'), 'rb'))
) )
languages = ['en'] + list(set(languages) - {'en', 'ja'}) languages = ['en'] + list(set(languages) - {'en'})
os.environ['ALL_USER_MANUAL_LANGUAGES'] = ' '.join(languages) os.environ['ALL_USER_MANUAL_LANGUAGES'] = ' '.join(languages)
for language in languages: for language in languages:
jobs.append(create_job([ jobs.append(create_job([