Skip to content

Commit 59de8d5

Browse files
authored
Revert "Support and prefer .jinja to _t for static templates (#11165)" (#11329)
This reverts commit 5d13215.
1 parent aee3c0a commit 59de8d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+60
-299
lines changed

CHANGES

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ Deprecated
2323
----------
2424

2525
* #11247: Deprecate the legacy ``intersphinx_mapping`` format
26-
* #11165: Warn when the ``_t`` suffix is used for template files. The formal
27-
deprecation process will begin no earlier than 31 December 2024.
28-
Templates should change to use the ``.jinja`` filename suffix instead.
29-
For more information, see :ref:`theming-static-templates`.
30-
Patch by James Addison and Adam Turner
3126

3227
Features added
3328
--------------
@@ -65,10 +60,6 @@ Features added
6560
``= 'xelatex'``. Patch by Dimitar Dimitrov
6661
* #11109, #9643: Add :confval:`python_display_short_literal_types` option for
6762
condensed rendering of ``Literal`` types.
68-
* #11165: Support the `officially recommended`_ ``.jinja`` suffix for template
69-
files. Patch by James Addison
70-
71-
.. _officially recommended: https://jinja.palletsprojects.com/en/latest/templates/#template-file-extension
7263

7364
Bugs fixed
7465
----------

doc/development/theming.rst

Lines changed: 4 additions & 42 deletions

doc/latex.rst

Lines changed: 4 additions & 4 deletions

sphinx/builders/_epub_base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,7 @@ def build_content(self) -> None:
603603
html.escape(self.refnodes[0]['refuri'])))
604604

605605
# write the project file
606-
content_t = path.join(self.template_dir, 'content.opf.jinja')
607-
copy_asset_file(content_t, self.outdir, metadata)
606+
copy_asset_file(path.join(self.template_dir, 'content.opf_t'), self.outdir, metadata)
608607

609608
def new_navpoint(self, node: dict[str, Any], level: int, incr: bool = True) -> NavPoint:
610609
"""Create a new entry in the toc from the node at given level."""
@@ -687,7 +686,7 @@ def build_toc(self) -> None:
687686
navpoints = self.build_navpoints(refnodes)
688687
level = max(item['level'] for item in self.refnodes)
689688
level = min(level, self.config.epub_tocdepth)
690-
copy_asset_file(path.join(self.template_dir, 'toc.ncx.jinja'), self.outdir,
689+
copy_asset_file(path.join(self.template_dir, 'toc.ncx_t'), self.outdir,
691690
self.toc_metadata(level, navpoints))
692691

693692
def build_epub(self) -> None:

sphinx/builders/changes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ def hl(no: int, line: str) -> str:
133133
f.write(self.templates.render('changes/rstsource.html', ctx))
134134
themectx = {'theme_' + key: val for (key, val) in
135135
self.theme.get_options({}).items()}
136-
default_t = path.join(package_dir, 'themes', 'default', 'static', 'default.css.jinja')
137-
copy_asset_file(default_t, self.outdir, context=themectx, renderer=self.templates)
138-
basic = path.join(package_dir, 'themes', 'basic', 'static', 'basic.css')
139-
copy_asset_file(basic, self.outdir)
136+
copy_asset_file(path.join(package_dir, 'themes', 'default', 'static', 'default.css_t'),
137+
self.outdir, context=themectx, renderer=self.templates)
138+
copy_asset_file(path.join(package_dir, 'themes', 'basic', 'static', 'basic.css'),
139+
self.outdir)
140140

141141
def hl(self, text: str, version: str) -> str:
142142
text = html.escape(text)

sphinx/builders/epub3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def build_navigation_doc(self) -> None:
184184
# 'includehidden'
185185
refnodes = self.refnodes
186186
navlist = self.build_navlist(refnodes)
187-
copy_asset_file(path.join(self.template_dir, 'nav.xhtml.jinja'), self.outdir,
187+
copy_asset_file(path.join(self.template_dir, 'nav.xhtml_t'), self.outdir,
188188
self.navigation_doc_metadata(navlist))
189189

190190
# Add nav.xhtml to epub file

sphinx/builders/gettext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def finish(self) -> None:
283283
ensuredir(path.join(self.outdir, path.dirname(textdomain)))
284284

285285
context['messages'] = list(catalog)
286-
content = GettextRenderer(outdir=self.outdir).render('message.pot.jinja', context)
286+
content = GettextRenderer(outdir=self.outdir).render('message.pot_t', context)
287287

288288
pofn = path.join(self.outdir, textdomain + '.pot')
289289
if should_write(pofn, content):

sphinx/builders/latex/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def copy_support_files(self) -> None:
402402
# use pre-1.6.x Makefile for make latexpdf on Windows
403403
if os.name == 'nt':
404404
staticdirname = path.join(package_dir, 'texinputs_win')
405-
copy_asset_file(path.join(staticdirname, 'Makefile.jinja'),
405+
copy_asset_file(path.join(staticdirname, 'Makefile_t'),
406406
self.outdir, context=context)
407407

408408
@progress_message(__('copying additional files'))
@@ -441,7 +441,7 @@ def write_message_catalog(self) -> None:
441441
if self.context['babel'] or self.context['polyglossia']:
442442
context['addtocaptions'] = r'\addto\captions%s' % self.babel.get_language()
443443

444-
filename = path.join(package_dir, 'templates', 'latex', 'sphinxmessages.sty.jinja')
444+
filename = path.join(package_dir, 'templates', 'latex', 'sphinxmessages.sty_t')
445445
copy_asset_file(filename, self.outdir, context=context, renderer=LaTeXRenderer())
446446

447447

sphinx/cmd/quickstart.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,29 +370,29 @@ def write_file(fpath: str, content: str, newline: str | None = None) -> None:
370370
if 'quiet' not in d:
371371
print(__('File %s already exists, skipping.') % fpath)
372372

373-
conf_path = os.path.join(templatedir, 'conf.py.jinja') if templatedir else None
373+
conf_path = os.path.join(templatedir, 'conf.py_t') if templatedir else None
374374
if not conf_path or not path.isfile(conf_path):
375-
conf_path = os.path.join(package_dir, 'templates', 'quickstart', 'conf.py.jinja')
375+
conf_path = os.path.join(package_dir, 'templates', 'quickstart', 'conf.py_t')
376376
with open(conf_path, encoding="utf-8") as f:
377377
conf_text = f.read()
378378

379379
write_file(path.join(srcdir, 'conf.py'), template.render_string(conf_text, d))
380380

381381
masterfile = path.join(srcdir, d['master'] + d['suffix'])
382-
if template._has_custom_template('quickstart/master_doc.rst.jinja'):
382+
if template._has_custom_template('quickstart/master_doc.rst_t'):
383383
msg = ('A custom template `master_doc.rst_t` found. It has been renamed to '
384384
'`root_doc.rst_t`. Please rename it on your project too.')
385385
print(colorize('red', msg))
386-
write_file(masterfile, template.render('quickstart/master_doc.rst.jinja', d))
386+
write_file(masterfile, template.render('quickstart/master_doc.rst_t', d))
387387
else:
388-
write_file(masterfile, template.render('quickstart/root_doc.rst.jinja', d))
388+
write_file(masterfile, template.render('quickstart/root_doc.rst_t', d))
389389

390390
if d.get('make_mode') is True:
391-
makefile_template = 'quickstart/Makefile.new.jinja'
392-
batchfile_template = 'quickstart/make.bat.new.jinja'
391+
makefile_template = 'quickstart/Makefile.new_t'
392+
batchfile_template = 'quickstart/make.bat.new_t'
393393
else:
394-
makefile_template = 'quickstart/Makefile.jinja'
395-
batchfile_template = 'quickstart/make.bat.jinja'
394+
makefile_template = 'quickstart/Makefile_t'
395+
batchfile_template = 'quickstart/make.bat_t'
396396

397397
if d['makefile'] is True:
398398
d['rsrcdir'] = 'source' if d['sep'] else '.'

sphinx/deprecation.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,31 +62,3 @@ def __getattr__(name):
6262

6363
warnings.warn(message + " Check CHANGES for Sphinx API modifications.",
6464
warning_class, stacklevel=3)
65-
66-
67-
class OldJinjaSuffixWarning(PendingDeprecationWarning):
68-
"""Warning class for ``_old_jinja_template_suffix_warning``.
69-
70-
This class exists only so that extensions and themes can silence the legacy
71-
filename warning via Python's `warning control`_ mechanisms. See
72-
:ref:`theming-static-templates` for an example.
73-
74-
This warning class will be removed, and the warning class changed to the
75-
appropriate RemovedInSphinx_0Warning no earlier than 31 December 2024, at
76-
which point the standard deprecation process for ``_t`` template suffixes
77-
will start.
78-
79-
.. _warning control: https://docs.python.org/3/library/warnings.html#the-warnings-filter
80-
"""
81-
82-
83-
def _old_jinja_template_suffix_warning(filename: str) -> None:
84-
if filename.endswith('_t'):
85-
warnings.warn(
86-
f"{filename!r}: the '_t' suffix for Jinja templates is deprecated. "
87-
"If the file is a template, use the suffix '.jinja' instead. "
88-
'For more information, see '
89-
'https://www.sphinx-doc.org/en/master/development/theming.html#static-templates',
90-
OldJinjaSuffixWarning,
91-
stacklevel=3,
92-
)

0 commit comments

Comments
 (0)