mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
More changes for Apple Help support.
This commit is contained in:
parent
b90f319e37
commit
8b0770126f
@ -32,6 +32,22 @@ except AttributeError:
|
||||
write_plist = plistlib.writePlist
|
||||
|
||||
|
||||
# False access page (used because helpd expects strict XHTML)
|
||||
access_page_template = '''\
|
||||
<!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">
|
||||
<head>
|
||||
<title>%(title)s</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta http-equiv="refresh" content="0;url=%(toc)s" />
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
|
||||
|
||||
class AppleHelpIndexerFailed(SphinxError):
|
||||
def __str__(self):
|
||||
return 'Help indexer failed'
|
||||
@ -77,20 +93,21 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
||||
ensuredir(d)
|
||||
|
||||
# Construct the Info.plist file
|
||||
toc = self.config.master_doc + self.out_suffix
|
||||
|
||||
info_plist = {
|
||||
'CFBundleDevelopmentRegion': self.config.applehelp_dev_region,
|
||||
'CFBundleIdentifier': self.config.applehelp_bundle_id,
|
||||
'CFBundleInfoDictionaryVersion': 6.0,
|
||||
'CFBundleName': self.config.applehelp_bundle_name,
|
||||
'CFBundleInfoDictionaryVersion': '6.0',
|
||||
'CFBundlePackageType': 'BNDL',
|
||||
'CFBundleShortVersionString': self.config.release,
|
||||
'CFBundleSignature': 'hbwr',
|
||||
'CFBundleVersion': self.config.applehelp_bundle_version,
|
||||
'CFBundleHelpTOCFile': 'index.html',
|
||||
'HPDBookAccessPath': 'index.html',
|
||||
'HPDBookIndexPath': 'index.helpindex',
|
||||
'HPDBookTitle': self.config.html_title,
|
||||
'HPDBookType': 3,
|
||||
'HPDBookAccessPath': '_access.html',
|
||||
'HPDBookIndexPath': 'search.helpindex',
|
||||
'HPDBookTitle': self.config.applehelp_title,
|
||||
'HPDBookType': '3',
|
||||
'HPDBookUsesExternalViewer': False,
|
||||
}
|
||||
|
||||
if self.config.applehelp_icon is not None:
|
||||
@ -127,13 +144,25 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
|
||||
err))
|
||||
del info_plist['HPDBookIconPath']
|
||||
|
||||
# Build the access page
|
||||
self.info(bold('building access page...'), nonl=True)
|
||||
f = codecs.open(path.join(language_dir, '_access.html'), 'w')
|
||||
try:
|
||||
f.write(access_page_template % {
|
||||
'toc': toc,
|
||||
'title': self.config.applehelp_title
|
||||
})
|
||||
finally:
|
||||
f.close()
|
||||
self.info('done')
|
||||
|
||||
# Generate the help index
|
||||
self.info(bold('generating help index... '), nonl=True)
|
||||
|
||||
args = [
|
||||
'/usr/bin/hiutil',
|
||||
'-Cf',
|
||||
path.join(language_dir, 'index.helpindex'),
|
||||
path.join(language_dir, 'search.helpindex'),
|
||||
language_dir
|
||||
]
|
||||
|
||||
|
@ -134,8 +134,8 @@ class Config(object):
|
||||
'applehelp'),
|
||||
applehelp_bundle_id = (lambda self: 'com.mycompany.%s.help' \
|
||||
% make_filename(self.project), 'applehelp'),
|
||||
applehelp_dev_region = ('en_us', 'applehelp'),
|
||||
applehelp_bundle_version = (1, 'applehelp'),
|
||||
applehelp_dev_region = ('en-us', 'applehelp'),
|
||||
applehelp_bundle_version = ('1', 'applehelp'),
|
||||
applehelp_icon = (None, 'applehelp'),
|
||||
applehelp_kb_product = (lambda self: '%s-%s' \
|
||||
% (make_filename(self.project), self.release),
|
||||
@ -146,6 +146,7 @@ class Config(object):
|
||||
applehelp_min_term_length = (None, 'applehelp'),
|
||||
applehelp_stopwords = (lambda self: self.language or 'en', 'applehelp'),
|
||||
applehelp_locale = (lambda self: self.language or 'en_us', 'applehelp'),
|
||||
applehelp_title = (lambda self: self.project + ' Help', 'applehelp'),
|
||||
|
||||
# Epub options
|
||||
epub_basename = (lambda self: make_filename(self.project), None),
|
||||
|
@ -269,20 +269,26 @@ htmlhelp_basename = '%(project_fn)sdoc'
|
||||
|
||||
# -- Options for Apple Help output ----------------------------------------
|
||||
|
||||
# The bundle name.
|
||||
# The help file title.
|
||||
#
|
||||
# This needs to go in the CFBundleHelpBookName field in your application,
|
||||
# and is displayed in the title bar of the help viewer.
|
||||
#applehelp_title = u'%(project_str)s Help'
|
||||
|
||||
# The name of the bundle.
|
||||
#applehelp_bundle_name = u'%(project_fn)s'
|
||||
|
||||
# The bundle id.
|
||||
#applehelp_bundle_id = 'com.mycompany.%(project_url)s.help'
|
||||
|
||||
# The development region. Should be 'en_us' in most cases.
|
||||
#applehelp_dev_region = 'en_us'
|
||||
# The development region. Should be 'en-us' in most cases.
|
||||
#applehelp_dev_region = 'en-us'
|
||||
|
||||
# The bundle version.
|
||||
#applehelp_bundle_version = 1
|
||||
#applehelp_bundle_version = '1'
|
||||
|
||||
# The icon file
|
||||
#applehelp_icon = '%(project_fn)s.icns'
|
||||
#applehelp_icon = '%(project_fn)s.png'
|
||||
|
||||
# These allow remote searching of a knowledge base on your server
|
||||
#applehelp_kb_url = "https://kb.example.com/search?p='product'&q='query'&l='lang'"
|
||||
|
Loading…
Reference in New Issue
Block a user