Fix docutils deprecation warning when generating RSS (#2744)
This commit is contained in:
parent
efab331949
commit
76fcf6b0ea
|
@ -7,8 +7,7 @@ import email.utils
|
|||
from pathlib import Path
|
||||
import re
|
||||
|
||||
import docutils
|
||||
from docutils import frontend
|
||||
import docutils.frontend
|
||||
from docutils import nodes
|
||||
from docutils import utils
|
||||
from docutils.parsers import rst
|
||||
|
@ -25,14 +24,6 @@ def _format_rfc_2822(dt: datetime.datetime) -> str:
|
|||
return email.utils.format_datetime(dt, usegmt=True)
|
||||
|
||||
|
||||
# Monkeypatch nodes.Node.findall for forwards compatability
|
||||
if docutils.__version_info__ < (0, 18, 1):
|
||||
def findall(self, *args, **kwargs):
|
||||
return iter(self.traverse(*args, **kwargs))
|
||||
|
||||
nodes.Node.findall = findall
|
||||
|
||||
|
||||
entry.formatRFC2822 = feed.formatRFC2822 = _format_rfc_2822
|
||||
line_cache: dict[Path, dict[str, str]] = {}
|
||||
|
||||
|
@ -131,7 +122,7 @@ def pep_creation(full_path: Path) -> datetime.datetime:
|
|||
|
||||
def parse_rst(full_path: Path) -> nodes.document:
|
||||
text = full_path.read_text(encoding="utf-8")
|
||||
settings = frontend.OptionParser((rst.Parser,)).get_default_values()
|
||||
settings = docutils.frontend.get_default_settings(rst.Parser)
|
||||
document = utils.new_document(f'<{full_path}>', settings=settings)
|
||||
rst.Parser(rfc2822=True).parse(text, document)
|
||||
return document
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Requirements for building PEPs with Sphinx
|
||||
Pygments >= 2.9.0
|
||||
Sphinx >= 4.0.2
|
||||
docutils >= 0.17.1
|
||||
docutils >= 0.19.0
|
||||
|
||||
# For RSS
|
||||
feedgen >= 0.9.0 # For RSS feed
|
||||
|
|
Loading…
Reference in New Issue