diff options
Diffstat (limited to 'sphinx/builders/qthelp.py')
-rw-r--r-- | sphinx/builders/qthelp.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/sphinx/builders/qthelp.py b/sphinx/builders/qthelp.py index e02985b94..c53b56657 100644 --- a/sphinx/builders/qthelp.py +++ b/sphinx/builders/qthelp.py @@ -21,6 +21,7 @@ from docutils import nodes from sphinx import addnodes from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.util import force_decode +from sphinx.util.osutil import make_filename from sphinx.util.pycompat import htmlescape @@ -104,8 +105,14 @@ class QtHelpBuilder(StandaloneHTMLBuilder): # don't add links add_permalinks = False + # don't add sidebar etc. embedded = True + # disable download role + download_support = False + + # don't generate the search index or include the search page + search = False def init(self): StandaloneHTMLBuilder.init(self) @@ -114,6 +121,9 @@ class QtHelpBuilder(StandaloneHTMLBuilder): self.link_suffix = '.html' # self.config.html_style = 'traditional.css' + def get_theme_config(self): + return self.config.qthelp_theme, self.config.qthelp_theme_options + def handle_finish(self): self.build_qhp(self.outdir, self.config.qthelp_basename) @@ -180,8 +190,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder): nspace = nspace.lower() # write the project file - f = codecs.open(path.join(outdir, outname+'.qhp'), 'w', 'utf-8') - try: + with codecs.open(path.join(outdir, outname+'.qhp'), 'w', 'utf-8') as f: f.write(project_template % { 'outname': htmlescape(outname), 'title': htmlescape(self.config.html_title), @@ -192,23 +201,18 @@ class QtHelpBuilder(StandaloneHTMLBuilder): 'sections': sections, 'keywords': keywords, 'files': projectfiles}) - finally: - f.close() homepage = 'qthelp://' + posixpath.join( nspace, 'doc', self.get_target_uri(self.config.master_doc)) startpage = 'qthelp://' + posixpath.join(nspace, 'doc', 'index.html') self.info('writing collection project file...') - f = codecs.open(path.join(outdir, outname+'.qhcp'), 'w', 'utf-8') - try: + with codecs.open(path.join(outdir, outname+'.qhcp'), 'w', 'utf-8') as f: f.write(collection_template % { 'outname': htmlescape(outname), 'title': htmlescape(self.config.html_short_title), 'homepage': htmlescape(homepage), 'startpage': htmlescape(startpage)}) - finally: - f.close() def isdocnode(self, node): if not isinstance(node, nodes.list_item): @@ -297,3 +301,12 @@ class QtHelpBuilder(StandaloneHTMLBuilder): keywords.extend(self.build_keywords(subitem[0], subitem[1], [])) return keywords + + +def setup(app): + app.setup_extension('sphinx.builders.html') + app.add_builder(QtHelpBuilder) + + app.add_config_value('qthelp_basename', lambda self: make_filename(self.project), None) + app.add_config_value('qthelp_theme', 'nonav', 'html') + app.add_config_value('qthelp_theme_options', {}, 'html') |