mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Catch DeprecationWarning for docutils.frontend.OptionParser
This commit is contained in:
@@ -5,6 +5,7 @@ import os
|
||||
import posixpath
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
from datetime import datetime
|
||||
from os import path
|
||||
from typing import IO, Any, Dict, Iterable, Iterator, List, Optional, Set, Tuple, Type
|
||||
@@ -443,10 +444,14 @@ class StandaloneHTMLBuilder(Builder):
|
||||
self.load_indexer(docnames)
|
||||
|
||||
self.docwriter = HTMLWriter(self)
|
||||
self.docsettings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(self.docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
||||
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
||||
self.docsettings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(self.docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
self.docsettings.compact_lists = bool(self.config.html_compact_lists)
|
||||
|
||||
# determine the additional indices to include
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""LaTeX builder."""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
from os import path
|
||||
from typing import Any, Dict, Iterable, List, Tuple, Union
|
||||
|
||||
@@ -250,10 +251,14 @@ class LaTeXBuilder(Builder):
|
||||
|
||||
def write(self, *ignored: Any) -> None:
|
||||
docwriter = LaTeXWriter(self)
|
||||
docsettings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
||||
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
||||
docsettings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
|
||||
self.init_document_data()
|
||||
self.write_stylesheet()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Manual pages builder."""
|
||||
|
||||
import warnings
|
||||
from os import path
|
||||
from typing import Any, Dict, List, Set, Tuple, Union
|
||||
|
||||
@@ -45,10 +46,14 @@ class ManualPageBuilder(Builder):
|
||||
@progress_message(__('writing'))
|
||||
def write(self, *ignored: Any) -> None:
|
||||
docwriter = ManualPageWriter(self)
|
||||
docsettings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
||||
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
||||
docsettings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
|
||||
for info in self.config.man_pages:
|
||||
docname, name, description, authors, section = info
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Texinfo builder."""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
from os import path
|
||||
from typing import Any, Dict, Iterable, List, Tuple, Union
|
||||
|
||||
@@ -101,10 +102,14 @@ class TexinfoBuilder(Builder):
|
||||
with progress_message(__("writing")):
|
||||
self.post_process_images(doctree)
|
||||
docwriter = TexinfoWriter(self)
|
||||
settings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
||||
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
||||
settings: Any = OptionParser(
|
||||
defaults=self.env.settings,
|
||||
components=(docwriter,),
|
||||
read_config_files=True).get_default_values()
|
||||
settings.author = author
|
||||
settings.title = title
|
||||
settings.texinfo_filename = targetname[:-5] + '.info'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Test various Sphinx-specific markup extensions."""
|
||||
|
||||
import re
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
from docutils import frontend, nodes, utils
|
||||
@@ -22,9 +23,13 @@ from sphinx.writers.latex import LaTeXTranslator, LaTeXWriter
|
||||
@pytest.fixture
|
||||
def settings(app):
|
||||
texescape.init() # otherwise done by the latex builder
|
||||
optparser = frontend.OptionParser(
|
||||
components=(RstParser, HTMLWriter, LaTeXWriter),
|
||||
defaults=default_settings)
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
||||
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
||||
optparser = frontend.OptionParser(
|
||||
components=(RstParser, HTMLWriter, LaTeXWriter),
|
||||
defaults=default_settings)
|
||||
settings = optparser.get_default_values()
|
||||
settings.smart_quotes = True
|
||||
settings.env = app.builder.env
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Test the search index builder."""
|
||||
|
||||
import warnings
|
||||
from collections import namedtuple
|
||||
from io import BytesIO
|
||||
|
||||
@@ -27,7 +28,11 @@ settings = parser = None
|
||||
|
||||
def setup_module():
|
||||
global settings, parser
|
||||
optparser = frontend.OptionParser(components=(rst.Parser,))
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
||||
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
||||
optparser = frontend.OptionParser(components=(rst.Parser,))
|
||||
settings = optparser.get_default_values()
|
||||
parser = rst.Parser()
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests uti.nodes functions."""
|
||||
import warnings
|
||||
from textwrap import dedent
|
||||
from typing import Any
|
||||
|
||||
@@ -17,8 +18,12 @@ def _transform(doctree):
|
||||
|
||||
|
||||
def create_new_document():
|
||||
settings = frontend.OptionParser(
|
||||
components=(rst.Parser,)).get_default_values()
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
# DeprecationWarning: The frontend.OptionParser class will be replaced
|
||||
# by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
|
||||
settings = frontend.OptionParser(
|
||||
components=(rst.Parser,)).get_default_values()
|
||||
settings.id_prefix = 'id'
|
||||
document = new_document('dummy.txt', settings)
|
||||
return document
|
||||
|
||||
Reference in New Issue
Block a user