Skip to content

Commit

Permalink
Fix docutils deprecation warning when generating RSS (#2744)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Aug 2, 2022
1 parent efab331 commit 76fcf6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 2 additions & 11 deletions generate_rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
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
Expand All @@ -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]] = {}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 76fcf6b

Please sign in to comment.