Update for sphinx 1.6

This commit is contained in:
Kovid Goyal 2017-05-26 00:08:46 +05:30
parent eef2219247
commit 56406e00d5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 23 additions and 22 deletions

View File

@ -12,6 +12,7 @@
# serve to show the default value.
import sys, os
from datetime import date
# If your extensions are in another directory, add it here.
sys.path.append(os.path.abspath('.'))
@ -141,10 +142,6 @@ html_static_path = ['resources', '../icons/favicon.ico']
# using the given strftime format.
html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
html_use_smartypants = True
# Overall title of the documentation
# html_title = title
html_short_title = _('Start')
@ -166,11 +163,13 @@ def sort_languages(x):
html_context['other_languages'].sort(key=sort_languages)
del sort_languages, get_language
epub_author = 'Kovid Goyal'
epub_publisher = 'Kovid Goyal'
epub_identifier = 'https://manual.calibre-ebook.com'
epub_scheme = 'url'
epub_uid = 'S54a88f8e9d42455e9c6db000e989225f'
epub_author = u'Kovid Goyal'
epub_publisher = u'Kovid Goyal'
epub_copyright = u'© {} Kovid Goyal'.format(date.today().year)
epub_description = u'Comprehensive documentation for calibre'
epub_identifier = u'https://manual.calibre-ebook.com'
epub_scheme = u'url'
epub_uid = u'S54a88f8e9d42455e9c6db000e989225f'
epub_tocdepth = 4
epub_tocdup = True
epub_cover = ('epub_cover.jpg', 'epub_cover_template.html')

2
manual/docutils.conf Normal file
View File

@ -0,0 +1,2 @@
[parsers]
smart_quotes: on

View File

@ -8,14 +8,15 @@ __docformat__ = 'restructuredtext en'
import os
from sphinx.builders.epub import EpubBuilder
from sphinx.builders.epub3 import Epub3Builder as EpubBuilder
from calibre.ebooks.oeb.base import OPF, DC
from calibre.ebooks.oeb.base import OPF
from calibre.ebooks.oeb.polish.container import get_container, OEB_DOCS
from calibre.ebooks.oeb.polish.check.links import check_links, UnreferencedResource
from calibre.ebooks.oeb.polish.pretty import pretty_html_tree, pretty_opf
from calibre.utils.imghdr import identify
class EPUBHelpBuilder(EpubBuilder):
name = 'myepub'
@ -62,18 +63,18 @@ class EPUBHelpBuilder(EpubBuilder):
container.remove_from_xml(item)
seen.add(name)
# Ensure that the meta cover tag is correct
# Remove the <guide> which is not needed in EPUB 3
for guide in container.opf_xpath('//*[local-name()="guide"]'):
guide.getparent().remove(guide)
# Ensure that the cover-image property is set
cover_id = rmap['_static/' + self.config.epub_cover[0]]
for item in container.opf_xpath('//opf:item[@id="{}"]'.format(cover_id)):
item.set('properties', 'cover-image')
# Remove any <meta cover> tag as it is not needed in epub 3
for meta in container.opf_xpath('//opf:meta[@name="cover"]'):
meta.set('content', cover_id)
# Add description metadata
metadata = container.opf_xpath('//opf:metadata')[0]
container.insert_into_xml(metadata, metadata.makeelement(DC('description')))
metadata[-1].text = 'Comprehensive documentation for calibre'
# Remove search.html since it is useless in EPUB
container.remove_item('search.html')
meta.getparent().remove(meta)
# Remove unreferenced files
for error in check_links(container):
@ -83,4 +84,3 @@ class EPUBHelpBuilder(EpubBuilder):
# Pretty print the OPF
pretty_opf(container.parsed(container.opf_name))
container.dirty(container.opf_name)