mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Update for sphinx 1.6
This commit is contained in:
parent
eef2219247
commit
56406e00d5
@ -12,6 +12,7 @@
|
|||||||
# serve to show the default value.
|
# serve to show the default value.
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
# If your extensions are in another directory, add it here.
|
# If your extensions are in another directory, add it here.
|
||||||
sys.path.append(os.path.abspath('.'))
|
sys.path.append(os.path.abspath('.'))
|
||||||
@ -141,10 +142,6 @@ html_static_path = ['resources', '../icons/favicon.ico']
|
|||||||
# using the given strftime format.
|
# using the given strftime format.
|
||||||
html_last_updated_fmt = '%b %d, %Y'
|
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
|
# Overall title of the documentation
|
||||||
# html_title = title
|
# html_title = title
|
||||||
html_short_title = _('Start')
|
html_short_title = _('Start')
|
||||||
@ -166,11 +163,13 @@ def sort_languages(x):
|
|||||||
html_context['other_languages'].sort(key=sort_languages)
|
html_context['other_languages'].sort(key=sort_languages)
|
||||||
del sort_languages, get_language
|
del sort_languages, get_language
|
||||||
|
|
||||||
epub_author = 'Kovid Goyal'
|
epub_author = u'Kovid Goyal'
|
||||||
epub_publisher = 'Kovid Goyal'
|
epub_publisher = u'Kovid Goyal'
|
||||||
epub_identifier = 'https://manual.calibre-ebook.com'
|
epub_copyright = u'© {} Kovid Goyal'.format(date.today().year)
|
||||||
epub_scheme = 'url'
|
epub_description = u'Comprehensive documentation for calibre'
|
||||||
epub_uid = 'S54a88f8e9d42455e9c6db000e989225f'
|
epub_identifier = u'https://manual.calibre-ebook.com'
|
||||||
|
epub_scheme = u'url'
|
||||||
|
epub_uid = u'S54a88f8e9d42455e9c6db000e989225f'
|
||||||
epub_tocdepth = 4
|
epub_tocdepth = 4
|
||||||
epub_tocdup = True
|
epub_tocdup = True
|
||||||
epub_cover = ('epub_cover.jpg', 'epub_cover_template.html')
|
epub_cover = ('epub_cover.jpg', 'epub_cover_template.html')
|
||||||
|
2
manual/docutils.conf
Normal file
2
manual/docutils.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[parsers]
|
||||||
|
smart_quotes: on
|
@ -8,14 +8,15 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import os
|
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.container import get_container, OEB_DOCS
|
||||||
from calibre.ebooks.oeb.polish.check.links import check_links, UnreferencedResource
|
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.ebooks.oeb.polish.pretty import pretty_html_tree, pretty_opf
|
||||||
from calibre.utils.imghdr import identify
|
from calibre.utils.imghdr import identify
|
||||||
|
|
||||||
|
|
||||||
class EPUBHelpBuilder(EpubBuilder):
|
class EPUBHelpBuilder(EpubBuilder):
|
||||||
name = 'myepub'
|
name = 'myepub'
|
||||||
|
|
||||||
@ -62,18 +63,18 @@ class EPUBHelpBuilder(EpubBuilder):
|
|||||||
container.remove_from_xml(item)
|
container.remove_from_xml(item)
|
||||||
seen.add(name)
|
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]]
|
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"]'):
|
for meta in container.opf_xpath('//opf:meta[@name="cover"]'):
|
||||||
meta.set('content', cover_id)
|
meta.getparent().remove(meta)
|
||||||
|
|
||||||
# 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')
|
|
||||||
|
|
||||||
# Remove unreferenced files
|
# Remove unreferenced files
|
||||||
for error in check_links(container):
|
for error in check_links(container):
|
||||||
@ -83,4 +84,3 @@ class EPUBHelpBuilder(EpubBuilder):
|
|||||||
# Pretty print the OPF
|
# Pretty print the OPF
|
||||||
pretty_opf(container.parsed(container.opf_name))
|
pretty_opf(container.parsed(container.opf_name))
|
||||||
container.dirty(container.opf_name)
|
container.dirty(container.opf_name)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user