# HG changeset patch # User Will Maier <[email protected]> # Date 1231506913 21600 # Node ID 17f5dbc6c30cf0e144ca492cebdf30ae01c274bd # Parent 85f7c25d934573cc8f36fc5d86782dedfc34acc6 Add prettyhtml.
prettyhtml.PrettyHTMLBuilder creates HTML pages that can be reached in a format-agnostic manner. For example, the source document foo.rst will be compiled to foo/index.html so that users can load http://example.com/foo/. diff --git a/sphinx/ext/prettyhtml.py b/sphinx/ext/prettyhtml.py new file mode 100644 --- /dev/null +++ b/sphinx/ext/prettyhtml.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +""" + sphinx.ext.prettyhtml + ~~~~~~~~~~~~~~~~~~~~~ + + Generate HTML output such that document URLs end in '/'. For + example, the source file 'foo.rst' would be compiled to HTML + file 'foo/index.html' so that, without any extra fiddling in the + server, a user can load http://example.com/foo/. + + :copyright: Copyright 2009 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from sphinx.builders.html import * + +class PrettyHTMLBuilder(StandaloneHTMLBuilder): + name = 'prettyhtml' + + def init(self): + self.init_templates() + self.init_translator_class() + + def get_target_uri(self, docname, typ=None): + """Stolen from sphinx.builder.SerializingHTMLBuilder.""" + if docname == 'index': + return '' + if docname.endswith(SEP + 'index'): + return docname[:-5] # up to sep + return docname + SEP + + def get_outfilename(self, pagename): + if pagename == 'index': + outfilename = path.join(self.outdir, os_path(pagename) + self.out_suffix) + else: + outfilename = path.join(self.outdir, os_path(pagename), 'index' + self.out_suffix) + + return outfilename + +def setup(app): + app.add_builder(PrettyHTMLBuilder) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en -~----------~----~----~----~------~----~------~--~---
