Skip to content

Commit

Permalink
Skip PDF version of manual for Japanese
Browse files Browse the repository at this point in the history
Getting a useable Japanese PDF out of Sphinx+LaTeX is a nightmare
  • Loading branch information
kovidgoyal committed May 31, 2022
1 parent 5f8e533 commit 46cc7dc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
44 changes: 23 additions & 21 deletions manual/build.py
Expand Up @@ -42,29 +42,31 @@ def build_manual(language, base):
sb = partial(sphinx_build, language, base)
onlinedir = sb(t='online')
epubdir = sb('myepub', 'epub')
latexdir = sb('latex', 'latex')
pwd = os.getcwd()
os.chdir(latexdir)

def run_cmd(cmd):
p = subprocess.Popen(cmd, stdout=open(os.devnull, 'wb'), stdin=subprocess.PIPE)
p.stdin.close()
return p.wait()
try:
for i in range(3):
run_cmd(['xelatex', '-interaction=nonstopmode', 'calibre.tex'])
run_cmd(['makeindex', '-s', 'python.ist', 'calibre.idx'])
for i in range(2):
run_cmd(['xelatex', '-interaction=nonstopmode', 'calibre.tex'])
if not os.path.exists('calibre.pdf'):
print('Failed to build pdf file, see calibre.log in the latex directory', file=sys.stderr)
raise SystemExit(1)
finally:
os.chdir(pwd)
pdf_ok = language not in ('ja',)
if pdf_ok:
latexdir = sb('latex', 'latex')
pwd = os.getcwd()
os.chdir(latexdir)

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


Expand Down
2 changes: 1 addition & 1 deletion setup/publish.py
Expand Up @@ -164,7 +164,7 @@ def run(self, opts):
languages = opts.language or list(
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)
for language in languages:
jobs.append(create_job([
Expand Down

0 comments on commit 46cc7dc

Please sign in to comment.