From f0e040639c1125212f51ed98e4f32f7fbd2b7edc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 24 Aug 2013 13:59:10 +0530 Subject: [PATCH] Fix duplicated sections in PDF user manual Fixes #1215799 [double-sized calibre manual in pdf version](https://bugs.launchpad.net/calibre/+bug/1215799) --- manual/index.rst | 1 + setup/publish.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/manual/index.rst b/manual/index.rst index b8f98a5561..fa19761b1b 100755 --- a/manual/index.rst +++ b/manual/index.rst @@ -38,6 +38,7 @@ Sections glossary +.. REMOVE_IN_PDF The main |app| user interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/setup/publish.py b/setup/publish.py index 40d002ee8a..ec4b7b31eb 100644 --- a/setup/publish.py +++ b/setup/publish.py @@ -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'