More changes for Apple Help support.

This commit is contained in:
Alastair Houghton 2015-01-13 18:31:23 +00:00
parent b90f319e37
commit 8b0770126f
3 changed files with 51 additions and 15 deletions

View File

@ -32,6 +32,22 @@ except AttributeError:
write_plist = plistlib.writePlist 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): class AppleHelpIndexerFailed(SphinxError):
def __str__(self): def __str__(self):
return 'Help indexer failed' return 'Help indexer failed'
@ -77,20 +93,21 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
ensuredir(d) ensuredir(d)
# Construct the Info.plist file # Construct the Info.plist file
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,
'CFBundleInfoDictionaryVersion': 6.0, 'CFBundleInfoDictionaryVersion': '6.0',
'CFBundleName': self.config.applehelp_bundle_name,
'CFBundlePackageType': 'BNDL', 'CFBundlePackageType': 'BNDL',
'CFBundleShortVersionString': self.config.release, 'CFBundleShortVersionString': self.config.release,
'CFBundleSignature': 'hbwr', 'CFBundleSignature': 'hbwr',
'CFBundleVersion': self.config.applehelp_bundle_version, 'CFBundleVersion': self.config.applehelp_bundle_version,
'CFBundleHelpTOCFile': 'index.html', 'HPDBookAccessPath': '_access.html',
'HPDBookAccessPath': 'index.html', 'HPDBookIndexPath': 'search.helpindex',
'HPDBookIndexPath': 'index.helpindex', 'HPDBookTitle': self.config.applehelp_title,
'HPDBookTitle': self.config.html_title, 'HPDBookType': '3',
'HPDBookType': 3, 'HPDBookUsesExternalViewer': False,
} }
if self.config.applehelp_icon is not None: if self.config.applehelp_icon is not None:
@ -127,13 +144,25 @@ class AppleHelpBuilder(StandaloneHTMLBuilder):
err)) err))
del info_plist['HPDBookIconPath'] 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 # Generate the help index
self.info(bold('generating help index... '), nonl=True) self.info(bold('generating help index... '), nonl=True)
args = [ args = [
'/usr/bin/hiutil', '/usr/bin/hiutil',
'-Cf', '-Cf',
path.join(language_dir, 'index.helpindex'), path.join(language_dir, 'search.helpindex'),
language_dir language_dir
] ]

View File

@ -134,8 +134,8 @@ class Config(object):
'applehelp'), 'applehelp'),
applehelp_bundle_id = (lambda self: 'com.mycompany.%s.help' \ applehelp_bundle_id = (lambda self: 'com.mycompany.%s.help' \
% make_filename(self.project), 'applehelp'), % make_filename(self.project), 'applehelp'),
applehelp_dev_region = ('en_us', 'applehelp'), applehelp_dev_region = ('en-us', 'applehelp'),
applehelp_bundle_version = (1, 'applehelp'), applehelp_bundle_version = ('1', 'applehelp'),
applehelp_icon = (None, 'applehelp'), applehelp_icon = (None, 'applehelp'),
applehelp_kb_product = (lambda self: '%s-%s' \ applehelp_kb_product = (lambda self: '%s-%s' \
% (make_filename(self.project), self.release), % (make_filename(self.project), self.release),
@ -146,6 +146,7 @@ class Config(object):
applehelp_min_term_length = (None, 'applehelp'), applehelp_min_term_length = (None, 'applehelp'),
applehelp_stopwords = (lambda self: self.language or 'en', 'applehelp'), applehelp_stopwords = (lambda self: self.language or 'en', 'applehelp'),
applehelp_locale = (lambda self: self.language or 'en_us', 'applehelp'), applehelp_locale = (lambda self: self.language or 'en_us', 'applehelp'),
applehelp_title = (lambda self: self.project + ' Help', 'applehelp'),
# Epub options # Epub options
epub_basename = (lambda self: make_filename(self.project), None), epub_basename = (lambda self: make_filename(self.project), None),

View File

@ -269,20 +269,26 @@ htmlhelp_basename = '%(project_fn)sdoc'
# -- Options for Apple Help output ---------------------------------------- # -- 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' #applehelp_bundle_name = u'%(project_fn)s'
# The bundle id. # The bundle id.
#applehelp_bundle_id = 'com.mycompany.%(project_url)s.help' #applehelp_bundle_id = 'com.mycompany.%(project_url)s.help'
# The development region. Should be 'en_us' in most cases. # The development region. Should be 'en-us' in most cases.
#applehelp_dev_region = 'en_us' #applehelp_dev_region = 'en-us'
# The bundle version. # The bundle version.
#applehelp_bundle_version = 1 #applehelp_bundle_version = '1'
# The icon file # 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 # 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'" #applehelp_kb_url = "https://kb.example.com/search?p='product'&q='query'&l='lang'"