Add html_file_suffix value.

This commit is contained in:
Georg Brandl 2008-05-06 14:25:29 +00:00
parent 356d5f6ed7
commit cc6b4ee1ec
5 changed files with 32 additions and 4 deletions

10
CHANGES
View File

@ -1,3 +1,13 @@
Changes in trunk
================
New features added
------------------
* A new config value, `html_file_suffix`, can be used to set the HTML file
suffix to e.g. ``.xhtml``.
Release 0.3 (May 6, 2008)
=========================

View File

@ -262,6 +262,13 @@ that use Sphinx' HTMLWriter class.
served (without trailing slash), e.g. ``"http://docs.python.org"``. The
default is ``''``.
.. confval:: html_file_suffix
If nonempty, this is the file name suffix for generated HTML files. The
default is ``".html"``.
.. versionadded:: 0.4
.. confval:: html_translator_class
A string with the fully-qualified name of a HTML Translator class, that is, a

View File

@ -275,6 +275,8 @@ class StandaloneHTMLBuilder(Builder):
"""Load templates."""
self.init_templates()
self.init_translator_class()
if self.config.html_out_suffix:
self.out_suffix = self.config.html_file_suffix
def init_translator_class(self):
if self.config.html_translator_class:
@ -556,7 +558,7 @@ class StandaloneHTMLBuilder(Builder):
# --------- these are overwritten by the Pickle builder
def get_target_uri(self, docname, typ=None):
return docname + '.html'
return docname + self.out_suffix
def handle_page(self, pagename, addctx, templatename='page.html',
outfilename=None):
@ -577,7 +579,7 @@ class StandaloneHTMLBuilder(Builder):
output = self.templates.render(templatename, ctx)
if not outfilename:
outfilename = path.join(self.outdir, os_path(pagename) + '.html')
outfilename = path.join(self.outdir, os_path(pagename) + self.out_suffix)
ensuredir(path.dirname(outfilename)) # normally different from self.outdir
try:
f = codecs.open(outfilename, 'w', 'utf-8')
@ -629,7 +631,7 @@ class PickleHTMLBuilder(StandaloneHTMLBuilder):
if sidebarfile:
ctx['customsidebar'] = sidebarfile
if not outfilename:
outfilename = path.join(self.outdir, os_path(pagename) + '.fpickle')
outfilename = path.join(self.outdir, os_path(pagename) + self.out_suffix)
ensuredir(path.dirname(outfilename))
f = open(outfilename, 'wb')
try:
@ -686,6 +688,11 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder):
# don't copy the reST source
copysource = False
def init(self):
StandaloneHTMLBuilder.init(self)
# the output files for HTML help must be .html only
self.out_suffix = '.html'
def handle_finish(self):
build_hhx(self, self.outdir, self.config.htmlhelp_basename)

View File

@ -58,8 +58,9 @@ class Config(object):
html_use_modindex = (True, False),
html_copy_source = (True, False),
html_use_opensearch = ('', False),
html_file_suffix = (None, False),
# HTML help options
# HTML help only options
htmlhelp_basename = ('pydoc', False),
# LaTeX options

View File

@ -139,6 +139,9 @@ html_last_updated_fmt = '%%b %%d, %%Y'
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = '%(project)sdoc'