diff options
author | Adam Turner <9087854+AA-Turner@users.noreply.github.com> | 2022-07-02 10:56:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-02 10:56:29 +0100 |
commit | 8d99168794ab8be0de1e6281d1b76af8177acd3d (patch) | |
tree | 42ed00ab9f90914e813f6a3cb6f2d2c6a8f3b7c4 | |
parent | cf8d5357fc703f24fc287b97d1f4534d94d5f4cf (diff) | |
download | sphinx-git-8d99168794ab8be0de1e6281d1b76af8177acd3d.tar.gz |
Use `get_settings()` from Docutils 0.19 (#10624)
-rw-r--r-- | sphinx/builders/html/__init__.py | 7 | ||||
-rw-r--r-- | sphinx/io.py | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index e023e8194..4a6bc6ce0 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -229,8 +229,11 @@ class StandaloneHTMLBuilder(Builder): source_class=DocTreeInput, destination=StringOutput(encoding='unicode'), ) - op = pub.setup_option_parser(output_encoding='unicode', traceback=True) - pub.settings = op.get_default_values() + if docutils.__version_info__[:2] >= (0, 19): + pub.get_settings(output_encoding='unicode', traceback=True) + else: + op = pub.setup_option_parser(output_encoding='unicode', traceback=True) + pub.settings = op.get_default_values() self._publisher = pub def init(self) -> None: diff --git a/sphinx/io.py b/sphinx/io.py index 5ab7b2b63..1c36a791d 100644 --- a/sphinx/io.py +++ b/sphinx/io.py @@ -3,6 +3,7 @@ import codecs import warnings from typing import TYPE_CHECKING, Any, List, Type +import docutils from docutils import nodes from docutils.core import Publisher from docutils.frontend import Values @@ -212,5 +213,8 @@ def create_publisher(app: "Sphinx", filetype: str) -> Publisher: # Propagate exceptions by default when used programmatically: defaults = {"traceback": True, **app.env.settings} # Set default settings - pub.settings = pub.setup_option_parser(**defaults).get_default_values() # type: ignore + if docutils.__version_info__[:2] >= (0, 19): + pub.get_settings(**defaults) # type: ignore[arg-type] + else: + pub.settings = pub.setup_option_parser(**defaults).get_default_values() # type: ignore return pub |