Fix duplicated sections in PDF user manual

Fixes #1215799 [double-sized calibre manual in pdf version](https://bugs.launchpad.net/calibre/+bug/1215799)
This commit is contained in:
Kovid Goyal 2013-08-24 13:59:10 +05:30
parent e90ba09426
commit f0e040639c
2 changed files with 15 additions and 1 deletions

View File

@ -38,6 +38,7 @@ Sections
glossary
.. REMOVE_IN_PDF
The main |app| user interface
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -84,7 +84,8 @@ class Manual(Command):
'-d', '.build/doctrees', '.', '.build/html'])
subprocess.check_call(['sphinx-build', '-b', 'myepub', '-d',
'.build/doctrees', '.', '.build/epub'])
subprocess.check_call(['sphinx-build', '-b', 'mylatex', '-d',
with self:
subprocess.check_call(['sphinx-build', '-b', 'mylatex', '-d',
'.build/doctrees', '.', '.build/latex'])
pwd = os.getcwdu()
os.chdir('.build/latex')
@ -107,6 +108,18 @@ class Manual(Command):
if os.path.exists(path):
shutil.rmtree(path)
def __enter__(self):
with open('index.rst', 'r+b') as f:
raw = self.orig_index = f.read()
f.seek(0)
f.truncate()
pos = raw.index(b'.. REMOVE_IN_PDF')
f.write(raw[:pos])
def __exit__(self, *args):
with open('index.rst', 'wb') as f:
f.write(self.orig_index)
class TagRelease(Command):
description = 'Tag a new release in git'