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
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import docutils
|
import docutils.frontend
|
||||||
from docutils import frontend
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils import utils
|
from docutils import utils
|
||||||
from docutils.parsers import rst
|
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)
|
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
|
entry.formatRFC2822 = feed.formatRFC2822 = _format_rfc_2822
|
||||||
line_cache: dict[Path, dict[str, str]] = {}
|
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:
|
def parse_rst(full_path: Path) -> nodes.document:
|
||||||
text = full_path.read_text(encoding="utf-8")
|
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)
|
document = utils.new_document(f'<{full_path}>', settings=settings)
|
||||||
rst.Parser(rfc2822=True).parse(text, document)
|
rst.Parser(rfc2822=True).parse(text, document)
|
||||||
return document
|
return document
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Requirements for building PEPs with Sphinx
|
# Requirements for building PEPs with Sphinx
|
||||||
Pygments >= 2.9.0
|
Pygments >= 2.9.0
|
||||||
Sphinx >= 4.0.2
|
Sphinx >= 4.0.2
|
||||||
docutils >= 0.17.1
|
docutils >= 0.19.0
|
||||||
|
|
||||||
# For RSS
|
# For RSS
|
||||||
feedgen >= 0.9.0 # For RSS feed
|
feedgen >= 0.9.0 # For RSS feed
|
||||||
|
|
Loading…
Reference in New Issue