Skip to content

Commit 5db3a19

Browse files
authored
Fix compatibility with MyST-Parser (#14194)
1 parent 038fc40 commit 5db3a19

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Dependencies
77
* #14153: Drop Python 3.11 support.
88
* #12555: Drop Docutils 0.20 support.
99
Patch by Adam Turner
10+
* #13713: Fix compatibility with MyST-Parser.
11+
Patch by Adam Turner
1012

1113
Incompatible changes
1214
--------------------

sphinx/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
warnings.warn('sphinx.io is deprecated', RemovedInSphinx10Warning, stacklevel=2)
3333

3434

35-
class SphinxBaseReader(standalone.Reader['Any']):
35+
class SphinxBaseReader(standalone.Reader): # type: ignore[type-arg]
3636
"""A base class of readers for Sphinx.
3737
3838
This replaces reporter by Sphinx's on generating document.

sphinx/util/docutils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import docutils
1414
import docutils.frontend
15+
import docutils.writers
1516
from docutils import nodes
1617
from docutils.io import FileOutput
1718
from docutils.parsers.rst import Directive, directives, roles
@@ -879,6 +880,8 @@ def _parse_str_to_doctree(
879880
transformer.add_transforms(_READER_TRANSFORMS)
880881
transformer.add_transforms(transforms)
881882
transformer.add_transforms(parser.get_transforms())
883+
# https://github.com/sphinx-doc/sphinx/issues/13713
884+
transformer.components['writer'] = _DummyWriter() # type: ignore[index]
882885

883886
if default_role:
884887
default_role_cm = rst.default_role(env.current_document.docname, default_role)
@@ -927,6 +930,11 @@ def _get_settings(
927930
return settings
928931

929932

933+
class _DummyWriter(docutils.writers.Writer): # type: ignore[type-arg]
934+
# compat for MyST-Parser
935+
supported = ('html',)
936+
937+
930938
if docutils.__version_info__[:2] < (0, 22):
931939
from docutils.parsers.rst import roles
932940

0 commit comments

Comments
 (0)