mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix flake8.
This commit is contained in:
parent
3437872b30
commit
7b9f03e383
@ -10,16 +10,14 @@
|
|||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
|
||||||
import codecs
|
import codecs
|
||||||
import errno
|
|
||||||
import pipes
|
import pipes
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||||
from sphinx.util import copy_static_entry
|
from sphinx.util import copy_static_entry
|
||||||
from sphinx.util.osutil import copyfile, ensuredir, os_path
|
from sphinx.util.osutil import copyfile, ensuredir
|
||||||
from sphinx.util.console import bold
|
from sphinx.util.console import bold
|
||||||
from sphinx.util.pycompat import htmlescape
|
from sphinx.util.pycompat import htmlescape
|
||||||
from sphinx.util.matching import compile_matchers
|
from sphinx.util.matching import compile_matchers
|
||||||
@ -38,7 +36,8 @@ except AttributeError:
|
|||||||
|
|
||||||
# False access page (used because helpd expects strict XHTML)
|
# False access page (used because helpd expects strict XHTML)
|
||||||
access_page_template = '''\
|
access_page_template = '''\
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"\
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>%(title)s</title>
|
<title>%(title)s</title>
|
||||||
@ -55,11 +54,11 @@ access_page_template = '''\
|
|||||||
class AppleHelpIndexerFailed(SphinxError):
|
class AppleHelpIndexerFailed(SphinxError):
|
||||||
category = 'Help indexer failed'
|
category = 'Help indexer failed'
|
||||||
|
|
||||||
|
|
||||||
class AppleHelpCodeSigningFailed(SphinxError):
|
class AppleHelpCodeSigningFailed(SphinxError):
|
||||||
category = 'Code signing failed'
|
category = 'Code signing failed'
|
||||||
|
|
||||||
|
|
||||||
class AppleHelpBuilder(StandaloneHTMLBuilder):
|
class AppleHelpBuilder(StandaloneHTMLBuilder):
|
||||||
"""
|
"""
|
||||||
Builder that outputs an Apple help book. Requires Mac OS X as it relies
|
Builder that outputs an Apple help book. Requires Mac OS X as it relies
|
||||||
@ -74,25 +73,25 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
# don't add links
|
# don't add links
|
||||||
add_permalinks = False
|
add_permalinks = False
|
||||||
|
|
||||||
# this is an embedded HTML format
|
# this is an embedded HTML format
|
||||||
embedded = True
|
embedded = True
|
||||||
|
|
||||||
# don't generate the search index or include the search page
|
# don't generate the search index or include the search page
|
||||||
search = False
|
search = False
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
super(AppleHelpBuilder, self).init()
|
super(AppleHelpBuilder, self).init()
|
||||||
# the output files for HTML help must be .html only
|
# the output files for HTML help must be .html only
|
||||||
self.out_suffix = '.html'
|
self.out_suffix = '.html'
|
||||||
|
|
||||||
if self.config.applehelp_bundle_id is None:
|
if self.config.applehelp_bundle_id is None:
|
||||||
raise SphinxError('You must set applehelp_bundle_id before ' \
|
raise SphinxError('You must set applehelp_bundle_id before '
|
||||||
'building Apple Help output')
|
'building Apple Help output')
|
||||||
|
|
||||||
self.bundle_path = path.join(self.outdir,
|
self.bundle_path = path.join(self.outdir,
|
||||||
self.config.applehelp_bundle_name \
|
self.config.applehelp_bundle_name +
|
||||||
+ '.help')
|
'.help')
|
||||||
self.outdir = path.join(self.bundle_path,
|
self.outdir = path.join(self.bundle_path,
|
||||||
'Contents',
|
'Contents',
|
||||||
'Resources',
|
'Resources',
|
||||||
@ -103,22 +102,22 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
self.finish_tasks.add_task(self.copy_localized_files)
|
self.finish_tasks.add_task(self.copy_localized_files)
|
||||||
self.finish_tasks.add_task(self.build_helpbook)
|
self.finish_tasks.add_task(self.build_helpbook)
|
||||||
|
|
||||||
def copy_localized_files(self):
|
def copy_localized_files(self):
|
||||||
source_dir = path.join(self.confdir,
|
source_dir = path.join(self.confdir,
|
||||||
self.config.applehelp_locale + '.lproj')
|
self.config.applehelp_locale + '.lproj')
|
||||||
target_dir = self.outdir
|
target_dir = self.outdir
|
||||||
|
|
||||||
if path.isdir(source_dir):
|
if path.isdir(source_dir):
|
||||||
self.info(bold('copying localized files... '), nonl=True)
|
self.info(bold('copying localized files... '), nonl=True)
|
||||||
|
|
||||||
ctx = self.globalcontext.copy()
|
ctx = self.globalcontext.copy()
|
||||||
matchers = compile_matchers(self.config.exclude_patterns)
|
matchers = compile_matchers(self.config.exclude_patterns)
|
||||||
copy_static_entry(source_dir, target_dir, self, ctx,
|
copy_static_entry(source_dir, target_dir, self, ctx,
|
||||||
exclude_matchers=matchers)
|
exclude_matchers=matchers)
|
||||||
|
|
||||||
self.info('done')
|
self.info('done')
|
||||||
|
|
||||||
def build_helpbook(self):
|
def build_helpbook(self):
|
||||||
contents_dir = path.join(self.bundle_path, 'Contents')
|
contents_dir = path.join(self.bundle_path, 'Contents')
|
||||||
resources_dir = path.join(contents_dir, 'Resources')
|
resources_dir = path.join(contents_dir, 'Resources')
|
||||||
@ -130,7 +129,7 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
|
|
||||||
# Construct the Info.plist file
|
# Construct the Info.plist file
|
||||||
toc = self.config.master_doc + self.out_suffix
|
toc = self.config.master_doc + self.out_suffix
|
||||||
|
|
||||||
info_plist = {
|
info_plist = {
|
||||||
'CFBundleDevelopmentRegion': self.config.applehelp_dev_region,
|
'CFBundleDevelopmentRegion': self.config.applehelp_dev_region,
|
||||||
'CFBundleIdentifier': self.config.applehelp_bundle_id,
|
'CFBundleIdentifier': self.config.applehelp_bundle_id,
|
||||||
@ -188,7 +187,7 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
self.info('done')
|
self.info('done')
|
||||||
|
|
||||||
# Generate the help index
|
# Generate the help index
|
||||||
self.info(bold('generating help index... '), nonl=True)
|
self.info(bold('generating help index... '), nonl=True)
|
||||||
|
|
||||||
@ -258,4 +257,3 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
|||||||
raise AppleHelpCodeSigningFailed(output)
|
raise AppleHelpCodeSigningFailed(output)
|
||||||
else:
|
else:
|
||||||
self.info('done')
|
self.info('done')
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
add_permalinks = True
|
add_permalinks = True
|
||||||
embedded = False # for things like HTML help or Qt help: suppresses sidebar
|
embedded = False # for things like HTML help or Qt help: suppresses sidebar
|
||||||
search = True # for things like HTML help and Apple help: suppress search
|
search = True # for things like HTML help and Apple help: suppress search
|
||||||
|
|
||||||
# This is a class attribute because it is mutated by Sphinx.add_javascript.
|
# This is a class attribute because it is mutated by Sphinx.add_javascript.
|
||||||
script_files = ['_static/jquery.js', '_static/underscore.js',
|
script_files = ['_static/jquery.js', '_static/underscore.js',
|
||||||
'_static/doctools.js']
|
'_static/doctools.js']
|
||||||
@ -584,7 +584,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
'translations.js'))
|
'translations.js'))
|
||||||
|
|
||||||
ctx = self.globalcontext.copy()
|
ctx = self.globalcontext.copy()
|
||||||
|
|
||||||
# add context items for search function used in searchtools.js_t
|
# add context items for search function used in searchtools.js_t
|
||||||
if self.indexer is not None:
|
if self.indexer is not None:
|
||||||
ctx.update(self.indexer.context_for_searchtool())
|
ctx.update(self.indexer.context_for_searchtool())
|
||||||
|
@ -14,7 +14,6 @@ from os import path, environ
|
|||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
from six import PY3, iteritems, string_types, binary_type, integer_types
|
from six import PY3, iteritems, string_types, binary_type, integer_types
|
||||||
from six.moves.urllib.parse import quote as urlquote
|
|
||||||
|
|
||||||
from sphinx.errors import ConfigError
|
from sphinx.errors import ConfigError
|
||||||
from sphinx.locale import l_
|
from sphinx.locale import l_
|
||||||
@ -161,7 +160,7 @@ class Config(object):
|
|||||||
applehelp_indexer_path = ('/usr/bin/hiutil', 'applehelp'),
|
applehelp_indexer_path = ('/usr/bin/hiutil', 'applehelp'),
|
||||||
applehelp_codesign_path = ('/usr/bin/codesign', 'applehelp'),
|
applehelp_codesign_path = ('/usr/bin/codesign', 'applehelp'),
|
||||||
applehelp_disable_external_tools = (False, None),
|
applehelp_disable_external_tools = (False, None),
|
||||||
|
|
||||||
# Epub options
|
# Epub options
|
||||||
epub_basename = (lambda self: make_filename(self.project), None),
|
epub_basename = (lambda self: make_filename(self.project), None),
|
||||||
epub_theme = ('epub', 'html'),
|
epub_theme = ('epub', 'html'),
|
||||||
|
Loading…
Reference in New Issue
Block a user