diff --git a/CHANGES b/CHANGES index 8a1d6a81b..8cfbadbb1 100644 --- a/CHANGES +++ b/CHANGES @@ -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) ========================= diff --git a/doc/config.rst b/doc/config.rst index b8e173450..83cf52599 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -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 diff --git a/sphinx/builder.py b/sphinx/builder.py index b1549894e..b97ad93f1 100644 --- a/sphinx/builder.py +++ b/sphinx/builder.py @@ -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) diff --git a/sphinx/config.py b/sphinx/config.py index 656df2cbe..ad04d5517 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -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 diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 5d3eb6e32..860103136 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -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'