Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate HTML 4 support #10843

Merged
merged 4 commits into from Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -14,6 +14,8 @@ Incompatible changes
Deprecated
----------

* #10843: Support for HTML 4 output. Patch by Adam Turner.

Features added
--------------

Expand Down
5 changes: 5 additions & 0 deletions doc/extdev/deprecated.rst
Expand Up @@ -22,6 +22,11 @@ The following is a list of deprecated interfaces.
- (will be) Removed
- Alternatives

* - HTML 4 support
- 5.2
- 7.0
- N/A

* - ``sphinx.util.path_stabilize``
- 5.1
- 7.0
Expand Down
13 changes: 12 additions & 1 deletion sphinx/builders/html/__init__.py
Expand Up @@ -374,7 +374,7 @@ def add_js_file(self, filename: str, **kwargs: Any) -> None:
@property
def default_translator_class(self) -> Type[nodes.NodeVisitor]: # type: ignore
if self.config.html4_writer:
return HTMLTranslator
return HTMLTranslator # RemovedInSphinx70Warning
else:
return HTML5Translator

Expand Down Expand Up @@ -1338,6 +1338,16 @@ def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None:
html_add_permalinks
)


def deprecate_html_4(_app: Sphinx, config: Config) -> None:
"""Warn on HTML 4."""
# RemovedInSphinx70Warning
if config.html4_writer:
logger.warning(_('Support for emitting HTML 4 output is deprecated and '
'will be removed in Sphinx 7. ("html4_writer=True '
'detected in configuration options)'))


# for compatibility
import sphinxcontrib.serializinghtml # NOQA

Expand Down Expand Up @@ -1414,6 +1424,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.connect('config-inited', validate_html_static_path, priority=800)
app.connect('config-inited', validate_html_logo, priority=800)
app.connect('config-inited', validate_html_favicon, priority=800)
app.connect('config-inited', deprecate_html_4, priority=800)
app.connect('builder-inited', validate_math_renderer)
app.connect('html-page-context', setup_css_tag_helper)
app.connect('html-page-context', setup_js_tag_helper)
Expand Down
1 change: 1 addition & 0 deletions sphinx/writers/html.py
Expand Up @@ -67,6 +67,7 @@ def translate(self) -> None:
self.clean_meta = ''.join(self.visitor.meta[2:])


# RemovedInSphinx70Warning
class HTMLTranslator(SphinxTranslator, BaseTranslator):
"""
Our custom HTML translator.
Expand Down
10 changes: 10 additions & 0 deletions tests/test_build_html.py
Expand Up @@ -131,6 +131,16 @@ def test_html4_output(app, status, warning):
app.build()


def test_html4_deprecation(make_app, tempdir):
(tempdir / 'conf.py').write_text('', encoding='utf-8')
app = make_app(
buildername='html',
srcdir=tempdir,
confoverrides={'html4_writer': True},
)
assert 'HTML 4 output is deprecated and will be removed' in app._warning.getvalue()


@pytest.mark.parametrize("fname,expect", flat_dict({
'images.html': [
(".//img[@src='_images/img.png']", ''),
Expand Down