Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f298234
static templates: also support filenames with .jinja suffix
jayaddison Jan 22, 2024
35678af
tests: backwards-compatibility: add test coverage for rendering the c…
jayaddison Jan 25, 2024
b1b575c
nitpick: do not introduce change-of-behaviour with regard to '_T' suf…
jayaddison Jan 25, 2024
ed00d76
ruff: apply suggested linter change to place docstring closing-quotes…
jayaddison Jan 25, 2024
ca21989
fixup: update a few lingering docstring and message variable referenc…
jayaddison Jan 25, 2024
7518c14
change-isolation: undo template file renames
jayaddison Feb 4, 2024
f0f22fd
Revert "fixup: update a few lingering docstring and message variable …
jayaddison Feb 4, 2024
cef1059
change-isolation: undo template file extension coupling in applicatio…
jayaddison Feb 4, 2024
2a5a9a0
change-isolation: undo modifications to LaTeX, imgmath writer templat…
jayaddison Feb 4, 2024
03b3611
tests: repurpose statictmpl.html template from legacy-suffix to recom…
jayaddison Feb 4, 2024
9a9c9df
Merge branch 'master' into issue-11165/support-jinja-suffix
jayaddison Feb 24, 2024
dccfbd6
Merge branch 'master' into issue-11165/support-jinja-suffix
jayaddison Mar 26, 2024
0f3a6d6
Merge branch 'master' into issue-11165/support-jinja-suffix
AA-Turner Apr 9, 2024
536650e
Merge branch 'refs/heads/master' into issue-11165/support-jinja-suffix
AA-Turner Apr 17, 2024
92dfd87
Updates
AA-Turner Apr 17, 2024
896e003
Update CHANGES.rst
AA-Turner Apr 17, 2024
6070691
[docs] Theming: update versionchanged record for Jina-suffix support.
jayaddison Apr 17, 2024
9303948
Merge branch 'master' into issue-11165/support-jinja-suffix
jayaddison Apr 18, 2024
8f6bc50
util.fileutil: restore case-insensitive .jinja suffix filename matches.
jayaddison Apr 18, 2024
059f420
Merge branch 'master' into issue-11165/support-jinja-suffix
AA-Turner Apr 23, 2024
5b27bd5
Merge branch 'refs/heads/master' into issue-11165/support-jinja-suffix
AA-Turner Apr 23, 2024
7ca39ca
CHANGES
AA-Turner Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions doc/development/theming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,13 @@ so-called "static templates", like this:

If the name of a file in the ``static/`` directory of a theme (or in the user's
static path) ends with ``.jinja`` or ``_t``, it will be processed by the
template engine. The suffix will be removed from the final file name. For
example, the *classic* theme has a file ``static/classic.css.jinja`` which uses
templating to put the color options into the stylesheet. When a documentation
project is built with the classic theme, the output directory will contain a
``_static/classic.css`` file where all template tags have been processed.
template engine. The suffix will be removed from the final file name.

For example, a theme with a ``static/theme_styles.css.jinja`` file could use
templating to put options into the stylesheet.
When a documentation project is built with that theme,
the output directory will contain a ``_static/theme_styles.css`` file
where all template tags have been processed.

.. versionchanged:: 7.3

Expand Down
5 changes: 5 additions & 0 deletions doc/latex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,11 @@ Miscellany
.. versionadded:: 1.6
currently all template variables are unstable and undocumented.

.. versionchanged:: 7.4
Added support for the ``.jinja`` file extension, which is preferred.
The old file names remain supported.
(``latex.tex_t``, ``longtable.tex_t``, ``tabulary.tex_t``, and ``tabular.tex_t``)

.. raw:: latex

\endgroup
2 changes: 1 addition & 1 deletion sphinx/builders/_epub_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def build_content(self) -> None:
html.escape(self.refnodes[0]['refuri'])))

# write the project file
copy_asset_file(path.join(self.template_dir, 'content.opf_t'), self.outdir, metadata) # NoQA: E501
copy_asset_file(path.join(self.template_dir, 'content.opf_t'), self.outdir, metadata)

def new_navpoint(self, node: dict[str, Any], level: int, incr: bool = True) -> NavPoint:
"""Create a new entry in the toc from the node at given level."""
Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def hl(no: int, line: str) -> str:
f.write(self.templates.render('changes/rstsource.html', ctx))
themectx = {'theme_' + key: val for (key, val) in
self.theme.get_options({}).items()}
copy_asset_file(path.join(package_dir, 'themes', 'default', 'static', 'default.css_t'), # NoQA: E501
copy_asset_file(path.join(package_dir, 'themes', 'default', 'static', 'default.css_t'),
self.outdir, context=themectx, renderer=self.templates)
copy_asset_file(path.join(package_dir, 'themes', 'basic', 'static', 'basic.css'),
self.outdir)
Expand Down
2 changes: 1 addition & 1 deletion sphinx/util/fileutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _template_basename(filename: str | os.PathLike[str]) -> str | None:
basename = os.path.basename(filename)
if basename.lower().endswith('_t'):
return str(filename)[:-2]
elif basename.lower().endswith(".jinja"):
elif basename.endswith('.jinja'):
return str(filename)[:-6]
return None

Expand Down
8 changes: 4 additions & 4 deletions tests/test_util/test_util_fileutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def excluded(path):


def test_template_basename():
assert not _template_basename("asset.txt")
assert _template_basename("asset.txt.jinja") == "asset.txt"
assert _template_basename("sidebar.html.jinja") == "sidebar.html"
assert _template_basename('asset.txt') is None
assert _template_basename('asset.txt.jinja') == 'asset.txt'
assert _template_basename('sidebar.html.jinja') == 'sidebar.html'


def test_legacy_template_basename():
assert _template_basename("asset.txt_t") == "asset.txt"
assert _template_basename('asset.txt_t') == 'asset.txt'