Add suffix to HTML context. Fixes #1873

This commit is contained in:
Eric Holscher 2015-06-06 13:12:56 -07:00 committed by shimizukawa
parent aefab514e2
commit c22f5beb75
2 changed files with 9 additions and 0 deletions

View File

@ -399,3 +399,8 @@ are in HTML form), these variables are also available:
* ``includehidden`` (``False`` by default): if true, the TOC tree will also
contain hidden entries.
.. data:: page_source_suffix
The suffix of the file that was rendered. Since we support a list of :confval:`source_suffix`,
this will allow you to properly link to the original source file.

View File

@ -408,6 +408,9 @@ class StandaloneHTMLBuilder(Builder):
# metadata for the document
meta = self.env.metadata.get(docname)
# Suffix for the document
source_suffix = '.' + self.env.doc2path(docname).split('.')[-1]
# local TOC and global TOC tree
self_toc = self.env.get_toc_for(docname, self)
toc = self.render_partial(self_toc)['fragment']
@ -425,6 +428,7 @@ class StandaloneHTMLBuilder(Builder):
toc = toc,
# only display a TOC if there's more than one item to show
display_toc = (self.env.toc_num_entries[docname] > 1),
page_source_suffix = source_suffix,
)
def write_doc(self, docname, doctree):