The arguments of EpubBuilder.build_mimetype() is deprecated

This commit is contained in:
Takeshi KOMIYA 2019-01-08 23:45:52 +09:00
parent 90b93dda33
commit 0f972e8bbf
4 changed files with 16 additions and 2 deletions

View File

@ -58,6 +58,7 @@ Deprecated
* Support for evaluating Python 2 syntax is deprecated. This includes * Support for evaluating Python 2 syntax is deprecated. This includes
configuration files which should be converted to Python 3. configuration files which should be converted to Python 3.
* The arguments of ``EpubBuilder.build_mimetype()``
* The ``encoding`` argument of ``autodoc.Documenter.get_doc()``, * The ``encoding`` argument of ``autodoc.Documenter.get_doc()``,
``autodoc.DocstringSignatureMixin.get_doc()``, ``autodoc.DocstringSignatureMixin.get_doc()``,
``autodoc.DocstringSignatureMixin._find_signature()``, and ``autodoc.DocstringSignatureMixin._find_signature()``, and

View File

@ -242,6 +242,11 @@ The following is a list of deprecated interfaces.
- 4.0 - 4.0
- N/A - N/A
* - arguments of ``EpubBuilder.build_mimetype()``
- 2.0
- 4.0
- N/A
* - ``nodetype`` argument of * - ``nodetype`` argument of
``sphinx.search.WordCollector.is_meta_keywords()`` ``sphinx.search.WordCollector.is_meta_keywords()``
- 2.0 - 2.0

View File

@ -10,6 +10,7 @@
import os import os
import re import re
import warnings
from collections import namedtuple from collections import namedtuple
from os import path from os import path
from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile from zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile
@ -19,6 +20,7 @@ from docutils.utils import smartquotes
from sphinx import addnodes from sphinx import addnodes
from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder
from sphinx.deprecation import RemovedInSphinx40Warning
from sphinx.locale import __ from sphinx.locale import __
from sphinx.util import logging from sphinx.util import logging
from sphinx.util import status_iterator from sphinx.util import status_iterator
@ -470,9 +472,15 @@ class EpubBuilder(StandaloneHTMLBuilder):
addctx['doctype'] = self.doctype addctx['doctype'] = self.doctype
super().handle_page(pagename, addctx, templatename, outfilename, event_arg) super().handle_page(pagename, addctx, templatename, outfilename, event_arg)
def build_mimetype(self, outdir, outname): def build_mimetype(self, outdir=None, outname='mimetype'):
# type: (str, str) -> None # type: (str, str) -> None
"""Write the metainfo file mimetype.""" """Write the metainfo file mimetype."""
if outdir:
warnings.warn('The arguments of EpubBuilder.build_mimetype() is deprecated.',
RemovedInSphinx40Warning, stacklevel=2)
else:
outdir = self.outdir
logger.info(__('writing %s file...'), outname) logger.info(__('writing %s file...'), outname)
copy_asset_file(path.join(self.template_dir, 'mimetype'), copy_asset_file(path.join(self.template_dir, 'mimetype'),
path.join(outdir, outname)) path.join(outdir, outname))

View File

@ -78,7 +78,7 @@ class Epub3Builder(_epub_base.EpubBuilder):
"""Create the metainfo files and finally the epub.""" """Create the metainfo files and finally the epub."""
self.validate_config_value() self.validate_config_value()
self.get_toc() self.get_toc()
self.build_mimetype(self.outdir, 'mimetype') self.build_mimetype()
self.build_container(self.outdir, 'META-INF/container.xml') self.build_container(self.outdir, 'META-INF/container.xml')
self.build_content(self.outdir, 'content.opf') self.build_content(self.outdir, 'content.opf')
self.build_navigation_doc(self.outdir, 'nav.xhtml') self.build_navigation_doc(self.outdir, 'nav.xhtml')