Skip to content

Commit

Permalink
Add suffix to HTML context. Fixes #1873
Browse files Browse the repository at this point in the history
  • Loading branch information
ericholscher committed Jun 6, 2015
1 parent 42f2b30 commit 5f6503c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/templating.rst
Expand Up @@ -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.
4 changes: 4 additions & 0 deletions sphinx/builders/html.py
Expand Up @@ -408,6 +408,9 @@ def get_doc_context(self, docname, body, metatags):
# 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']
Expand All @@ -425,6 +428,7 @@ def get_doc_context(self, docname, body, metatags):
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):
Expand Down

0 comments on commit 5f6503c

Please sign in to comment.