mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-11-03 04:40:16 -06:00
Remove deprecated feature: epub2 builder
This commit is contained in:
1 parent
3cd87176b6
commit
f2c93b3175
5 files changed
+25
-125
No files matched your search
@@ -125,26 +125,6 @@ The builder's "name" must be given to the **-b** command-line option of
|
|||||||
|
|
||||||
.. autoattribute:: supported_image_types
|
.. autoattribute:: supported_image_types
|
||||||
|
|
||||||
.. module:: sphinx.builders.epub2
|
|
||||||
.. class:: Epub2Builder
|
|
||||||
|
|
||||||
This builder produces the same output as the standalone HTML builder, but
|
|
||||||
also generates an *epub* file for ebook readers. See :ref:`epub-faq` for
|
|
||||||
details about it. For definition of the epub format, have a look at
|
|
||||||
`<http://idpf.org/epub>`_ or `<https://en.wikipedia.org/wiki/EPUB>`_.
|
|
||||||
The builder creates *EPUB 2* files.
|
|
||||||
|
|
||||||
.. autoattribute:: name
|
|
||||||
|
|
||||||
.. autoattribute:: format
|
|
||||||
|
|
||||||
.. autoattribute:: supported_image_types
|
|
||||||
|
|
||||||
.. deprecated:: 1.5
|
|
||||||
|
|
||||||
Since Sphinx-1.5, the epub3 builder is used for the default builder of epub.
|
|
||||||
Now EpubBuilder is renamed to epub2.
|
|
||||||
|
|
||||||
.. module:: sphinx.builders.epub3
|
.. module:: sphinx.builders.epub3
|
||||||
.. class:: Epub3Builder
|
.. class:: Epub3Builder
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ if False:
|
|||||||
builtin_extensions = (
|
builtin_extensions = (
|
||||||
'sphinx.builders.applehelp',
|
'sphinx.builders.applehelp',
|
||||||
'sphinx.builders.changes',
|
'sphinx.builders.changes',
|
||||||
'sphinx.builders.epub2',
|
|
||||||
'sphinx.builders.epub3',
|
'sphinx.builders.epub3',
|
||||||
'sphinx.builders.devhelp',
|
'sphinx.builders.devhelp',
|
||||||
'sphinx.builders.dummy',
|
'sphinx.builders.dummy',
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
sphinx.builders.epub2
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Build epub2 files.
|
|
||||||
Originally derived from qthelp.py.
|
|
||||||
|
|
||||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
|
||||||
:license: BSD, see LICENSE for details.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import warnings
|
|
||||||
from os import path
|
|
||||||
|
|
||||||
from sphinx import package_dir
|
|
||||||
from sphinx.builders import _epub_base
|
|
||||||
from sphinx.util.osutil import make_filename
|
|
||||||
from sphinx.deprecation import RemovedInSphinx17Warning
|
|
||||||
|
|
||||||
if False:
|
|
||||||
# For type annotation
|
|
||||||
from typing import Any, Dict # NOQA
|
|
||||||
from sphinx.application import Sphinx # NOQA
|
|
||||||
|
|
||||||
|
|
||||||
DOCTYPE = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'''
|
|
||||||
|
|
||||||
|
|
||||||
# The epub publisher
|
|
||||||
|
|
||||||
class Epub2Builder(_epub_base.EpubBuilder):
|
|
||||||
"""
|
|
||||||
Builder that outputs epub files.
|
|
||||||
|
|
||||||
It creates the metainfo files container.opf, toc.ncx, mimetype, and
|
|
||||||
META-INF/container.xml. Afterwards, all necessary files are zipped to an
|
|
||||||
epub file.
|
|
||||||
"""
|
|
||||||
name = 'epub2'
|
|
||||||
|
|
||||||
template_dir = path.join(package_dir, 'templates', 'epub2')
|
|
||||||
doctype = DOCTYPE
|
|
||||||
|
|
||||||
# Finish by building the epub file
|
|
||||||
def handle_finish(self):
|
|
||||||
# type: () -> None
|
|
||||||
"""Create the metainfo files and finally the epub."""
|
|
||||||
self.get_toc()
|
|
||||||
self.build_mimetype(self.outdir, 'mimetype')
|
|
||||||
self.build_container(self.outdir, 'META-INF/container.xml')
|
|
||||||
self.build_content(self.outdir, 'content.opf')
|
|
||||||
self.build_toc(self.outdir, 'toc.ncx')
|
|
||||||
self.build_epub(self.outdir, self.config.epub_basename + '.epub')
|
|
||||||
|
|
||||||
|
|
||||||
def emit_deprecation_warning(app):
|
|
||||||
# type: (Sphinx) -> None
|
|
||||||
if app.builder.__class__ is Epub2Builder:
|
|
||||||
warnings.warn('epub2 builder is deprecated. Please use epub3 builder instead.',
|
|
||||||
RemovedInSphinx17Warning)
|
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
|
||||||
# type: (Sphinx) -> Dict[unicode, Any]
|
|
||||||
app.setup_extension('sphinx.builders.html')
|
|
||||||
app.add_builder(Epub2Builder)
|
|
||||||
app.connect('builder-inited', emit_deprecation_warning)
|
|
||||||
|
|
||||||
# config values
|
|
||||||
app.add_config_value('epub_basename', lambda self: make_filename(self.project), None)
|
|
||||||
app.add_config_value('epub_theme', 'epub', 'html')
|
|
||||||
app.add_config_value('epub_theme_options', {}, 'html')
|
|
||||||
app.add_config_value('epub_title', lambda self: self.html_title, 'html')
|
|
||||||
app.add_config_value('epub_author', 'unknown', 'html')
|
|
||||||
app.add_config_value('epub_language', lambda self: self.language or 'en', 'html')
|
|
||||||
app.add_config_value('epub_publisher', 'unknown', 'html')
|
|
||||||
app.add_config_value('epub_copyright', lambda self: self.copyright, 'html')
|
|
||||||
app.add_config_value('epub_identifier', 'unknown', 'html')
|
|
||||||
app.add_config_value('epub_scheme', 'unknown', 'html')
|
|
||||||
app.add_config_value('epub_uid', 'unknown', 'env')
|
|
||||||
app.add_config_value('epub_cover', (), 'env')
|
|
||||||
app.add_config_value('epub_guide', (), 'env')
|
|
||||||
app.add_config_value('epub_pre_files', [], 'env')
|
|
||||||
app.add_config_value('epub_post_files', [], 'env')
|
|
||||||
app.add_config_value('epub_exclude_files', [], 'env')
|
|
||||||
app.add_config_value('epub_tocdepth', 3, 'env')
|
|
||||||
app.add_config_value('epub_tocdup', True, 'env')
|
|
||||||
app.add_config_value('epub_tocscope', 'default', 'env')
|
|
||||||
app.add_config_value('epub_fix_images', False, 'env')
|
|
||||||
app.add_config_value('epub_max_image_width', 0, 'env')
|
|
||||||
app.add_config_value('epub_show_urls', 'inline', 'html')
|
|
||||||
app.add_config_value('epub_use_index', lambda self: self.html_use_index, 'html')
|
|
||||||
|
|
||||||
return {
|
|
||||||
'version': 'builtin',
|
|
||||||
'parallel_read_safe': True,
|
|
||||||
'parallel_write_safe': True,
|
|
||||||
}
|
|
||||||
@@ -19,6 +19,7 @@ from sphinx.config import string_classes, ENUM
|
|||||||
from sphinx.builders import _epub_base
|
from sphinx.builders import _epub_base
|
||||||
from sphinx.util import logging
|
from sphinx.util import logging
|
||||||
from sphinx.util.fileutil import copy_asset_file
|
from sphinx.util.fileutil import copy_asset_file
|
||||||
|
from sphinx.util.osutil import make_filename
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@@ -225,12 +226,32 @@ class Epub3Builder(_epub_base.EpubBuilder):
|
|||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
# type: (Sphinx) -> Dict[unicode, Any]
|
# type: (Sphinx) -> Dict[unicode, Any]
|
||||||
|
|
||||||
app.setup_extension('sphinx.builders.epub2')
|
|
||||||
|
|
||||||
app.add_builder(Epub3Builder)
|
app.add_builder(Epub3Builder)
|
||||||
|
|
||||||
# config values
|
# config values
|
||||||
|
app.add_config_value('epub_basename', lambda self: make_filename(self.project), None)
|
||||||
|
app.add_config_value('epub_theme', 'epub', 'html')
|
||||||
|
app.add_config_value('epub_theme_options', {}, 'html')
|
||||||
|
app.add_config_value('epub_title', lambda self: self.html_title, 'html')
|
||||||
|
app.add_config_value('epub_author', 'unknown', 'html')
|
||||||
|
app.add_config_value('epub_language', lambda self: self.language or 'en', 'html')
|
||||||
|
app.add_config_value('epub_publisher', 'unknown', 'html')
|
||||||
|
app.add_config_value('epub_copyright', lambda self: self.copyright, 'html')
|
||||||
|
app.add_config_value('epub_identifier', 'unknown', 'html')
|
||||||
|
app.add_config_value('epub_scheme', 'unknown', 'html')
|
||||||
|
app.add_config_value('epub_uid', 'unknown', 'env')
|
||||||
|
app.add_config_value('epub_cover', (), 'env')
|
||||||
|
app.add_config_value('epub_guide', (), 'env')
|
||||||
|
app.add_config_value('epub_pre_files', [], 'env')
|
||||||
|
app.add_config_value('epub_post_files', [], 'env')
|
||||||
|
app.add_config_value('epub_exclude_files', [], 'env')
|
||||||
|
app.add_config_value('epub_tocdepth', 3, 'env')
|
||||||
|
app.add_config_value('epub_tocdup', True, 'env')
|
||||||
|
app.add_config_value('epub_tocscope', 'default', 'env')
|
||||||
|
app.add_config_value('epub_fix_images', False, 'env')
|
||||||
|
app.add_config_value('epub_max_image_width', 0, 'env')
|
||||||
|
app.add_config_value('epub_show_urls', 'inline', 'html')
|
||||||
|
app.add_config_value('epub_use_index', lambda self: self.html_use_index, 'html')
|
||||||
app.add_config_value('epub_description', 'unknown', 'epub3', string_classes)
|
app.add_config_value('epub_description', 'unknown', 'epub3', string_classes)
|
||||||
app.add_config_value('epub_contributor', 'unknown', 'epub3', string_classes)
|
app.add_config_value('epub_contributor', 'unknown', 'epub3', string_classes)
|
||||||
app.add_config_value('epub_writing_mode', 'horizontal', 'epub3',
|
app.add_config_value('epub_writing_mode', 'horizontal', 'epub3',
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ def nonascii_srcdir(request):
|
|||||||
[
|
[
|
||||||
# note: no 'html' - if it's ok with dirhtml it's ok with html
|
# note: no 'html' - if it's ok with dirhtml it's ok with html
|
||||||
'dirhtml', 'singlehtml', 'latex', 'texinfo', 'pickle', 'json', 'text',
|
'dirhtml', 'singlehtml', 'latex', 'texinfo', 'pickle', 'json', 'text',
|
||||||
'htmlhelp', 'qthelp', 'epub2', 'epub', 'applehelp', 'changes', 'xml',
|
'htmlhelp', 'qthelp', 'epub', 'applehelp', 'changes', 'xml',
|
||||||
'pseudoxml', 'man', 'linkcheck',
|
'pseudoxml', 'man', 'linkcheck',
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user